source: tags/Mars-V0.8.3/status.cc@ 17541

Last change on this file since 17541 was 2561, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 8.8 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 4/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// Status - Example how to use the MStatusDisplay
28//
29// Use a camera file as input ----- PRELIMINARY
30//
31/////////////////////////////////////////////////////////////////////////////
32
33#include "MStatusDisplay.h"
34#include "MArray.h"
35#include "MArgs.h"
36#include "MLog.h"
37#include "MLogManip.h"
38#include "MParList.h"
39#include "MTaskList.h"
40#include "MReadMarsFile.h"
41#include "MGeomApply.h"
42#include "MMcPedestalCopy.h"
43#include "MMcPedestalNSBAdd.h"
44#include "MCerPhotCalc.h"
45#include "MCerPhotAnal2.h"
46//#include "MBlindPixelCalc.h"
47#include "MSigmabarCalc.h"
48#include "MImgCleanStd.h"
49#include "MHillasCalc.h"
50#include "MHillasSrcCalc.h"
51#include "MCT1SupercutsCalc.h"
52#include "MHCamEvent.h"
53#include "MFillH.h"
54#include "MEvtLoop.h"
55#include "MFDataMember.h"
56
57#include <TApplication.h>
58#include <TSystem.h>
59
60using namespace std;
61
62static void StartUpMessage()
63{
64 gLog << all << endl;
65
66 // 1 2 3 4 5
67 // 12345678901234567890123456789012345678901234567890
68 gLog << "==================================================" << endl;
69 gLog << " status - MARS V" << MARSVER << endl;
70 gLog << " MARS - Merging and Preprocessing Program" << endl;
71 gLog << " Compiled on <" << __DATE__ << ">" << endl;
72 gLog << " Using ROOT v" << ROOTVER << endl;
73 gLog << " PROGRAM IS PRELIMINARY - FOR TEST CASES ONLY" << endl;
74 gLog << "==================================================" << endl;
75 gLog << endl;
76}
77
78static void Usage()
79{
80 gLog << all << endl;
81 gLog << "Sorry the usage is:" << endl;
82 gLog << " status [-a0] [-vn] [-cn] inputfile[.root]" << endl << endl;
83 gLog << " input file: Mars root file." << endl;
84 gLog << " -a0: Do not use Ansii codes." << endl;
85 gLog << " -vn: Verbosity level n [default=2]" << endl;
86 gLog << " -?/-h: This help" << endl << endl;
87}
88
89
90int main(int argc, char **argv)
91{
92 StartUpMessage();
93
94 //
95 // Evaluate arguments
96 //
97 MArgs arg(argc, argv);
98
99 if (arg.HasOption("-?") || arg.HasOption("-h"))
100 {
101 Usage();
102 return -1;
103 }
104
105 //
106 // Set verbosity to highest level.
107 //
108 gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
109
110 if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
111 gLog.SetNoColors();
112
113 //
114 // check for the right usage of the program
115 //
116 if (arg.GetNumArguments()!=1)
117 {
118 Usage();
119 return -1;
120 }
121
122 //
123 // This is to make argv[i] more readable insidethe code
124 //
125 TString kNamein = arg.GetArgumentStr(0);
126
127 if (!kNamein.EndsWith(".root"))
128 kNamein += ".root";
129
130 //
131 // check whether the given files are OK.
132 //
133 if (gSystem->AccessPathName(kNamein, kFileExists))
134 {
135 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
136 return -1;
137 }
138
139 TApplication app("Status", &argc, argv);
140 if (gROOT->IsBatch() || !gClient)
141 {
142 gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
143 return 1;
144 }
145
146 MArray::Class()->IgnoreTObjectStreamer();
147 MParContainer::Class()->IgnoreTObjectStreamer();
148
149 //
150 // Update frequency by default = 1Hz
151 //
152 MStatusDisplay *d = new MStatusDisplay;
153
154 // From now on each 'Exit' means: Terminate the application
155 d->SetBit(MStatusDisplay::kExitLoopOnExit);
156
157 // Set update time to 5s
158 // d->SetUpdateTime(5000);
159
160 // Disable online update
161 // d->SetUpdateTime(-1);
162
163 d->SetLogStream(&gLog, kTRUE); // Disables output to stdout
164 gLog.SetOutputFile("status.log", kTRUE); // Enable output to file
165 //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
166
167 //
168 // Create a empty Parameter List and an empty Task List
169 // The tasklist is identified in the eventloop by its name
170 //
171 MParList plist;
172
173 MTaskList tlist;
174 plist.AddToList(&tlist);
175
176 /*
177 MSrcPosCam src;
178 src.SetXY(1./geomcam.GetConvMm2Deg(), 0);
179 plist.AddToList(&src);
180 */
181
182 //
183 // Now setup the tasks and tasklist:
184 // ---------------------------------
185 //
186 MReadMarsFile read("Events");
187 //read.DisableAutoScheme();
188
189 // ------------- user change -----------------
190 read.AddFile(kNamein);
191
192 MGeomApply geomapl;
193 MMcPedestalCopy pcopy;
194 MMcPedestalNSBAdd pnsb;
195 MCerPhotCalc ncalc;
196 MCerPhotAnal2 nanal;
197
198 MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
199 MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
200
201 ncalc.SetFilter(&f1);
202 nanal.SetFilter(&f2);
203/*
204 TArrayS blinds(6);
205 blinds[0] = 0;
206 blinds[1] = 195;
207 blinds[2] = 227;
208 blinds[3] = 248;
209 blinds[4] = 271;
210 blinds[5] = 291;
211
212 blinds[3] = 51;
213 blinds[4] = 56;
214 blinds[5] = 112;
215 blinds[6] = 31;
216 blinds[7] = 116;
217 blinds[8] = 507;
218 blinds[9] = 559;
219 blinds[10]= 291; // 311, 119, 54, 85, 125, 92, 133, 224
220
221 MBlindPixelCalc blind;
222 blind.SetPixelIndices(blinds);
223 //blind.SetUseInterpolation();
224*/
225 // MSigmabarCalc sgcal;
226 MImgCleanStd clean;
227 MHillasCalc hcalc;
228 MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
229 // MCT1SupercutsCalc calc1;
230
231 // -------------------------------------------
232
233 MHCamEvent hist("PedestalRms");
234 hist.SetType(1);
235 plist.AddToList(&hist);
236
237 // -------------------------------------------
238
239 MHCamEvent maxhi("MaxIdxHi", "Index of slice with maximum content (hi-gain)");
240 MHCamEvent maxlo("MaxIdxLo", "Index of slice with maximum content (lo-gain)");
241 maxhi.SetType(3);
242 maxlo.SetType(4);
243 plist.AddToList(&maxhi);
244 plist.AddToList(&maxlo);
245
246 // -------------------------------------------
247
248 MFillH hfilhi("MaxIdxHi", "MRawEvtData");
249 MFillH hfillo("MaxIdxLo", "MRawEvtData");
250 MFillH hfill0("Uncleaned [MHCamEvent]", "MCerPhotEvt");
251 MFillH hfill1("Pedestals [MHCamEvent]", "MPedestalCam");
252 MFillH hfill2("PedestalRms", "MPedestalCam");
253 MFillH hfill3("MHHillas", "MHillas");
254 MFillH hfill4("MHHillasExt");
255 MFillH hfill5("MHHillasExtSrc [MHHillasExt]", "MHillasSrc");
256 MFillH hfill6("MHHillasSrc","MHillasSrc");
257 MFillH hfill7("MHNewImagePar","MNewImagePar");
258 //MFillH hfill8a("MHStarMap", "MHillas");
259 //MFillH hfill8b("MHStarMap2", "MHillas");
260 MFillH hfill9("Cleaned [MHCamEvent]", "MCerPhotEvt");
261 //MFillH hfill10("MHHadronness", "MHadronness");
262 //MFillH hfill11("MHSigmaTheta");
263
264 tlist.AddToList(&read);
265 tlist.AddToList(&f1);
266 tlist.AddToList(&f2);
267 tlist.AddToList(&geomapl);
268 tlist.AddToList(&pcopy);
269 tlist.AddToList(&pnsb);
270 tlist.AddToList(&ncalc);
271 tlist.AddToList(&nanal);
272 //tlist.AddToList(&blind);
273 tlist.AddToList(&hfilhi);
274 tlist.AddToList(&hfillo);
275 tlist.AddToList(&hfill0);
276 //tlist.AddToList(&sgcal);
277 tlist.AddToList(&clean);
278 tlist.AddToList(&hcalc);
279 tlist.AddToList(&scalc);
280 //tlist.AddToList(&calc1);
281 tlist.AddToList(&hfill1);
282 tlist.AddToList(&hfill2);
283 tlist.AddToList(&hfill3);
284 tlist.AddToList(&hfill4);
285 tlist.AddToList(&hfill5);
286 tlist.AddToList(&hfill6);
287 tlist.AddToList(&hfill7);
288 //tlist.AddToList(&hfill8a);
289 //tlist.AddToList(&hfill8b);
290 tlist.AddToList(&hfill9);
291 //tlist.AddToList(&hfill10);
292 //tlist.AddToList(&hfill11);
293
294 MEvtLoop evtloop;
295 evtloop.SetParList(&plist);
296 evtloop.SetDisplay(d);
297
298 //
299 // Execute your analysis
300 //
301 if (!evtloop.Eventloop())
302 return 1;
303
304 tlist.PrintStatistics();
305
306 if (!evtloop.GetDisplay())
307 return 0;
308
309 // From now on each 'Close' means: Terminate the application
310 d->SetBit(MStatusDisplay::kExitLoopOnClose);
311
312 // Wait until the user decides to exit the application
313 app.Run(kFALSE);
314 return 0;
315}
Note: See TracBrowser for help on using the repository browser.