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

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