source: trunk/MagicSoft/Mars/star.cc@ 2714

Last change on this file since 2714 was 2623, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 7.4 KB
Line 
1#include <TSystem.h>
2
3#include "MParList.h"
4#include "MTaskList.h"
5#include "MEvtLoop.h"
6/*'
7#include "MLog.h"
8 */
9#include "MLogManip.h"
10
11#include "MArgs.h"
12
13#include "MArray.h"
14#include "MReadMarsFile.h"
15#include "MGeomApply.h"
16#include "MMcPedestalCopy.h"
17#include "MMcPedestalNSBAdd.h"
18#include "MCerPhotCalc.h"
19#include "MCerPhotAnal2.h"
20#include "MBlindPixelCalc.h"
21#include "MSigmabarCalc.h"
22#include "MImgCleanStd.h"
23#include "MHillasCalc.h"
24#include "MHillasSrcCalc.h"
25#include "MWriteRootFile.h"
26#include "MFDataMember.h"
27#include "MFillH.h"
28#include "MReportDrive.h" // PRELIMINARY:
29//#include "MPointingPos.h" // PRELIMINARY:
30//#include "MPointingPosCalc.h"
31
32using namespace std;
33
34//////////////////////////////////////////////////////////////////////////////
35//
36// This is an easy implementation of the Star process
37// (as compilable prog)
38//
39//////////////////////////////////////////////////////////////////////////////
40
41static void StartUpMessage()
42{
43 gLog << all << endl;
44
45 // 1 2 3 4 5
46 // 12345678901234567890123456789012345678901234567890
47 gLog << "==================================================" << endl;
48 gLog << " STAR - MARS V" << MARSVER << endl;
49 gLog << " MARS - STandard Analysis and Reconstruction" << endl;
50 gLog << " Compiled on <" << __DATE__ << ">" << endl;
51 gLog << " Using ROOT v" << ROOTVER << endl;
52 gLog << "==================================================" << endl;
53 gLog << endl;
54}
55
56static void Usage()
57{
58 gLog << all << endl;
59 gLog << "Sorry the usage is:" << endl;
60 gLog << " star [-a0] [-vn] [-cn] inputfile[.root] outputfile[.root]" << endl << endl;
61 gLog << " input file: Merpped or MC root file." << endl;
62 gLog << " ouput file: Star-file (image parameter file)" << endl;
63 gLog << " -a0: Do not use Ansii codes." << endl;
64 gLog << " -cn: Compression level n=1..9 [default=2]" << endl;
65 gLog << " -vn: Verbosity level n [default=2]" << endl;
66 gLog << " -u1: Update File (instead of Recreate)" << endl;
67 gLog << " -tn: Telescope Serial Number n [default=0]" << endl << endl;
68 gLog << " -> Further setup is not possible at the moment, please use" << endl;
69 gLog << " the star.C root macro instead. Using an input card will" << endl;
70 gLog << " be implemented in the future." << endl << endl;
71}
72
73int main(const int argc, char **argv)
74{
75 StartUpMessage();
76
77 //
78 // Evaluate arguments
79 //
80 MArgs arg(argc, argv);
81
82 //
83 // Set verbosity to highest level.
84 //
85 gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
86
87 if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
88 gLog.SetNoColors();
89
90 const int kComprlvl = arg.HasOption("-c") ? arg.GetIntAndRemove("-c") : 1;
91 const int kTelIndex = arg.HasOption("-t") ? arg.GetIntAndRemove("-t") : 0;
92 const bool kUpdate = arg.HasOption("-u") && arg.GetIntAndRemove("-u")==1;
93
94 //
95 // check for the right usage of the program
96 //
97 if (arg.GetNumArguments()!=2)
98 {
99 Usage();
100 return -1;
101 }
102
103 //
104 // This is to make argv[i] more readable inside the code
105 //
106 TString kNamein = arg.GetArgumentStr(0);
107 TString kNameout = arg.GetArgumentStr(1);
108
109 if (!kNamein.EndsWith(".root"))
110 kNamein += ".root";
111
112 if (!kNameout.EndsWith(".root"))
113 kNameout += ".root";
114
115 //
116 // Initialize Non-GUI (batch) mode
117 //
118 gROOT->SetBatch();
119
120 //
121 // check whether the given files are OK.
122 //
123 if (gSystem->AccessPathName(kNamein, kFileExists))
124 {
125 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
126 return -1;
127 }
128
129 if (!gSystem->AccessPathName(kNameout, kFileExists))
130 {
131 if (kUpdate)
132 gLog << warn << "Warning: File doesn't '" << kNameout << "' exist... recreating." << endl;
133 }
134
135 if (kUpdate || gSystem->AccessPathName(kNameout, kFileExists))
136 if (!gSystem->AccessPathName(kNameout, kWritePermission))
137 {
138 gLog << err << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
139 return -1;
140 }
141
142 MArray::Class()->IgnoreTObjectStreamer();
143 MParContainer::Class()->IgnoreTObjectStreamer();
144
145 //
146 // Create a empty Parameter List and an empty Task List
147 // The tasklist is identified in the eventloop by its name
148 //
149 MParList plist;
150
151 MTaskList tlist;
152 plist.AddToList(&tlist);
153
154 // PRELIMINARY:
155 /*
156 MReportDrive rep;
157 plist.AddToList(&rep);
158 MPointingPos pos;
159 plist.AddToList(&pos);
160 */
161
162 //
163 // Now setup the tasks and tasklist:
164 // ---------------------------------
165 //
166 MReadMarsFile read("Events", kNamein);
167 read.DisableAutoScheme();
168
169 MGeomApply apply;
170 MMcPedestalCopy pcopy;
171 MMcPedestalNSBAdd pnsb;
172
173 //MPointingPosCalc pcalc;
174
175 MCerPhotCalc ncalc;
176 MCerPhotAnal2 nanal;
177
178 MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
179 MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
180
181 ncalc.SetFilter(&f1);
182 nanal.SetFilter(&f2);
183
184 MBlindPixelCalc blind;
185 MSigmabarCalc sgcal;
186 //MFillH fills("MHSigmaTheta", "", "FillSigmaTheta");
187 //MFillH fillb("MHBlindPixels", "", "FillBlindPixels");
188 MImgCleanStd clean;
189 MHillasCalc hcalc;
190 MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
191 MWriteRootFile write(kNameout, kUpdate?"UPDATE":"RECREATE", "Star output", kComprlvl);
192
193 tlist.AddToList(&read);
194 tlist.AddToList(&f1);
195 tlist.AddToList(&f2);
196 tlist.AddToList(&apply);
197 tlist.AddToList(&pcopy);
198 tlist.AddToList(&pnsb);
199 //tlist.AddToList(&pcalc);
200 tlist.AddToList(&ncalc);
201 tlist.AddToList(&nanal);
202 tlist.AddToList(&blind);
203 tlist.AddToList(&sgcal);
204 //tlist.AddToList(&fills);
205 //tlist.AddToList(&fillb);
206 tlist.AddToList(&clean);
207 tlist.AddToList(&hcalc);
208 tlist.AddToList(&scalc);
209 tlist.AddToList(&write);
210
211 //
212 // Set the serial number for all tasks in the current tasklist
213 //
214 tlist.SetSerialNumber(kTelIndex);
215
216 //
217 // Setup tasks
218 //
219 blind.SetUseInterpolation();
220
221 write.AddContainer(write.AddSerialNumber("MMcEvt"), "Events", kFALSE);
222 write.AddContainer(write.AddSerialNumber("MSigmabar"), "Events");
223 write.AddContainer(write.AddSerialNumber("MHillas"), "Events");
224 write.AddContainer(write.AddSerialNumber("MHillasExt"), "Events");
225 write.AddContainer(write.AddSerialNumber("MHillasSrc"), "Events");
226 write.AddContainer(write.AddSerialNumber("MNewImagePar"), "Events");
227 write.AddContainer(write.AddSerialNumber("MSrcPosCam"), "RunHeaders");
228 //write.AddContainer(write.AddSerialNumber("MHSigmaTheta"), "RunHeaders");
229 if (!kUpdate)
230 {
231 write.AddContainer("MRawRunHeader", "RunHeaders");
232 write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
233 }
234
235 //
236 // Create and set up the eventloop
237 //
238 MEvtLoop evtloop;
239 evtloop.SetParList(&plist);
240
241 //
242 // Execute your analysis
243 //
244 if (!evtloop.Eventloop())
245 {
246 gLog << err << "ERROR: Star eventloop failed!" << endl;
247 return -1;
248 }
249
250 tlist.PrintStatistics();
251
252 //plist.FindObject("MHSigmaTheta")->Write();
253 //plist.FindObject("MHBlindPixels")->Write();
254
255 gLog << all << "Star finished successfull!" << endl;
256 return 0;
257}
Note: See TracBrowser for help on using the repository browser.