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 | MRunIter pruns;
|
---|
63 | MRunIter cruns;
|
---|
64 | MRunIter druns;
|
---|
65 |
|
---|
66 | pruns.AddRun(prun,inpath);
|
---|
67 |
|
---|
68 | if (crun2==0)
|
---|
69 | cruns.AddRun(crun1,inpath);
|
---|
70 | else
|
---|
71 | cruns.AddRuns(crun1,crun2,inpath);
|
---|
72 |
|
---|
73 | if (drun2==0)
|
---|
74 | druns.AddRun(drun1,inpath);
|
---|
75 | else
|
---|
76 | druns.AddRuns(drun1,drun2,inpath);
|
---|
77 |
|
---|
78 | //
|
---|
79 | // Now setup the tasks and tasklist for the pedestals:
|
---|
80 | // ---------------------------------------------------
|
---|
81 | //
|
---|
82 | MBadPixelsCam badcam;
|
---|
83 | MGeomCamMagic geomcam;
|
---|
84 | MGeomApply geomapl;
|
---|
85 | //
|
---|
86 | // If you want to exclude pixels from the beginning, read
|
---|
87 | // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
|
---|
88 | //
|
---|
89 | // badcam.AsciiRead("badpixels.dat");
|
---|
90 |
|
---|
91 | /************************************/
|
---|
92 | /* FIRST LOOP: PEDESTAL COMPUTATION */
|
---|
93 | /************************************/
|
---|
94 |
|
---|
95 | MJPedestal pedloop;
|
---|
96 | pedloop.SetInput(&pruns);
|
---|
97 | if (usedisplay)
|
---|
98 | {
|
---|
99 | MStatusDisplay *display = new MStatusDisplay;
|
---|
100 | display->SetUpdateTime(3000);
|
---|
101 | display->Resize(850,700);
|
---|
102 | pedloop.SetDisplay(display);
|
---|
103 | }
|
---|
104 | pedloop.SetBadPixels(badcam);
|
---|
105 |
|
---|
106 | if (!pedloop.Process())
|
---|
107 | return;
|
---|
108 |
|
---|
109 | /****************************************/
|
---|
110 | /* SECOND LOOP: CALIBRATION COMPUTATION */
|
---|
111 | /****************************************/
|
---|
112 |
|
---|
113 | //
|
---|
114 | // Now setup the new tasks for the calibration:
|
---|
115 | // ---------------------------------------------------
|
---|
116 | //
|
---|
117 | MCalibrationQECam qecam;
|
---|
118 | MJCalibration calloop;
|
---|
119 | calloop.SetInput(&cruns);
|
---|
120 | //
|
---|
121 | // Use as signal extractor MExtractSignal:
|
---|
122 | //
|
---|
123 | calloop.SetExtractorLevel(1);
|
---|
124 | //
|
---|
125 | // Set the corr. cams:
|
---|
126 | //
|
---|
127 | calloop.SetQECam(qecam);
|
---|
128 | calloop.SetBadPixels(pedloop.GetBadPixels());
|
---|
129 | //
|
---|
130 | // The next two commands are for the display:
|
---|
131 | //
|
---|
132 | if (usedisplay)
|
---|
133 | calloop.SetDisplay(display);
|
---|
134 |
|
---|
135 | //
|
---|
136 | // Apply rel. time calibration:
|
---|
137 | //
|
---|
138 | calloop.SetRelTimeCalibration();
|
---|
139 | //
|
---|
140 | // Use as arrival time extractor MArrivalTimeCalc2:
|
---|
141 | //
|
---|
142 | calloop.SetArrivalTimeLevel(2);
|
---|
143 |
|
---|
144 | //
|
---|
145 | // Do the event-loop:
|
---|
146 | //
|
---|
147 | if (!calloop.Process(pedloop.GetPedestalCam()))
|
---|
148 | return;
|
---|
149 |
|
---|
150 |
|
---|
151 | /*************************************/
|
---|
152 | /* THIRD LOOP: PEDESTAL CALIBRATION */
|
---|
153 | /*************************************/
|
---|
154 |
|
---|
155 | //
|
---|
156 | // Create a empty Parameter List and an empty Task List
|
---|
157 | //
|
---|
158 | MParList plist3;
|
---|
159 | MTaskList tlist3;
|
---|
160 | plist3.AddToList(&tlist3);
|
---|
161 |
|
---|
162 | //
|
---|
163 | // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
|
---|
164 | // -----------------------------------------------------------------------------------
|
---|
165 | //
|
---|
166 |
|
---|
167 | MCerPhotEvt nphot;
|
---|
168 | MPedPhotCam nphotrms;
|
---|
169 |
|
---|
170 | plist3.AddToList(&geomcam);
|
---|
171 |
|
---|
172 | //
|
---|
173 | // Retrieve the cameras from the previous runs:
|
---|
174 | //
|
---|
175 | plist3.AddToList(&pedloop.GetPedestalCam());
|
---|
176 | plist3.AddToList(&calloop.GetCalibrationCam());
|
---|
177 | plist3.AddToList(&calloop.GetQECam());
|
---|
178 | plist3.AddToList(&calloop.GetRelTimeCam());
|
---|
179 | plist3.AddToList(&calloop.GetBadPixels());
|
---|
180 | plist3.AddToList(&nphot);
|
---|
181 | plist3.AddToList(&nphotrms);
|
---|
182 |
|
---|
183 | //tasks
|
---|
184 | MReadMarsFile read3("Events");
|
---|
185 | read3.DisableAutoScheme();
|
---|
186 | static_cast<MRead&>(read3).AddFiles(pruns);
|
---|
187 |
|
---|
188 | MExtractSignal extsig;
|
---|
189 | MCalibrate photcalc;
|
---|
190 | photcalc.SetCalibrationMode(MCalibrate::kFfactor);
|
---|
191 | // MPedPhotCalc photrmscalc; //It doesn't exist yet
|
---|
192 |
|
---|
193 | tlist3.AddToList(&read3);
|
---|
194 | tlist3.AddToList(&geomapl);
|
---|
195 | tlist3.AddToList(&extsig);
|
---|
196 | tlist3.AddToList(&photcalc);
|
---|
197 | // tlist3.AddToList(&photrmscalc);
|
---|
198 |
|
---|
199 | //
|
---|
200 | // Create and setup the eventloop
|
---|
201 | //
|
---|
202 | MEvtLoop evtloop3;
|
---|
203 | evtloop3.SetParList(&plist3);
|
---|
204 |
|
---|
205 | //
|
---|
206 | // Execute first analysis
|
---|
207 | //
|
---|
208 | if (!evtloop3.Eventloop())
|
---|
209 | return;
|
---|
210 |
|
---|
211 | tlist3.PrintStatistics();
|
---|
212 |
|
---|
213 | /*************************************/
|
---|
214 | /* FOURTH LOOP: DATA CALIBRATION */
|
---|
215 | /*************************************/
|
---|
216 |
|
---|
217 | //
|
---|
218 | // Create a empty Parameter List and an empty Task List
|
---|
219 | //
|
---|
220 | MParList plist4;
|
---|
221 | MTaskList tlist4;
|
---|
222 | plist4.AddToList(&tlist4);
|
---|
223 |
|
---|
224 | //
|
---|
225 | // Now setup the tasks and tasklist to analize the data
|
---|
226 | // -----------------------------------------------------
|
---|
227 | //
|
---|
228 |
|
---|
229 | plist4.AddToList(&geomcam);
|
---|
230 | //
|
---|
231 | // Retrieve the cameras from the previous runs:
|
---|
232 | //
|
---|
233 | plist4.AddToList(&pedloop.GetPedestalCam());
|
---|
234 | plist4.AddToList(&calloop.GetCalibrationCam());
|
---|
235 | plist4.AddToList(&calloop.GetQECam());
|
---|
236 | plist4.AddToList(&calloop.GetRelTimeCam());
|
---|
237 | plist4.AddToList(&calloop.GetBadPixels());
|
---|
238 | plist4.AddToList(&nphot);
|
---|
239 | plist4.AddToList(&nphotrms);
|
---|
240 |
|
---|
241 | MArrivalTime times;
|
---|
242 | plist4.AddToList(×);
|
---|
243 |
|
---|
244 | //tasks
|
---|
245 | MReadMarsFile read4("Events");
|
---|
246 | read4.DisableAutoScheme();
|
---|
247 | static_cast<MRead&>(read4).AddFiles(druns);
|
---|
248 |
|
---|
249 | MArrivalTimeCalc2 timecalc;
|
---|
250 | MCalibrateRelTimes timecal;
|
---|
251 |
|
---|
252 | tlist4.AddToList(&read4);
|
---|
253 | tlist4.AddToList(&geomapl);
|
---|
254 | tlist4.AddToList(&extsig);
|
---|
255 | tlist4.AddToList(&timecalc);
|
---|
256 | tlist4.AddToList(&photcalc);
|
---|
257 | tlist4.AddToList(&timecal);
|
---|
258 |
|
---|
259 | //
|
---|
260 | // Create and setup the eventloop
|
---|
261 | //
|
---|
262 | MEvtLoop evtloop4;
|
---|
263 | evtloop4.SetParList(&plist4);
|
---|
264 |
|
---|
265 | if (!evtloop4.PreProcess())
|
---|
266 |
|
---|
267 | return;
|
---|
268 |
|
---|
269 | TCanvas *c1 = new TCanvas;
|
---|
270 | MHCamera disp1(geomcam);
|
---|
271 | disp1.SetPrettyPalette();
|
---|
272 | //disp1.SetInvDeepBlueSeaPalette()
|
---|
273 | disp1.Draw();
|
---|
274 | gPad->SetLogy();
|
---|
275 | gPad->cd(1);
|
---|
276 |
|
---|
277 | /*
|
---|
278 | TCanvas *c2 = new TCanvas;
|
---|
279 | MHCamera disp2(geomcam);
|
---|
280 | disp2.SetPrettyPalette();
|
---|
281 | //disp2.SetInvDeepBlueSeaPalette()
|
---|
282 | disp2.Draw();
|
---|
283 | gPad->SetLogy();
|
---|
284 | gPad->cd(1);
|
---|
285 | */
|
---|
286 | while (tlist4.Process())
|
---|
287 | {
|
---|
288 | disp1.SetCamContent(nphot);
|
---|
289 |
|
---|
290 | gPad->Modified();
|
---|
291 | gPad->Update();
|
---|
292 |
|
---|
293 | /*
|
---|
294 | disp2.SetCamContent(times);
|
---|
295 |
|
---|
296 | gPad->Modified();
|
---|
297 | gPad->Update();
|
---|
298 | */
|
---|
299 |
|
---|
300 | // Remove the comments if you want to go through the file
|
---|
301 | // event-by-event:
|
---|
302 | if (!HandleInput())
|
---|
303 | break;
|
---|
304 | }
|
---|
305 |
|
---|
306 | evtloop4.PostProcess();
|
---|
307 |
|
---|
308 | }
|
---|
309 |
|
---|
310 | Bool_t HandleInput()
|
---|
311 | {
|
---|
312 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
313 |
|
---|
314 | while (1)
|
---|
315 | {
|
---|
316 | //
|
---|
317 | // While reading the input process gui events asynchronously
|
---|
318 | //
|
---|
319 | timer.TurnOn();
|
---|
320 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
---|
321 | timer.TurnOff();
|
---|
322 |
|
---|
323 | if (input=="q\n")
|
---|
324 | return kFALSE;
|
---|
325 |
|
---|
326 | if (input=="\n")
|
---|
327 | return kTRUE;
|
---|
328 | };
|
---|
329 |
|
---|
330 | return kFALSE;
|
---|
331 | }
|
---|
332 |
|
---|