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

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