1 | /*********************************/
|
---|
2 | /* Compute the hillas parameters */
|
---|
3 | /*********************************/
|
---|
4 |
|
---|
5 | #include "TString.h"
|
---|
6 | #include "TArrayS.h"
|
---|
7 |
|
---|
8 | #include "MParList.h"
|
---|
9 | #include "MTaskList.h"
|
---|
10 | #include "MPedestalCam.h"
|
---|
11 | #include "MBadPixelsCam.h"
|
---|
12 | #include "MBadPixelsTreat.h"
|
---|
13 | #include "MReadMarsFile.h"
|
---|
14 | #include "MReadReports.h"
|
---|
15 | #include "MGeomApply.h"
|
---|
16 | #include "MPedCalcPedRun.h"
|
---|
17 | #include "MEvtLoop.h"
|
---|
18 | #include "MGeomCamMagic.h"
|
---|
19 | #include "MExtractedSignalCam.h"
|
---|
20 | #include "MCalibrationChargeCam.h"
|
---|
21 | #include "MHCalibrationChargeCam.h"
|
---|
22 | #include "MHCalibrationRelTimeCam.h"
|
---|
23 | #include "MExtractor.h"
|
---|
24 | #include "MExtractFixedWindow.h"
|
---|
25 | #include "MExtractFixedWindowPeakSearch.h"
|
---|
26 | #include "MExtractSlidingWindow.h"
|
---|
27 | #include "MPedCalcFromLoGain.h"
|
---|
28 | #include "MExtractSignal.h"
|
---|
29 | #include "MCalibrationChargeCalc.h"
|
---|
30 | #include "MFCosmics.h"
|
---|
31 | #include "MContinue.h"
|
---|
32 | #include "MLog.h"
|
---|
33 | #include "MCerPhotEvt.h"
|
---|
34 | #include "MPedPhotCam.h"
|
---|
35 | #include "MCalibrateData.h"
|
---|
36 | #include "MPedPhotCalc.h"
|
---|
37 | #include "MHillas.h"
|
---|
38 | #include "MNewImagePar.h"
|
---|
39 | #include "MRawRunHeader.h"
|
---|
40 | #include "MSrcPosCam.h"
|
---|
41 | #include "MImgCleanStd.h"
|
---|
42 | #include "MHillasSrcCalc.h"
|
---|
43 | #include "MHillasCalc.h"
|
---|
44 | #include "MArrivalTimeCam.h"
|
---|
45 | #include "MArrivalTimeCalc2.h"
|
---|
46 | #include "MIslands.h"
|
---|
47 | #include "MImgIsland.h"
|
---|
48 | #include "MIslandsCalc.h"
|
---|
49 | #include "MIslandsClean.h"
|
---|
50 | #include "MWriteRootFile.h"
|
---|
51 | #include "MArgs.h"
|
---|
52 | #include "MRunIter.h"
|
---|
53 | #include "MJPedestal.h"
|
---|
54 | #include "MJCalibration.h"
|
---|
55 | #include "MHillasDisplay.h"
|
---|
56 | #include "MF.h"
|
---|
57 | #include "MContinue.h"
|
---|
58 | #include "MReportDrive.h"
|
---|
59 |
|
---|
60 | #include "TApplication.h"
|
---|
61 |
|
---|
62 | #include <iostream>
|
---|
63 | #include <fstream>
|
---|
64 | #include <stdlib.h>
|
---|
65 |
|
---|
66 | using namespace std;
|
---|
67 |
|
---|
68 | Bool_t readDatacards(TString& filename);
|
---|
69 | void makeHillas();
|
---|
70 |
|
---|
71 |
|
---|
72 | // declaration of variables read from datacards
|
---|
73 | TString outname;
|
---|
74 | const TString outpath = "./";
|
---|
75 | TString idirname;
|
---|
76 | TString filter;
|
---|
77 | TString psfilename("makehillas.ps");
|
---|
78 | MRunIter pedcaliter;
|
---|
79 | MRunIter caliter;
|
---|
80 | MRunIter pediter;
|
---|
81 | MRunIter datiter;
|
---|
82 | UInt_t display = 0;
|
---|
83 | ULong_t nmaxevents= 999999999;
|
---|
84 | Short_t calflag = 1;
|
---|
85 | Bool_t caltimeflag = kFALSE;
|
---|
86 | Short_t cleanflag = 1;
|
---|
87 | UShort_t lrings = 1;
|
---|
88 | Float_t lcore = 3.0;
|
---|
89 | Float_t ltail = 1.5;
|
---|
90 | Int_t islflag = 0;
|
---|
91 | Float_t lnew = 40;
|
---|
92 | Int_t kmethod = 1;
|
---|
93 | Int_t kalgorithm = 1;
|
---|
94 | Int_t nfiles = 0;
|
---|
95 | Int_t hifirst = 0;
|
---|
96 | Int_t hilast = 14;
|
---|
97 | Int_t lofirst = 2;
|
---|
98 | Int_t lolast = 14;
|
---|
99 | Int_t wsize = 6;
|
---|
100 | Int_t sext = 0;
|
---|
101 |
|
---|
102 | const TString defaultcard="makehillas.datacard";
|
---|
103 | char* chext[3]={"Fixed window","Sliding window","Peak Search"};
|
---|
104 | /*************************************************************/
|
---|
105 | static void Usage()
|
---|
106 | {
|
---|
107 | gLog <<endl;
|
---|
108 | gLog << "Usage is:" << endl;
|
---|
109 | gLog << " makeHillas [-h] [-?] <datacards>" << endl << endl;
|
---|
110 | gLog << " <datacards>: datacards file name (dafault makehillas.datacards)" << endl;
|
---|
111 | gLog << " -?/-h: This help" << endl << endl;
|
---|
112 | }
|
---|
113 | /*************************************************************/
|
---|
114 | int main(int argc, char **argv)
|
---|
115 | {
|
---|
116 | // create a TApplication to be able to
|
---|
117 | TApplication app("Application",0,0);
|
---|
118 |
|
---|
119 | // evaluate arguments
|
---|
120 | MArgs arg(argc, argv);
|
---|
121 | if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
|
---|
122 | {
|
---|
123 | Usage();
|
---|
124 | return -1;
|
---|
125 | }
|
---|
126 |
|
---|
127 | TString datacard = arg.GetArgumentStr(0);
|
---|
128 | if(!datacard.Length())
|
---|
129 | datacard = defaultcard;
|
---|
130 |
|
---|
131 | if(!readDatacards(datacard))
|
---|
132 | {
|
---|
133 | cout << "Error reading datacards. Stoping" << endl;
|
---|
134 | return -1;
|
---|
135 | }
|
---|
136 |
|
---|
137 | makeHillas();
|
---|
138 | }
|
---|
139 |
|
---|
140 | /*************************************************************/
|
---|
141 | void makeHillas()
|
---|
142 | {
|
---|
143 | // Set the signal extractor
|
---|
144 | MExtractor* extractor;
|
---|
145 | switch(sext)
|
---|
146 | {
|
---|
147 | case 0:
|
---|
148 | extractor = new MExtractFixedWindow();
|
---|
149 | break;
|
---|
150 | case 1:
|
---|
151 | extractor = new MExtractSlidingWindow();
|
---|
152 | ((MExtractSlidingWindow*)extractor)->SetWindowSize(wsize,wsize);
|
---|
153 | break;
|
---|
154 | case 2:
|
---|
155 | extractor = new MExtractFixedWindowPeakSearch();
|
---|
156 | ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(wsize,wsize,4);
|
---|
157 | break;
|
---|
158 | default:
|
---|
159 | extractor = new MExtractFixedWindow();
|
---|
160 | break;
|
---|
161 | }
|
---|
162 |
|
---|
163 | extractor->SetRange(hifirst,hilast,lofirst,lolast);
|
---|
164 |
|
---|
165 |
|
---|
166 | /****************************************************/
|
---|
167 | /* FIRST LOOP: PEDESTAL COMPUTATION FOR CALIBRATION */
|
---|
168 | /****************************************************/
|
---|
169 |
|
---|
170 | // If you want to exclude pixels from the beginning, read
|
---|
171 | // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
|
---|
172 | //badcam.AsciiRead("badpixels.dat");
|
---|
173 |
|
---|
174 | MJPedestal pedcalloop;
|
---|
175 | pedcalloop.SetInput(&pedcaliter);
|
---|
176 | pedcalloop.SetExtractor(extractor);
|
---|
177 | // pedloop.SetBadPixels(badcam);
|
---|
178 | //pedcalloop.SetOutputPath(outpath.Data());
|
---|
179 |
|
---|
180 |
|
---|
181 | if (!pedcalloop.Process())
|
---|
182 | return;
|
---|
183 |
|
---|
184 | /*****************************/
|
---|
185 | /* SECOND LOOP: CALIBRATION */
|
---|
186 | /*****************************/
|
---|
187 |
|
---|
188 | MJCalibration calloop;
|
---|
189 |
|
---|
190 | calloop.SetRelTimeCalibration(caltimeflag);
|
---|
191 | calloop.SetExtractor(extractor);
|
---|
192 | calloop.SetInput(&caliter);
|
---|
193 | calloop.SetBadPixels(pedcalloop.GetBadPixels());
|
---|
194 | if(calflag==2)
|
---|
195 | calloop.SetUseBlindPixel();
|
---|
196 | if(calflag>0)
|
---|
197 | if (!calloop.Process(pedcalloop.GetPedestalCam()))
|
---|
198 | return;
|
---|
199 |
|
---|
200 | // Next loops are different if we take pedestals from data or from pedestal files
|
---|
201 | if(pediter.GetNumRuns()==0)
|
---|
202 | {
|
---|
203 | /************************************************************************/
|
---|
204 | /* THIRD (SMALL) LOOP TO GET INITIAl PEDESTALS */
|
---|
205 | /************************************************************************/
|
---|
206 | MParList plist3;
|
---|
207 | MTaskList tlist3;
|
---|
208 |
|
---|
209 | // containers
|
---|
210 | MPedestalCam pedcamdata;
|
---|
211 | MGeomCamMagic geomcam;
|
---|
212 |
|
---|
213 | plist3.AddToList(&tlist3);
|
---|
214 | plist3.AddToList(&geomcam);
|
---|
215 | plist3.AddToList(&pedcamdata);
|
---|
216 |
|
---|
217 | //tasks
|
---|
218 | MReadMarsFile read3("Events");
|
---|
219 | static_cast<MRead&>(read3).AddFiles(datiter);
|
---|
220 | read3.DisableAutoScheme();
|
---|
221 |
|
---|
222 | MGeomApply geomapl;
|
---|
223 |
|
---|
224 | MPedCalcFromLoGain peddatacalc;
|
---|
225 | peddatacalc.SetPedestalUpdate(kFALSE);
|
---|
226 | peddatacalc.SetRange(hifirst,hilast,lofirst,lolast);
|
---|
227 | peddatacalc.SetWindowSize(wsize,wsize);
|
---|
228 | peddatacalc.SetNumEventsDump(500);
|
---|
229 | peddatacalc.SetMaxHiGainVar(40);
|
---|
230 |
|
---|
231 | tlist3.AddToList(&read3);
|
---|
232 | tlist3.AddToList(&geomapl);
|
---|
233 | tlist3.AddToList(&peddatacalc);
|
---|
234 |
|
---|
235 | // Create and setup the eventloop
|
---|
236 | MEvtLoop evtloop3;
|
---|
237 | evtloop3.SetParList(&plist3);
|
---|
238 | if (!evtloop3.Eventloop(500))
|
---|
239 | return;
|
---|
240 |
|
---|
241 | tlist3.PrintStatistics();
|
---|
242 |
|
---|
243 | /************************************************************************/
|
---|
244 | /* FOURTH LOOP: PEDESTAL+DATA CALIBRATION INTO PHOTONS */
|
---|
245 | /************************************************************************/
|
---|
246 |
|
---|
247 | MParList plist4;
|
---|
248 | MTaskList tlist4;
|
---|
249 | plist4.AddToList(&tlist4);
|
---|
250 |
|
---|
251 | // containers
|
---|
252 | MCerPhotEvt nphot;
|
---|
253 | MPedPhotCam nphotrms;
|
---|
254 | MHillas hillas;
|
---|
255 | MNewImagePar newimagepar;
|
---|
256 | MSrcPosCam source;
|
---|
257 | MRawRunHeader runhead;
|
---|
258 | MArrivalTimeCam timecam;
|
---|
259 | MReportDrive reportdrive;
|
---|
260 | // islands
|
---|
261 | MIslands isl;
|
---|
262 | MIslands isl2;
|
---|
263 | MIslands isl3;
|
---|
264 |
|
---|
265 | isl.SetName("MIslands");
|
---|
266 | isl2.SetName("MIslands2");
|
---|
267 | isl3.SetName("MIslands3");
|
---|
268 |
|
---|
269 | plist4.AddToList(&timecam);
|
---|
270 | plist4.AddToList(&isl);
|
---|
271 |
|
---|
272 | if (islflag == 2)
|
---|
273 | plist4.AddToList(&isl2);
|
---|
274 | if (islflag == 3)
|
---|
275 | plist4.AddToList(&isl3);
|
---|
276 |
|
---|
277 | plist4.AddToList(&geomcam);
|
---|
278 | plist4.AddToList(&pedcamdata);
|
---|
279 | plist4.AddToList(&calloop.GetCalibrationCam());
|
---|
280 | plist4.AddToList(&calloop.GetQECam());
|
---|
281 | plist4.AddToList(&calloop.GetRelTimeCam());
|
---|
282 | plist4.AddToList(&calloop.GetBadPixels());
|
---|
283 | plist4.AddToList(&nphot);
|
---|
284 | plist4.AddToList(&nphotrms);
|
---|
285 | plist4.AddToList(&source);
|
---|
286 | plist4.AddToList(&hillas);
|
---|
287 | plist4.AddToList(&newimagepar);
|
---|
288 | plist4.AddToList(&runhead);
|
---|
289 | plist4.AddToList(&reportdrive);
|
---|
290 |
|
---|
291 | // cuts
|
---|
292 | MF cut(filter);
|
---|
293 |
|
---|
294 | //tasks
|
---|
295 | // MReadMarsFile read4("Events");
|
---|
296 | MReadReports read4;
|
---|
297 | read4.AddTree("Events","MTime.",kTRUE);
|
---|
298 | read4.AddTree("Drive");
|
---|
299 | // read4.DisableAutoScheme();
|
---|
300 | static_cast<MRead&>(read4).AddFiles(datiter);
|
---|
301 |
|
---|
302 | peddatacalc.SetPedestalUpdate(kTRUE);
|
---|
303 |
|
---|
304 | MCalibrateData::CalibrationMode_t calMode=MCalibrateData::kDefault;
|
---|
305 | if(calflag==0)
|
---|
306 | calMode=MCalibrateData::kNone;
|
---|
307 | if(calflag==-1)
|
---|
308 | calMode=MCalibrateData::kDummy;
|
---|
309 | MCalibrateData photcalc;
|
---|
310 | photcalc.SetCalibrationMode(calMode);
|
---|
311 | photcalc.EnablePedestalType(MCalibrateData::kRun);
|
---|
312 | photcalc.EnablePedestalType(MCalibrateData::kEvent);
|
---|
313 |
|
---|
314 | MImgCleanStd clean(lcore,ltail);
|
---|
315 | clean.SetCleanRings(lrings);
|
---|
316 | MImgCleanStd::CleaningMethod_t cleanMeth= MImgCleanStd::kStandard;
|
---|
317 | if(cleanflag==2)
|
---|
318 | cleanMeth=MImgCleanStd::kDemocratic;
|
---|
319 | clean.SetMethod(cleanMeth);
|
---|
320 |
|
---|
321 | MArrivalTimeCalc2 timecalc;
|
---|
322 | MIslandsCalc island;
|
---|
323 | island.SetOutputName("MIslands");
|
---|
324 | island.SetAlgorithm(kalgorithm);
|
---|
325 |
|
---|
326 | MBadPixelsTreat interpolatebadpixels;
|
---|
327 | interpolatebadpixels.SetUseInterpolation();
|
---|
328 | interpolatebadpixels.SetProcessPedestal();
|
---|
329 |
|
---|
330 | MIslandsClean islclean(lnew);
|
---|
331 | islclean.SetInputName("MIslands");
|
---|
332 | islclean.SetMethod(kmethod);
|
---|
333 |
|
---|
334 | MIslandsCalc island2;
|
---|
335 | island2.SetOutputName("MIslands2");
|
---|
336 | island2.SetAlgorithm(kalgorithm);
|
---|
337 |
|
---|
338 | MIslandsCalc island3;
|
---|
339 | island3.SetOutputName("MIslands3");
|
---|
340 |
|
---|
341 |
|
---|
342 | MHillasCalc hcalc;
|
---|
343 | MHillasSrcCalc csrc1;
|
---|
344 |
|
---|
345 | MContinue applycut(&cut);
|
---|
346 | applycut.SetInverted(kTRUE);
|
---|
347 | MWriteRootFile write(outname,"RECREATE");
|
---|
348 |
|
---|
349 | MHillasDisplay* disphillas=NULL;
|
---|
350 |
|
---|
351 | write.AddContainer("MHillas" , "Parameters");
|
---|
352 | write.AddContainer("MHillasSrc" , "Parameters");
|
---|
353 | write.AddContainer("MHillasExt" , "Parameters");
|
---|
354 | write.AddContainer("MNewImagePar" , "Parameters");
|
---|
355 | write.AddContainer("MRawEvtHeader" , "Parameters");
|
---|
356 | write.AddContainer("MRawRunHeader" , "Parameters");
|
---|
357 | write.AddContainer("MTime" , "Parameters");
|
---|
358 | write.AddContainer("MConcentration" , "Parameters");
|
---|
359 | write.AddContainer("MSrcPosCam" , "Parameters");
|
---|
360 | write.AddContainer("MIslands" , "Parameters");
|
---|
361 | write.AddContainer("MReportDrive" , "Parameters");
|
---|
362 |
|
---|
363 | if (islflag == 2)
|
---|
364 | write.AddContainer("MIslands2" , "Parameters");
|
---|
365 | if (islflag == 3)
|
---|
366 | write.AddContainer("MIslands3" , "Parameters");
|
---|
367 |
|
---|
368 |
|
---|
369 | if(display)
|
---|
370 | {
|
---|
371 | disphillas = new MHillasDisplay(&nphot,&geomcam);
|
---|
372 | disphillas->SetIslandsName("MIslands");
|
---|
373 | if (islflag == 2)
|
---|
374 | disphillas->SetIslandsName("MIslands2");
|
---|
375 | if (islflag == 3)
|
---|
376 | disphillas->SetIslandsName("MIslands3");
|
---|
377 | }
|
---|
378 |
|
---|
379 | tlist4.AddToList(&read4);
|
---|
380 | tlist4.AddToList(&geomapl);
|
---|
381 | tlist4.AddToList(&peddatacalc);
|
---|
382 | tlist4.AddToList(extractor);
|
---|
383 | tlist4.AddToList(&timecalc);
|
---|
384 | tlist4.AddToList(&photcalc);
|
---|
385 | if(calflag==11 || calflag==21)
|
---|
386 | tlist4.AddToList(&interpolatebadpixels);
|
---|
387 | tlist4.AddToList(&clean);
|
---|
388 | tlist4.AddToList(&island);
|
---|
389 |
|
---|
390 | if (islflag == 2)
|
---|
391 | {
|
---|
392 | tlist4.AddToList(&islclean);
|
---|
393 | tlist4.AddToList(&island2);
|
---|
394 | }
|
---|
395 |
|
---|
396 | if (islflag == 3)
|
---|
397 | {
|
---|
398 | tlist4.AddToList(&islclean);
|
---|
399 | tlist4.AddToList(&island3);
|
---|
400 | }
|
---|
401 |
|
---|
402 | tlist4.AddToList(&hcalc);
|
---|
403 | tlist4.AddToList(&csrc1);
|
---|
404 | if(filter.Length())
|
---|
405 | tlist4.AddToList(&applycut);
|
---|
406 | tlist4.AddToList(&write);
|
---|
407 | if(display)
|
---|
408 | {
|
---|
409 | disphillas->SetPSFile();
|
---|
410 | disphillas->SetPSFileName(psfilename);
|
---|
411 | if(display==2)
|
---|
412 | disphillas->SetPause(kFALSE);
|
---|
413 | tlist4.AddToList(disphillas);
|
---|
414 | }
|
---|
415 |
|
---|
416 | // Create and setup the eventloop
|
---|
417 | MEvtLoop datloop;
|
---|
418 | datloop.SetParList(&plist4);
|
---|
419 |
|
---|
420 | cout << "*************************************************************" << endl;
|
---|
421 | cout << "*** COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS) ***" << endl;
|
---|
422 | cout << "*************************************************************" << endl;
|
---|
423 |
|
---|
424 | if (!datloop.Eventloop(nmaxevents))
|
---|
425 | return;
|
---|
426 |
|
---|
427 | tlist4.PrintStatistics();
|
---|
428 | delete extractor;
|
---|
429 | }
|
---|
430 | else
|
---|
431 | {
|
---|
432 | /************************************************************************/
|
---|
433 | /* THIRD LOOP: PEDESTAL CALIBRATION INTO PHOTONS */
|
---|
434 | /************************************************************************/
|
---|
435 |
|
---|
436 | // First Compute the pedestals
|
---|
437 | MJPedestal pedloop;
|
---|
438 | pedloop.SetInput(&pediter);
|
---|
439 |
|
---|
440 | if (!pedloop.Process())
|
---|
441 | return;
|
---|
442 |
|
---|
443 | MParList plist3;
|
---|
444 | MTaskList tlist3;
|
---|
445 | plist3.AddToList(&tlist3);
|
---|
446 |
|
---|
447 | // containers
|
---|
448 | MGeomCamMagic geomcam;
|
---|
449 | MCerPhotEvt nphot;
|
---|
450 | MPedPhotCam nphotrms;
|
---|
451 | MExtractedSignalCam sigcam;
|
---|
452 |
|
---|
453 | plist3.AddToList(&geomcam);
|
---|
454 | plist3.AddToList(&pedloop.GetPedestalCam());
|
---|
455 | plist3.AddToList(&calloop.GetCalibrationCam());
|
---|
456 | plist3.AddToList(&calloop.GetQECam());
|
---|
457 | plist3.AddToList(&calloop.GetRelTimeCam());
|
---|
458 | plist3.AddToList(&calloop.GetBadPixels());
|
---|
459 | plist3.AddToList(&sigcam);
|
---|
460 | plist3.AddToList(&nphot);
|
---|
461 | plist3.AddToList(&nphotrms);
|
---|
462 |
|
---|
463 |
|
---|
464 | MCalibrateData::CalibrationMode_t calMode=MCalibrateData::kDefault;
|
---|
465 | if(calflag==0)
|
---|
466 | calMode=MCalibrateData::kNone;
|
---|
467 | if(calflag==-1)
|
---|
468 | calMode=MCalibrateData::kDummy;
|
---|
469 |
|
---|
470 | //tasks
|
---|
471 | MReadMarsFile read3("Events");
|
---|
472 | static_cast<MRead&>(read3).AddFiles(pediter);
|
---|
473 | read3.DisableAutoScheme();
|
---|
474 |
|
---|
475 | MGeomApply geomapl;
|
---|
476 | MPedPhotCalc photrmscalc;
|
---|
477 | MCalibrateData photcalc;
|
---|
478 | photcalc.SetCalibrationMode(calMode);
|
---|
479 |
|
---|
480 | tlist3.AddToList(&read3);
|
---|
481 | tlist3.AddToList(&geomapl);
|
---|
482 | tlist3.AddToList(extractor);
|
---|
483 | tlist3.AddToList(&photcalc);
|
---|
484 | tlist3.AddToList(&photrmscalc);
|
---|
485 |
|
---|
486 | // Create and setup the eventloop
|
---|
487 | MEvtLoop evtloop3;
|
---|
488 | evtloop3.SetParList(&plist3);
|
---|
489 | if (!evtloop3.Eventloop())
|
---|
490 | return;
|
---|
491 |
|
---|
492 | tlist3.PrintStatistics();
|
---|
493 |
|
---|
494 | /************************************************************************/
|
---|
495 | /* FOURTH LOOP: DATA CALIBRATION INTO PHOTONS */
|
---|
496 | /************************************************************************/
|
---|
497 |
|
---|
498 | MParList plist4;
|
---|
499 | MTaskList tlist4;
|
---|
500 | plist4.AddToList(&tlist4);
|
---|
501 |
|
---|
502 | // containers
|
---|
503 | MHillas hillas;
|
---|
504 | MNewImagePar newimagepar;
|
---|
505 | MSrcPosCam source;
|
---|
506 | MRawRunHeader runhead;
|
---|
507 |
|
---|
508 | MArrivalTimeCam timecam;
|
---|
509 |
|
---|
510 |
|
---|
511 | // islands
|
---|
512 | MIslands isl;
|
---|
513 | MIslands isl2;
|
---|
514 | MIslands isl3;
|
---|
515 |
|
---|
516 | isl.SetName("MIslands");
|
---|
517 | isl2.SetName("MIslands2");
|
---|
518 | isl3.SetName("MIslands3");
|
---|
519 |
|
---|
520 | plist4.AddToList(&timecam);
|
---|
521 | plist4.AddToList(&isl);
|
---|
522 |
|
---|
523 | if (islflag == 2)
|
---|
524 | plist4.AddToList(&isl2);
|
---|
525 | if (islflag == 3)
|
---|
526 | plist4.AddToList(&isl3);
|
---|
527 |
|
---|
528 | plist4.AddToList(&geomcam);
|
---|
529 | plist4.AddToList(&pedloop.GetPedestalCam());
|
---|
530 | plist4.AddToList(&calloop.GetCalibrationCam());
|
---|
531 | plist4.AddToList(&calloop.GetQECam());
|
---|
532 | plist4.AddToList(&calloop.GetRelTimeCam());
|
---|
533 | plist4.AddToList(&calloop.GetBadPixels());
|
---|
534 | plist4.AddToList(&nphot);
|
---|
535 | plist4.AddToList(&nphotrms);
|
---|
536 | plist4.AddToList(&source);
|
---|
537 | plist4.AddToList(&hillas);
|
---|
538 | plist4.AddToList(&newimagepar);
|
---|
539 | plist4.AddToList(&runhead);
|
---|
540 |
|
---|
541 | // cuts
|
---|
542 | MF cut(filter);
|
---|
543 |
|
---|
544 | //tasks
|
---|
545 | // MReadMarsFile read4("Events");
|
---|
546 | MReadReports read4;
|
---|
547 | read4.AddTree("Events","MTime.",kTRUE);
|
---|
548 | read4.AddTree("Drive");
|
---|
549 | // read4.DisableAutoScheme();
|
---|
550 | static_cast<MRead&>(read4).AddFiles(datiter);
|
---|
551 |
|
---|
552 |
|
---|
553 |
|
---|
554 | MImgCleanStd clean(lcore,ltail);
|
---|
555 | clean.SetCleanRings(lrings);
|
---|
556 | MImgCleanStd::CleaningMethod_t cleanMeth= MImgCleanStd::kStandard;
|
---|
557 | if(cleanflag==2)
|
---|
558 | cleanMeth=MImgCleanStd::kDemocratic;
|
---|
559 | clean.SetMethod(cleanMeth);
|
---|
560 |
|
---|
561 | MArrivalTimeCalc2 timecalc;
|
---|
562 | MIslandsCalc island;
|
---|
563 | island.SetOutputName("MIslands");
|
---|
564 | island.SetAlgorithm(kalgorithm);
|
---|
565 |
|
---|
566 | MBadPixelsTreat interpolatebadpixels;
|
---|
567 | interpolatebadpixels.SetUseInterpolation();
|
---|
568 | interpolatebadpixels.SetProcessPedestal();
|
---|
569 | // interpolatebadpixels.SetSloppyTreatment();
|
---|
570 |
|
---|
571 | MIslandsClean islclean(lnew);
|
---|
572 | islclean.SetInputName("MIslands");
|
---|
573 | islclean.SetMethod(kmethod);
|
---|
574 |
|
---|
575 | MIslandsCalc island2;
|
---|
576 | island2.SetOutputName("MIslands2");
|
---|
577 | island2.SetAlgorithm(kalgorithm);
|
---|
578 |
|
---|
579 | MIslandsCalc island3;
|
---|
580 | island3.SetOutputName("MIslands3");
|
---|
581 |
|
---|
582 |
|
---|
583 | MHillasCalc hcalc;
|
---|
584 | MHillasSrcCalc csrc1;
|
---|
585 |
|
---|
586 | MContinue applycut(&cut);
|
---|
587 | applycut.SetInverted(kTRUE);
|
---|
588 | MWriteRootFile write(outname,"RECREATE");
|
---|
589 |
|
---|
590 | MHillasDisplay* disphillas=NULL;
|
---|
591 |
|
---|
592 | write.AddContainer("MHillas" , "Parameters");
|
---|
593 | write.AddContainer("MHillasSrc" , "Parameters");
|
---|
594 | write.AddContainer("MHillasExt" , "Parameters");
|
---|
595 | write.AddContainer("MNewImagePar" , "Parameters");
|
---|
596 | write.AddContainer("MRawEvtHeader" , "Parameters");
|
---|
597 | write.AddContainer("MRawRunHeader" , "Parameters");
|
---|
598 | write.AddContainer("MTime" , "Parameters");
|
---|
599 | write.AddContainer("MConcentration" , "Parameters");
|
---|
600 | write.AddContainer("MSrcPosCam" , "Parameters");
|
---|
601 | write.AddContainer("MIslands" , "Parameters");
|
---|
602 |
|
---|
603 | if (islflag == 2)
|
---|
604 | write.AddContainer("MIslands2" , "Parameters");
|
---|
605 | if (islflag == 3)
|
---|
606 | write.AddContainer("MIslands3" , "Parameters");
|
---|
607 |
|
---|
608 |
|
---|
609 | if(display)
|
---|
610 | {
|
---|
611 | disphillas = new MHillasDisplay(&nphot,&geomcam);
|
---|
612 | disphillas->SetIslandsName("MIslands");
|
---|
613 | if (islflag == 2)
|
---|
614 | disphillas->SetIslandsName("MIslands2");
|
---|
615 | if (islflag == 3)
|
---|
616 | disphillas->SetIslandsName("MIslands3");
|
---|
617 | }
|
---|
618 |
|
---|
619 | tlist4.AddToList(&read4);
|
---|
620 | tlist4.AddToList(&geomapl);
|
---|
621 | tlist4.AddToList(extractor);
|
---|
622 | tlist4.AddToList(&photcalc);
|
---|
623 | if(calflag==11 || calflag==21)
|
---|
624 | tlist4.AddToList(&interpolatebadpixels);
|
---|
625 | tlist4.AddToList(&clean);
|
---|
626 | tlist4.AddToList(&timecalc);
|
---|
627 | tlist4.AddToList(&island);
|
---|
628 |
|
---|
629 | if (islflag == 2)
|
---|
630 | {
|
---|
631 | tlist4.AddToList(&islclean);
|
---|
632 | tlist4.AddToList(&island2);
|
---|
633 | }
|
---|
634 |
|
---|
635 | if (islflag == 3)
|
---|
636 | {
|
---|
637 | tlist4.AddToList(&islclean);
|
---|
638 | tlist4.AddToList(&island3);
|
---|
639 | }
|
---|
640 |
|
---|
641 | tlist4.AddToList(&hcalc);
|
---|
642 | tlist4.AddToList(&csrc1);
|
---|
643 | if(filter.Length())
|
---|
644 | tlist4.AddToList(&applycut);
|
---|
645 | tlist4.AddToList(&write);
|
---|
646 | if(display)
|
---|
647 | {
|
---|
648 | disphillas->SetPSFile();
|
---|
649 | disphillas->SetPSFileName(psfilename);
|
---|
650 | if(display==2)
|
---|
651 | disphillas->SetPause(kFALSE);
|
---|
652 | tlist4.AddToList(disphillas);
|
---|
653 | }
|
---|
654 |
|
---|
655 | // Create and setup the eventloop
|
---|
656 | MEvtLoop datloop;
|
---|
657 | datloop.SetParList(&plist4);
|
---|
658 |
|
---|
659 | cout << "*************************************************************" << endl;
|
---|
660 | cout << "*** COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS) ***" << endl;
|
---|
661 | cout << "*************************************************************" << endl;
|
---|
662 |
|
---|
663 | if (!datloop.Eventloop(nmaxevents))
|
---|
664 | return;
|
---|
665 |
|
---|
666 | tlist4.PrintStatistics();
|
---|
667 | delete extractor;
|
---|
668 | }
|
---|
669 | }
|
---|
670 | //-------------------------------------------------------------------------------
|
---|
671 |
|
---|
672 | Bool_t readDatacards(TString& filename)
|
---|
673 | {
|
---|
674 | ifstream ifun(filename.Data());
|
---|
675 | if(!ifun)
|
---|
676 | {
|
---|
677 | cout << "File " << filename << " not found" << endl;
|
---|
678 | return kFALSE;
|
---|
679 | }
|
---|
680 |
|
---|
681 | TString word;
|
---|
682 |
|
---|
683 | while(ifun >> word)
|
---|
684 | {
|
---|
685 | // skip comments
|
---|
686 | if(word[0]=='/' && word[1]=='/')
|
---|
687 | {
|
---|
688 | while(ifun.get()!='\n'); // skip line
|
---|
689 | continue;
|
---|
690 | }
|
---|
691 |
|
---|
692 | // number of events
|
---|
693 | if(strcmp(word.Data(),"NEVENTS")==0)
|
---|
694 | ifun >> nmaxevents;
|
---|
695 |
|
---|
696 |
|
---|
697 | // input file directory
|
---|
698 | if(strcmp(word.Data(),"IDIR")==0)
|
---|
699 | {
|
---|
700 | if(idirname.Length())
|
---|
701 | cout << "readDataCards Warning: overriding input directory file name" << endl;
|
---|
702 | ifun >> idirname;
|
---|
703 | }
|
---|
704 |
|
---|
705 | // pedestal runs
|
---|
706 | if(strcmp(word.Data(),"PRUNS")==0)
|
---|
707 | {
|
---|
708 | if(pediter.GetNumRuns())
|
---|
709 | cout << "readDataCards Warning: adding pedestal runs to the existing list" << endl;
|
---|
710 | ifun >> word;
|
---|
711 | if(strcmp(word.Data(),"0")!=0)
|
---|
712 | pediter.AddRuns(word.Data(),idirname.Data());
|
---|
713 | }
|
---|
714 |
|
---|
715 | // pedestal runs for calibration
|
---|
716 | if(strcmp(word.Data(),"PCRUNS")==0)
|
---|
717 | {
|
---|
718 | if(pedcaliter.GetNumRuns())
|
---|
719 | cout << "readDataCards Warning: adding pedestal runs for calibration to the existing list" << endl;
|
---|
720 | ifun >> word;
|
---|
721 | pedcaliter.AddRuns(word.Data(),idirname.Data());
|
---|
722 | }
|
---|
723 |
|
---|
724 | // calibration runs
|
---|
725 | if(strcmp(word.Data(),"CRUNS")==0)
|
---|
726 | {
|
---|
727 | if(caliter.GetNumRuns())
|
---|
728 | cout << "readDataCards Warning: adding calibration runs to the existing list" << endl;
|
---|
729 | ifun >> word;
|
---|
730 | caliter.AddRuns(word.Data(),idirname.Data());
|
---|
731 | }
|
---|
732 |
|
---|
733 | // data runs
|
---|
734 | if(strcmp(word.Data(),"DRUNS")==0)
|
---|
735 | {
|
---|
736 | if(datiter.GetNumRuns())
|
---|
737 | cout << "readDataCards Warning: adding data runs to the existing list" << endl;
|
---|
738 | ifun >> word;
|
---|
739 | datiter.AddRuns(word.Data(),idirname.Data());
|
---|
740 | }
|
---|
741 |
|
---|
742 | // output file name
|
---|
743 | if(strcmp(word.Data(),"OUTFILE")==0)
|
---|
744 | {
|
---|
745 | if(outname.Length())
|
---|
746 | cout << "readDataCards Warning: overriding output file name" << endl;
|
---|
747 | ifun >> outname;
|
---|
748 | }
|
---|
749 |
|
---|
750 | // exclusion cut
|
---|
751 | if(strcmp(word.Data(),"FILTER")==0)
|
---|
752 | {
|
---|
753 | if(filter.Length())
|
---|
754 | cout << "readDataCards Warning: overriding existing cut" << endl;
|
---|
755 |
|
---|
756 | char ch;
|
---|
757 | while((ch=ifun.get())!='\n')
|
---|
758 | filter.Append(ch);
|
---|
759 | }
|
---|
760 |
|
---|
761 | // display flag
|
---|
762 | if(strcmp(word.Data(),"DISPLAY")==0)
|
---|
763 | ifun >> display;
|
---|
764 |
|
---|
765 | // ps file name
|
---|
766 | if(strcmp(word.Data(),"PSFILENAME")==0)
|
---|
767 | ifun >> psfilename;
|
---|
768 |
|
---|
769 | // calibration flag
|
---|
770 | if(strcmp(word.Data(),"CALFLAG")==0)
|
---|
771 | ifun >> calflag;
|
---|
772 |
|
---|
773 | // calibration flag
|
---|
774 | if(strcmp(word.Data(),"CALTIME")==0)
|
---|
775 | ifun >> caltimeflag;
|
---|
776 |
|
---|
777 | // cleaning level
|
---|
778 | if(strcmp(word.Data(),"CLEANLEVEL")==0)
|
---|
779 | {
|
---|
780 | ifun >> lcore;
|
---|
781 | ifun >> ltail;
|
---|
782 | if(ifun.get()!='\n'){
|
---|
783 | ifun.unget();
|
---|
784 | ifun >> lrings;
|
---|
785 | if(ifun.get()!='\n'){
|
---|
786 | ifun.unget();
|
---|
787 | ifun >> cleanflag;
|
---|
788 | }
|
---|
789 | }
|
---|
790 | }
|
---|
791 |
|
---|
792 | // cleaning level
|
---|
793 | if(strcmp(word.Data(),"EXTRACTOR")==0)
|
---|
794 | ifun >> sext >> hifirst >> hilast >> lofirst >> lolast >> wsize;
|
---|
795 |
|
---|
796 | if(strcmp(word.Data(),"ISLFLAG")==0)
|
---|
797 | {
|
---|
798 | ifun >> islflag;
|
---|
799 |
|
---|
800 | // if (islflag == 1 || islflag == 2)
|
---|
801 | ifun >> kalgorithm;
|
---|
802 | }
|
---|
803 |
|
---|
804 | // island cleaning
|
---|
805 | if (islflag == 2){
|
---|
806 | if(strcmp(word.Data(),"ISLANDCLEAN")==0)
|
---|
807 | {
|
---|
808 | ifun >> kmethod;
|
---|
809 | ifun >> lnew;
|
---|
810 | }
|
---|
811 | }
|
---|
812 | }
|
---|
813 |
|
---|
814 | pediter.Reset();
|
---|
815 | pedcaliter.Reset();
|
---|
816 | caliter.Reset();
|
---|
817 | datiter.Reset();
|
---|
818 | TString pfile;
|
---|
819 |
|
---|
820 | // Dump read values
|
---|
821 | cout << "************************************************" << endl;
|
---|
822 | cout << "* Datacards read from file " << filename << endl;
|
---|
823 | cout << "************************************************" << endl;
|
---|
824 | cout << "Pedestal file (s) for calibration: " << endl;
|
---|
825 | while(!(pfile=pedcaliter.Next()).IsNull())
|
---|
826 | cout << pfile << endl;
|
---|
827 | cout << "Calibration file (s): " << endl;
|
---|
828 | while(!(pfile=caliter.Next()).IsNull())
|
---|
829 | cout << pfile << endl;
|
---|
830 | if(pediter.GetNumRuns()>0)
|
---|
831 | {
|
---|
832 | cout << "Pedestal file (s): " << endl;
|
---|
833 | while(!(pfile=pediter.Next()).IsNull())
|
---|
834 | cout << pfile << endl;
|
---|
835 | }
|
---|
836 | else
|
---|
837 | cout << "Warning: Pedestals for data will be computed from data themselves" << endl;
|
---|
838 | cout << "Data file (s): " << endl;
|
---|
839 | while(!(pfile=datiter.Next()).IsNull())
|
---|
840 | cout << pfile << endl;
|
---|
841 | cout << "Maximum number of events: " << nmaxevents << endl;
|
---|
842 | if(filter.Length())
|
---|
843 | cout << "Applying rejection cut: " << filter << endl;
|
---|
844 | cout << "Output file name: " << outname << endl;
|
---|
845 | if(display)
|
---|
846 | cout << "Generating PS file: " << psfilename << endl;
|
---|
847 | cout << "Signal Extractor: " << chext[sext] << " with bounds ("<<hifirst<<","<<hilast<<","<<lofirst<<","<<lolast<<"), window size " << wsize << endl;
|
---|
848 | cout << "Calibration: ";
|
---|
849 | if(calflag==0)
|
---|
850 | cout << "Pixel area proportional intercalibration (kNone)" << endl;
|
---|
851 | else if(calflag==-1)
|
---|
852 | cout << "No calibration whatsoever" << endl;
|
---|
853 | else if(calflag==1)
|
---|
854 | cout << "Default calibration" << endl;
|
---|
855 | else if(calflag==11)
|
---|
856 | cout << "Default calibration + bad pixels interpolation" << endl;
|
---|
857 | cout << "Cleaning level: ("<<lcore<<","<<ltail<<") - " << lrings << "ring" << endl;
|
---|
858 | cout << "Cleaning method: "<< cleanflag << endl;
|
---|
859 | if (islflag == 1 || islflag == 2)
|
---|
860 | cout << "Island calcultation..." << "using algorithm #" << kalgorithm <<endl;
|
---|
861 | if (islflag == 2)
|
---|
862 | {
|
---|
863 | cout << "Island Cleaning: "<< kmethod <<" method "<< lnew << " new threshold" << endl;
|
---|
864 | }
|
---|
865 | cout << "***********" << endl << endl;
|
---|
866 |
|
---|
867 | if(!pedcaliter.GetNumEntries())
|
---|
868 | {
|
---|
869 | cout << "No pedestal file for calibration specified" << endl;
|
---|
870 | return kFALSE;
|
---|
871 | }
|
---|
872 | if(!caliter.GetNumEntries() && calflag>0)
|
---|
873 | {
|
---|
874 | cout << "No calibration file name specified" << endl;
|
---|
875 | return kFALSE;
|
---|
876 | }
|
---|
877 | if(!datiter.GetNumEntries())
|
---|
878 | {
|
---|
879 | cout << "No data file name specified" << endl;
|
---|
880 | return kFALSE;
|
---|
881 | }
|
---|
882 | if(!outname.Length())
|
---|
883 | {
|
---|
884 | cout << "No output file name specified" << endl;
|
---|
885 | return kFALSE;
|
---|
886 | }
|
---|
887 |
|
---|
888 |
|
---|
889 | return kTRUE;
|
---|
890 | }
|
---|
891 |
|
---|