source: trunk/MagicSoft/Mars/status.cc@ 3421

Last change on this file since 3421 was 2773, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 8.9 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 // Set input file as display title (bottom line in ps file)
168 d->SetTitle(kNamein);
169
170 //
171 // Create a empty Parameter List and an empty Task List
172 // The tasklist is identified in the eventloop by its name
173 //
174 MParList plist;
175
176 MTaskList tlist;
177 plist.AddToList(&tlist);
178
179 /*
180 MSrcPosCam src;
181 src.SetXY(1./geomcam.GetConvMm2Deg(), 0);
182 plist.AddToList(&src);
183 */
184
185 //
186 // Now setup the tasks and tasklist:
187 // ---------------------------------
188 //
189 MReadMarsFile read("Events");
190 //read.DisableAutoScheme();
191
192 // ------------- user change -----------------
193 read.AddFile(kNamein);
194
195 MGeomApply geomapl;
196 MMcPedestalCopy pcopy;
197 MMcPedestalNSBAdd pnsb;
198 MCerPhotCalc ncalc;
199 MCerPhotAnal2 nanal;
200
201 MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
202 MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
203
204 ncalc.SetFilter(&f1);
205 nanal.SetFilter(&f2);
206/*
207 TArrayS blinds(6);
208 blinds[0] = 0;
209 blinds[1] = 195;
210 blinds[2] = 227;
211 blinds[3] = 248;
212 blinds[4] = 271;
213 blinds[5] = 291;
214
215 blinds[3] = 51;
216 blinds[4] = 56;
217 blinds[5] = 112;
218 blinds[6] = 31;
219 blinds[7] = 116;
220 blinds[8] = 507;
221 blinds[9] = 559;
222 blinds[10]= 291; // 311, 119, 54, 85, 125, 92, 133, 224
223
224 MBlindPixelCalc blind;
225 blind.SetPixelIndices(blinds);
226 //blind.SetUseInterpolation();
227*/
228 // MSigmabarCalc sgcal;
229 MImgCleanStd clean;
230 MHillasCalc hcalc;
231 MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
232 // MCT1SupercutsCalc calc1;
233
234 // -------------------------------------------
235
236 MHCamEvent hist("PedestalRms");
237 hist.SetType(1);
238 plist.AddToList(&hist);
239
240 // -------------------------------------------
241
242 MHCamEvent maxhi("MaxIdxHi", "Index of slice with maximum content (hi-gain)");
243 MHCamEvent maxlo("MaxIdxLo", "Index of slice with maximum content (lo-gain)");
244 maxhi.SetType(3);
245 maxlo.SetType(4);
246 plist.AddToList(&maxhi);
247 plist.AddToList(&maxlo);
248
249 // -------------------------------------------
250
251 MFillH hfilhi("MaxIdxHi", "MRawEvtData");
252 MFillH hfillo("MaxIdxLo", "MRawEvtData");
253 MFillH hfill0("Uncleaned [MHCamEvent]", "MCerPhotEvt");
254 MFillH hfill1("Pedestals [MHCamEvent]", "MPedestalCam");
255 MFillH hfill2("PedestalRms", "MPedestalCam");
256 MFillH hfill3("MHHillas", "MHillas");
257 MFillH hfill4("MHHillasExt");
258 MFillH hfill5("MHHillasExtSrc [MHHillasExt]", "MHillasSrc");
259 MFillH hfill6("MHHillasSrc","MHillasSrc");
260 MFillH hfill7("MHNewImagePar","MNewImagePar");
261 //MFillH hfill8a("MHStarMap", "MHillas");
262 //MFillH hfill8b("MHStarMap2", "MHillas");
263 MFillH hfill9("Cleaned [MHCamEvent]", "MCerPhotEvt");
264 //MFillH hfill10("MHHadronness", "MHadronness");
265 //MFillH hfill11("MHSigmaTheta");
266
267 tlist.AddToList(&read);
268 tlist.AddToList(&f1);
269 tlist.AddToList(&f2);
270 tlist.AddToList(&geomapl);
271 tlist.AddToList(&pcopy);
272 tlist.AddToList(&pnsb);
273 tlist.AddToList(&ncalc);
274 tlist.AddToList(&nanal);
275 //tlist.AddToList(&blind);
276 tlist.AddToList(&hfilhi);
277 tlist.AddToList(&hfillo);
278 tlist.AddToList(&hfill0);
279 //tlist.AddToList(&sgcal);
280 tlist.AddToList(&clean);
281 tlist.AddToList(&hcalc);
282 tlist.AddToList(&scalc);
283 //tlist.AddToList(&calc1);
284 tlist.AddToList(&hfill1);
285 tlist.AddToList(&hfill2);
286 tlist.AddToList(&hfill3);
287 tlist.AddToList(&hfill4);
288 tlist.AddToList(&hfill5);
289 tlist.AddToList(&hfill6);
290 tlist.AddToList(&hfill7);
291 //tlist.AddToList(&hfill8a);
292 //tlist.AddToList(&hfill8b);
293 tlist.AddToList(&hfill9);
294 //tlist.AddToList(&hfill10);
295 //tlist.AddToList(&hfill11);
296
297 MEvtLoop evtloop;
298 evtloop.SetParList(&plist);
299 evtloop.SetDisplay(d);
300
301 //
302 // Execute your analysis
303 //
304 if (!evtloop.Eventloop())
305 return 1;
306
307 tlist.PrintStatistics();
308
309 if (!evtloop.GetDisplay())
310 return 0;
311
312 // From now on each 'Close' means: Terminate the application
313 d->SetBit(MStatusDisplay::kExitLoopOnClose);
314
315 // Wait until the user decides to exit the application
316 app.Run(kFALSE);
317 return 0;
318}
Note: See TracBrowser for help on using the repository browser.