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): Thomas Bretz, 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 | //////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // MCalibColorSet
|
---|
27 | //
|
---|
28 | // Sets the color for events depending on the color which was used for
|
---|
29 | // the run. This is a workaround for runs which were taken before the
|
---|
30 | // digital module could deliver the color 'per event'
|
---|
31 | //
|
---|
32 | // Input Containers:
|
---|
33 | // MRawRunHeader
|
---|
34 | //
|
---|
35 | // Output Containers:
|
---|
36 | // MRawEvtHeader
|
---|
37 | //
|
---|
38 | //////////////////////////////////////////////////////////////////////////////
|
---|
39 | #include "MCalibColorSet.h"
|
---|
40 |
|
---|
41 | #include "TRegexp.h"
|
---|
42 |
|
---|
43 | #include "MLog.h"
|
---|
44 | #include "MLogManip.h"
|
---|
45 |
|
---|
46 | #include "MParList.h"
|
---|
47 |
|
---|
48 | #include "MRawEvtHeader.h"
|
---|
49 | #include "MRawRunHeader.h"
|
---|
50 |
|
---|
51 | ClassImp(MCalibColorSet);
|
---|
52 |
|
---|
53 |
|
---|
54 | using namespace std;
|
---|
55 |
|
---|
56 | const Int_t MCalibColorSet::gkIFAEBoxInaugurationRun = 20113;
|
---|
57 | const Int_t MCalibColorSet::gkMCRunLimit = 1000;
|
---|
58 | // --------------------------------------------------------------------------
|
---|
59 | //
|
---|
60 | // Default constructor. MGeomCamMagic is the default geometry.
|
---|
61 | //
|
---|
62 | MCalibColorSet::MCalibColorSet(const char *name, const char *title)
|
---|
63 | : fHeader(0)
|
---|
64 | {
|
---|
65 | fName = name ? name : "MCalibColorSet";
|
---|
66 | fTitle = title ? title : "Task to set workaround missing colors calibration events";
|
---|
67 |
|
---|
68 | Clear();
|
---|
69 | }
|
---|
70 |
|
---|
71 | void MCalibColorSet::Clear(const Option_t *o)
|
---|
72 | {
|
---|
73 |
|
---|
74 | fPattern = 0;
|
---|
75 | fIsValid = kFALSE;
|
---|
76 |
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | // -----------------------------------------------------------------------------------
|
---|
81 | //
|
---|
82 | // The following container are searched for and execution aborted if not in MParList:
|
---|
83 | // - MRawEvtHeader
|
---|
84 | //
|
---|
85 | Int_t MCalibColorSet::PreProcess(MParList *pList)
|
---|
86 | {
|
---|
87 |
|
---|
88 | fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
|
---|
89 | if (!fHeader)
|
---|
90 | {
|
---|
91 | *fLog << err << "MRawEvtHeader not found... abort." << endl;
|
---|
92 | return kFALSE;
|
---|
93 | }
|
---|
94 |
|
---|
95 | return kTRUE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | // --------------------------------------------------------------------------
|
---|
99 | //
|
---|
100 | // Search for the following input containers and abort if not existing:
|
---|
101 | // - MRawRunHeader
|
---|
102 | //
|
---|
103 | // If Runnumber < gkIFAEBoxInaugurationRun, set colour pattern: 0
|
---|
104 | //
|
---|
105 | // If Runnumber > gkIFAEBoxInaugurationRun, search for colour in
|
---|
106 | // the project name: Set colour pattern according to the following
|
---|
107 | // convention:
|
---|
108 | // Green: assume slot 1 ( 5 Leds Green)
|
---|
109 | // Blue: assume slot 14 ( 5 Leds Blue )
|
---|
110 | // UV: assume slot 12 ( 5 Leds UV )
|
---|
111 | // CT1: take 'slot 17'
|
---|
112 | //
|
---|
113 | Bool_t MCalibColorSet::ReInit(MParList *pList)
|
---|
114 | {
|
---|
115 |
|
---|
116 | Clear();
|
---|
117 |
|
---|
118 | MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
119 | if (!header)
|
---|
120 | {
|
---|
121 | *fLog << err << "MRawRunHeader not found... abort." << endl;
|
---|
122 | return kFALSE;
|
---|
123 | }
|
---|
124 |
|
---|
125 | enum { kNONE, kGREEN, kBLUE, kUV, kCT1 };
|
---|
126 |
|
---|
127 | enum ColorCode_t
|
---|
128 | {
|
---|
129 | k01LedGreen = BIT(15),
|
---|
130 | k1LedGreen = BIT(14),
|
---|
131 | k2LedGreen = BIT(1 ),
|
---|
132 | k3LedGreen = k1LedGreen | k2LedGreen,
|
---|
133 | k5LedGreen = BIT(0 ),
|
---|
134 | k6LedGreen = k5LedGreen | k1LedGreen,
|
---|
135 | k7LedGreen = k5LedGreen | k2LedGreen,
|
---|
136 | k8LedGreen = k5LedGreen | k3LedGreen,
|
---|
137 | k1LedUV = BIT(3 ),
|
---|
138 | k2LedUV = BIT(4 ),
|
---|
139 | k3LedUV = k1LedUV | k2LedUV,
|
---|
140 | k5LedUV1 = BIT(11),
|
---|
141 | k5LedUV2 = BIT(12),
|
---|
142 | k6LedUV = k5LedUV1 | k1LedUV,
|
---|
143 | k7LedUV = k5LedUV1 | k2LedUV,
|
---|
144 | k8LedUV = k5LedUV1 | k3LedUV,
|
---|
145 | k10LedUV = k5LedUV1 | k5LedUV2,
|
---|
146 | k11LedUV = k10LedUV | k1LedUV,
|
---|
147 | k12LedUV = k10LedUV | k2LedUV,
|
---|
148 | k13LedUV = k10LedUV | k1LedUV,
|
---|
149 | k01LedBlue = BIT(8 ),
|
---|
150 | k1LedBlue = BIT(10),
|
---|
151 | k2LedBlue = BIT(7 ),
|
---|
152 | k3LedBlue = k1LedBlue | k2LedBlue,
|
---|
153 | k5LedBlue1 = BIT(13),
|
---|
154 | k5LedBlue2 = BIT(2 ),
|
---|
155 | k5LedBlue3 = BIT(5 ),
|
---|
156 | k5LedBlue4 = BIT(6 ),
|
---|
157 | k6LedBlue = k5LedBlue1 | k1LedBlue,
|
---|
158 | k7LedBlue = k5LedBlue1 | k2LedBlue,
|
---|
159 | k8LedBlue = k5LedBlue1 | k3LedBlue,
|
---|
160 | k10LedBlue = k5LedBlue1 | k5LedBlue2,
|
---|
161 | k15LedBlue = k10LedBlue | k5LedBlue3,
|
---|
162 | k20LedBlue = k15LedBlue | k5LedBlue4,
|
---|
163 | k21LedBlue = k20LedBlue | k1LedBlue,
|
---|
164 | k22LedBlue = k20LedBlue | k2LedBlue,
|
---|
165 | k23LedBlue = k22LedBlue | k1LedBlue,
|
---|
166 | kCT1Pulser = BIT(16)
|
---|
167 | };
|
---|
168 |
|
---|
169 | const Int_t num = header->GetRunNumber();
|
---|
170 |
|
---|
171 | if (num<gkMCRunLimit)
|
---|
172 | {
|
---|
173 | *fLog << inf << "Assumed MC run ... using GREEN pulser." << endl;
|
---|
174 | fPattern |= k1LedGreen;
|
---|
175 | fIsValid = kTRUE;
|
---|
176 | return kTRUE;
|
---|
177 | }
|
---|
178 |
|
---|
179 | if (num<gkIFAEBoxInaugurationRun)
|
---|
180 | {
|
---|
181 | *fLog << inf << "Run taken before inauguration of IFAE-box... using CT1 pulser." << endl;
|
---|
182 | fPattern |= kCT1Pulser;
|
---|
183 | fIsValid = kTRUE;
|
---|
184 | return kTRUE;
|
---|
185 | }
|
---|
186 |
|
---|
187 | Int_t color = kNONE;
|
---|
188 |
|
---|
189 | switch (num)
|
---|
190 | {
|
---|
191 | case 26402:
|
---|
192 | case 22246:
|
---|
193 | case 22253:
|
---|
194 | color = kBLUE;
|
---|
195 | break;
|
---|
196 |
|
---|
197 | case 30090:
|
---|
198 | case 20660:
|
---|
199 | case 20661:
|
---|
200 | case 26408:
|
---|
201 | case 26409:
|
---|
202 | case 26412:
|
---|
203 | case 26568:
|
---|
204 | case 26924:
|
---|
205 | color = kGREEN;
|
---|
206 | break;
|
---|
207 |
|
---|
208 | case 27474:
|
---|
209 | *fLog << err << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! " << endl;
|
---|
210 | return kFALSE;
|
---|
211 | }
|
---|
212 |
|
---|
213 | if (color!=kNONE)
|
---|
214 | {
|
---|
215 | *fLog << inf << "Color determined from the run-number... ";
|
---|
216 | switch (color)
|
---|
217 | {
|
---|
218 | case kGREEN: *fLog << "Green."; fPattern |= k5LedGreen; break;
|
---|
219 | case kBLUE: *fLog << "Blue."; fPattern |= k5LedBlue1; break;
|
---|
220 | }
|
---|
221 | *fLog << endl;
|
---|
222 | fIsValid = kTRUE;
|
---|
223 | return kTRUE;
|
---|
224 | }
|
---|
225 | else
|
---|
226 | {
|
---|
227 |
|
---|
228 | const TString proj = header->GetProjectName();
|
---|
229 |
|
---|
230 | // Possible green combinations
|
---|
231 | TRegexp gre0("0.1[lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
|
---|
232 | if (proj.Contains(gre0))
|
---|
233 | { fPattern |= k01LedGreen; color = kGREEN; }
|
---|
234 | TRegexp gre1("1[lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
|
---|
235 | if (proj.Contains(gre1))
|
---|
236 | { fPattern |= k1LedGreen; color = kGREEN; }
|
---|
237 | TRegexp gre2("[2][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
|
---|
238 | if (proj.Contains(gre2))
|
---|
239 | { fPattern |= k2LedGreen; color = kGREEN; }
|
---|
240 | TRegexp gre3("[3][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
|
---|
241 | if (proj.Contains(gre3))
|
---|
242 | { fPattern |= k3LedGreen; color = kGREEN; }
|
---|
243 | TRegexp gre5("[5][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
|
---|
244 | if (proj.Contains(gre5))
|
---|
245 | { fPattern |= k5LedGreen; color = kGREEN; }
|
---|
246 | TRegexp gre6("[6][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
|
---|
247 | if (proj.Contains(gre6))
|
---|
248 | { fPattern |= k6LedGreen; color = kGREEN; }
|
---|
249 | TRegexp gre7("[7][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
|
---|
250 | if (proj.Contains(gre7))
|
---|
251 | { fPattern |= k7LedGreen; color = kGREEN; }
|
---|
252 | TRegexp gre8("[8][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
|
---|
253 | if (proj.Contains(gre8))
|
---|
254 | { fPattern |= k8LedGreen; color = kGREEN; }
|
---|
255 |
|
---|
256 | // Possible green combinations
|
---|
257 | TRegexp blu0("0.1[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
258 | if (proj.Contains(blu0))
|
---|
259 | { fPattern |= k01LedBlue; color = kBLUE; }
|
---|
260 | TRegexp blu1("1[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
261 | if (proj.Contains(blu1))
|
---|
262 | { fPattern |= k1LedBlue; color = kBLUE; }
|
---|
263 | TRegexp blu2("2[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
264 | if (proj.Contains(blu2))
|
---|
265 | { fPattern |= k2LedBlue; color = kBLUE; }
|
---|
266 | TRegexp blu3("3[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
267 | if (proj.Contains(blu3))
|
---|
268 | { fPattern |= k3LedBlue; color = kBLUE; }
|
---|
269 | TRegexp blu5("5[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
270 | if (proj.Contains(blu5))
|
---|
271 | { fPattern |= k5LedBlue1; color = kBLUE; }
|
---|
272 | TRegexp blu6("6[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
273 | if (proj.Contains(blu6))
|
---|
274 | { fPattern |= k6LedBlue; color = kBLUE; }
|
---|
275 | TRegexp blu7("7[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
276 | if (proj.Contains(blu7))
|
---|
277 | { fPattern |= k7LedBlue; color = kBLUE; }
|
---|
278 | TRegexp blu8("8[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
279 | if (proj.Contains(blu8))
|
---|
280 | { fPattern |= k8LedBlue; color = kBLUE; }
|
---|
281 | TRegexp blu10("10[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
282 | if (proj.Contains(blu10))
|
---|
283 | { fPattern |= k10LedBlue; color = kBLUE; }
|
---|
284 | TRegexp blu15("15[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
285 | if (proj.Contains(blu15))
|
---|
286 | { fPattern |= k15LedBlue; color = kBLUE; }
|
---|
287 | TRegexp blu20("20[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
288 | if (proj.Contains(blu20))
|
---|
289 | { fPattern |= k20LedBlue; color = kBLUE; }
|
---|
290 | TRegexp blu21("21[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
291 | if (proj.Contains(blu21))
|
---|
292 | { fPattern |= k21LedBlue; color = kBLUE; }
|
---|
293 | TRegexp blu22("22[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
294 | if (proj.Contains(blu22))
|
---|
295 | { fPattern |= k22LedBlue; color = kBLUE; }
|
---|
296 | TRegexp blu23("23[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
|
---|
297 | if (proj.Contains(blu23))
|
---|
298 | { fPattern |= k23LedBlue; color = kBLUE; }
|
---|
299 |
|
---|
300 | // Possible UV combinations
|
---|
301 | TRegexp uv1("[1][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
302 | if (proj.Contains(uv1))
|
---|
303 | { fPattern |= k1LedUV; color = kUV; }
|
---|
304 | TRegexp uv2("[2][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
305 | if (proj.Contains(uv2))
|
---|
306 | { fPattern |= k2LedUV; color = kUV; }
|
---|
307 | TRegexp uv3("[3][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
308 | if (proj.Contains(uv3))
|
---|
309 | { fPattern |= k3LedUV; color = kUV; }
|
---|
310 | TRegexp uv5("[5][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
311 | if (proj.Contains(uv5))
|
---|
312 | { fPattern |= k5LedUV1; color = kUV; }
|
---|
313 | TRegexp uv6("[6][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
314 | if (proj.Contains(uv6))
|
---|
315 | { fPattern |= k6LedUV; color = kUV; }
|
---|
316 | TRegexp uv7("[7][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
317 | if (proj.Contains(uv7))
|
---|
318 | { fPattern |= k7LedUV; color = kUV; }
|
---|
319 | TRegexp uv8("[8][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
320 | if (proj.Contains(uv8))
|
---|
321 | { fPattern |= k8LedUV; color = kUV; }
|
---|
322 | TRegexp uv10("[10][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
323 | if (proj.Contains(uv10))
|
---|
324 | { fPattern |= k10LedUV; color = kUV; }
|
---|
325 | TRegexp uv11("[11][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
326 | if (proj.Contains(uv11))
|
---|
327 | { fPattern |= k11LedUV; color = kUV; }
|
---|
328 | TRegexp uv12("[12][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
329 | if (proj.Contains(uv12))
|
---|
330 | { fPattern |= k12LedUV; color = kUV; }
|
---|
331 | TRegexp uv13("[13][lL]?[eE]?[dD]?[sS]?[U][vV]");
|
---|
332 | if (proj.Contains(uv13))
|
---|
333 | { fPattern |= k13LedUV; color = kUV; }
|
---|
334 |
|
---|
335 | if (color != kNONE)
|
---|
336 | *fLog << inf << "Color and Intensity determined from project-name (" << proj << ")... ";
|
---|
337 | else
|
---|
338 | {
|
---|
339 | if (proj.Contains("gree",TString::kIgnoreCase))
|
---|
340 | { fPattern |= k5LedGreen; color = kGREEN; }
|
---|
341 | if (proj.Contains("blue",TString::kIgnoreCase))
|
---|
342 | { fPattern |=k5LedBlue1; color = kBLUE;}
|
---|
343 | if (proj.Contains("uv",TString::kIgnoreCase))
|
---|
344 | { fPattern |=k5LedUV1 ; color = kUV; }
|
---|
345 | if (proj.Contains("ct1",TString::kIgnoreCase))
|
---|
346 | { fPattern |=kCT1Pulser; color = kCT1; }
|
---|
347 | if (color != kNONE)
|
---|
348 | *fLog << inf << "Color determined from project-name (" << proj << ")... ";
|
---|
349 | else if (proj.Contains("cl",TString::kIgnoreCase))
|
---|
350 | {
|
---|
351 | *fLog << err << "This run has been taken with the continuous light source." << endl;
|
---|
352 | *fLog << err
|
---|
353 | << "It cannot be used for calibration. Try to run a pedestal extraction on it." << endl;
|
---|
354 | return kFALSE;
|
---|
355 | }
|
---|
356 | }
|
---|
357 | }
|
---|
358 |
|
---|
359 | if (color==kNONE)
|
---|
360 | {
|
---|
361 | *fLog << err << "Sorry, calibration run was taken before the events could be" << endl;
|
---|
362 | *fLog << "flagged with a color by the digital modul and no color" << endl;
|
---|
363 | *fLog << "could be determined... abort." << endl;
|
---|
364 | return kFALSE;
|
---|
365 | }
|
---|
366 |
|
---|
367 | switch (color)
|
---|
368 | {
|
---|
369 | case kGREEN: *fLog << "Green."; break;
|
---|
370 | case kBLUE: *fLog << "Blue."; break;
|
---|
371 | case kUV: *fLog << "UV."; break;
|
---|
372 | case kCT1: *fLog << "CT1."; break;
|
---|
373 | }
|
---|
374 | *fLog << endl;
|
---|
375 |
|
---|
376 | fIsValid = kTRUE;
|
---|
377 |
|
---|
378 | return kTRUE;
|
---|
379 | }
|
---|
380 |
|
---|
381 | // --------------------------------------------------------------------------
|
---|
382 | //
|
---|
383 | // Sets the pattern to MRawEvtHeader from outside, if fIsValid is set.
|
---|
384 | //
|
---|
385 | Int_t MCalibColorSet::Process()
|
---|
386 | {
|
---|
387 |
|
---|
388 | if (fIsValid)
|
---|
389 | fHeader->SetCalibrationPattern(fPattern);
|
---|
390 | return kTRUE;
|
---|
391 | }
|
---|