source: trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc@ 5541

Last change on this file since 5541 was 5453, checked in by gaug, 20 years ago
*** empty log message ***
File size: 13.6 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): 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
51ClassImp(MCalibColorSet);
52
53
54using namespace std;
55
56const Int_t MCalibColorSet::gkIFAEBoxInaugurationRun = 20113;
57const Int_t MCalibColorSet::gkMCRunLimit = 1000;
58// --------------------------------------------------------------------------
59//
60// Default constructor. MGeomCamMagic is the default geometry.
61//
62MCalibColorSet::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
71void 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//
85Int_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//
113Bool_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 //
126 // Consider the case that a pedestal run is interleaved in the calibration run sequence ... prepare
127 // to skip this run.
128 //
129 const UShort_t runtype = header->GetRunType();
130
131 if (runtype == 1)
132 {
133 *fLog << warn << "New run is a pedestal run... need intensity calibration to treat this case!" << endl;
134 fPattern = 0;
135 fIsValid = kTRUE;
136 return kTRUE;
137 }
138
139 enum { kNONE, kGREEN, kBLUE, kUV, kCT1 };
140
141 enum ColorCode_t
142 {
143 k01LedGreen = BIT(15),
144 k1LedGreen = BIT(14),
145 k2LedGreen = BIT(1 ),
146 k3LedGreen = k1LedGreen | k2LedGreen,
147 k5LedGreen = BIT(0 ),
148 k6LedGreen = k5LedGreen | k1LedGreen,
149 k7LedGreen = k5LedGreen | k2LedGreen,
150 k8LedGreen = k5LedGreen | k3LedGreen,
151 k1LedUV = BIT(3 ),
152 k2LedUV = BIT(4 ),
153 k3LedUV = k1LedUV | k2LedUV,
154 k5LedUV1 = BIT(11),
155 k5LedUV2 = BIT(12),
156 k6LedUV = k5LedUV1 | k1LedUV,
157 k7LedUV = k5LedUV1 | k2LedUV,
158 k8LedUV = k5LedUV1 | k3LedUV,
159 k10LedUV = k5LedUV1 | k5LedUV2,
160 k11LedUV = k10LedUV | k1LedUV,
161 k12LedUV = k10LedUV | k2LedUV,
162 k13LedUV = k10LedUV | k1LedUV,
163 k01LedBlue = BIT(8 ),
164 k1LedBlue = BIT(10),
165 k2LedBlue = BIT(7 ),
166 k3LedBlue = k1LedBlue | k2LedBlue,
167 k5LedBlue1 = BIT(13),
168 k5LedBlue2 = BIT(2 ),
169 k5LedBlue3 = BIT(5 ),
170 k5LedBlue4 = BIT(6 ),
171 k6LedBlue = k5LedBlue1 | k1LedBlue,
172 k7LedBlue = k5LedBlue1 | k2LedBlue,
173 k8LedBlue = k5LedBlue1 | k3LedBlue,
174 k10LedBlue = k5LedBlue1 | k5LedBlue2,
175 k15LedBlue = k10LedBlue | k5LedBlue3,
176 k20LedBlue = k15LedBlue | k5LedBlue4,
177 k21LedBlue = k20LedBlue | k1LedBlue,
178 k22LedBlue = k20LedBlue | k2LedBlue,
179 k23LedBlue = k22LedBlue | k1LedBlue,
180 kCT1Pulser = BIT(16)
181 };
182
183 const Int_t num = header->GetRunNumber();
184
185 if (num<gkMCRunLimit)
186 {
187 *fLog << inf << "Assumed MC run ... using GREEN pulser." << endl;
188 fPattern |= k1LedGreen;
189 fIsValid = kTRUE;
190 return kTRUE;
191 }
192
193 if (num<gkIFAEBoxInaugurationRun)
194 {
195 *fLog << inf << "Run taken before inauguration of IFAE-box... using CT1 pulser." << endl;
196 fPattern |= kCT1Pulser;
197 fIsValid = kTRUE;
198 return kTRUE;
199 }
200
201 Int_t color = kNONE;
202
203 switch (num)
204 {
205 case 26402:
206 case 22246:
207 case 22253:
208 case 25792:
209 case 35415:
210 case 44768:
211 case 44976:
212 case 45368:
213 // case 31756:
214 color = kBLUE;
215 break;
216
217 case 30090:
218 case 20660:
219 case 20661:
220 case 26408:
221 case 26409:
222 case 26412:
223 case 26568:
224 case 26924:
225 color = kGREEN;
226 break;
227
228 case 27474:
229 *fLog << err << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! " << endl;
230 return kFALSE;
231 }
232
233 if (num>44900)
234 {
235 *fLog << inf << "Assumed 10Led UV..." << endl;
236 fPattern |= k10LedUV;
237 fIsValid = kTRUE;
238 return kTRUE;
239 }
240
241 if (color!=kNONE)
242 {
243 *fLog << inf << "Color determined from the run-number... ";
244 switch (color)
245 {
246 case kGREEN: *fLog << "Green."; fPattern |= k5LedGreen; break;
247 case kBLUE: *fLog << "Blue."; fPattern |= k5LedBlue1; break;
248 }
249 *fLog << endl;
250 fIsValid = kTRUE;
251 return kTRUE;
252 }
253 else
254 {
255
256 const TString proj = header->GetProjectName();
257
258 // Possible green combinations
259 TRegexp gre0("0.1[lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
260 if (proj.Contains(gre0))
261 { fPattern |= k01LedGreen; color = kGREEN; }
262 TRegexp gre1("1[lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
263 if (proj.Contains(gre1))
264 { fPattern |= k1LedGreen; color = kGREEN; }
265 TRegexp gre2("[2][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
266 if (proj.Contains(gre2))
267 { fPattern |= k2LedGreen; color = kGREEN; }
268 TRegexp gre3("[3][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
269 if (proj.Contains(gre3))
270 { fPattern |= k3LedGreen; color = kGREEN; }
271 TRegexp gre5("[5][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
272 if (proj.Contains(gre5))
273 { fPattern |= k5LedGreen; color = kGREEN; }
274 TRegexp gre6("[6][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
275 if (proj.Contains(gre6))
276 { fPattern |= k6LedGreen; color = kGREEN; }
277 TRegexp gre7("[7][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
278 if (proj.Contains(gre7))
279 { fPattern |= k7LedGreen; color = kGREEN; }
280 TRegexp gre8("[8][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
281 if (proj.Contains(gre8))
282 { fPattern |= k8LedGreen; color = kGREEN; }
283
284 // Possible green combinations
285 TRegexp blu0("0.1[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
286 if (proj.Contains(blu0))
287 { fPattern |= k01LedBlue; color = kBLUE; }
288 TRegexp blu1("1[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
289 if (proj.Contains(blu1))
290 { fPattern |= k1LedBlue; color = kBLUE; }
291 TRegexp blu2("2[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
292 if (proj.Contains(blu2))
293 { fPattern |= k2LedBlue; color = kBLUE; }
294 TRegexp blu3("3[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
295 if (proj.Contains(blu3))
296 { fPattern |= k3LedBlue; color = kBLUE; }
297 TRegexp blu5("5[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
298 if (proj.Contains(blu5))
299 { fPattern |= k5LedBlue1; color = kBLUE; }
300 TRegexp blu6("6[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
301 if (proj.Contains(blu6))
302 { fPattern |= k6LedBlue; color = kBLUE; }
303 TRegexp blu7("7[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
304 if (proj.Contains(blu7))
305 { fPattern |= k7LedBlue; color = kBLUE; }
306 TRegexp blu8("8[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
307 if (proj.Contains(blu8))
308 { fPattern |= k8LedBlue; color = kBLUE; }
309 TRegexp blu10("10[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
310 if (proj.Contains(blu10))
311 { fPattern |= k10LedBlue; color = kBLUE; }
312 TRegexp blu15("15[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
313 if (proj.Contains(blu15))
314 { fPattern |= k15LedBlue; color = kBLUE; }
315 TRegexp blu20("20[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
316 if (proj.Contains(blu20))
317 { fPattern |= k20LedBlue; color = kBLUE; }
318 TRegexp blu21("21[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
319 if (proj.Contains(blu21))
320 { fPattern |= k21LedBlue; color = kBLUE; }
321 TRegexp blu22("22[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
322 if (proj.Contains(blu22))
323 { fPattern |= k22LedBlue; color = kBLUE; }
324 TRegexp blu23("23[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
325 if (proj.Contains(blu23))
326 { fPattern |= k23LedBlue; color = kBLUE; }
327
328 // Possible UV combinations
329 TRegexp uv1("[1][lL]?[eE]?[dD]?[sS]?[U][vV]");
330 if (proj.Contains(uv1))
331 { fPattern |= k1LedUV; color = kUV; }
332 TRegexp uv2("[2][lL]?[eE]?[dD]?[sS]?[U][vV]");
333 if (proj.Contains(uv2))
334 { fPattern |= k2LedUV; color = kUV; }
335 TRegexp uv3("[3][lL]?[eE]?[dD]?[sS]?[U][vV]");
336 if (proj.Contains(uv3))
337 { fPattern |= k3LedUV; color = kUV; }
338 TRegexp uv5("[5][lL]?[eE]?[dD]?[sS]?[U][vV]");
339 if (proj.Contains(uv5))
340 { fPattern |= k5LedUV1; color = kUV; }
341 TRegexp uv6("[6][lL]?[eE]?[dD]?[sS]?[U][vV]");
342 if (proj.Contains(uv6))
343 { fPattern |= k6LedUV; color = kUV; }
344 TRegexp uv7("[7][lL]?[eE]?[dD]?[sS]?[U][vV]");
345 if (proj.Contains(uv7))
346 { fPattern |= k7LedUV; color = kUV; }
347 TRegexp uv8("[8][lL]?[eE]?[dD]?[sS]?[U][vV]");
348 if (proj.Contains(uv8))
349 { fPattern |= k8LedUV; color = kUV; }
350 TRegexp uv10("[10][lL]?[eE]?[dD]?[sS]?[U][vV]");
351 if (proj.Contains(uv10))
352 { fPattern |= k10LedUV; color = kUV; }
353 TRegexp uv11("[11][lL]?[eE]?[dD]?[sS]?[U][vV]");
354 if (proj.Contains(uv11))
355 { fPattern |= k11LedUV; color = kUV; }
356 TRegexp uv12("[12][lL]?[eE]?[dD]?[sS]?[U][vV]");
357 if (proj.Contains(uv12))
358 { fPattern |= k12LedUV; color = kUV; }
359 TRegexp uv13("[13][lL]?[eE]?[dD]?[sS]?[U][vV]");
360 if (proj.Contains(uv13))
361 { fPattern |= k13LedUV; color = kUV; }
362
363 if (color != kNONE)
364 *fLog << inf << "Color and Intensity determined from project-name (" << proj << ")... ";
365 else
366 {
367 if (proj.Contains("gree",TString::kIgnoreCase))
368 { fPattern |= k5LedGreen; color = kGREEN; }
369 if (proj.Contains("blue",TString::kIgnoreCase))
370 { fPattern |=k5LedBlue1; color = kBLUE;}
371 if (proj.Contains("uv",TString::kIgnoreCase))
372 { fPattern |=k5LedUV1 ; color = kUV; }
373 if (proj.Contains("ct1",TString::kIgnoreCase))
374 { fPattern |=kCT1Pulser; color = kCT1; }
375 if (color != kNONE)
376 *fLog << inf << "Color determined from project-name (" << proj << ")... ";
377 else if (proj.Contains("cl",TString::kIgnoreCase))
378 {
379 *fLog << err << "This run has been taken with the continuous light source." << endl;
380 *fLog << err
381 << "It cannot be used for calibration. Try to run a pedestal extraction on it." << endl;
382 return kFALSE;
383 }
384 }
385 }
386
387 if (color==kNONE)
388 {
389 *fLog << err << "Sorry, calibration run was taken before the events could be" << endl;
390 *fLog << "flagged with a color by the digital modul and no color" << endl;
391 *fLog << "could be determined... abort." << endl;
392 return kFALSE;
393 }
394
395 switch (color)
396 {
397 case kGREEN: *fLog << "Green."; break;
398 case kBLUE: *fLog << "Blue."; break;
399 case kUV: *fLog << "UV."; break;
400 case kCT1: *fLog << "CT1."; break;
401 }
402 *fLog << endl;
403
404 fIsValid = kTRUE;
405
406 return kTRUE;
407}
408
409// --------------------------------------------------------------------------
410//
411// Sets the pattern to MRawEvtHeader from outside, if fIsValid is set.
412//
413Int_t MCalibColorSet::Process()
414{
415
416 if (fIsValid)
417 {
418 if (fPattern == 0)
419 {
420 *fLog << err << "CONTINUE " << endl;
421 return kCONTINUE;
422 }
423 fHeader->SetCalibrationPattern(fPattern);
424 }
425
426 return kTRUE;
427}
Note: See TracBrowser for help on using the repository browser.