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

Last change on this file since 4875 was 4866, checked in by gaug, 20 years ago
*** empty log message ***
File size: 5.7 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 "MLog.h"
42#include "MLogManip.h"
43
44#include "MParList.h"
45
46#include "MRawEvtHeader.h"
47#include "MRawRunHeader.h"
48
49ClassImp(MCalibColorSet);
50
51using namespace std;
52
53const Int_t MCalibColorSet::gkIFAEBoxInaugurationRun = 20113;
54// --------------------------------------------------------------------------
55//
56// Default constructor. MGeomCamMagic is the default geometry.
57//
58MCalibColorSet::MCalibColorSet(const char *name, const char *title)
59 : fHeader(0)
60{
61 fName = name ? name : "MCalibColorSet";
62 fTitle = title ? title : "Task to set workaround missing colors calibration events";
63
64 Clear();
65}
66
67void MCalibColorSet::Clear(const Option_t *o)
68{
69
70 fPattern = 0;
71 fIsValid = kFALSE;
72
73}
74
75
76// -----------------------------------------------------------------------------------
77//
78// The following container are searched for and execution aborted if not in MParList:
79// - MRawEvtHeader
80//
81Int_t MCalibColorSet::PreProcess(MParList *pList)
82{
83
84 fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
85 if (!fHeader)
86 {
87 *fLog << err << "MRawEvtHeader not found... abort." << endl;
88 return kFALSE;
89 }
90
91 return kTRUE;
92}
93
94// --------------------------------------------------------------------------
95//
96// Search for the following input containers and abort if not existing:
97// - MRawRunHeader
98//
99// If Runnumber < gkIFAEBoxInaugurationRun, set colour pattern: 0
100//
101// If Runnumber > gkIFAEBoxInaugurationRun, search for colour in
102// the project name: Set colour pattern according to the following
103// convention:
104// Green: assume slot 1 ( 5 Leds Green)
105// Blue: assume slot 14 ( 5 Leds Blue )
106// UV: assume slot 12 ( 5 Leds UV )
107// CT1: take 'slot 17'
108//
109Bool_t MCalibColorSet::ReInit(MParList *pList)
110{
111
112 Clear();
113
114 MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
115 if (!header)
116 {
117 *fLog << err << "MRawRunHeader not found... abort." << endl;
118 return kFALSE;
119 }
120
121 enum { kNONE, kGREEN, kBLUE, kUV, kCT1 };
122
123 enum ColorCode_t
124 {
125 k5LedGreen = BIT(0 ),
126 k5LedUV = BIT(11),
127 k5LedBlue = BIT(13),
128 kCT1Pulser = BIT(16)
129 };
130
131 const Int_t num = header->GetRunNumber();
132
133 if (num<gkIFAEBoxInaugurationRun)
134 {
135 *fLog << inf << "Run taken before inauguration of IFAE-box... using CT1 pulser." << endl;
136 fPattern |= kCT1Pulser;
137 fIsValid = kTRUE;
138 return kTRUE;
139 }
140
141 Int_t color = kNONE;
142
143 switch (num)
144 {
145 case 26402:
146 case 22246:
147 case 22253:
148 color = kBLUE;
149 break;
150
151 case 30090:
152 case 20660:
153 case 20661:
154 case 26408:
155 case 26409:
156 case 26412:
157 case 26568:
158 case 26924:
159 color = kGREEN;
160 break;
161
162 case 27474:
163 *fLog << err << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! " << endl;
164 return kFALSE;
165 }
166
167 if (color!=kNONE)
168 *fLog << inf << "Color determined from the run-number... ";
169 else
170 {
171 const TString proj = header->GetProjectName();
172
173 if (proj.Contains("gree",TString::kIgnoreCase))
174 color = kGREEN;
175 if (proj.Contains("blue",TString::kIgnoreCase))
176 color = kBLUE;
177 if (proj.Contains("uv",TString::kIgnoreCase))
178 color = kUV;
179 if (proj.Contains("ct1",TString::kIgnoreCase))
180 color = kCT1;
181
182 *fLog << inf << "Color determined from project-name (" << proj << ")... ";
183 }
184
185 if (color==kNONE)
186 {
187 *fLog << err << "Sorry, calibration run was taken before the events could be" << endl;
188 *fLog << "flagged with a color by the digital modul and no color" << endl;
189 *fLog << "could be determined... abort." << endl;
190 return kFALSE;
191 }
192
193 switch (color)
194 {
195 case kGREEN: *fLog << "Green."; fPattern |= k5LedGreen; break;
196 case kBLUE: *fLog << "Blue."; fPattern |= k5LedBlue ; break;
197 case kUV: *fLog << "UV."; fPattern |= k5LedUV ; break;
198 case kCT1: *fLog << "CT1."; fPattern |= kCT1Pulser; break;
199 }
200 *fLog << endl;
201
202 fIsValid = kTRUE;
203
204 return kTRUE;
205}
206
207// --------------------------------------------------------------------------
208//
209// Sets the pattern to MRawEvtHeader from outside, if fIsValid is set.
210//
211Int_t MCalibColorSet::Process()
212{
213
214 if (fIsValid)
215 fHeader->SetCalibrationPattern(fPattern);
216 return kTRUE;
217}
Note: See TracBrowser for help on using the repository browser.