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 |
|
---|
60 | static 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 |
|
---|
76 | static 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 |
|
---|
88 | int 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 | // Set update time to 5s
|
---|
153 | // d->SetUpdateTime(5000);
|
---|
154 |
|
---|
155 | // Disable online update
|
---|
156 | // d->SetUpdateTime(-1);
|
---|
157 |
|
---|
158 | d->SetLogStream(&gLog, kTRUE); // Disables output to stdout
|
---|
159 | gLog.SetOutputFile("status.log", kTRUE); // Enable output to file
|
---|
160 | //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
|
---|
161 |
|
---|
162 | //
|
---|
163 | // Create a empty Parameter List and an empty Task List
|
---|
164 | // The tasklist is identified in the eventloop by its name
|
---|
165 | //
|
---|
166 | MParList plist;
|
---|
167 |
|
---|
168 | MTaskList tlist;
|
---|
169 | plist.AddToList(&tlist);
|
---|
170 |
|
---|
171 | /*
|
---|
172 | MSrcPosCam src;
|
---|
173 | src.SetXY(1./geomcam.GetConvMm2Deg(), 0);
|
---|
174 | plist.AddToList(&src);
|
---|
175 | */
|
---|
176 |
|
---|
177 | //
|
---|
178 | // Now setup the tasks and tasklist:
|
---|
179 | // ---------------------------------
|
---|
180 | //
|
---|
181 | MReadMarsFile read("Events");
|
---|
182 | //read.DisableAutoScheme();
|
---|
183 |
|
---|
184 | // ------------- user change -----------------
|
---|
185 | read.AddFile(kNamein);
|
---|
186 |
|
---|
187 | MGeomApply geomapl;
|
---|
188 | MMcPedestalCopy pcopy;
|
---|
189 | MMcPedestalNSBAdd pnsb;
|
---|
190 | MCerPhotCalc ncalc;
|
---|
191 | MCerPhotAnal2 nanal;
|
---|
192 |
|
---|
193 | MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
|
---|
194 | MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
|
---|
195 |
|
---|
196 | ncalc.SetFilter(&f1);
|
---|
197 | nanal.SetFilter(&f2);
|
---|
198 | /*
|
---|
199 | TArrayS blinds(6);
|
---|
200 | blinds[0] = 0;
|
---|
201 | blinds[1] = 195;
|
---|
202 | blinds[2] = 227;
|
---|
203 | blinds[3] = 248;
|
---|
204 | blinds[4] = 271;
|
---|
205 | blinds[5] = 291;
|
---|
206 |
|
---|
207 | blinds[3] = 51;
|
---|
208 | blinds[4] = 56;
|
---|
209 | blinds[5] = 112;
|
---|
210 | blinds[6] = 31;
|
---|
211 | blinds[7] = 116;
|
---|
212 | blinds[8] = 507;
|
---|
213 | blinds[9] = 559;
|
---|
214 | blinds[10]= 291; // 311, 119, 54, 85, 125, 92, 133, 224
|
---|
215 |
|
---|
216 | MBlindPixelCalc blind;
|
---|
217 | blind.SetPixelIndices(blinds);
|
---|
218 | //blind.SetUseInterpolation();
|
---|
219 | */
|
---|
220 | // MSigmabarCalc sgcal;
|
---|
221 | MImgCleanStd clean;
|
---|
222 | MHillasCalc hcalc;
|
---|
223 | MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
|
---|
224 | // MCT1SupercutsCalc calc1;
|
---|
225 |
|
---|
226 | // -------------------------------------------
|
---|
227 |
|
---|
228 | MHCamEvent hist("PedestalRms");
|
---|
229 | hist.SetType(1);
|
---|
230 | plist.AddToList(&hist);
|
---|
231 |
|
---|
232 | // -------------------------------------------
|
---|
233 | - added display of average index of slice witg maximum value
|
---|
234 |
|
---|
235 | MHCamEvent maxhi("MaxIdxHi", "Index of slice with maximum content (hi-gain)");
|
---|
236 | MHCamEvent maxlo("MaxIdxLo", "Index of slice with maximum content (lo-gain)");
|
---|
237 | maxhi.SetType(3);
|
---|
238 | maxlo.SetType(4);
|
---|
239 | plist.AddToList(&maxhi);
|
---|
240 | plist.AddToList(&maxlo);
|
---|
241 |
|
---|
242 | // -------------------------------------------
|
---|
243 |
|
---|
244 | MFillH hfilhi("MaxIdxHi", "MRawEvtData");
|
---|
245 | MFillH hfillo("MaxIdxLo", "MRawEvtData");
|
---|
246 | MFillH hfill0("Uncleaned [MHCamEvent]", "MCerPhotEvt");
|
---|
247 | MFillH hfill1("Pedestals [MHCamEvent]", "MPedestalCam");
|
---|
248 | MFillH hfill2("PedestalRms", "MPedestalCam");
|
---|
249 | MFillH hfill3("MHHillas", "MHillas");
|
---|
250 | MFillH hfill4("MHHillasExt");
|
---|
251 | MFillH hfill5("MHHillasExtSrc [MHHillasExt]", "MHillasSrc");
|
---|
252 | MFillH hfill6("MHHillasSrc","MHillasSrc");
|
---|
253 | MFillH hfill7("MHNewImagePar","MNewImagePar");
|
---|
254 | //MFillH hfill8a("MHStarMap", "MHillas");
|
---|
255 | //MFillH hfill8b("MHStarMap2", "MHillas");
|
---|
256 | MFillH hfill9("Cleaned [MHCamEvent]", "MCerPhotEvt");
|
---|
257 | //MFillH hfill10("MHHadronness", "MHadronness");
|
---|
258 | //MFillH hfill11("MHSigmaTheta");
|
---|
259 |
|
---|
260 | tlist.AddToList(&read);
|
---|
261 | tlist.AddToList(&f1);
|
---|
262 | tlist.AddToList(&f2);
|
---|
263 | tlist.AddToList(&geomapl);
|
---|
264 | tlist.AddToList(&pcopy);
|
---|
265 | tlist.AddToList(&pnsb);
|
---|
266 | tlist.AddToList(&ncalc);
|
---|
267 | tlist.AddToList(&nanal);
|
---|
268 | //tlist.AddToList(&blind);
|
---|
269 | tlist.AddToList(&hfilhi);
|
---|
270 | tlist.AddToList(&hfillo);
|
---|
271 | tlist.AddToList(&hfill0);
|
---|
272 | //tlist.AddToList(&sgcal);
|
---|
273 | tlist.AddToList(&clean);
|
---|
274 | tlist.AddToList(&hcalc);
|
---|
275 | tlist.AddToList(&scalc);
|
---|
276 | //tlist.AddToList(&calc1);
|
---|
277 | tlist.AddToList(&hfill1);
|
---|
278 | tlist.AddToList(&hfill2);
|
---|
279 | tlist.AddToList(&hfill3);
|
---|
280 | tlist.AddToList(&hfill4);
|
---|
281 | tlist.AddToList(&hfill5);
|
---|
282 | tlist.AddToList(&hfill6);
|
---|
283 | tlist.AddToList(&hfill7);
|
---|
284 | //tlist.AddToList(&hfill8a);
|
---|
285 | //tlist.AddToList(&hfill8b);
|
---|
286 | tlist.AddToList(&hfill9);
|
---|
287 | //tlist.AddToList(&hfill10);
|
---|
288 | //tlist.AddToList(&hfill11);
|
---|
289 |
|
---|
290 | MEvtLoop evtloop;
|
---|
291 | evtloop.SetParList(&plist);
|
---|
292 | evtloop.SetDisplay(d);
|
---|
293 |
|
---|
294 | //
|
---|
295 | // Execute your analysis
|
---|
296 | //
|
---|
297 | if (!evtloop.Eventloop())
|
---|
298 | return 1;
|
---|
299 |
|
---|
300 | tlist.PrintStatistics();
|
---|
301 |
|
---|
302 | return 0;
|
---|
303 | }
|
---|