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

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