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