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

Last change on this file since 6013 was 6004, checked in by gaug, 20 years ago
*** empty log message ***
File size: 9.2 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
57#include "MBadPixelsIntensityCam.h"
58
59#include "MCalibrationChargeCalc.h"
60#include "MCalibrationRelTimeCalc.h"
61#include "MCalibrateData.h"
62
63#include "MGeomCam.h"
64
65ClassImp(MCalibCalcFromPast);
66
67using namespace std;
68
69const UInt_t MCalibCalcFromPast::fgNumEventsDump = 1000;
70// --------------------------------------------------------------------------
71//
72// Default constructor.
73//
74// Sets:
75// - fNumEventsDump to fgNumEventsDump
76//
77MCalibCalcFromPast::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//
95Int_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//
221Int_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 {
247 fCalibrate->SetCalibUpdate((MCalibrationChargeCam*)fIntensCharge->GetCam());
248 fCalibrate->UpdateConversionFactors();
249 }
250
251 ReInitialize();
252
253 return kTRUE;
254}
255
256
257// --------------------------------------------------------------------------
258//
259// Searches for name in the MParList and calls, if existing:
260// - MHCalibrationCam::Finalize()
261// - MHCalibrationCam::ResetHists()
262//
263Bool_t MCalibCalcFromPast::Finalize(const char* name)
264{
265
266 MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name);
267 if (hist)
268 {
269 hist->Finalize();
270 hist->ResetHists();
271 return kTRUE;
272 }
273
274 return kFALSE;
275
276}
277
278// --------------------------------------------------------------------------
279//
280// Re-Intitializes new containers inside the Intensity Cams.
281// From now on, a call to the IntensityCam functions returns pointers
282// to the newly created Containers.
283//
284Bool_t MCalibCalcFromPast::ReInitialize()
285{
286
287 *fLog << endl;
288
289 fNumCam++;
290
291 if (fIntensBad)
292 {
293 fIntensBad->AddToList(Form("MBadPixelsCam%04d",fNumCam),*fGeom);
294 *fLog << inf << "New MBadPixelsCam Nr. " << fNumCam << endl;
295 }
296
297 if (fIntensCharge)
298 {
299 fIntensCharge->AddToList(Form("MCalibrationChargeCam%04d",fNumCam),*fGeom);
300 *fLog << inf << "New MCalibrationChargeCam Nr. " << fNumCam << endl;
301 }
302 if (fIntensQE)
303 {
304 fIntensQE->AddToList(Form("MCalibrationQECam%04d",fNumCam),*fGeom);
305 *fLog << inf << "New MCalibrationQECam Nr. " << fNumCam << endl;
306 }
307 if (fIntensBlind)
308 {
309 fIntensBlind->AddToList(Form("MCalibrationBlindCam%04d",fNumCam),*fGeom);
310 *fLog << inf << "New MCalibrationBlindCam Nr. " << fNumCam << endl;
311 }
312
313 return kTRUE;
314
315}
316
317Int_t MCalibCalcFromPast::PostProcess()
318{
319 *fLog << inf << GetDescriptor()
320 << ": Number of Calibration Cams: " << fNumCam << endl;
321 return kTRUE;
322
323}
324
Note: See TracBrowser for help on using the repository browser.