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