source: trunk/MagicSoft/Mars/mtemp/mpisa/macros/production3.C@ 4438

Last change on this file since 4438 was 4187, checked in by galante, 20 years ago
*** empty log message ***
File size: 10.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 Bool_t usedisplay = kTRUE;
48const TString defpath = "/data1/earth/magic/data/Period015/rootdata/2004_03_19/";
49const TString outpath = "./";
50const TString defrout = "output_Mrk421_20040319.root";
51// Mrk (13)
52const Int_t defpedr[] = {20823};
53//const Int_t defpedr [] = {20590,20593,20596,20599,20601,20602,20605,
54// 20608,20611,20614,20649,20652,20654};
55// OffMrk (14)
56//const Int_t defpedr [] = {20617,20619,20621,20623,20625,20628,20630,
57// 20632,20635,20637,20640,20643,20645,20647};
58
59
60//const Int_t defcalr [] = {20651};
61const Int_t defcalr [] = {20822};
62
63// Mrk (20)
64const Int_t defdatar[] = {20824};
65//const Int_t defdatar[] = {20591,20592,20594,20595,20597,20598,20600,
66// 20603,20604,20606,20607,20609,20610,20612,
67// 20613,20615,20616,20650,20653,20655};
68// OffMrk (18)
69// const Int_t defdatar[] = {20618,20620,20622,20624,20626,20627,20629,
70// 20631,20633,20634,20636,20638,20639,20641,
71// 20642,20644,20646,20648};
72
73
74void production3(const TString inpath=defpath,
75 const Int_t psize=1, const Int_t pedruns[]=defpedr,
76 const Int_t csize=1, const Int_t calruns[]=defcalr,
77 const Int_t dsize=1, const Int_t dataruns[]=defdatar,
78 const TString resname=defrout)
79
80{
81
82 //
83 // Choose the signal Extractor:
84 //
85 //MExtractSlidingWindow extractor;
86 MExtractFixedWindowPeakSearch extractor;
87 //MExtractFixedWindow extractor;
88
89 //
90 // Set Ranges or Windows
91 //
92 extractor.SetRange(3,14,3,14);
93 //extractor.SetWindows(8,8);
94
95 //
96 // Choose the arrival time Extractor:
97 //
98 MExtractTimeFastSpline timeext;
99 // MExtractTimeHighestIntegral timeext;
100 // MExtractTimeSpline timeext;
101 //
102 // Set Ranges or Windows
103 //
104 timeext.SetRange(2,12,4,14);
105
106
107 MRunIter pruns;
108 MRunIter cruns;
109 MRunIter druns;
110
111 for (Int_t i=0;i<psize;i++) {
112 cout << "Adding pedestal run: " << pedruns[i] << endl;
113 pruns.AddRun(pedruns[i],inpath);
114 }
115 for (Int_t i=0;i<csize;i++) {
116 cout << "Adding calibration run: " << calruns[i] << endl;
117 cruns.AddRun(calruns[i],inpath);
118 }
119 for (Int_t i=0;i<dsize;i++) {
120 cout << "Adding data run: " << dataruns[i] << endl;
121 druns.AddRun(dataruns[i],inpath);
122 }
123
124
125 //
126 // Now setup the tasks and tasklist for the pedestals:
127 // ---------------------------------------------------
128 //
129 MBadPixelsCam badcam;
130 MGeomCamMagic geomcam;
131 MGeomApply geomapl;
132 //
133 // If you want to exclude pixels from the beginning, read
134 // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
135 //
136 // badcam.AsciiRead("badpixels.dat");
137
138 /************************************/
139 /* FIRST LOOP: PEDESTAL COMPUTATION */
140 /************************************/
141
142 MJPedestal pedloop;
143 pedloop.SetInput(&pruns);
144 if (usedisplay)
145 {
146 MStatusDisplay *display = new MStatusDisplay;
147 display->SetUpdateTime(3000);
148 display->Resize(850,700);
149 pedloop.SetDisplay(display);
150 }
151 pedloop.SetBadPixels(badcam);
152 pedloop.SetExtractor(&extractor);
153
154 if (!pedloop.Process())
155 return;
156
157 /****************************************/
158 /* SECOND LOOP: CALIBRATION COMPUTATION */
159 /****************************************/
160
161 //
162 // Now setup the new tasks for the calibration:
163 // ---------------------------------------------------
164 //
165 MCalibrationQECam qecam;
166 MJCalibration calloop;
167 calloop.SetInput(&cruns);
168 calloop.SetExtractor(&extractor);
169 //
170 // Apply rel. time calibration:
171 //
172 calloop.SetRelTimeCalibration();
173 calloop.SetTimeExtractor(&timeext);
174 //
175 // Set the corr. cams:
176 //
177 calloop.SetQECam(qecam);
178 calloop.SetBadPixels(pedloop.GetBadPixels());
179 //
180 // The next two commands are for the display:
181 //
182 if (usedisplay)
183 calloop.SetDisplay(display);
184 cout << "Minchia 0" << endl;
185 //
186 // Do the event-loop:
187 //
188 if (!calloop.Process(pedloop.GetPedestalCam()))
189 return;
190
191 cout << "Minchia 1" << endl;
192 /*************************************/
193 /* THIRD LOOP: PEDESTAL CALIBRATION */
194 /*************************************/
195
196 //
197 // Create a empty Parameter List and an empty Task List
198 //
199 MParList plist3;
200 MTaskList tlist3;
201 plist3.AddToList(&tlist3);
202 cout << "Minchia 2" << endl;
203 //
204 // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
205 // -----------------------------------------------------------------------------------
206 //
207
208 MCerPhotEvt nphot;
209 MPedPhotCam nphotrms;
210
211 plist3.AddToList(&geomcam);
212 cout << "Minchia 3" << endl;
213 //
214 // Retrieve the cameras from the previous runs:
215 //
216 plist3.AddToList(&pedloop.GetPedestalCam());
217 plist3.AddToList(&calloop.GetCalibrationCam());
218 plist3.AddToList(&calloop.GetQECam());
219 plist3.AddToList(&calloop.GetRelTimeCam());
220 plist3.AddToList(&calloop.GetBadPixels());
221 plist3.AddToList(&nphot);
222 plist3.AddToList(&nphotrms);
223 cout << "Minchia 4" << endl;
224 //tasks
225 MReadMarsFile read3("Events");
226 read3.DisableAutoScheme();
227 static_cast<MRead&>(read3).AddFiles(pruns);
228
229 //MCalibrate photcalc;
230 MCalibrateData photcalc;
231 photcalc.SetCalibrationMode(MCalibrate::kFfactor);
232 MPedPhotCalc photrmscalc; //It doesn't exist yet
233
234 tlist3.AddToList(&read3);
235 tlist3.AddToList(&geomapl);
236 tlist3.AddToList(&extractor);
237 tlist3.AddToList(&photrmscalc);
238 //tlist3.AddToList(&photcalc);
239
240
241 //
242 // Create and setup the eventloop
243 //
244 MEvtLoop evtloop3;
245 evtloop3.SetParList(&plist3);
246
247 //
248 // Execute first analysis
249 //
250 if (!evtloop3.Eventloop())
251 return;
252
253 tlist3.PrintStatistics();
254
255 /*************************************/
256 /* FOURTH LOOP: DATA CALIBRATION */
257 /*************************************/
258
259 //
260 // Create a empty Parameter List and an empty Task List
261 //
262 MParList plist4;
263 MTaskList tlist4;
264 plist4.AddToList(&tlist4);
265
266 //
267 // Now setup the tasks and tasklist to analize the data
268 // -----------------------------------------------------
269 //
270
271 plist4.AddToList(&geomcam);
272 //
273 // Retrieve the cameras from the previous runs:
274 //
275 plist4.AddToList(&pedloop.GetPedestalCam());
276 plist4.AddToList(&calloop.GetCalibrationCam());
277 plist4.AddToList(&calloop.GetQECam());
278 plist4.AddToList(&calloop.GetRelTimeCam());
279 plist4.AddToList(&calloop.GetBadPixels());
280 plist4.AddToList(&nphot);
281 plist4.AddToList(&nphotrms);
282
283 MArrivalTime times;
284 plist4.AddToList(&times);
285
286 //tasks
287 MReadMarsFile read4("Events");
288 read4.DisableAutoScheme();
289 static_cast<MRead&>(read4).AddFiles(druns);
290
291 MArrivalTimeCalc2 timecalc;
292 MCalibrateRelTimes timecal;
293
294 tlist4.AddToList(&read4);
295 tlist4.AddToList(&geomapl);
296 tlist4.AddToList(&extractor);
297 tlist4.AddToList(&timecalc);
298 tlist4.AddToList(&photcalc);
299 tlist4.AddToList(&timecal);
300
301 //
302 // Create and setup the eventloop
303 //
304 MEvtLoop evtloop4;
305 evtloop4.SetParList(&plist4);
306
307 if (!evtloop4.PreProcess())
308 return;
309
310 TCanvas *c1 = new TCanvas;
311 MHCamera disp1(geomcam);
312 disp1.SetPrettyPalette();
313 //disp1.SetInvDeepBlueSeaPalette()
314 disp1.Draw();
315 gPad->SetLogy();
316 gPad->cd(1);
317
318 /*
319 TCanvas *c2 = new TCanvas;
320 MHCamera disp2(geomcam);
321 disp2.SetPrettyPalette();
322 //disp2.SetInvDeepBlueSeaPalette()
323 disp2.Draw();
324 gPad->SetLogy();
325 gPad->cd(1);
326 */
327 while (tlist4.Process())
328 {
329 disp1.SetCamContent(nphot);
330
331 gPad->Modified();
332 gPad->Update();
333
334 /*
335 disp2.SetCamContent(times);
336
337 gPad->Modified();
338 gPad->Update();
339 */
340
341 // Remove the comments if you want to go through the file
342 // event-by-event:
343 if (!HandleInput())
344 break;
345 }
346
347 evtloop4.PostProcess();
348
349}
350
351Bool_t HandleInput()
352{
353 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
354
355 while (1)
356 {
357 //
358 // While reading the input process gui events asynchronously
359 //
360 timer.TurnOn();
361 TString input = Getline("Type 'q' to exit, <return> to go on: ");
362 timer.TurnOff();
363
364 if (input=="q\n")
365 return kFALSE;
366
367 if (input=="\n")
368 return kTRUE;
369 };
370
371 return kFALSE;
372}
373
Note: See TracBrowser for help on using the repository browser.