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): Markus Gaug, 12/2004 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 | //////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // MCalibCalcFromPast
|
---|
27 | //
|
---|
28 | // Steers the occurrance of interlaced calibration events in one data run
|
---|
29 | //
|
---|
30 | // Input Containers:
|
---|
31 | // MParList
|
---|
32 | // MCalibrationIntensityChargeCam
|
---|
33 | // MCalibrationIntensityRelTimeCam
|
---|
34 | // MBadPixelsIntensityCam
|
---|
35 | //
|
---|
36 | // Output Containers:
|
---|
37 | // MCalibrationIntensityChargeCam
|
---|
38 | // MCalibrationIntensityRelTimeCam
|
---|
39 | // MBadPixelsIntensityCam
|
---|
40 | //
|
---|
41 | //////////////////////////////////////////////////////////////////////////////
|
---|
42 | #include "MCalibCalcFromPast.h"
|
---|
43 |
|
---|
44 | #include "MLog.h"
|
---|
45 | #include "MLogManip.h"
|
---|
46 |
|
---|
47 | #include "MParList.h"
|
---|
48 | #include "MTaskList.h"
|
---|
49 |
|
---|
50 | #include "MHCalibrationCam.h"
|
---|
51 |
|
---|
52 | #include "MCalibrationIntensityChargeCam.h"
|
---|
53 | #include "MCalibrationIntensityBlindCam.h"
|
---|
54 | #include "MCalibrationIntensityQECam.h"
|
---|
55 | #include "MCalibrationIntensityRelTimeCam.h"
|
---|
56 |
|
---|
57 | #include "MBadPixelsIntensityCam.h"
|
---|
58 |
|
---|
59 | #include "MCalibrationChargeCalc.h"
|
---|
60 | #include "MCalibrationRelTimeCalc.h"
|
---|
61 | #include "MCalibrateData.h"
|
---|
62 |
|
---|
63 | #include "MGeomCam.h"
|
---|
64 |
|
---|
65 | ClassImp(MCalibCalcFromPast);
|
---|
66 |
|
---|
67 | using namespace std;
|
---|
68 |
|
---|
69 | const UInt_t MCalibCalcFromPast::fgNumEventsDump = 500;
|
---|
70 | // --------------------------------------------------------------------------
|
---|
71 | //
|
---|
72 | // Default constructor.
|
---|
73 | //
|
---|
74 | // Sets:
|
---|
75 | // - fNumEventsDump to fgNumEventsDump
|
---|
76 | //
|
---|
77 | MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
|
---|
78 | : fGeom(NULL), fParList(NULL),
|
---|
79 | fIntensCharge(NULL), fIntensBlind(NULL), fIntensRelTime(NULL), fIntensBad(NULL),
|
---|
80 | fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
|
---|
81 | fNumEvents(0), fNumCam(0)
|
---|
82 | {
|
---|
83 |
|
---|
84 | fName = name ? name : "MCalibCalcFromPast";
|
---|
85 | fTitle = title ? title : "Task to steer the processing of interlaced calibration events";
|
---|
86 |
|
---|
87 | SetNumEventsDump();
|
---|
88 | }
|
---|
89 |
|
---|
90 | // -----------------------------------------------------------------------------------
|
---|
91 | //
|
---|
92 | // The following container are searched for and execution aborted if not in MParList:
|
---|
93 | // - MTaskList
|
---|
94 | //
|
---|
95 | Int_t MCalibCalcFromPast::PreProcess(MParList *pList)
|
---|
96 | {
|
---|
97 |
|
---|
98 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
99 | if (!fGeom)
|
---|
100 | {
|
---|
101 | *fLog << err << "MGeomCam not found... abort." << endl;
|
---|
102 | return kFALSE;
|
---|
103 | }
|
---|
104 |
|
---|
105 | fParList = pList;
|
---|
106 | if (!fParList)
|
---|
107 | {
|
---|
108 | *fLog << err << "MParList not found... abort." << endl;
|
---|
109 | return kFALSE;
|
---|
110 | }
|
---|
111 |
|
---|
112 | //
|
---|
113 | // Look for the MBadPixels Intensity Cam
|
---|
114 | //
|
---|
115 | fIntensBad = (MBadPixelsIntensityCam*)pList->FindCreateObj("MBadPixelsIntensityCam");
|
---|
116 | if (fIntensBad)
|
---|
117 | *fLog << inf << "Found MBadPixelsIntensityCam ... " << flush;
|
---|
118 | else
|
---|
119 | return kFALSE;
|
---|
120 |
|
---|
121 | //
|
---|
122 | // Look for the MFillH-class "MHCalibrationBlindCam". In case yes, initialize the
|
---|
123 | // corresponding IntensityCam
|
---|
124 | //
|
---|
125 | if (pList->FindObject(AddSerialNumber("MHCalibrationBlindCam")))
|
---|
126 | {
|
---|
127 |
|
---|
128 | *fLog << inf << "Found MHCalibrationBlindCam ... " << flush;
|
---|
129 |
|
---|
130 | fIntensBlind = (MCalibrationIntensityBlindCam*)pList->FindCreateObj("MCalibrationIntensityBlindCam");
|
---|
131 | if (!fIntensBlind)
|
---|
132 | {
|
---|
133 | *fLog << err << "Could not find nor create MCalibrationIntensitBlindCam abort... " << endl;
|
---|
134 | return kFALSE;
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | //
|
---|
139 | // Look for the MFillH-class "MHCalibrationChargeCam". In case yes, initialize the
|
---|
140 | // corresponding IntensityCam
|
---|
141 | //
|
---|
142 | if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
|
---|
143 | {
|
---|
144 |
|
---|
145 | fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
|
---|
146 | fIntensQE = (MCalibrationIntensityQECam*) pList->FindCreateObj("MCalibrationIntensityQECam");
|
---|
147 |
|
---|
148 | if (!fChargeCalc)
|
---|
149 | fChargeCalc = (MCalibrationChargeCalc*)pList->FindObject("MCalibrationChargeCalc");
|
---|
150 |
|
---|
151 | if (!fCalibrate)
|
---|
152 | fCalibrate = (MCalibrateData*)pList->FindObject("MCalibrateData");
|
---|
153 |
|
---|
154 | *fLog << inf << "Found MHCalibrationChargeCam ... " << flush;
|
---|
155 |
|
---|
156 | if (!fIntensCharge)
|
---|
157 | {
|
---|
158 | *fLog << err << "Could not find nor create MCalibrationIntensityChargeCam abort... " << endl;
|
---|
159 | return kFALSE;
|
---|
160 | }
|
---|
161 |
|
---|
162 | if (!fIntensQE)
|
---|
163 | {
|
---|
164 | *fLog << err << "Could not find nor create MCalibrationIntensityQECam abort... " << endl;
|
---|
165 | return kFALSE;
|
---|
166 | }
|
---|
167 |
|
---|
168 | if (!fChargeCalc)
|
---|
169 | {
|
---|
170 | *fLog << err << "Could not find MCalibrationChargeCalc abort... " << endl;
|
---|
171 | return kFALSE;
|
---|
172 | }
|
---|
173 |
|
---|
174 | if (!fCalibrate)
|
---|
175 | {
|
---|
176 | *fLog << err << "Could not find MCalibrateData abort... " << endl;
|
---|
177 | return kFALSE;
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | //
|
---|
182 | // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
|
---|
183 | // corresponding IntensityCam
|
---|
184 | //
|
---|
185 | if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
|
---|
186 | {
|
---|
187 |
|
---|
188 | fIntensRelTime = (MCalibrationIntensityRelTimeCam*)pList->FindCreateObj("MCalibrationIntensityRelTimeCam");
|
---|
189 | if (!fRelTimeCalc)
|
---|
190 | fRelTimeCalc = (MCalibrationRelTimeCalc*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCalc"));
|
---|
191 |
|
---|
192 | *fLog << inf << "Found MHCalibrationRelTimeCam ... " << flush;
|
---|
193 |
|
---|
194 | if (!fIntensRelTime)
|
---|
195 | {
|
---|
196 | *fLog << err << "Could not find nor create MCalibrationIntensityRelTimeCam abort... " << endl;
|
---|
197 | return kFALSE;
|
---|
198 | }
|
---|
199 |
|
---|
200 | if (!fRelTimeCalc)
|
---|
201 | {
|
---|
202 | *fLog << err << "Could not find MCalibrationRelTimeCalc abort... " << endl;
|
---|
203 | return kFALSE;
|
---|
204 | }
|
---|
205 | }
|
---|
206 |
|
---|
207 | fNumCam = 0;
|
---|
208 | fNumEvents = 0;
|
---|
209 |
|
---|
210 | return kTRUE;
|
---|
211 | }
|
---|
212 |
|
---|
213 | // --------------------------------------------------------------------------
|
---|
214 | //
|
---|
215 | // - Initializes new containers in the
|
---|
216 | // - Intensity Cams, if the number of calibration events has reach fNumEventsDump.
|
---|
217 | // - Executes Finalize() of the MCalibration*Calc classes in that case.
|
---|
218 | // - Sets the latest MCalibrationChargeCam as update class into MCalibrateData
|
---|
219 | // - Initialize new MCalibration*Cams into the intensity cams.
|
---|
220 | //
|
---|
221 | Int_t MCalibCalcFromPast::Process()
|
---|
222 | {
|
---|
223 |
|
---|
224 | if (fNumEvents++ < fNumEventsDump)
|
---|
225 | return kTRUE;
|
---|
226 |
|
---|
227 | fNumEvents = 0;
|
---|
228 | //
|
---|
229 | // Finalize Possible calibration histogram classes...
|
---|
230 | //
|
---|
231 | *fLog << inf << GetDescriptor() << " : Finalize calibration histograms..." << endl;
|
---|
232 | if (Finalize("MHCalibrationChargeCam")) *fLog << "MHCalibrationChargeCam ready" << flush;
|
---|
233 | if (Finalize("MHCalibrationChargeBlindCam")) *fLog << "MHCalibrationChargeBlindCam ready" << flush;
|
---|
234 | if (Finalize("MHCalibrationRelTimeCam")) *fLog << "MHCalibrationRelTimeCam ready" << flush;
|
---|
235 |
|
---|
236 | //
|
---|
237 | // Finalize possible calibration calculation tasks
|
---|
238 | //
|
---|
239 | *fLog << endl;
|
---|
240 | *fLog << inf << GetDescriptor() << " : Finalize calibration calculations..." << endl;
|
---|
241 | if (fChargeCalc)
|
---|
242 | fChargeCalc->Finalize();
|
---|
243 | if (fRelTimeCalc)
|
---|
244 | fRelTimeCalc->Finalize();
|
---|
245 | if (fCalibrate)
|
---|
246 | fCalibrate->UpdateConversionFactors((MCalibrationChargeCam*)fIntensCharge->GetCam());
|
---|
247 |
|
---|
248 | ReInitialize();
|
---|
249 |
|
---|
250 | return kTRUE;
|
---|
251 | }
|
---|
252 |
|
---|
253 |
|
---|
254 | // --------------------------------------------------------------------------
|
---|
255 | //
|
---|
256 | // Searches for name in the MParList and calls, if existing:
|
---|
257 | // - MHCalibrationCam::Finalize()
|
---|
258 | // - MHCalibrationCam::ResetHists()
|
---|
259 | //
|
---|
260 | Bool_t MCalibCalcFromPast::Finalize(const char* name)
|
---|
261 | {
|
---|
262 |
|
---|
263 | MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name);
|
---|
264 | if (hist)
|
---|
265 | {
|
---|
266 | hist->Finalize();
|
---|
267 | hist->ResetHists();
|
---|
268 | return kTRUE;
|
---|
269 | }
|
---|
270 |
|
---|
271 | return kFALSE;
|
---|
272 |
|
---|
273 | }
|
---|
274 |
|
---|
275 | // --------------------------------------------------------------------------
|
---|
276 | //
|
---|
277 | // Re-Intitializes new containers inside the Intensity Cams.
|
---|
278 | // From now on, a call to the IntensityCam functions returns pointers
|
---|
279 | // to the newly created Containers.
|
---|
280 | //
|
---|
281 | Bool_t MCalibCalcFromPast::ReInitialize()
|
---|
282 | {
|
---|
283 |
|
---|
284 | *fLog << endl;
|
---|
285 |
|
---|
286 | fNumCam++;
|
---|
287 |
|
---|
288 | if (fIntensBad)
|
---|
289 | {
|
---|
290 | fIntensBad->AddToList(Form("MBadPixelsCam%04d",fNumCam),*fGeom);
|
---|
291 | *fLog << inf << "New MBadPixelsCam Nr. " << fNumCam << endl;
|
---|
292 | }
|
---|
293 |
|
---|
294 | if (fIntensCharge)
|
---|
295 | {
|
---|
296 | fIntensCharge->AddToList(Form("MCalibrationChargeCam%04d",fNumCam),*fGeom);
|
---|
297 | *fLog << inf << "New MCalibrationChargeCam Nr. " << fNumCam << endl;
|
---|
298 | }
|
---|
299 | if (fIntensQE)
|
---|
300 | {
|
---|
301 | fIntensQE->AddToList(Form("MCalibrationQECam%04d",fNumCam),*fGeom);
|
---|
302 | *fLog << inf << "New MCalibrationQECam Nr. " << fNumCam << endl;
|
---|
303 | }
|
---|
304 | if (fIntensBlind)
|
---|
305 | {
|
---|
306 | fIntensBlind->AddToList(Form("MCalibrationBlindCam%04d",fNumCam),*fGeom);
|
---|
307 | *fLog << inf << "New MCalibrationBlindCam Nr. " << fNumCam << endl;
|
---|
308 | }
|
---|
309 |
|
---|
310 | return kTRUE;
|
---|
311 |
|
---|
312 | }
|
---|
313 |
|
---|
314 | Int_t MCalibCalcFromPast::PostProcess()
|
---|
315 | {
|
---|
316 | *fLog << inf << GetDescriptor()
|
---|
317 | << ": Number of Calibration Cams: " << fNumCam << endl;
|
---|
318 | return kTRUE;
|
---|
319 |
|
---|
320 | }
|
---|
321 |
|
---|