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

Last change on this file since 5426 was 5415, checked in by gaug, 21 years ago
*** empty log message ***
File size: 13.4 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 31756:
211 color = kBLUE;
212 break;
213
214 case 30090:
215 case 20660:
216 case 20661:
217 case 26408:
218 case 26409:
219 case 26412:
220 case 26568:
221 case 26924:
222 color = kGREEN;
223 break;
224
225 case 27474:
226 *fLog << err << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! " << endl;
227 return kFALSE;
228 }
229
230 if (color!=kNONE)
231 {
232 *fLog << inf << "Color determined from the run-number... ";
233 switch (color)
234 {
235 case kGREEN: *fLog << "Green."; fPattern |= k5LedGreen; break;
236 case kBLUE: *fLog << "Blue."; fPattern |= k5LedBlue1; break;
237 }
238 *fLog << endl;
239 fIsValid = kTRUE;
240 return kTRUE;
241 }
242 else
243 {
244
245 const TString proj = header->GetProjectName();
246
247 // Possible green combinations
248 TRegexp gre0("0.1[lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
249 if (proj.Contains(gre0))
250 { fPattern |= k01LedGreen; color = kGREEN; }
251 TRegexp gre1("1[lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
252 if (proj.Contains(gre1))
253 { fPattern |= k1LedGreen; color = kGREEN; }
254 TRegexp gre2("[2][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
255 if (proj.Contains(gre2))
256 { fPattern |= k2LedGreen; color = kGREEN; }
257 TRegexp gre3("[3][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
258 if (proj.Contains(gre3))
259 { fPattern |= k3LedGreen; color = kGREEN; }
260 TRegexp gre5("[5][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
261 if (proj.Contains(gre5))
262 { fPattern |= k5LedGreen; color = kGREEN; }
263 TRegexp gre6("[6][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
264 if (proj.Contains(gre6))
265 { fPattern |= k6LedGreen; color = kGREEN; }
266 TRegexp gre7("[7][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
267 if (proj.Contains(gre7))
268 { fPattern |= k7LedGreen; color = kGREEN; }
269 TRegexp gre8("[8][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
270 if (proj.Contains(gre8))
271 { fPattern |= k8LedGreen; color = kGREEN; }
272
273 // Possible green combinations
274 TRegexp blu0("0.1[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
275 if (proj.Contains(blu0))
276 { fPattern |= k01LedBlue; color = kBLUE; }
277 TRegexp blu1("1[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
278 if (proj.Contains(blu1))
279 { fPattern |= k1LedBlue; color = kBLUE; }
280 TRegexp blu2("2[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
281 if (proj.Contains(blu2))
282 { fPattern |= k2LedBlue; color = kBLUE; }
283 TRegexp blu3("3[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
284 if (proj.Contains(blu3))
285 { fPattern |= k3LedBlue; color = kBLUE; }
286 TRegexp blu5("5[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
287 if (proj.Contains(blu5))
288 { fPattern |= k5LedBlue1; color = kBLUE; }
289 TRegexp blu6("6[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
290 if (proj.Contains(blu6))
291 { fPattern |= k6LedBlue; color = kBLUE; }
292 TRegexp blu7("7[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
293 if (proj.Contains(blu7))
294 { fPattern |= k7LedBlue; color = kBLUE; }
295 TRegexp blu8("8[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
296 if (proj.Contains(blu8))
297 { fPattern |= k8LedBlue; color = kBLUE; }
298 TRegexp blu10("10[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
299 if (proj.Contains(blu10))
300 { fPattern |= k10LedBlue; color = kBLUE; }
301 TRegexp blu15("15[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
302 if (proj.Contains(blu15))
303 { fPattern |= k15LedBlue; color = kBLUE; }
304 TRegexp blu20("20[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
305 if (proj.Contains(blu20))
306 { fPattern |= k20LedBlue; color = kBLUE; }
307 TRegexp blu21("21[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
308 if (proj.Contains(blu21))
309 { fPattern |= k21LedBlue; color = kBLUE; }
310 TRegexp blu22("22[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
311 if (proj.Contains(blu22))
312 { fPattern |= k22LedBlue; color = kBLUE; }
313 TRegexp blu23("23[lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
314 if (proj.Contains(blu23))
315 { fPattern |= k23LedBlue; color = kBLUE; }
316
317 // Possible UV combinations
318 TRegexp uv1("[1][lL]?[eE]?[dD]?[sS]?[U][vV]");
319 if (proj.Contains(uv1))
320 { fPattern |= k1LedUV; color = kUV; }
321 TRegexp uv2("[2][lL]?[eE]?[dD]?[sS]?[U][vV]");
322 if (proj.Contains(uv2))
323 { fPattern |= k2LedUV; color = kUV; }
324 TRegexp uv3("[3][lL]?[eE]?[dD]?[sS]?[U][vV]");
325 if (proj.Contains(uv3))
326 { fPattern |= k3LedUV; color = kUV; }
327 TRegexp uv5("[5][lL]?[eE]?[dD]?[sS]?[U][vV]");
328 if (proj.Contains(uv5))
329 { fPattern |= k5LedUV1; color = kUV; }
330 TRegexp uv6("[6][lL]?[eE]?[dD]?[sS]?[U][vV]");
331 if (proj.Contains(uv6))
332 { fPattern |= k6LedUV; color = kUV; }
333 TRegexp uv7("[7][lL]?[eE]?[dD]?[sS]?[U][vV]");
334 if (proj.Contains(uv7))
335 { fPattern |= k7LedUV; color = kUV; }
336 TRegexp uv8("[8][lL]?[eE]?[dD]?[sS]?[U][vV]");
337 if (proj.Contains(uv8))
338 { fPattern |= k8LedUV; color = kUV; }
339 TRegexp uv10("[10][lL]?[eE]?[dD]?[sS]?[U][vV]");
340 if (proj.Contains(uv10))
341 { fPattern |= k10LedUV; color = kUV; }
342 TRegexp uv11("[11][lL]?[eE]?[dD]?[sS]?[U][vV]");
343 if (proj.Contains(uv11))
344 { fPattern |= k11LedUV; color = kUV; }
345 TRegexp uv12("[12][lL]?[eE]?[dD]?[sS]?[U][vV]");
346 if (proj.Contains(uv12))
347 { fPattern |= k12LedUV; color = kUV; }
348 TRegexp uv13("[13][lL]?[eE]?[dD]?[sS]?[U][vV]");
349 if (proj.Contains(uv13))
350 { fPattern |= k13LedUV; color = kUV; }
351
352 if (color != kNONE)
353 *fLog << inf << "Color and Intensity determined from project-name (" << proj << ")... ";
354 else
355 {
356 if (proj.Contains("gree",TString::kIgnoreCase))
357 { fPattern |= k5LedGreen; color = kGREEN; }
358 if (proj.Contains("blue",TString::kIgnoreCase))
359 { fPattern |=k5LedBlue1; color = kBLUE;}
360 if (proj.Contains("uv",TString::kIgnoreCase))
361 { fPattern |=k5LedUV1 ; color = kUV; }
362 if (proj.Contains("ct1",TString::kIgnoreCase))
363 { fPattern |=kCT1Pulser; color = kCT1; }
364 if (color != kNONE)
365 *fLog << inf << "Color determined from project-name (" << proj << ")... ";
366 else if (proj.Contains("cl",TString::kIgnoreCase))
367 {
368 *fLog << err << "This run has been taken with the continuous light source." << endl;
369 *fLog << err
370 << "It cannot be used for calibration. Try to run a pedestal extraction on it." << endl;
371 return kFALSE;
372 }
373 }
374 }
375
376 if (color==kNONE)
377 {
378 *fLog << err << "Sorry, calibration run was taken before the events could be" << endl;
379 *fLog << "flagged with a color by the digital modul and no color" << endl;
380 *fLog << "could be determined... abort." << endl;
381 return kFALSE;
382 }
383
384 switch (color)
385 {
386 case kGREEN: *fLog << "Green."; break;
387 case kBLUE: *fLog << "Blue."; break;
388 case kUV: *fLog << "UV."; break;
389 case kCT1: *fLog << "CT1."; break;
390 }
391 *fLog << endl;
392
393 fIsValid = kTRUE;
394
395 return kTRUE;
396}
397
398// --------------------------------------------------------------------------
399//
400// Sets the pattern to MRawEvtHeader from outside, if fIsValid is set.
401//
402Int_t MCalibColorSet::Process()
403{
404
405 if (fIsValid)
406 {
407 if (fPattern == 0)
408 {
409 *fLog << err << "CONTINUE " << endl;
410 return kCONTINUE;
411 }
412 fHeader->SetCalibrationPattern(fPattern);
413 }
414
415 return kTRUE;
416}
Note: See TracBrowser for help on using the repository browser.