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): Nicola Galante 12/2004 <mailto:nicola.galante@pi.infn.it>
|
---|
19 | ! Author(s): Thomas Bretz 12/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2004
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MCalibrationPatternDecode
|
---|
28 | //
|
---|
29 | // Decodes the trigger pattern from MRawEvtData into MCalibrationPattern.
|
---|
30 | //
|
---|
31 | // For files before file version 5 the trigger pattern is set to 00000000.
|
---|
32 | // This can be changed using the information about the file-type.
|
---|
33 | //
|
---|
34 | // Input:
|
---|
35 | // MRawEvtData
|
---|
36 | // MRawRunHeader
|
---|
37 | //
|
---|
38 | // Output:
|
---|
39 | // MCalibrationPattern
|
---|
40 | //
|
---|
41 | /////////////////////////////////////////////////////////////////////////////
|
---|
42 | #include "MCalibrationPatternDecode.h"
|
---|
43 |
|
---|
44 | #include "MLog.h"
|
---|
45 | #include "MLogManip.h"
|
---|
46 |
|
---|
47 | #include "MParList.h"
|
---|
48 | #include "MRawEvtHeader.h"
|
---|
49 | #include "MRawRunHeader.h"
|
---|
50 | #include "MCalibrationPattern.h"
|
---|
51 |
|
---|
52 | ClassImp(MCalibrationPatternDecode);
|
---|
53 |
|
---|
54 | using namespace std;
|
---|
55 |
|
---|
56 | // --------------------------------------------------------------------------
|
---|
57 | //
|
---|
58 | // Default constructor
|
---|
59 | //
|
---|
60 | MCalibrationPatternDecode::MCalibrationPatternDecode(const char *name, const char *title)
|
---|
61 | : fRunHeader(0), fEvtHeader(0), fPattern(0)
|
---|
62 | {
|
---|
63 | fName = name ? name : "MCalibrationPatternDecode";
|
---|
64 | fTitle = title ? title : "Task to decode Trigger Pattern";
|
---|
65 | }
|
---|
66 |
|
---|
67 | // --------------------------------------------------------------------------
|
---|
68 | //
|
---|
69 | Int_t MCalibrationPatternDecode::PreProcess(MParList *pList)
|
---|
70 | {
|
---|
71 | fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
72 | if (!fRunHeader)
|
---|
73 | {
|
---|
74 | *fLog << err << "MRawRunHeader not found... abort." << endl;
|
---|
75 | return kFALSE;
|
---|
76 | }
|
---|
77 |
|
---|
78 | fEvtHeader = (MRawEvtHeader *)pList->FindObject("MRawEvtHeader");
|
---|
79 | if (!fEvtHeader)
|
---|
80 | {
|
---|
81 | *fLog << err << "MRawEvtHeader not found... abort." << endl;
|
---|
82 | return kFALSE;
|
---|
83 | }
|
---|
84 |
|
---|
85 | fPattern = (MCalibrationPattern*)pList->FindCreateObj("MCalibrationPattern");
|
---|
86 | if (!fPattern)
|
---|
87 | return kFALSE;
|
---|
88 |
|
---|
89 | return kTRUE;
|
---|
90 | }
|
---|
91 |
|
---|
92 | // --------------------------------------------------------------------------
|
---|
93 | //
|
---|
94 | // For files before file version 5 the trigger pattern is set to 00000000.
|
---|
95 | // This can be changed using the information about the file-type.
|
---|
96 | //
|
---|
97 | Int_t MCalibrationPatternDecode::Process()
|
---|
98 | {
|
---|
99 | // No setting necessary because MCalibrationPattern::Reset() has
|
---|
100 | // been called just before
|
---|
101 | if (fRunHeader->GetFormatVersion()<5)
|
---|
102 | return kTRUE;
|
---|
103 |
|
---|
104 | // Get calibration pattern from event header
|
---|
105 | const UInt_t pattern = fEvtHeader->GetCalibrationPattern();
|
---|
106 |
|
---|
107 | const UInt_t str = (pattern ) & 0x00ff;
|
---|
108 | const UInt_t col = (pattern>> 8) & 0x000f;
|
---|
109 | const UInt_t pat = (pattern>>16) & 0xffff;
|
---|
110 |
|
---|
111 | fPattern->fCLStrength = str;
|
---|
112 | fPattern->fCLColor = (MCalibrationPattern::CLColor_t)col;
|
---|
113 |
|
---|
114 | // Set a default pattern
|
---|
115 | fPattern->fPulserColor = MCalibrationCam::kNONE;
|
---|
116 |
|
---|
117 | // Check the pattern
|
---|
118 | if ((pat & kGreenAndBlue) || (pat & kBlueAndUV) || (pat & kGreenAndUV))
|
---|
119 | fPattern->fPulserColor = MCalibrationCam::kNONE;
|
---|
120 |
|
---|
121 | if (pat & kCT1Pulser)
|
---|
122 | fPattern->fPulserColor = MCalibrationCam::kCT1;
|
---|
123 |
|
---|
124 | if (pat & kAnyUV)
|
---|
125 | fPattern->fPulserColor = MCalibrationCam::kUV;
|
---|
126 |
|
---|
127 | if (pat & kAnyGreen)
|
---|
128 | fPattern->fPulserColor = MCalibrationCam::kGREEN;
|
---|
129 |
|
---|
130 | if (pat & kAnyBlue)
|
---|
131 | fPattern->fPulserColor = MCalibrationCam::kBLUE;
|
---|
132 |
|
---|
133 | // Now decode the strength
|
---|
134 | fPattern->fPulserStrength = 0.;
|
---|
135 |
|
---|
136 | switch (fPattern->fPulserColor)
|
---|
137 | {
|
---|
138 | case MCalibrationCam::kNONE:
|
---|
139 | break;
|
---|
140 |
|
---|
141 | case MCalibrationCam::kGREEN:
|
---|
142 | if (pat & kSlot1Green)
|
---|
143 | fPattern->fPulserStrength += 5.0;
|
---|
144 | if (pat & kSlot2Green)
|
---|
145 | fPattern->fPulserStrength += 2.0;
|
---|
146 | if (pat & kSlot15Green)
|
---|
147 | fPattern->fPulserStrength += 1.0;
|
---|
148 | if (pat & kSlot16AttGreen)
|
---|
149 | fPattern->fPulserStrength += 0.2;
|
---|
150 | break;
|
---|
151 |
|
---|
152 | case MCalibrationCam::kBLUE:
|
---|
153 | if (pat & kSlot3Blue)
|
---|
154 | fPattern->fPulserStrength += 5.1;
|
---|
155 | if (pat & kSlot6Blue)
|
---|
156 | fPattern->fPulserStrength += 5.2;
|
---|
157 | if (pat & kSlot7Blue)
|
---|
158 | fPattern->fPulserStrength += 5.4;
|
---|
159 | if (pat & kSlot8Blue)
|
---|
160 | fPattern->fPulserStrength += 2.0;
|
---|
161 | if (pat & kSlot9AttBlue)
|
---|
162 | fPattern->fPulserStrength += 0.25;
|
---|
163 | if (pat & kSlot10Blue)
|
---|
164 | fPattern->fPulserStrength += 0.0;
|
---|
165 | if (pat & kSlot11Blue)
|
---|
166 | fPattern->fPulserStrength += 1.0;
|
---|
167 | if (pat & kSlot14Blue)
|
---|
168 | fPattern->fPulserStrength += 5.8;
|
---|
169 | break;
|
---|
170 |
|
---|
171 | case MCalibrationCam::kUV:
|
---|
172 | if (pat & kSlot4UV)
|
---|
173 | fPattern->fPulserStrength += 1.0;
|
---|
174 | if (pat & kSlot5UV)
|
---|
175 | fPattern->fPulserStrength += 2.0;
|
---|
176 | if (pat & kSlot12UV)
|
---|
177 | fPattern->fPulserStrength += 5.1;
|
---|
178 | if (pat & kSlot13UV)
|
---|
179 | fPattern->fPulserStrength += 5.2;
|
---|
180 | break;
|
---|
181 |
|
---|
182 | case MCalibrationCam::kCT1:
|
---|
183 | fPattern->fPulserStrength = 20.;
|
---|
184 | break;
|
---|
185 | }
|
---|
186 |
|
---|
187 | return kTRUE;
|
---|
188 | }
|
---|