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): Javier López, 12/2003 <mailto:jlopez@ifae.es>
|
---|
19 | ! Markus Gaug , 04/2004 <mailto:markus@ifae.es>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // bootcampstandardanalysis.C
|
---|
28 | //
|
---|
29 | // Updated version of the macro designed at the Wuerzburg bootcamp and
|
---|
30 | // compatible with the latest changes in Mars for general usage at the
|
---|
31 | // Udine bootcamp.
|
---|
32 | //
|
---|
33 | // Needs as arguments the run number of a pedestal file ("*_P_*.root"),
|
---|
34 | // one of a calibration file ("*_C_*.root") and one of a data file
|
---|
35 | // ("*_D_*.root"). Performs the pedestal calculation, the calibration
|
---|
36 | /// constants calculation and the calibration of the data.
|
---|
37 | //
|
---|
38 | // The TString inpath has to be set correctly.
|
---|
39 | //
|
---|
40 | // The macro searches for the pulser colour which corresponds to the calibration
|
---|
41 | // run number. If the run number is smaller than 20000, pulser colour "CT1"
|
---|
42 | // is assumed, otherwise, it searches for the strings "green", "blue", "uv" or
|
---|
43 | // "ct1" in the filenames. If no colour or multiple colours are found, the
|
---|
44 | // execution is aborted.
|
---|
45 | //
|
---|
46 | //////////////////////////////////////////////////////////////////////////////////
|
---|
47 | const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_02_10/";
|
---|
48 | const Int_t dpedrun = 14607;
|
---|
49 | const Int_t dcalrun1 = 14608;
|
---|
50 | const Int_t dcalrun2 = 0;
|
---|
51 | const Int_t ddatrun1 = 14609;
|
---|
52 | const Int_t ddatrun2 = 14614;
|
---|
53 | const Bool_t usedisplay = kTRUE;
|
---|
54 |
|
---|
55 | void bootcampstandardanalysis(const Int_t prun=dpedrun, // pedestal file
|
---|
56 | const Int_t crun1=dcalrun1, const Int_t crun2=dcalrun2, // calibration file(s)
|
---|
57 | const Int_t drun1=ddatrun1, const Int_t drun2=ddatrun2 // data files(s)
|
---|
58 | )
|
---|
59 |
|
---|
60 | {
|
---|
61 |
|
---|
62 | MExtractSlidingWindow extractor;
|
---|
63 |
|
---|
64 | MRunIter pruns;
|
---|
65 | MRunIter cruns;
|
---|
66 | MRunIter druns;
|
---|
67 |
|
---|
68 | pruns.AddRun(prun,inpath);
|
---|
69 |
|
---|
70 | if (crun2==0)
|
---|
71 | cruns.AddRun(crun1,inpath);
|
---|
72 | else
|
---|
73 | cruns.AddRuns(crun1,crun2,inpath);
|
---|
74 |
|
---|
75 | if (drun2==0)
|
---|
76 | druns.AddRun(drun1,inpath);
|
---|
77 | else
|
---|
78 | druns.AddRuns(drun1,drun2,inpath);
|
---|
79 |
|
---|
80 | //
|
---|
81 | // Now setup the tasks and tasklist for the pedestals:
|
---|
82 | // ---------------------------------------------------
|
---|
83 | //
|
---|
84 | MBadPixelsCam badcam;
|
---|
85 | MGeomCamMagic geomcam;
|
---|
86 | MGeomApply geomapl;
|
---|
87 | //
|
---|
88 | // If you want to exclude pixels from the beginning, read
|
---|
89 | // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
|
---|
90 | //
|
---|
91 | // badcam.AsciiRead("badpixels.dat");
|
---|
92 |
|
---|
93 | /************************************/
|
---|
94 | /* FIRST LOOP: PEDESTAL COMPUTATION */
|
---|
95 | /************************************/
|
---|
96 |
|
---|
97 | MJPedestal pedloop;
|
---|
98 | pedloop.SetInput(&pruns);
|
---|
99 | if (usedisplay)
|
---|
100 | {
|
---|
101 | MStatusDisplay *display = new MStatusDisplay;
|
---|
102 | display->SetUpdateTime(3000);
|
---|
103 | display->Resize(850,700);
|
---|
104 | pedloop.SetDisplay(display);
|
---|
105 | }
|
---|
106 | pedloop.SetBadPixels(badcam);
|
---|
107 |
|
---|
108 | if (!pedloop.Process())
|
---|
109 | return;
|
---|
110 |
|
---|
111 | /****************************************/
|
---|
112 | /* SECOND LOOP: CALIBRATION COMPUTATION */
|
---|
113 | /****************************************/
|
---|
114 |
|
---|
115 | //
|
---|
116 | // Now setup the new tasks for the calibration:
|
---|
117 | // ---------------------------------------------------
|
---|
118 | //
|
---|
119 | MCalibrationQECam qecam;
|
---|
120 | MJCalibration calloop;
|
---|
121 | calloop.SetInput(&cruns);
|
---|
122 | calloop.SetExtractor(&extractor);
|
---|
123 | //
|
---|
124 | // Set the corr. cams:
|
---|
125 | //
|
---|
126 | calloop.SetQECam(qecam);
|
---|
127 | calloop.SetBadPixels(pedloop.GetBadPixels());
|
---|
128 | //
|
---|
129 | // The next two commands are for the display:
|
---|
130 | //
|
---|
131 | if (usedisplay)
|
---|
132 | calloop.SetDisplay(display);
|
---|
133 |
|
---|
134 | //
|
---|
135 | // Apply rel. time calibration:
|
---|
136 | //
|
---|
137 | calloop.SetRelTimeCalibration();
|
---|
138 | //
|
---|
139 | // Use as arrival time extractor MArrivalTimeCalc2:
|
---|
140 | //
|
---|
141 | calloop.SetArrivalTimeLevel(2);
|
---|
142 |
|
---|
143 | //
|
---|
144 | // Do the event-loop:
|
---|
145 | //
|
---|
146 | if (!calloop.Process(pedloop.GetPedestalCam()))
|
---|
147 | return;
|
---|
148 |
|
---|
149 |
|
---|
150 | /*************************************/
|
---|
151 | /* THIRD LOOP: PEDESTAL CALIBRATION */
|
---|
152 | /*************************************/
|
---|
153 |
|
---|
154 | //
|
---|
155 | // Create a empty Parameter List and an empty Task List
|
---|
156 | //
|
---|
157 | MParList plist3;
|
---|
158 | MTaskList tlist3;
|
---|
159 | plist3.AddToList(&tlist3);
|
---|
160 |
|
---|
161 | //
|
---|
162 | // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
|
---|
163 | // -----------------------------------------------------------------------------------
|
---|
164 | //
|
---|
165 |
|
---|
166 | MCerPhotEvt nphot;
|
---|
167 | MPedPhotCam nphotrms;
|
---|
168 |
|
---|
169 | plist3.AddToList(&geomcam);
|
---|
170 |
|
---|
171 | //
|
---|
172 | // Retrieve the cameras from the previous runs:
|
---|
173 | //
|
---|
174 | plist3.AddToList(&pedloop.GetPedestalCam());
|
---|
175 | plist3.AddToList(&calloop.GetCalibrationCam());
|
---|
176 | plist3.AddToList(&calloop.GetQECam());
|
---|
177 | plist3.AddToList(&calloop.GetRelTimeCam());
|
---|
178 | plist3.AddToList(&calloop.GetBadPixels());
|
---|
179 | plist3.AddToList(&nphot);
|
---|
180 | plist3.AddToList(&nphotrms);
|
---|
181 |
|
---|
182 | //tasks
|
---|
183 | MReadMarsFile read3("Events");
|
---|
184 | read3.DisableAutoScheme();
|
---|
185 | static_cast<MRead&>(read3).AddFiles(pruns);
|
---|
186 |
|
---|
187 | MCalibrate photcalc;
|
---|
188 | photcalc.SetCalibrationMode(MCalibrate::kFfactor);
|
---|
189 | // MPedPhotCalc photrmscalc; //It doesn't exist yet
|
---|
190 |
|
---|
191 | tlist3.AddToList(&read3);
|
---|
192 | tlist3.AddToList(&geomapl);
|
---|
193 | tlist3.AddToList(&extractor);
|
---|
194 | tlist3.AddToList(&photcalc);
|
---|
195 | // tlist3.AddToList(&photrmscalc);
|
---|
196 |
|
---|
197 | //
|
---|
198 | // Create and setup the eventloop
|
---|
199 | //
|
---|
200 | MEvtLoop evtloop3;
|
---|
201 | evtloop3.SetParList(&plist3);
|
---|
202 |
|
---|
203 | //
|
---|
204 | // Execute first analysis
|
---|
205 | //
|
---|
206 | if (!evtloop3.Eventloop())
|
---|
207 | return;
|
---|
208 |
|
---|
209 | tlist3.PrintStatistics();
|
---|
210 |
|
---|
211 | /*************************************/
|
---|
212 | /* FOURTH LOOP: DATA CALIBRATION */
|
---|
213 | /*************************************/
|
---|
214 |
|
---|
215 | //
|
---|
216 | // Create a empty Parameter List and an empty Task List
|
---|
217 | //
|
---|
218 | MParList plist4;
|
---|
219 | MTaskList tlist4;
|
---|
220 | plist4.AddToList(&tlist4);
|
---|
221 |
|
---|
222 | //
|
---|
223 | // Now setup the tasks and tasklist to analize the data
|
---|
224 | // -----------------------------------------------------
|
---|
225 | //
|
---|
226 |
|
---|
227 | plist4.AddToList(&geomcam);
|
---|
228 | //
|
---|
229 | // Retrieve the cameras from the previous runs:
|
---|
230 | //
|
---|
231 | plist4.AddToList(&pedloop.GetPedestalCam());
|
---|
232 | plist4.AddToList(&calloop.GetCalibrationCam());
|
---|
233 | plist4.AddToList(&calloop.GetQECam());
|
---|
234 | plist4.AddToList(&calloop.GetRelTimeCam());
|
---|
235 | plist4.AddToList(&calloop.GetBadPixels());
|
---|
236 | plist4.AddToList(&nphot);
|
---|
237 | plist4.AddToList(&nphotrms);
|
---|
238 |
|
---|
239 | MArrivalTime times;
|
---|
240 | plist4.AddToList(×);
|
---|
241 |
|
---|
242 | //tasks
|
---|
243 | MReadMarsFile read4("Events");
|
---|
244 | read4.DisableAutoScheme();
|
---|
245 | static_cast<MRead&>(read4).AddFiles(druns);
|
---|
246 |
|
---|
247 | MArrivalTimeCalc2 timecalc;
|
---|
248 | MCalibrateRelTimes timecal;
|
---|
249 |
|
---|
250 | tlist4.AddToList(&read4);
|
---|
251 | tlist4.AddToList(&geomapl);
|
---|
252 | tlist4.AddToList(&extractor);
|
---|
253 | tlist4.AddToList(&timecalc);
|
---|
254 | tlist4.AddToList(&photcalc);
|
---|
255 | tlist4.AddToList(&timecal);
|
---|
256 |
|
---|
257 | //
|
---|
258 | // Create and setup the eventloop
|
---|
259 | //
|
---|
260 | MEvtLoop evtloop4;
|
---|
261 | evtloop4.SetParList(&plist4);
|
---|
262 |
|
---|
263 | if (!evtloop4.PreProcess())
|
---|
264 | return;
|
---|
265 |
|
---|
266 | TCanvas *c1 = new TCanvas;
|
---|
267 | MHCamera disp1(geomcam);
|
---|
268 | disp1.SetPrettyPalette();
|
---|
269 | //disp1.SetInvDeepBlueSeaPalette()
|
---|
270 | disp1.Draw();
|
---|
271 | gPad->SetLogy();
|
---|
272 | gPad->cd(1);
|
---|
273 |
|
---|
274 | /*
|
---|
275 | TCanvas *c2 = new TCanvas;
|
---|
276 | MHCamera disp2(geomcam);
|
---|
277 | disp2.SetPrettyPalette();
|
---|
278 | //disp2.SetInvDeepBlueSeaPalette()
|
---|
279 | disp2.Draw();
|
---|
280 | gPad->SetLogy();
|
---|
281 | gPad->cd(1);
|
---|
282 | */
|
---|
283 | while (tlist4.Process())
|
---|
284 | {
|
---|
285 | disp1.SetCamContent(nphot);
|
---|
286 |
|
---|
287 | gPad->Modified();
|
---|
288 | gPad->Update();
|
---|
289 |
|
---|
290 | /*
|
---|
291 | disp2.SetCamContent(times);
|
---|
292 |
|
---|
293 | gPad->Modified();
|
---|
294 | gPad->Update();
|
---|
295 | */
|
---|
296 |
|
---|
297 | // Remove the comments if you want to go through the file
|
---|
298 | // event-by-event:
|
---|
299 | if (!HandleInput())
|
---|
300 | break;
|
---|
301 | }
|
---|
302 |
|
---|
303 | evtloop4.PostProcess();
|
---|
304 |
|
---|
305 | }
|
---|
306 |
|
---|
307 | Bool_t HandleInput()
|
---|
308 | {
|
---|
309 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
310 |
|
---|
311 | while (1)
|
---|
312 | {
|
---|
313 | //
|
---|
314 | // While reading the input process gui events asynchronously
|
---|
315 | //
|
---|
316 | timer.TurnOn();
|
---|
317 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
---|
318 | timer.TurnOff();
|
---|
319 |
|
---|
320 | if (input=="q\n")
|
---|
321 | return kFALSE;
|
---|
322 |
|
---|
323 | if (input=="\n")
|
---|
324 | return kTRUE;
|
---|
325 | };
|
---|
326 |
|
---|
327 | return kFALSE;
|
---|
328 | }
|
---|
329 |
|
---|