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