| 1 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 2 | //
|
|---|
| 3 | // mmcCleaning - calibrate/clean mc events
|
|---|
| 4 | //
|
|---|
| 5 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | void mmcCleaning()
|
|---|
| 9 | {
|
|---|
| 10 | //
|
|---|
| 11 | // This is a demonstration program which reads in MC camera files
|
|---|
| 12 | // and produces and output with calibrated events (signal in photons
|
|---|
| 13 | // for all pixels, in MCerPhotEvt containers).
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | // ------------- user change -----------------
|
|---|
| 17 | Char_t* NonoiseFilename = "/local_disk/jrico/mc/Gammas/Gamma_zbin0_0_7_1000to1009_w0_nonoise.root"; // File to be used for the calibration (must be a camera file without added noise)
|
|---|
| 18 | Char_t* NoiseFilename = "/local_disk/jrico/mc/Gammas/Gamma_zbin0_0_7_1000to1009_w0.root"; // File to be analyzed
|
|---|
| 19 |
|
|---|
| 20 | Char_t* NoiseOutFilename = "/local_disk/jrico/mc/Gammas/prueba.root"; // Output file name
|
|---|
| 21 |
|
|---|
| 22 | // Signal extractor
|
|---|
| 23 | // (other extraction methods can be used)
|
|---|
| 24 | MExtractFixedWindowPeakSearch sigextract;
|
|---|
| 25 |
|
|---|
| 26 | // Define FADC slices to be integrated in high and low gain:
|
|---|
| 27 | sigextract.SetRange(1, 14, 2, 14);
|
|---|
| 28 | sigextract.SetWindows(6,6,4);
|
|---|
| 29 |
|
|---|
| 30 | // Defines when to switch to low gain
|
|---|
| 31 | sigextract.SetSaturationLimit(240);
|
|---|
| 32 |
|
|---|
| 33 | // ---------------------------------------------------------------------
|
|---|
| 34 | //
|
|---|
| 35 | // Create a empty Parameter List and an empty Task List
|
|---|
| 36 | // The tasklist is identified in the eventloop by its name
|
|---|
| 37 | //
|
|---|
| 38 | MParList plist;
|
|---|
| 39 | MTaskList tlist;
|
|---|
| 40 | plist.AddToList(&tlist);
|
|---|
| 41 |
|
|---|
| 42 | MPedestalCam pedcam;
|
|---|
| 43 | MGeomCamMagic geomcam;
|
|---|
| 44 | MCerPhotEvt nphot;
|
|---|
| 45 |
|
|---|
| 46 | plist.AddToList(&pedcam);
|
|---|
| 47 | plist.AddToList(&geomcam);
|
|---|
| 48 | plist.AddToList(&nphot);
|
|---|
| 49 |
|
|---|
| 50 | //
|
|---|
| 51 | // Now setup the tasks and tasklist:
|
|---|
| 52 | // ---------------------------------
|
|---|
| 53 | //
|
|---|
| 54 | MReadMarsFile read("Events");
|
|---|
| 55 | read.AddFile(NonoiseFilename);
|
|---|
| 56 | read.DisableAutoScheme();
|
|---|
| 57 |
|
|---|
| 58 | MGeomApply geom;
|
|---|
| 59 | // Reads in geometry from MC file and sets the right sizes for
|
|---|
| 60 | // several parameter containers.
|
|---|
| 61 |
|
|---|
| 62 | MMcPedestalCopy pcopy;
|
|---|
| 63 | // Copies pedestal data from the MC file run fadc header to the
|
|---|
| 64 | // MPedestalCam container.
|
|---|
| 65 |
|
|---|
| 66 | MDisplay display(&nphot,&geomcam);
|
|---|
| 67 | MHillasDisplay display2(&nphot,&geomcam);
|
|---|
| 68 |
|
|---|
| 69 | MPointingPosCalc pointcalc;
|
|---|
| 70 | // Creates MPointingPos object and fill it with the telescope orientation
|
|---|
| 71 | // information taken from MMcEvt.
|
|---|
| 72 |
|
|---|
| 73 | MMcCalibrationUpdate mccalibupdate;
|
|---|
| 74 |
|
|---|
| 75 | MCalibrate calib;
|
|---|
| 76 | // MCalibrate transforms signals from ADC counts into photons. In the first
|
|---|
| 77 | // loop it applies a "dummy" calibration supplied by MMcCalibrationUpdate, just
|
|---|
| 78 | // to equalize inner and outer pixels. At the end of the first loop, in the
|
|---|
| 79 | // PostProcess of MMcCalibrationCalc (see below) the true calibration constants
|
|---|
| 80 | // are calculated.
|
|---|
| 81 |
|
|---|
| 82 | calib.SetCalibrationMode(MCalibrate::kFfactor);
|
|---|
| 83 |
|
|---|
| 84 | MImgCleanStd clean(2.5,2.0);
|
|---|
| 85 | clean.SetCleanRings(1);
|
|---|
| 86 | // clean.SetRemoveSingle(kFALSE);
|
|---|
| 87 | //
|
|---|
| 88 | // Applies tail cuts to image. Since the calibration is performed on
|
|---|
| 89 | // noiseless camera files, the precise values of the cleaning levels
|
|---|
| 90 | // are unimportant (in any case, only pixels without any C-photon will
|
|---|
| 91 | // be rejected).
|
|---|
| 92 | //
|
|---|
| 93 |
|
|---|
| 94 | MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
|
|---|
| 95 | MHillasSrcCalc hsrccalc;
|
|---|
| 96 |
|
|---|
| 97 | MMcCalibrationCalc mccalibcalc;
|
|---|
| 98 | // Calculates calibration constants to convert from ADC counts to photons.
|
|---|
| 99 |
|
|---|
| 100 | tlist.AddToList(&read);
|
|---|
| 101 | tlist.AddToList(&geom);
|
|---|
| 102 | tlist.AddToList(&pcopy);
|
|---|
| 103 | tlist.AddToList(&pointcalc);
|
|---|
| 104 | tlist.AddToList(&sigextract);
|
|---|
| 105 | tlist.AddToList(&mccalibupdate);
|
|---|
| 106 | tlist.AddToList(&calib);
|
|---|
| 107 | tlist.AddToList(&clean);
|
|---|
| 108 | tlist.AddToList(&hcalc);
|
|---|
| 109 | tlist.AddToList(&hsrccalc);
|
|---|
| 110 | tlist.AddToList(&mccalibcalc);
|
|---|
| 111 | //tlist.AddToList(&display2);
|
|---|
| 112 |
|
|---|
| 113 | //
|
|---|
| 114 | // First loop: No noise
|
|---|
| 115 | //
|
|---|
| 116 | MProgressBar bar;
|
|---|
| 117 | bar.SetWindowName("No noise...");
|
|---|
| 118 |
|
|---|
| 119 | MEvtLoop evtloop;
|
|---|
| 120 | evtloop.SetProgressBar(&bar);
|
|---|
| 121 | evtloop.SetParList(&plist);
|
|---|
| 122 |
|
|---|
| 123 | if (!evtloop.Eventloop())
|
|---|
| 124 | return;
|
|---|
| 125 | mccalibcalc.GetHistADC2PhotEl()->Write();
|
|---|
| 126 | mccalibcalc.GetHistPhot2PhotEl()->Write();
|
|---|
| 127 | // Writes out the histograms used for calibration.
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | //
|
|---|
| 131 | // Second loop: process file with noise
|
|---|
| 132 | //
|
|---|
| 133 | MIslands isl;
|
|---|
| 134 | MArrivalTimeCam timecam;
|
|---|
| 135 | plist.AddToList(&isl);
|
|---|
| 136 | plist.AddToList(&timecam);
|
|---|
| 137 |
|
|---|
| 138 | MArrivalTimeCalc2 timecalc;
|
|---|
| 139 | MIslandsCalc islandcalc;
|
|---|
| 140 | islandcalc.SetOutputName("MIslands");
|
|---|
| 141 | islandcalc.SetAlgorithm(1);
|
|---|
| 142 | MIslandsClean islclean(40);
|
|---|
| 143 | islclean.SetInputName("MIslands");
|
|---|
| 144 | islclean.SetMethod(1);
|
|---|
| 145 |
|
|---|
| 146 | MReadMarsFile read2("Events");
|
|---|
| 147 | read2.AddFile(NoiseFilename);
|
|---|
| 148 | read2.DisableAutoScheme();
|
|---|
| 149 | tlist.AddToListBefore(&read2, &read, "All");
|
|---|
| 150 | tlist.RemoveFromList(&read);
|
|---|
| 151 |
|
|---|
| 152 | tlist.AddToListBefore(&timecalc,&mccalibupdate,"All");
|
|---|
| 153 | tlist.AddToListBefore(&islandcalc,&hcalc,"All");
|
|---|
| 154 | tlist.AddToListBefore(&islclean,&hcalc,"All");
|
|---|
| 155 |
|
|---|
| 156 | MWriteRootFile write(NoiseOutFilename); // Writes output
|
|---|
| 157 | write.AddContainer("MRawRunHeader", "Events");
|
|---|
| 158 | write.AddContainer("MMcEvt", "Events");
|
|---|
| 159 | write.AddContainer("MRawEvtHeader", "Events");
|
|---|
| 160 | write.AddContainer("MHillas", "Events");
|
|---|
| 161 | write.AddContainer("MHillasSrc", "Events");
|
|---|
| 162 | write.AddContainer("MImagePar", "Events");
|
|---|
| 163 | write.AddContainer("MNewImagePar", "Events");
|
|---|
| 164 | write.AddContainer("MIslands", "Events");
|
|---|
| 165 |
|
|---|
| 166 | tlist.RemoveFromList(&mccalibcalc);
|
|---|
| 167 | tlist.AddToList(&write);
|
|---|
| 168 | // tlist.AddToListBefore(&display2,&write, "All");
|
|---|
| 169 |
|
|---|
| 170 | bar.SetWindowName("Calibrating/Cleaning...");
|
|---|
| 171 | // clean.SetRemoveSingle();
|
|---|
| 172 | // clean.SetMethod(MImgCleanStd::kDemocratic);
|
|---|
| 173 |
|
|---|
| 174 | if (!evtloop.Eventloop())
|
|---|
| 175 | return;
|
|---|
| 176 |
|
|---|
| 177 | tlist.PrintStatistics();
|
|---|
| 178 | }
|
|---|