source: tags/Mars-V0.9.4.3/status.cc@ 9792

Last change on this file since 9792 was 4460, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 9.3 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#include "MCalibrate.h"
57#include "MExtractSignal.h"
58#include "MMcCalibrationUpdate.h"
59
60#include <TApplication.h>
61#include <TSystem.h>
62
63using namespace std;
64
65static void StartUpMessage()
66{
67 gLog << all << endl;
68
69 // 1 2 3 4 5
70 // 12345678901234567890123456789012345678901234567890
71 gLog << "==================================================" << endl;
72 gLog << " status - MARS V" << MARSVER << endl;
73 gLog << " MARS - Merging and Preprocessing Program" << endl;
74 gLog << " Compiled on <" << __DATE__ << ">" << endl;
75 gLog << " Using ROOT v" << ROOTVER << endl;
76 gLog << " PROGRAM IS PRELIMINARY - FOR TEST CASES ONLY" << endl;
77 gLog << "==================================================" << endl;
78 gLog << endl;
79}
80
81static void Usage()
82{
83 gLog << all << endl;
84 gLog << "Sorry the usage is:" << endl;
85 gLog << " status [-a0] [-vn] [-cn] inputfile[.root]" << endl << endl;
86 gLog << " input file: Mars root file." << endl;
87 gLog << " -a0: Do not use Ansii codes." << endl;
88 gLog << " -vn: Verbosity level n [default=2]" << endl;
89 gLog << " -?/-h: This help" << endl << endl;
90}
91
92
93int main(int argc, char **argv)
94{
95 StartUpMessage();
96
97 //
98 // Evaluate arguments
99 //
100 MArgs arg(argc, argv);
101
102 if (arg.HasOption("-?") || arg.HasOption("-h"))
103 {
104 Usage();
105 return -1;
106 }
107
108 //
109 // Set verbosity to highest level.
110 //
111 gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
112
113 if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
114 gLog.SetNoColors();
115
116 //
117 // check for the right usage of the program
118 //
119 if (arg.GetNumArguments()!=1)
120 {
121 Usage();
122 return -1;
123 }
124
125 //
126 // This is to make argv[i] more readable insidethe code
127 //
128 TString kNamein = arg.GetArgumentStr(0);
129
130 if (!kNamein.EndsWith(".root"))
131 kNamein += ".root";
132
133 //
134 // check whether the given files are OK.
135 //
136 if (gSystem->AccessPathName(kNamein, kFileExists))
137 {
138 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
139 return -1;
140 }
141
142 TApplication app("Status", &argc, argv);
143 if (gROOT->IsBatch() || !gClient)
144 {
145 gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
146 return 1;
147 }
148
149 MArray::Class()->IgnoreTObjectStreamer();
150 MParContainer::Class()->IgnoreTObjectStreamer();
151
152 //
153 // Update frequency by default = 1Hz
154 //
155 MStatusDisplay *d = new MStatusDisplay;
156
157 // From now on each 'Exit' means: Terminate the application
158 d->SetBit(MStatusDisplay::kExitLoopOnExit);
159
160 // Set update time to 5s
161 // d->SetUpdateTime(5000);
162
163 // Disable online update
164 // d->SetUpdateTime(-1);
165
166 d->SetLogStream(&gLog, kTRUE); // Disables output to stdout
167 gLog.SetOutputFile("status.log", kTRUE); // Enable output to file
168 //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
169
170 // Set input file as display title (bottom line in ps file)
171 d->SetTitle(kNamein);
172
173 //
174 // Create a empty Parameter List and an empty Task List
175 // The tasklist is identified in the eventloop by its name
176 //
177 MParList plist;
178
179 MTaskList tlist;
180 plist.AddToList(&tlist);
181
182 /*
183 MSrcPosCam src;
184 src.SetXY(1./geomcam.GetConvMm2Deg(), 0);
185 plist.AddToList(&src);
186 */
187
188 //
189 // Now setup the tasks and tasklist:
190 // ---------------------------------
191 //
192 MReadMarsFile read("Events");
193 //read.DisableAutoScheme();
194
195 // ------------- user change -----------------
196 read.AddFile(kNamein);
197
198 MGeomApply geomapl;
199 MMcPedestalCopy pcopy;
200 MMcPedestalNSBAdd pnsb;
201 //MCerPhotCalc ncalc;
202 MCerPhotAnal2 nanal;
203
204 MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
205 MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
206 f1.SetName("MFMonteCarlo");
207 f2.SetName("MFRealData");
208
209 MExtractSignal extra;
210 extra.SetRange(5, 9, 5, 9);
211
212 MMcCalibrationUpdate mcupd;
213 mcupd.SetOuterPixelsGainScaling(kFALSE);
214
215 MCalibrate calib;
216
217 // MC
218 extra.SetFilter(&f1);
219 mcupd.SetFilter(&f1);
220 calib.SetFilter(&f1);
221 nanal.SetFilter(&f2);
222
223 /*
224 TArrayS blinds(6);
225 blinds[0] = 0;
226 blinds[1] = 195;
227 blinds[2] = 227;
228 blinds[3] = 248;
229 blinds[4] = 271;
230 blinds[5] = 291;
231
232 blinds[3] = 51;
233 blinds[4] = 56;
234 blinds[5] = 112;
235 blinds[6] = 31;
236 blinds[7] = 116;
237 blinds[8] = 507;
238 blinds[9] = 559;
239 blinds[10]= 291; // 311, 119, 54, 85, 125, 92, 133, 224
240
241 MBlindPixelCalc blind;
242 blind.SetPixelIndices(blinds);
243 //blind.SetUseInterpolation();
244 */
245
246 // MSigmabarCalc sgcal;
247 MImgCleanStd clean;
248 MHillasCalc hcalc;
249 MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
250 // MCT1SupercutsCalc calc1;
251
252 // -------------------------------------------
253
254 MHCamEvent hist("PedestalRms");
255 hist.SetType(1);
256 plist.AddToList(&hist);
257
258 // -------------------------------------------
259
260 MHCamEvent maxhi("MaxIdxHi", "Index of slice with maximum content (hi-gain)");
261 MHCamEvent maxlo("MaxIdxLo", "Index of slice with maximum content (lo-gain)");
262 maxhi.SetType(3);
263 maxlo.SetType(4);
264 plist.AddToList(&maxhi);
265 plist.AddToList(&maxlo);
266
267 // -------------------------------------------
268
269 MFillH hfilhi("MaxIdxHi", "MRawEvtData");
270 MFillH hfillo("MaxIdxLo", "MRawEvtData");
271 MFillH hfill0("Uncleaned [MHCamEvent]", "MCerPhotEvt");
272 MFillH hfill1("Pedestals [MHCamEvent]", "MPedestalCam");
273 MFillH hfill2("PedestalRms", "MPedestalCam");
274 MFillH hfill3("MHHillas", "MHillas");
275 MFillH hfill4("MHHillasExt");
276 MFillH hfill5("MHHillasExtSrc [MHHillasExt]", "MHillasSrc");
277 MFillH hfill6("MHHillasSrc","MHillasSrc");
278 MFillH hfill7("MHNewImagePar","MNewImagePar");
279 //MFillH hfill8a("MHStarMap", "MHillas");
280 //MFillH hfill8b("MHStarMap2", "MHillas");
281 MFillH hfill9("Cleaned [MHCamEvent]", "MCerPhotEvt");
282 //MFillH hfill10("MHHadronness", "MHadronness");
283 //MFillH hfill11("MHSigmaTheta");
284
285 tlist.AddToList(&read);
286 tlist.AddToList(&f1);
287 tlist.AddToList(&f2);
288 tlist.AddToList(&geomapl);
289 tlist.AddToList(&pcopy);
290 tlist.AddToList(&pnsb);
291
292 tlist.AddToList(&extra);
293 tlist.AddToList(&mcupd);
294 tlist.AddToList(&calib);
295
296 tlist.AddToList(&nanal);
297 //tlist.AddToList(&blind);
298 tlist.AddToList(&hfilhi);
299 tlist.AddToList(&hfillo);
300 tlist.AddToList(&hfill0);
301 //tlist.AddToList(&sgcal);
302 tlist.AddToList(&clean);
303 tlist.AddToList(&hcalc);
304 tlist.AddToList(&scalc);
305 //tlist.AddToList(&calc1);
306 tlist.AddToList(&hfill1);
307 tlist.AddToList(&hfill2);
308 tlist.AddToList(&hfill3);
309 tlist.AddToList(&hfill4);
310 tlist.AddToList(&hfill5);
311 tlist.AddToList(&hfill6);
312 tlist.AddToList(&hfill7);
313 //tlist.AddToList(&hfill8a);
314 //tlist.AddToList(&hfill8b);
315 tlist.AddToList(&hfill9);
316 //tlist.AddToList(&hfill10);
317 //tlist.AddToList(&hfill11);
318
319 MEvtLoop evtloop;
320 evtloop.SetParList(&plist);
321 evtloop.SetDisplay(d);
322
323 //
324 // Execute your analysis
325 //
326 if (!evtloop.Eventloop())
327 return 1;
328
329 tlist.PrintStatistics();
330
331 if (!evtloop.GetDisplay())
332 return 0;
333
334 // From now on each 'Close' means: Terminate the application
335 d->SetBit(MStatusDisplay::kExitLoopOnClose);
336
337 // Wait until the user decides to exit the application
338 app.Run(kFALSE);
339 return 0;
340}
Note: See TracBrowser for help on using the repository browser.