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

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