source: trunk/MagicSoft/Mars/mars.cc@ 8898

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