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 |
|
---|
49 | ClassImp(MCalibColorSet);
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | const Int_t MCalibColorSet::gkIFAEBoxInaugurationRun = 20113;
|
---|
54 |
|
---|
55 | // --------------------------------------------------------------------------
|
---|
56 | //
|
---|
57 | // Default constructor. MGeomCamMagic is the default geometry.
|
---|
58 | //
|
---|
59 | MCalibColorSet::MCalibColorSet(const char *name, const char *title)
|
---|
60 | : fHeader(0), fIsValid(kFALSE)
|
---|
61 | {
|
---|
62 | fName = name ? name : "MCalibColorSet";
|
---|
63 | fTitle = title ? title : "Task to set workaround missing colors calibration events";
|
---|
64 | }
|
---|
65 |
|
---|
66 | Int_t MCalibColorSet::PreProcess(MParList *pList)
|
---|
67 | {
|
---|
68 | fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
|
---|
69 | if (!fHeader)
|
---|
70 | {
|
---|
71 | *fLog << err << "MRawEvtHeader not found... abort." << endl;
|
---|
72 | return kFALSE;
|
---|
73 | }
|
---|
74 | return kTRUE;
|
---|
75 | }
|
---|
76 |
|
---|
77 | // --------------------------------------------------------------------------
|
---|
78 | //
|
---|
79 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
---|
80 | // processing is stopped.
|
---|
81 | //
|
---|
82 | Bool_t MCalibColorSet::ReInit(MParList *pList)
|
---|
83 | {
|
---|
84 | fIsValid = kFALSE;
|
---|
85 |
|
---|
86 | MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
87 | if (!header)
|
---|
88 | {
|
---|
89 | *fLog << err << "MRawRunHeader not found... abort." << endl;
|
---|
90 | return kFALSE;
|
---|
91 | }
|
---|
92 |
|
---|
93 | enum { kNONE, kGREEN, kBLUE, kUV, kCT1 };
|
---|
94 |
|
---|
95 | Int_t color = kNONE;
|
---|
96 |
|
---|
97 | const Int_t num = header->GetRunNumber();
|
---|
98 | if (num<gkIFAEBoxInaugurationRun)
|
---|
99 | {
|
---|
100 | *fLog << inf << "Run taken before inauguration of IFAE-box... using CT1 pulser." << endl;
|
---|
101 | color = kCT1;
|
---|
102 | return kTRUE;
|
---|
103 | }
|
---|
104 |
|
---|
105 | switch (num)
|
---|
106 | {
|
---|
107 | case 26402:
|
---|
108 | case 22246:
|
---|
109 | case 22253:
|
---|
110 | color = kBLUE;
|
---|
111 | break;
|
---|
112 |
|
---|
113 | case 30090:
|
---|
114 | case 20660:
|
---|
115 | case 20661:
|
---|
116 | case 26408:
|
---|
117 | case 26409:
|
---|
118 | case 26412:
|
---|
119 | case 26568:
|
---|
120 | case 26924:
|
---|
121 | color = kGREEN;
|
---|
122 | break;
|
---|
123 |
|
---|
124 | case 27474:
|
---|
125 | *fLog << err << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! " << endl;
|
---|
126 | return kFALSE;
|
---|
127 | }
|
---|
128 |
|
---|
129 | if (color!=kNONE)
|
---|
130 | *fLog << inf << "Color determined from the run-number... ";
|
---|
131 | else
|
---|
132 | {
|
---|
133 | const TString proj = header->GetProjectName();
|
---|
134 |
|
---|
135 | if (proj.Contains("green",TString::kIgnoreCase))
|
---|
136 | color = kGREEN;
|
---|
137 | if (proj.Contains("blue",TString::kIgnoreCase))
|
---|
138 | color = kBLUE;
|
---|
139 | if (proj.Contains("uv",TString::kIgnoreCase))
|
---|
140 | color = kUV;
|
---|
141 | if (proj.Contains("ct1",TString::kIgnoreCase))
|
---|
142 | color = kCT1;
|
---|
143 |
|
---|
144 | *fLog << inf << "Color determined from project-name (" << proj << ")... ";
|
---|
145 | }
|
---|
146 |
|
---|
147 | if (color==kNONE)
|
---|
148 | {
|
---|
149 | *fLog << err << "Sorry, calibration run was taken before the events could be" << endl;
|
---|
150 | *fLog << "flagged with a color by the digital modul and no color" << endl;
|
---|
151 | *fLog << "could be determined... abort." << endl;
|
---|
152 | return kFALSE;
|
---|
153 | }
|
---|
154 |
|
---|
155 | switch (color)
|
---|
156 | {
|
---|
157 | case kGREEN: *fLog << "Green."; fPattern = 0; break;
|
---|
158 | case kBLUE: *fLog << "Blue."; fPattern = 0; break;
|
---|
159 | case kUV: *fLog << "UV."; fPattern = 0; break;
|
---|
160 | case kCT1: *fLog << "CT1."; fPattern = 0; break;
|
---|
161 | }
|
---|
162 | *fLog << endl;
|
---|
163 |
|
---|
164 | fIsValid = kTRUE;
|
---|
165 |
|
---|
166 | return kTRUE;
|
---|
167 | }
|
---|
168 |
|
---|
169 | Int_t MCalibColorSet::Process()
|
---|
170 | {
|
---|
171 | if (fIsValid)
|
---|
172 | fHeader->SetCalibrationPattern(fPattern);
|
---|
173 | return kTRUE;
|
---|
174 | }
|
---|