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

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