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