source: branches/Corsika7500Compatibility/mars.cc@ 18454

Last change on this file since 18454 was 9141, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.7 KB
Line 
1#include <TClass.h>
2#include <TApplication.h>
3
4#include "MAGIC.h"
5
6#include "MLog.h"
7#include "MLogManip.h"
8
9#include "MArgs.h"
10#include "MArray.h"
11#include "MParContainer.h"
12
13#ifdef HAVE_XPM
14#include "MLogo.h"
15#endif
16
17#include "MCameraDisplay.h"
18#include "MEventDisplay.h"
19
20using namespace std;
21
22// **********************************************************************
23//
24// MARS main program
25//
26// The only job of the main program is the initialization of ROOT and
27// the start of the GUI interface for the mars program
28//
29// started by h. kornmayer january, 3rd 2001
30static void StartUpMessage()
31{
32 gLog << all << endl;
33
34 // 1 2 3 4 5
35 // 12345678901234567890123456789012345678901234567890
36 gLog << "==================================================" << endl;
37 gLog << " MARS V" << MARSVER << endl;
38 gLog << " Modular Analysis and Reconstruction Software" << endl;
39 gLog << " Compiled with ROOT v" << ROOT_RELEASE << " on <" << __DATE__ << ">" << endl;
40 gLog << "==================================================" << endl;
41 gLog << endl;
42}
43
44static void Usage()
45{
46 gLog << all << endl;
47 gLog << "Sorry the usage is:" << endl;
48 gLog << " mars [options] filename|number" << endl << endl;
49 gLog << " Arguments:" << endl;
50 gLog << " filename: Name of a merpped raw file, a calibrated (Y) file," << endl;
51 gLog << " sequence file or sequence number." << endl;
52 gLog << " Options:" << endl;
53 gLog << " --ind=path Path to files, valid if sequence file or number given." << endl;
54 gLog << " --config=mars.rc: Change configuration file" << endl;
55 gLog << " <not yet implemented!>" << endl;
56 gLog.Usage();
57 gLog << " -?/-h: This help" << endl << endl;
58}
59
60/*
61Bool_t InflateRun(TString &run, Bool_t ismc)
62{
63 if (run.IsDigit())
64 {
65 const Int_t numrun = run.Atoi();
66 seq = "/magic/";
67 if (ismc)
68 seq += ismc ? "montecarlo/" : "rawfiles/";
69 seq += Form("sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
70 gLog << inf << "Inflated sequence file: " << seq << endl;
71 }
72
73 if (!gSystem->AccessPathName(seq, kFileExists))
74 return kTRUE;
75
76 gLog << err << "Sorry, sequence file '" << seq << "' doesn't exist." << endl;
77 return kFALSE;
78}
79*/
80
81int main(int argc, char **argv)
82{
83 if (!MARS::CheckRootVer())
84 return 0xff;
85
86 MLog::RedirectErrorHandler(MLog::kColor);
87
88 //
89 // Evaluate arguments
90 //
91 MArgs arg(argc, argv);
92 gLog.Setup(arg);
93
94 StartUpMessage();
95
96 if (arg.HasOnly("-V") || arg.HasOnly("--version"))
97 return 0;
98
99 if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
100 {
101 Usage();
102 return 2;
103 }
104
105 //const Bool_t kIsSequence = arg.HasOnlyAndRemove("--seq");
106 const TString kConfig = arg.GetStringAndRemove("--config=", "mars.rc");
107 const TString kInpathD = arg.GetStringAndRemove("--ind=", "");
108
109 if (arg.GetNumOptions()>0)
110 {
111 gLog << warn << "WARNING - Unknown commandline options..." << endl;
112 arg.Print("options");
113 gLog << endl;
114 return 2;
115 }
116
117 //
118 // check for the right usage of the program
119 //
120 if (arg.GetNumArguments()>1)
121 {
122 gLog << warn << "WARNING - Too many arguments..." << endl;
123 Usage();
124 return 2;
125 }
126
127 //
128 // This is to make argv[i] more readable inside the code
129 //
130 const TString kFilename = arg.GetArgumentStr(0);
131
132 //if (!kIsSequence && !InflateRun(kFilename))
133 // return 3;
134
135#ifdef HAVE_XPM
136 MLogo logo;
137 logo.Popup();
138#endif
139
140 //
141 // initialize ROOT
142 //
143 TApplication app("mars", &argc, argv);
144 if (gROOT->IsBatch() || !gClient)
145 {
146 gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
147 return 1;
148 }
149
150 //
151 // Switch of TObject Streamer in our base classes derived from TObject
152 //
153 MArray::Class()->IgnoreTObjectStreamer();
154 MParContainer::Class()->IgnoreTObjectStreamer();
155
156#ifdef HAVE_XPM
157 logo.Popdown();
158#endif
159
160 /*
161 MEnv env(kConfig);
162 if (!env.IsValid())
163 {
164 gLog << err << "Configuration file " << kConfig << " not found." << endl;
165 return 0xfe;
166 }
167 */
168
169 //
170 // start the main window
171 //
172 if (kFilename.IsNull())
173 new MCameraDisplay;
174 else
175 {
176 MEventDisplay *d = new MEventDisplay(kFilename, kInpathD);
177 d->SetBit(MStatusDisplay::kExitLoopOnExit);
178 d->SetTitle(kFilename);
179 }
180
181 //
182 // run the application
183 //
184 app.Run();
185
186 gLog << all << endl;
187
188 return 0;
189}
Note: See TracBrowser for help on using the repository browser.