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

Last change on this file since 5857 was 5857, checked in by gaug, 20 years ago
*** empty log message ***
File size: 9.6 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), 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 if (pList->FindObject(AddSerialNumber("MHCalibrationHiLoCam")))
213 {
214
215 fIntensHiLo = (MCalibrationIntensityHiLoCam*)pList->FindCreateObj("MCalibrationIntensityHiLoCam");
216
217 *fLog << inf << "Found MHCalibrationHiLoCam ... " << flush;
218
219 if (!fIntensHiLo)
220 {
221 *fLog << err << "Could not find nor create MCalibrationIntensityHiLoCam abort... " << endl;
222 return kFALSE;
223 }
224 }
225
226
227 fNumCam = 0;
228 fNumEvents = 0;
229
230 return kTRUE;
231}
232
233// --------------------------------------------------------------------------
234//
235// Initializes new containers in the
236// Intensity Cams, if the number of calibration events has reach fNumEventsDump.
237// Executes CallPostProcess of the MCalibration*Calc classes in that case.
238//
239Int_t MCalibCalcFromPast::Process()
240{
241
242 if (fNumEvents++ < fNumEventsDump)
243 return kTRUE;
244
245 fNumEvents = 0;
246 //
247 // Finalize Possible calibration histogram classes...
248 //
249 *fLog << inf << GetDescriptor() << " : Finalize calibration histograms..." << flush;
250 if (Finalize("MHCalibrationChargeCam")) *fLog << "MHCalibrationChargeCam";
251 if (Finalize("MHCalibrationChargeBlindCam")) *fLog << "MHCalibrationChargeBlindCam";
252 if (Finalize("MHCalibrationRelTimeCam")) *fLog << "MHCalibrationRelTimeCam";
253 if (Finalize("MHCalibrationHiLoCam")) *fLog << "MHCalibrationHiLoCam";
254
255 //
256 // Finalize possible calibration calculation tasks
257 //
258 *fLog << endl;
259 *fLog << inf << GetDescriptor() << " : Finalize calibration calculations..." << flush;
260 if (fChargeCalc)
261 fChargeCalc->Finalize();
262 if (fRelTimeCalc)
263 fRelTimeCalc->Finalize();
264 if (fCalibrate)
265 {
266 fCalibrate->SetCalibUpdate((MCalibrationChargeCam*)fIntensCharge->GetCam());
267 fCalibrate->UpdateConversionFactors();
268 }
269
270 ReInitialize();
271
272 return kTRUE;
273}
274
275
276// --------------------------------------------------------------------------
277//
278// Searches for name in the MParList and calls, if existing:
279// - MHCalibrationCam::Finalize()
280// - MHCalibrationCam::ResetHists()
281//
282Bool_t MCalibCalcFromPast::Finalize(const char* name)
283{
284
285 MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name);
286 if (hist)
287 {
288 hist->Finalize();
289 hist->ResetHists();
290 return kTRUE;
291 }
292
293 return kFALSE;
294
295}
296
297// --------------------------------------------------------------------------
298//
299// Re-Intitializes new containers inside the Intensity Cams.
300// From now on, a call to the IntensityCam functions returns pointers
301// to the newly created Containers.
302//
303Bool_t MCalibCalcFromPast::ReInitialize()
304{
305
306 *fLog << endl;
307
308 fNumCam++;
309
310 if (fIntensBad)
311 {
312 fIntensBad->AddToList(Form("MBadPixelsCam%04d",fNumCam),*fGeom);
313 *fLog << inf << "New MBadPixelsCam Nr. " << fNumCam << endl;
314 }
315
316 if (fIntensCharge)
317 {
318 fIntensCharge->AddToList(Form("MCalibrationChargeCam%04d",fNumCam),*fGeom);
319 *fLog << inf << "New MCalibrationChargeCam Nr. " << fNumCam << endl;
320 }
321 if (fIntensQE)
322 {
323 fIntensQE->AddToList(Form("MCalibrationQECam%04d",fNumCam),*fGeom);
324 *fLog << inf << "New MCalibrationQECam Nr. " << fNumCam << endl;
325 }
326 if (fIntensBlind)
327 {
328 fIntensBlind->AddToList(Form("MCalibrationBlindCam%04d",fNumCam),*fGeom);
329 *fLog << inf << "New MCalibrationBlindCam Nr. " << fNumCam << endl;
330 }
331
332 return kTRUE;
333
334}
335
336Int_t MCalibCalcFromPast::PostProcess()
337{
338 *fLog << inf << GetDescriptor()
339 << ": Number of Calibration Cams: " << fNumCam << endl;
340 return kTRUE;
341
342}
Note: See TracBrowser for help on using the repository browser.