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

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