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 TString outpath = "./";
|
---|
49 | const Int_t dpedrun = 14607;
|
---|
50 | const Int_t dcalrun1 = 14608;
|
---|
51 | const Int_t dcalrun2 = 0;
|
---|
52 | const Int_t ddatrun1 = 14609;
|
---|
53 | const Int_t ddatrun2 = 14614;
|
---|
54 | const Bool_t usedisplay = kTRUE;
|
---|
55 | //
|
---|
56 | // A switch to use the Blind Pixel
|
---|
57 | //
|
---|
58 | const Bool_t blindpix = kTRUE;
|
---|
59 | //
|
---|
60 | // A switch to use the PIN Diode
|
---|
61 | //
|
---|
62 | const Bool_t pindiode = kFALSE;
|
---|
63 | //
|
---|
64 | void 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(×);
|
---|
233 |
|
---|
234 | //tasks
|
---|
235 | MReadMarsFile read4("Events");
|
---|
236 | read4.DisableAutoScheme();
|
---|
237 | static_cast<MRead&>(read4).AddFiles(druns);
|
---|
238 |
|
---|
239 | MCalibrate photcalc;
|
---|
240 | photcalc.SetCalibrationMode(MCalibrate::kFfactor);
|
---|
241 | MCalibrateRelTimes timecal;
|
---|
242 |
|
---|
243 | tlist4.AddToList(&read4);
|
---|
244 | tlist4.AddToList(&geomapl);
|
---|
245 | tlist4.AddToList(&extractor);
|
---|
246 | tlist4.AddToList(&timeext);
|
---|
247 | tlist4.AddToList(&photcalc);
|
---|
248 | tlist4.AddToList(&timecal);
|
---|
249 |
|
---|
250 | //
|
---|
251 | // Create and setup the eventloop
|
---|
252 | //
|
---|
253 | MEvtLoop evtloop4;
|
---|
254 | evtloop4.SetParList(&plist4);
|
---|
255 |
|
---|
256 | if (!evtloop4.PreProcess())
|
---|
257 | return;
|
---|
258 |
|
---|
259 | TCanvas *c1 = new TCanvas;
|
---|
260 | MHCamera disp1(geomcam);
|
---|
261 | disp1.SetPrettyPalette();
|
---|
262 | //disp1.SetInvDeepBlueSeaPalette()
|
---|
263 | disp1.Draw();
|
---|
264 | gPad->SetLogy();
|
---|
265 | gPad->cd(1);
|
---|
266 |
|
---|
267 | /*
|
---|
268 | TCanvas *c2 = new TCanvas;
|
---|
269 | MHCamera disp2(geomcam);
|
---|
270 | disp2.SetPrettyPalette();
|
---|
271 | //disp2.SetInvDeepBlueSeaPalette()
|
---|
272 | disp2.Draw();
|
---|
273 | gPad->SetLogy();
|
---|
274 | gPad->cd(1);
|
---|
275 | */
|
---|
276 | while (tlist4.Process())
|
---|
277 | {
|
---|
278 | disp1.SetCamContent(nphot);
|
---|
279 |
|
---|
280 | gPad->Modified();
|
---|
281 | gPad->Update();
|
---|
282 |
|
---|
283 | /*
|
---|
284 | disp2.SetCamContent(times);
|
---|
285 |
|
---|
286 | gPad->Modified();
|
---|
287 | gPad->Update();
|
---|
288 | */
|
---|
289 |
|
---|
290 | // Remove the comments if you want to go through the file
|
---|
291 | // event-by-event:
|
---|
292 | if (!HandleInput())
|
---|
293 | break;
|
---|
294 | }
|
---|
295 |
|
---|
296 | evtloop4.PostProcess();
|
---|
297 |
|
---|
298 | }
|
---|
299 |
|
---|
300 | Bool_t HandleInput()
|
---|
301 | {
|
---|
302 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
303 |
|
---|
304 | while (1)
|
---|
305 | {
|
---|
306 | //
|
---|
307 | // While reading the input process gui events asynchronously
|
---|
308 | //
|
---|
309 | timer.TurnOn();
|
---|
310 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
---|
311 | timer.TurnOff();
|
---|
312 |
|
---|
313 | if (input=="q\n")
|
---|
314 | return kFALSE;
|
---|
315 |
|
---|
316 | if (input=="\n")
|
---|
317 | return kTRUE;
|
---|
318 | };
|
---|
319 |
|
---|
320 | return kFALSE;
|
---|
321 | }
|
---|
322 |
|
---|