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