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

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