source: trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc@ 5972

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