1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
|
---|
19 | ! Thomas Bretz 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MMCALIBRATE - Calibration of MC data
|
---|
29 | //
|
---|
30 | // This macro is a version of the standard procedure to convert raw MC data
|
---|
31 | // into calibrated data (photons per pixel)
|
---|
32 | //
|
---|
33 | /////////////////////////////////////////////////////////////////////////////
|
---|
34 |
|
---|
35 | #include "MImgCleanStd.h"
|
---|
36 |
|
---|
37 | void mccalibrate()
|
---|
38 | {
|
---|
39 | //
|
---|
40 | // This is a demonstration program which reads in MC camera files
|
---|
41 | // and produces and output with calibrated events (signal in photons
|
---|
42 | // for all pixels, in MCerPhotEvt containers).
|
---|
43 | //
|
---|
44 |
|
---|
45 |
|
---|
46 | // ------------- user change -----------------
|
---|
47 | TString* CalibrationFilename;
|
---|
48 | CalibrationFilename = new TString("../../gammas_nonoise/Gamma_zbin0_0*.root");
|
---|
49 | // File to be used for the calibration (must be a camera file without added noise)
|
---|
50 |
|
---|
51 | Char_t* AnalysisFilename = "Gamma_zbin0*.root"; // File to be analyzed
|
---|
52 |
|
---|
53 | Char_t* OutFilename = "calibrated_data.root"; // Output file name
|
---|
54 |
|
---|
55 |
|
---|
56 | Int_t BinsHigh[2] = {5, 10}; // First and last FADC bin of the range to be integrated,
|
---|
57 | Int_t BinsLow[2] = {5, 10}; // for high and low gain respectively.
|
---|
58 |
|
---|
59 | // -------------------------------------------
|
---|
60 |
|
---|
61 | //
|
---|
62 | // Create a empty Parameter List and an empty Task List
|
---|
63 | // The tasklist is identified in the eventloop by its name
|
---|
64 | //
|
---|
65 | MParList plist;
|
---|
66 |
|
---|
67 | MTaskList tlist;
|
---|
68 |
|
---|
69 | plist.AddToList(&tlist);
|
---|
70 |
|
---|
71 | MSrcPosCam src;
|
---|
72 | src.SetReadyToSave();
|
---|
73 | plist.AddToList(&src);
|
---|
74 |
|
---|
75 | MBadPixelsCam badpix;
|
---|
76 | plist.AddToList(&badpix);
|
---|
77 |
|
---|
78 |
|
---|
79 | //
|
---|
80 | // Now setup the tasks and tasklist:
|
---|
81 | // ---------------------------------
|
---|
82 | //
|
---|
83 | MReadMarsFile read("Events");
|
---|
84 |
|
---|
85 | if (CalibrationFilename)
|
---|
86 | read.AddFile(CalibrationFilename->Data());
|
---|
87 |
|
---|
88 | read.DisableAutoScheme();
|
---|
89 |
|
---|
90 | MGeomApply geom; // Reads in geometry from MC file and sets the right sizes for
|
---|
91 | // several parameter containers.
|
---|
92 |
|
---|
93 | MMcPedestalCopy pcopy;
|
---|
94 | // Copies pedestal data from the MC file run fadc header to the MPedestalCam container.
|
---|
95 |
|
---|
96 | MExtractSignal sigextract;
|
---|
97 | sigextract.SetSaturationLimit(240);
|
---|
98 |
|
---|
99 | // Define ADC slices to be integrated in high and low gain:
|
---|
100 | sigextract.SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
|
---|
101 |
|
---|
102 | MMcCalibrationUpdate mccalibupdate;
|
---|
103 |
|
---|
104 | MCalibrate calib; // Transforms signals from ADC counts into photons.
|
---|
105 | calib.SetCalibrationMode(MCalibrate::kFfactor);
|
---|
106 |
|
---|
107 | // MBlindPixelCalc blind;
|
---|
108 | // blind.SetUseInterpolation();
|
---|
109 |
|
---|
110 | //
|
---|
111 | // Applies tail cuts to image. Since the calibration is performed on
|
---|
112 | // noiseless camera files, the precise values of the cleaning levels
|
---|
113 | // are unimportant (in any case, only pixels without any C-photon will
|
---|
114 | // be rejected).
|
---|
115 | //
|
---|
116 | MImgCleanStd clean;
|
---|
117 |
|
---|
118 |
|
---|
119 | MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
|
---|
120 |
|
---|
121 | MMcCalibrationCalc mccalibcalc;
|
---|
122 |
|
---|
123 | tlist.AddToList(&read);
|
---|
124 | tlist.AddToList(&geom);
|
---|
125 | tlist.AddToList(&pcopy);
|
---|
126 |
|
---|
127 | tlist.AddToList(&sigextract);
|
---|
128 | tlist.AddToList(&mccalibupdate);
|
---|
129 | tlist.AddToList(&calib);
|
---|
130 | tlist.AddToList(&clean);
|
---|
131 | // tlist.AddToList(&blind);
|
---|
132 | tlist.AddToList(&hcalc);
|
---|
133 |
|
---|
134 | tlist.AddToList(&mccalibcalc);
|
---|
135 |
|
---|
136 | //
|
---|
137 | // Open output file:
|
---|
138 | //
|
---|
139 | MWriteRootFile write(OutFilename); // Writes output
|
---|
140 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
141 | write.AddContainer("MMcConfigRunHeader", "RunHeaders");
|
---|
142 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
|
---|
143 | write.AddContainer("MMcFadcHeader", "RunHeaders");
|
---|
144 | write.AddContainer("MMcRunHeader", "RunHeaders");
|
---|
145 | write.AddContainer("MMcTrigHeader", "RunHeaders");
|
---|
146 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
147 | write.AddContainer("MSrcPosCam", "RunHeaders");
|
---|
148 |
|
---|
149 |
|
---|
150 | write.AddContainer("MMcEvt", "Events");
|
---|
151 | write.AddContainer("MMcTrig", "Events");
|
---|
152 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
153 | write.AddContainer("MCerPhotEvt", "Events");
|
---|
154 | write.AddContainer("MPedPhotCam", "Events");
|
---|
155 |
|
---|
156 | //
|
---|
157 | // First loop: Calibration loop
|
---|
158 | //
|
---|
159 |
|
---|
160 | MProgressBar bar;
|
---|
161 | bar.SetWindowName("Calibrating...");
|
---|
162 |
|
---|
163 | MEvtLoop evtloop;
|
---|
164 | evtloop.SetProgressBar(&bar);
|
---|
165 | evtloop.SetParList(&plist);
|
---|
166 |
|
---|
167 | if (CalibrationFilename)
|
---|
168 | {
|
---|
169 | if (!evtloop.Eventloop())
|
---|
170 | return;
|
---|
171 | mccalibcalc->GetHist()->Write();
|
---|
172 | }
|
---|
173 |
|
---|
174 | //
|
---|
175 | // Second loop: analysis loop
|
---|
176 | //
|
---|
177 |
|
---|
178 | //
|
---|
179 | // Change the read task by another one which reads the file we want to analyze:
|
---|
180 | //
|
---|
181 |
|
---|
182 | MReadMarsFile read2("Events");
|
---|
183 | read2.AddFile(AnalysisFilename);
|
---|
184 | read2.DisableAutoScheme();
|
---|
185 | tlist.AddToListBefore(&read2, &read, "All");
|
---|
186 | tlist.RemoveFromList(&read);
|
---|
187 |
|
---|
188 | bar.SetWindowName("Writing...");
|
---|
189 |
|
---|
190 | tlist.RemoveFromList(&clean);
|
---|
191 | tlist.RemoveFromList(&hcalc);
|
---|
192 | tlist.RemoveFromList(&mccalibcalc);
|
---|
193 |
|
---|
194 | tlist.AddToList(&write); // Add task to write output.
|
---|
195 |
|
---|
196 | if (!evtloop.Eventloop())
|
---|
197 | return;
|
---|
198 |
|
---|
199 |
|
---|
200 | tlist.PrintStatistics();
|
---|
201 | }
|
---|