source: trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc@ 5947

Last change on this file since 5947 was 5947, checked in by mazin, 20 years ago
MCalibrateRelTimes.cc
File size: 9.8 KB
Line 
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#include "MCalibrationIntensityHiLoCam.h"
57
58#include "MBadPixelsIntensityCam.h"
59
60#include "MCalibrationChargeCalc.h"
61#include "MCalibrationRelTimeCalc.h"
62#include "MCalibrateData.h"
63
64#include "MGeomCam.h"
65
66ClassImp(MCalibCalcFromPast);
67
68using namespace std;
69
70const UInt_t MCalibCalcFromPast::fgNumEventsDump = 1000;
71// --------------------------------------------------------------------------
72//
73// Default constructor.
74//
75// Sets:
76// - fNumEventsDump to fgNumEventsDump
77//
78MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
79 : fGeom(NULL), fParList(NULL),
80 fIntensCharge(NULL), fIntensBlind(NULL), fIntensRelTime(NULL), fIntensBad(NULL),
81 fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
82 fNumEvents(0), fNumCam(0)
83{
84
85 fName = name ? name : "MCalibCalcFromPast";
86 fTitle = title ? title : "Task to steer the processing of interlaced calibration events";
87
88 SetNumEventsDump();
89}
90
91// -----------------------------------------------------------------------------------
92//
93// The following container are searched for and execution aborted if not in MParList:
94// - MTaskList
95//
96Int_t MCalibCalcFromPast::PreProcess(MParList *pList)
97{
98
99 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
100 if (!fGeom)
101 {
102 *fLog << err << "MGeomCam not found... abort." << endl;
103 return kFALSE;
104 }
105
106 fParList = pList;
107 if (!fParList)
108 {
109 *fLog << err << "MParList not found... abort." << endl;
110 return kFALSE;
111 }
112
113 //
114 // Look for the MBadPixels Intensity Cam
115 //
116 fIntensBad = (MBadPixelsIntensityCam*)pList->FindCreateObj("MBadPixelsIntensityCam");
117 if (fIntensBad)
118 *fLog << inf << "Found MBadPixelsIntensityCam ... " << flush;
119 else
120 return kFALSE;
121
122 //
123 // Look for the MFillH-class "MHCalibrationBlindCam". In case yes, initialize the
124 // corresponding IntensityCam
125 //
126 if (pList->FindObject(AddSerialNumber("MHCalibrationBlindCam")))
127 {
128
129 *fLog << inf << "Found MHCalibrationBlindCam ... " << flush;
130
131 fIntensBlind = (MCalibrationIntensityBlindCam*)pList->FindCreateObj("MCalibrationIntensityBlindCam");
132 if (!fIntensBlind)
133 {
134 *fLog << err << "Could not find nor create MCalibrationIntensitBlindCam abort... " << endl;
135 return kFALSE;
136 }
137 }
138
139 //
140 // Look for the MFillH-class "MHCalibrationChargeCam". In case yes, initialize the
141 // corresponding IntensityCam
142 //
143 if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
144 {
145
146 fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
147 fIntensQE = (MCalibrationIntensityQECam*) pList->FindCreateObj("MCalibrationIntensityQECam");
148
149 if (!fChargeCalc)
150 fChargeCalc = (MCalibrationChargeCalc*)pList->FindObject("MCalibrationChargeCalc");
151
152 if (!fCalibrate)
153 fCalibrate = (MCalibrateData*)pList->FindObject("MCalibrateData");
154
155 *fLog << inf << "Found MHCalibrationChargeCam ... " << flush;
156
157 if (!fIntensCharge)
158 {
159 *fLog << err << "Could not find nor create MCalibrationIntensityChargeCam abort... " << endl;
160 return kFALSE;
161 }
162
163 if (!fIntensQE)
164 {
165 *fLog << err << "Could not find nor create MCalibrationIntensityQECam abort... " << endl;
166 return kFALSE;
167 }
168
169 if (!fChargeCalc)
170 {
171 *fLog << err << "Could not find MCalibrationChargeCalc abort... " << endl;
172 return kFALSE;
173 }
174
175 if (!fCalibrate)
176 {
177 *fLog << err << "Could not find MCalibrateData abort... " << endl;
178 return kFALSE;
179 }
180 }
181
182 //
183 // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
184 // corresponding IntensityCam
185 //
186 if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
187 {
188
189 fIntensRelTime = (MCalibrationIntensityRelTimeCam*)pList->FindCreateObj("MCalibrationIntensityRelTimeCam");
190 if (!fRelTimeCalc)
191 fRelTimeCalc = (MCalibrationRelTimeCalc*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCalc"));
192
193 *fLog << inf << "Found MHCalibrationRelTimeCam ... " << flush;
194
195 if (!fIntensRelTime)
196 {
197 *fLog << err << "Could not find nor create MCalibrationIntensityRelTimeCam abort... " << endl;
198 return kFALSE;
199 }
200
201 if (!fRelTimeCalc)
202 {
203 *fLog << err << "Could not find MCalibrationRelTimeCalc abort... " << endl;
204 return kFALSE;
205 }
206 }
207
208 //
209 // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
210 // corresponding IntensityCam
211 //
212 /*
213 if (pList->FindObject(AddSerialNumber("MHCalibrationHiLoCam")))
214 {
215
216 fIntensHiLo = (MCalibrationIntensityHiLoCam*)pList->FindCreateObj("MCalibrationIntensityHiLoCam");
217
218 *fLog << inf << "Found MHCalibrationHiLoCam ... " << flush;
219
220 if (!fIntensHiLo)
221 {
222 *fLog << err << "Could not find nor create MCalibrationIntensityHiLoCam abort... " << endl;
223 return kFALSE;
224 }
225 }
226 */
227
228 fNumCam = 0;
229 fNumEvents = 0;
230
231 return kTRUE;
232}
233
234// --------------------------------------------------------------------------
235//
236// - Initializes new containers in the
237// - Intensity Cams, if the number of calibration events has reach fNumEventsDump.
238// - Executes Finalize() of the MCalibration*Calc classes in that case.
239// - Sets the latest MCalibrationChargeCam as update class into MCalibrateData
240// - Initialize new MCalibration*Cams into the intensity cams.
241//
242Int_t MCalibCalcFromPast::Process()
243{
244
245 if (fNumEvents++ < fNumEventsDump)
246 return kTRUE;
247
248 fNumEvents = 0;
249 //
250 // Finalize Possible calibration histogram classes...
251 //
252 *fLog << inf << GetDescriptor() << " : Finalize calibration histograms..." << flush;
253 if (Finalize("MHCalibrationChargeCam")) *fLog << "MHCalibrationChargeCam";
254 if (Finalize("MHCalibrationChargeBlindCam")) *fLog << "MHCalibrationChargeBlindCam";
255 if (Finalize("MHCalibrationRelTimeCam")) *fLog << "MHCalibrationRelTimeCam";
256 if (Finalize("MHCalibrationHiLoCam")) *fLog << "MHCalibrationHiLoCam";
257
258 //
259 // Finalize possible calibration calculation tasks
260 //
261 *fLog << endl;
262 *fLog << inf << GetDescriptor() << " : Finalize calibration calculations..." << flush;
263 if (fChargeCalc)
264 fChargeCalc->Finalize();
265 if (fRelTimeCalc)
266 fRelTimeCalc->Finalize();
267 if (fCalibrate)
268 {
269 fCalibrate->SetCalibUpdate((MCalibrationChargeCam*)fIntensCharge->GetCam());
270 fCalibrate->UpdateConversionFactors();
271 }
272
273 ReInitialize();
274
275 return kTRUE;
276}
277
278
279// --------------------------------------------------------------------------
280//
281// Searches for name in the MParList and calls, if existing:
282// - MHCalibrationCam::Finalize()
283// - MHCalibrationCam::ResetHists()
284//
285Bool_t MCalibCalcFromPast::Finalize(const char* name)
286{
287
288 MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name);
289 if (hist)
290 {
291 hist->Finalize();
292 hist->ResetHists();
293 return kTRUE;
294 }
295
296 return kFALSE;
297
298}
299
300// --------------------------------------------------------------------------
301//
302// Re-Intitializes new containers inside the Intensity Cams.
303// From now on, a call to the IntensityCam functions returns pointers
304// to the newly created Containers.
305//
306Bool_t MCalibCalcFromPast::ReInitialize()
307{
308
309 *fLog << endl;
310
311 fNumCam++;
312
313 if (fIntensBad)
314 {
315 fIntensBad->AddToList(Form("MBadPixelsCam%04d",fNumCam),*fGeom);
316 *fLog << inf << "New MBadPixelsCam Nr. " << fNumCam << endl;
317 }
318
319 if (fIntensCharge)
320 {
321 fIntensCharge->AddToList(Form("MCalibrationChargeCam%04d",fNumCam),*fGeom);
322 *fLog << inf << "New MCalibrationChargeCam Nr. " << fNumCam << endl;
323 }
324 if (fIntensQE)
325 {
326 fIntensQE->AddToList(Form("MCalibrationQECam%04d",fNumCam),*fGeom);
327 *fLog << inf << "New MCalibrationQECam Nr. " << fNumCam << endl;
328 }
329 if (fIntensBlind)
330 {
331 fIntensBlind->AddToList(Form("MCalibrationBlindCam%04d",fNumCam),*fGeom);
332 *fLog << inf << "New MCalibrationBlindCam Nr. " << fNumCam << endl;
333 }
334
335 return kTRUE;
336
337}
338
339Int_t MCalibCalcFromPast::PostProcess()
340{
341 *fLog << inf << GetDescriptor()
342 << ": Number of Calibration Cams: " << fNumCam << endl;
343 return kTRUE;
344
345}
Note: See TracBrowser for help on using the repository browser.