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

Last change on this file since 5023 was 5019, checked in by gaug, 20 years ago
*** empty log message ***
File size: 10.4 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
51#include "MHCalibrationCam.h"
52
53#include "MCalibrationIntensityChargeCam.h"
54#include "MCalibrationIntensityQECam.h"
55#include "MCalibrationIntensityRelTimeCam.h"
56
57#include "MBadPixelsIntensityCam.h"
58
59#include "MCalibrationChargeCalc.h"
60#include "MCalibrationRelTimeCalc.h"
61
62#include "MRawEvtHeader.h"
63
64#include "MGeomCam.h"
65
66ClassImp(MCalibColorSteer);
67
68using namespace std;
69
70// --------------------------------------------------------------------------
71//
72// Default constructor.
73//
74MCalibColorSteer::MCalibColorSteer(const char *name, const char *title)
75 : fHeader(NULL), fGeom(NULL), fParList(NULL),
76 fIntensCharge(NULL), fIntensRelTime(NULL), fIntensBad(NULL),
77 fChargeCalc(NULL), fRelTimeCalc(NULL),
78 fPattern(0)
79{
80
81 fName = name ? name : "MCalibColorSteer";
82 fTitle = title ? title : "Task to steer the processing of different colours in the calibration events";
83
84}
85
86// -----------------------------------------------------------------------------------
87//
88// The following container are searched for and execution aborted if not in MParList:
89// - MRawEvtHeader
90// - MTaskList
91//
92Int_t MCalibColorSteer::PreProcess(MParList *pList)
93{
94
95 fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
96 if (!fHeader)
97 {
98 *fLog << err << "MRawEvtHeader not found... abort." << endl;
99 return kFALSE;
100 }
101
102 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
103 if (!fGeom)
104 {
105 *fLog << err << "MGeomCam not found... abort." << endl;
106 return kFALSE;
107 }
108
109 fParList = pList;
110 if (!fParList)
111 {
112 *fLog << err << "MParList 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
121 //
122 // Look for the MFillH name "FillChargeCam". In case yes, initialize the
123 // corresponding IntensityCam
124 //
125 if (pList->FindObject(AddSerialNumber("FillChargeCam")))
126 {
127
128 fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
129 fIntensQE = (MCalibrationIntensityQECam*) pList->FindCreateObj("MCalibrationIntensityQECam");
130 fChargeCalc = (MCalibrationChargeCalc*) pList->FindObject("MCalibrationChargeCalc");
131
132 if (!fIntensCharge)
133 {
134 *fLog << err << "Could not find nor create MCalibrationIntensityChargeCam abort... " << endl;
135 return kFALSE;
136 }
137
138 if (!fIntensQE)
139 {
140 *fLog << err << "Could not find nor create MCalibrationIntensityQECam abort... " << endl;
141 return kFALSE;
142 }
143
144 if (!fChargeCalc)
145 {
146 *fLog << err << "Could not find MCalibrationChargeCalc abort... " << endl;
147 return kFALSE;
148 }
149 }
150
151 //
152 // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
153 // corresponding IntensityCam
154 //
155 if (pList->FindObject(AddSerialNumber("FillRelTimeCam")))
156 {
157
158 fIntensRelTime = (MCalibrationIntensityRelTimeCam*)pList->FindCreateObj("MCalibrationIntensityRelTimeCam");
159 fRelTimeCalc = (MCalibrationRelTimeCalc*) pList->FindObject(AddSerialNumber("MCalibrationRelTimeCalc"));
160
161 if (!fIntensRelTime)
162 {
163 *fLog << err << "Could not find nor create MCalibrationIntensityRelTimeCam abort... " << endl;
164 return kFALSE;
165 }
166
167 if (!fRelTimeCalc)
168 {
169 *fLog << err << "Could not find MCalibrationRelTimeCalc abort... " << endl;
170 return kFALSE;
171 }
172 }
173
174 return kTRUE;
175}
176
177// --------------------------------------------------------------------------
178//
179// Reads the pattern from MRawEvtHeader and initializes new containers in the
180// Intensity Cams, if the pattern has changed
181//
182Int_t MCalibColorSteer::Process()
183{
184
185 const UInt_t pattern = fHeader->GetCalibrationPattern();
186
187 if (pattern == fPattern)
188 return kTRUE;
189
190 if (fPattern == 0)
191 {
192 fPattern = pattern;
193 return kTRUE;
194 }
195
196 fPattern = pattern;
197
198 //
199 // Finalize Possible calibration histogram classes...
200 //
201 *fLog << inf << GetDescriptor() << " : Finalize calibration histograms..." << flush;
202 if (Finalize("MHCalibrationChargeCam")) *fLog << "MHCalibrationChargeCam";
203 if (Finalize("MHCalibrationRelTimeCam")) *fLog << "MHCalibrationRelTimeCam";
204 if (Finalize("MHCalibrationTestCam")) *fLog << "MHCalibrationChargeCam";
205 if (Finalize("MHCalibrationTestTimeCam")) *fLog << "MHCalibrationChargeCam";
206
207 //
208 // Finalize possible calibration calculation tasks
209 //
210 *fLog << inf << GetDescriptor() << " : Finalize calibration calculations..." << flush;
211 if (fChargeCalc)
212 fChargeCalc->CallPostProcess();
213 if (fRelTimeCalc)
214 fRelTimeCalc->CallPostProcess();
215
216 ReInitialize();
217
218 return kTRUE;
219}
220
221// --------------------------------------------------------------------------
222//
223// Searches for name in the MParList and calls, if existing:
224// - MHCalibrationCam::Finalize()
225// - MHCalibrationCam::ResetHists()
226//
227Bool_t MCalibColorSteer::Finalize(const char* name)
228{
229
230 MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name);
231 if (hist)
232 {
233 hist->Finalize();
234 hist->ResetHists();
235 return kTRUE;
236 }
237
238 return kFALSE;
239
240}
241
242// --------------------------------------------------------------------------
243//
244// Re-Intitializes new containers inside the Intensity Cams.
245// From now on, a call to the IntensityCam functions returns pointers
246// to the newly created Containers.
247//
248Bool_t MCalibColorSteer::ReInitialize()
249{
250
251 if (fIntensBad)
252 {
253 fIntensBad->AddToList(Form("MBadPixelsCam%s",GetNamePattern()),*fGeom);
254 *fLog << inf << "New MBadPixelsCam with " << GetNamePattern() << endl;
255 }
256 if (fIntensCharge)
257 {
258 fIntensCharge->AddToList(Form("MCalibrationChargeCam%s",GetNamePattern()),*fGeom);
259 *fLog << inf << "New MCalibrationChargeCam with " << GetNamePattern() << endl;
260 }
261 if (fIntensQE)
262 {
263 fIntensQE->AddToList(Form("MCalibrationQECam%s",GetNamePattern()),*fGeom);
264 *fLog << inf << "New MCalibrationQECam with " << GetNamePattern() << endl;
265 }
266 if (fIntensRelTime)
267 {
268 fIntensRelTime->AddToList(Form("MCalibrationRelTimeCam%s",GetNamePattern()),*fGeom);
269 *fLog << inf << "New MCalibrationRelTimeCam with " << GetNamePattern() << endl;
270 }
271
272 return kTRUE;
273
274}
275
276const char* MCalibColorSteer::GetNamePattern()
277{
278
279 Float_t number[MCalibrationCam::gkNumPulserColors];
280 memset(number,0,MCalibrationCam::gkNumPulserColors*sizeof(Float_t));
281
282 enum ColorCode_t
283 {
284 k5LedGreen = BIT(0 ),
285 k2LedGreen = BIT(1 ),
286 k5LedBlue2 = BIT(2 ),
287 k1LedUV = BIT(3 ),
288 k2LedUV = BIT(4 ),
289 k5LedBlue3 = BIT(5 ),
290 k5LedBlue4 = BIT(6 ),
291 k2LedBlue = BIT(7 ),
292 k01LedBlue = BIT(8 ),
293 k1LedBlue = BIT(10),
294 k5LedUV1 = BIT(11),
295 k5LedUV2 = BIT(12),
296 k5LedBlue1 = BIT(13),
297 k1LedGreen = BIT(14),
298 k01LedGreen = BIT(15),
299 kCT1Pulser = BIT(16)
300 };
301
302 if (fPattern & k5LedGreen)
303 number[MCalibrationCam::kGREEN] += 5;
304 if (fPattern & k2LedGreen)
305 number[MCalibrationCam::kGREEN] += 2;
306 if (fPattern & k5LedBlue2)
307 number[MCalibrationCam::kBLUE] += 2;
308 if (fPattern & k1LedUV)
309 number[MCalibrationCam::kUV] += 1;
310 if (fPattern & k2LedUV)
311 number[MCalibrationCam::kUV] += 2;
312 if (fPattern & k5LedBlue3)
313 number[MCalibrationCam::kBLUE] += 5;
314 if (fPattern & k5LedBlue4)
315 number[MCalibrationCam::kBLUE] += 5;
316 if (fPattern & k2LedBlue)
317 number[MCalibrationCam::kBLUE] += 2;
318 if (fPattern & k01LedBlue)
319 number[MCalibrationCam::kBLUE] += 0.5;
320 if (fPattern & k1LedBlue)
321 number[MCalibrationCam::kBLUE] += 1;
322 if (fPattern & k5LedUV1)
323 number[MCalibrationCam::kUV] += 5;
324 if (fPattern & k5LedUV2)
325 number[MCalibrationCam::kUV] += 5;
326 if (fPattern & k5LedBlue1)
327 number[MCalibrationCam::kBLUE] += 5;
328 if (fPattern & k1LedGreen)
329 number[MCalibrationCam::kGREEN] += 1;
330 if (fPattern & k01LedGreen)
331 number[MCalibrationCam::kGREEN] += 0.5;
332 if (fPattern & kCT1Pulser)
333 number[MCalibrationCam::kCT1] += 1;
334
335 TString result;
336
337 for (Int_t i=0; i<MCalibrationCam::gkNumPulserColors; i++)
338 {
339 switch (i)
340 {
341 case MCalibrationCam::kGREEN:
342 if (number[i] > 0.1)
343 {
344 result += number[i];
345 result += "GREEN";
346 }
347 break;
348 case MCalibrationCam::kBLUE:
349 if (number[i] > 0.1)
350 {
351 result += number[i];
352 result += "BLUE";
353 }
354 break;
355 case MCalibrationCam::kUV:
356 if (number[i] > 0.1)
357 {
358 result += number[i];
359 result += "UV";
360 }
361 break;
362 case MCalibrationCam::kCT1:
363 if (number[i] > 0.1)
364 result += "CT1";
365 break;
366 }
367 }
368 return result.Data();
369}
Note: See TracBrowser for help on using the repository browser.