source: trunk/MagicSoft/Mars/macros/bootcampstandardanalysis.C@ 4122

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