source: trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc@ 5679

Last change on this file since 5679 was 5679, checked in by gaug, 20 years ago
*** empty log message ***
File size: 10.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, 09/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24//////////////////////////////////////////////////////////////////////////////
25//
26// MCalibColorSteer
27//
28// Steers the occurrance of different calibration colours in one calibration
29// run.
30//
31// Input Containers:
32// MRawEvtHeader
33// MParList
34// MCalibrationIntensityChargeCam
35// MCalibrationIntensityRelTimeCam
36// MBadPixelsIntensityCam
37//
38// Output Containers:
39// MCalibrationIntensityChargeCam
40// MCalibrationIntensityRelTimeCam
41// MBadPixelsIntensityCam
42//
43//////////////////////////////////////////////////////////////////////////////
44#include "MCalibColorSteer.h"
45
46#include "MLog.h"
47#include "MLogManip.h"
48
49#include "MParList.h"
50#include "MTaskList.h"
51
52#include "MHCalibrationCam.h"
53#include "MCalibrationCam.h"
54#include "MCalibrationBlindCam.h"
55
56#include "MCalibrationIntensityChargeCam.h"
57#include "MCalibrationIntensityBlindCam.h"
58#include "MCalibrationIntensityQECam.h"
59#include "MCalibrationIntensityRelTimeCam.h"
60
61#include "MBadPixelsIntensityCam.h"
62
63#include "MCalibrationChargeCalc.h"
64#include "MCalibrationRelTimeCalc.h"
65
66#include "MRawRunHeader.h"
67#include "MRawEvtHeader.h"
68
69#include "MGeomCam.h"
70
71ClassImp(MCalibColorSteer);
72
73using namespace std;
74
75// --------------------------------------------------------------------------
76//
77// Default constructor.
78//
79MCalibColorSteer::MCalibColorSteer(const char *name, const char *title)
80 : fHeader(NULL), fGeom(NULL), fParList(NULL),
81 fIntensCharge(NULL), fIntensRelTime(NULL), fIntensBad(NULL),
82 fBad(NULL), fChargeCalc(NULL), fRelTimeCalc(NULL), fPattern(0)
83{
84
85 fName = name ? name : "MCalibColorSteer";
86 fTitle = title ? title : "Task to steer the processing of different colours in the calibration events";
87
88}
89
90// -----------------------------------------------------------------------------------
91//
92// The following container are searched for and execution aborted if not in MParList:
93// - MRawEvtHeader
94// - MTaskList
95//
96Int_t MCalibColorSteer::PreProcess(MParList *pList)
97{
98
99 fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
100 if (!fHeader)
101 {
102 *fLog << err << "MRawEvtHeader not found... abort." << endl;
103 return kFALSE;
104 }
105
106 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
107 if (!fHeader)
108 {
109 *fLog << err << "MRawRunHeader not found... abort." << endl;
110 return kFALSE;
111 }
112
113 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
114 if (!fGeom)
115 {
116 *fLog << err << "MGeomCam not found... abort." << endl;
117 return kFALSE;
118 }
119
120 fParList = pList;
121 if (!fParList)
122 {
123 *fLog << err << "MParList not found... abort." << endl;
124 return kFALSE;
125 }
126
127 MTaskList *tlist = (MTaskList*)pList->FindObject("MTaskList");
128 if (!tlist)
129 {
130 *fLog << err << "MTaskList not found... abort." << endl;
131 return kFALSE;
132 }
133
134 //
135 // Look for the MBadPixels Intensity Cam
136 //
137 fIntensBad = (MBadPixelsIntensityCam*)pList->FindCreateObj("MBadPixelsIntensityCam");
138 if (fIntensBad)
139 *fLog << inf << "Found MBadPixelsIntensityCam ... " << flush;
140 else
141 return kFALSE;
142
143 //
144 // Look for the MBadPixels Intensity Cam
145 //
146 fBad = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
147 if (fBad)
148 {
149 *fLog << inf << "Found also MBadPixelsCam ... " << flush;
150 fIntensBad->GetCam()->Merge(*fBad);
151 }
152 else
153 return kFALSE;
154
155 //
156 // Look for the MCalibrationIntensityBlindCam
157 //
158 fIntensBlind = (MCalibrationIntensityBlindCam*)pList->FindCreateObj("MCalibrationIntensityBlindCam");
159
160 if (fIntensBlind)
161 *fLog << inf << "Found MCalibrationIntensityBlindCam ... " << flush;
162 else
163 return kFALSE;
164
165 //
166 // Look for the MFillH name "FillChargeCam". In case yes, initialize the
167 // corresponding IntensityCam
168 //
169 if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
170 {
171
172 fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
173 fIntensQE = (MCalibrationIntensityQECam*) pList->FindCreateObj("MCalibrationIntensityQECam");
174
175 fChargeCalc = (MCalibrationChargeCalc*)tlist->FindObject("MCalibrationChargeCalc");
176
177 *fLog << inf << "Found MHCalibrationChargeCam ... " << flush;
178
179 if (!fIntensCharge)
180 {
181 *fLog << err << "Could not find nor create MCalibrationIntensityChargeCam abort... " << endl;
182 return kFALSE;
183 }
184
185 if (!fIntensQE)
186 {
187 *fLog << err << "Could not find nor create MCalibrationIntensityQECam abort... " << endl;
188 return kFALSE;
189 }
190
191 if (!fChargeCalc)
192 {
193 *fLog << err << "Could not find MCalibrationChargeCalc abort... " << endl;
194 return kFALSE;
195 }
196 }
197
198 //
199 // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
200 // corresponding IntensityCam
201 //
202 if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
203 {
204
205 fIntensRelTime = (MCalibrationIntensityRelTimeCam*)pList->FindCreateObj("MCalibrationIntensityRelTimeCam");
206 fRelTimeCalc = (MCalibrationRelTimeCalc*)tlist->FindObject(AddSerialNumber("MCalibrationRelTimeCalc"));
207
208 *fLog << inf << "Found MHCalibrationRelTimeCam ... " << flush;
209
210 if (!fIntensRelTime)
211 {
212 *fLog << err << "Could not find nor create MCalibrationIntensityRelTimeCam abort... " << endl;
213 return kFALSE;
214 }
215
216 if (!fRelTimeCalc)
217 {
218 *fLog << err << "Could not find MCalibrationRelTimeCalc abort... " << endl;
219 return kFALSE;
220 }
221 }
222
223 return kTRUE;
224}
225
226// --------------------------------------------------------------------------
227//
228// Reads the pattern from MRawEvtHeader and initializes new containers in the
229// Intensity Cams, if the pattern has changed. Executes Finalize of the
230// MCalibration*Calc classes in that case.
231//
232Int_t MCalibColorSteer::Process()
233{
234
235 const UInt_t pattern = fHeader->GetPulserSlotPattern();
236
237 if (fPattern == 0)
238 {
239 fPattern = pattern;
240 return kTRUE;
241 }
242
243 if (pattern == 0 || pattern == fPattern)
244 return kTRUE;
245
246 *fLog << inf << GetDescriptor() << " : old pattern: " << fPattern << flush;
247
248 fPattern = pattern;
249
250 *fLog << " : new pattern: " << pattern << flush;
251
252 //
253 // Finalize Possible calibration histogram classes...
254 //
255 *fLog << inf << GetDescriptor() << " : Finalize calibration histograms..." << flush;
256 if (Finalize("MHCalibrationChargeCam")) *fLog << "MHCalibrationChargeCam";
257 if (Finalize("MHCalibrationChargeBlindCam")) *fLog << "MHCalibrationChargeBlindCam";
258 if (Finalize("MHCalibrationRelTimeCam")) *fLog << "MHCalibrationRelTimeCam";
259 if (Finalize("MHCalibrationTestCam")) *fLog << "MHCalibrationChargeCam";
260 if (Finalize("MHCalibrationTestTimeCam")) *fLog << "MHCalibrationChargeCam";
261
262 //
263 // Finalize possible calibration calculation tasks
264 //
265 *fLog << endl;
266 *fLog << inf << GetDescriptor() << " : Finalize calibration calculations..." << flush;
267 if (fChargeCalc)
268 fChargeCalc->Finalize();
269 if (fRelTimeCalc)
270 fRelTimeCalc->Finalize();
271
272 ReInitialize();
273
274 return kTRUE;
275}
276
277
278// --------------------------------------------------------------------------
279//
280// Searches for name in the MParList and calls, if existing:
281// - MHCalibrationCam::Finalize()
282// - MHCalibrationCam::ResetHists()
283//
284Bool_t MCalibColorSteer::Finalize(const char* name)
285{
286
287 MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name);
288 if (hist)
289 {
290 hist->Finalize();
291 hist->ResetHists();
292 hist->SetColor( fHeader->GetPulserColor());
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 MCalibColorSteer::ReInitialize()
307{
308
309 *fLog << endl;
310
311 TString namep = GetNamePattern();
312
313 if (fIntensBad)
314 {
315 fIntensBad->AddToList(Form("MBadPixelsCam%s",namep.Data()),*fGeom);
316 *fLog << inf << "New MBadPixelsCam with " << namep << endl;
317 fIntensBad->GetCam()->Merge(*fBad);
318 *fLog << inf << "Merged new MBadPixelsCam with first of list" << endl;
319 }
320 if (fIntensCharge)
321 {
322 fIntensCharge->AddToList(Form("MCalibrationChargeCam%s",namep.Data()),*fGeom);
323 MCalibrationCam *cam = fIntensCharge->GetCam();
324 cam->SetPulserColor(fHeader->GetPulserColor());
325 *fLog << inf << "New MCalibrationChargeCam with name: " << cam->GetName() << endl;
326 }
327 if (fIntensQE)
328 {
329 fIntensQE->AddToList(Form("MCalibrationQECam%s",namep.Data()),*fGeom);
330 *fLog << inf << "New MCalibrationQECam with: " << namep << endl;
331 }
332
333 if (fIntensBlind)
334 {
335 fIntensBlind->AddToList(Form("MCalibrationBlindCam%s",namep.Data()),*fGeom);
336 MCalibrationCam *cam = fIntensBlind->GetCam();
337 cam->SetPulserColor(fHeader->GetPulserColor());
338 *fLog << inf << "New MCalibrationBlindCam with name: " << cam->GetName() << endl;
339 }
340
341 if (fIntensRelTime)
342 {
343 fIntensRelTime->AddToList(Form("MCalibrationRelTimeCam%s",namep.Data()),*fGeom);
344 MCalibrationCam *cam = fIntensRelTime->GetCam();
345 cam->SetPulserColor(fHeader->GetPulserColor());
346 *fLog << inf << "New MCalibrationRelTimeCam with name: " << cam->GetName() << endl;
347 }
348
349 return kTRUE;
350
351}
352
353TString MCalibColorSteer::GetNamePattern()
354{
355
356 const Float_t strength = fHeader->GetPulserStrength();
357 const MCalibrationCam::PulserColor_t col = fHeader->GetPulserColor();
358
359 TString result = Form("%2.1f",strength);
360
361 switch (col)
362 {
363 case MCalibrationCam::kCT1:
364 result += "CT1";
365 break;
366 case MCalibrationCam::kGREEN:
367 result += "GREEN";
368 break;
369 case MCalibrationCam::kBLUE:
370 result += "BLUE";
371 break;
372 case MCalibrationCam::kUV:
373 result += "UV";
374 break;
375 default:
376 break;
377 }
378 return result;
379}
Note: See TracBrowser for help on using the repository browser.