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

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