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

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