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): Markus Gaug 11/2003 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MCalibrationRelTimeCam
|
---|
28 | //
|
---|
29 | // Hold the whole Calibration results of the camera:
|
---|
30 | //
|
---|
31 | // 1) MCalibrationRelTimeCam initializes a TClonesArray whose elements are
|
---|
32 | // pointers to MCalibrationRelTimePix Containers
|
---|
33 | //
|
---|
34 | // The calculated values (types of GetPixelContent) are:
|
---|
35 | //
|
---|
36 | // Fitted values:
|
---|
37 | // ==============
|
---|
38 | //
|
---|
39 | // 0: Fitted RelTime
|
---|
40 | // 1: Error of fitted RelTime
|
---|
41 | // 2: Sigma of fitted RelTime
|
---|
42 | // 3: Error of Sigma of fitted RelTime
|
---|
43 | //
|
---|
44 | // Useful variables derived from the fit results:
|
---|
45 | // =============================================
|
---|
46 | //
|
---|
47 | // 4: Returned probability of Gauss fit to RelTime distribution
|
---|
48 | //
|
---|
49 | /////////////////////////////////////////////////////////////////////////////
|
---|
50 | #include "MCalibrationRelTimeCam.h"
|
---|
51 | #include "MCalibrationCam.h"
|
---|
52 |
|
---|
53 | #include <TClonesArray.h>
|
---|
54 |
|
---|
55 | #include "MLog.h"
|
---|
56 | #include "MLogManip.h"
|
---|
57 |
|
---|
58 | #include "MGeomCam.h"
|
---|
59 | #include "MGeomPix.h"
|
---|
60 |
|
---|
61 | #include "MCalibrationRelTimePix.h"
|
---|
62 |
|
---|
63 | ClassImp(MCalibrationRelTimeCam);
|
---|
64 |
|
---|
65 | using namespace std;
|
---|
66 |
|
---|
67 | // --------------------------------------------------------------------------
|
---|
68 | //
|
---|
69 | // Default constructor.
|
---|
70 | //
|
---|
71 | // Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry
|
---|
72 | // Later, a call to MCalibrationRelTimeCam::InitSize(Int_t size) has to be performed
|
---|
73 | //
|
---|
74 | // Creates an MCalibrationBlindPix container
|
---|
75 | //
|
---|
76 | MCalibrationRelTimeCam::MCalibrationRelTimeCam(const char *name, const char *title)
|
---|
77 | {
|
---|
78 | fName = name ? name : "MCalibrationRelTimeCam";
|
---|
79 | fTitle = title ? title : "Storage container for the Calibration Information in the camera";
|
---|
80 |
|
---|
81 | fPixels = new TClonesArray("MCalibrationRelTimePix",1);
|
---|
82 | fAverageAreas = new TClonesArray("MCalibrationRelTimePix",1);
|
---|
83 | fAverageSectors = new TClonesArray("MCalibrationRelTimePix",1);
|
---|
84 |
|
---|
85 | Clear();
|
---|
86 |
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 | // --------------------------------------
|
---|
92 | //
|
---|
93 | void MCalibrationRelTimeCam::Clear(Option_t *o)
|
---|
94 | {
|
---|
95 |
|
---|
96 | MCalibrationCam::Clear();
|
---|
97 |
|
---|
98 | CLRBIT(fFlags,kValid);
|
---|
99 |
|
---|
100 | return;
|
---|
101 | }
|
---|
102 |
|
---|
103 | void MCalibrationRelTimeCam::SetValid(const Bool_t b)
|
---|
104 | {
|
---|
105 | b ? SETBIT(fFlags, kValid) : CLRBIT(fFlags, kValid);
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | Bool_t MCalibrationRelTimeCam::IsValid() const
|
---|
110 | {
|
---|
111 | return TESTBIT(fFlags,kValid);
|
---|
112 | }
|
---|
113 |
|
---|
114 | // --------------------------------------------------------------------------
|
---|
115 | //
|
---|
116 | // Print first the well fitted pixels
|
---|
117 | // and then the ones which are not FitValid
|
---|
118 | //
|
---|
119 | void MCalibrationRelTimeCam::Print(Option_t *o) const
|
---|
120 | {
|
---|
121 |
|
---|
122 | *fLog << all << GetDescriptor() << ":" << endl;
|
---|
123 | int id = 0;
|
---|
124 |
|
---|
125 | *fLog << all << "Calibrated pixels:" << endl;
|
---|
126 | *fLog << all << endl;
|
---|
127 |
|
---|
128 | TIter Next(fPixels);
|
---|
129 | MCalibrationRelTimePix *pix;
|
---|
130 | while ((pix=(MCalibrationRelTimePix*)Next()))
|
---|
131 | {
|
---|
132 |
|
---|
133 | if (!pix->IsExcluded())
|
---|
134 | {
|
---|
135 |
|
---|
136 | *fLog << all
|
---|
137 | << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Pix ",pix->GetPixId(),
|
---|
138 | ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
|
---|
139 | " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
|
---|
140 | << endl;
|
---|
141 | id++;
|
---|
142 | }
|
---|
143 | }
|
---|
144 |
|
---|
145 | *fLog << all << id << " pixels" << endl;
|
---|
146 | id = 0;
|
---|
147 |
|
---|
148 |
|
---|
149 | *fLog << all << endl;
|
---|
150 | *fLog << all << "Excluded pixels:" << endl;
|
---|
151 | *fLog << all << endl;
|
---|
152 |
|
---|
153 | id = 0;
|
---|
154 |
|
---|
155 | TIter Next4(fPixels);
|
---|
156 | while ((pix=(MCalibrationRelTimePix*)Next4()))
|
---|
157 | {
|
---|
158 | if (pix->IsExcluded())
|
---|
159 | {
|
---|
160 | *fLog << all << pix->GetPixId() << endl;
|
---|
161 | id++;
|
---|
162 | }
|
---|
163 | }
|
---|
164 | *fLog << all << id << " Excluded pixels " << endl;
|
---|
165 | *fLog << endl;
|
---|
166 |
|
---|
167 | TIter Next5(fAverageAreas);
|
---|
168 | while ((pix=(MCalibrationRelTimePix*)Next5()))
|
---|
169 | {
|
---|
170 | *fLog << all
|
---|
171 | << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Area ",pix->GetPixId(),
|
---|
172 | ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
|
---|
173 | " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
|
---|
174 | << endl;
|
---|
175 | }
|
---|
176 |
|
---|
177 | TIter Next6(fAverageSectors);
|
---|
178 | while ((pix=(MCalibrationRelTimePix*)Next5()))
|
---|
179 | {
|
---|
180 | *fLog << all
|
---|
181 | << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Sector ",pix->GetPixId(),
|
---|
182 | ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
|
---|
183 | " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
|
---|
184 | << endl;
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 |
|
---|
189 | // --------------------------------------------------------------------------
|
---|
190 | //
|
---|
191 | // The types are as follows:
|
---|
192 | //
|
---|
193 | // Fitted values:
|
---|
194 | // ==============
|
---|
195 | //
|
---|
196 | // 0: Fitted RelTime
|
---|
197 | // 1: Error of fitted RelTime
|
---|
198 | // 2: Sigma of fitted RelTime
|
---|
199 | // 3: Error of Sigma of fitted RelTime
|
---|
200 | //
|
---|
201 | // Useful variables derived from the fit results:
|
---|
202 | // =============================================
|
---|
203 | //
|
---|
204 | // 4: Returned probability of Gauss fit to RelTime distribution
|
---|
205 | //
|
---|
206 | Bool_t MCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
207 | {
|
---|
208 |
|
---|
209 | if (idx > GetSize())
|
---|
210 | return kFALSE;
|
---|
211 |
|
---|
212 | Float_t area = cam[idx].GetA();
|
---|
213 |
|
---|
214 | if (area == 0)
|
---|
215 | return kFALSE;
|
---|
216 |
|
---|
217 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*this)[idx];
|
---|
218 |
|
---|
219 | switch (type)
|
---|
220 | {
|
---|
221 | case 0:
|
---|
222 | if (pix.IsExcluded())
|
---|
223 | return kFALSE;
|
---|
224 | val = pix.GetMean();
|
---|
225 | break;
|
---|
226 | case 1:
|
---|
227 | if (pix.IsExcluded())
|
---|
228 | return kFALSE;
|
---|
229 | val = pix.GetMeanErr();
|
---|
230 | break;
|
---|
231 | case 2:
|
---|
232 | if (pix.IsExcluded())
|
---|
233 | return kFALSE;
|
---|
234 | val = pix.GetSigma();
|
---|
235 | break;
|
---|
236 | case 3:
|
---|
237 | if (pix.IsExcluded())
|
---|
238 | return kFALSE;
|
---|
239 | val = pix.GetSigmaErr();
|
---|
240 | break;
|
---|
241 | case 4:
|
---|
242 | if (pix.IsExcluded())
|
---|
243 | return kFALSE;
|
---|
244 | val = pix.GetProb();
|
---|
245 | break;
|
---|
246 | default:
|
---|
247 | return kFALSE;
|
---|
248 | }
|
---|
249 |
|
---|
250 | return val!=-1.;
|
---|
251 |
|
---|
252 | }
|
---|
253 |
|
---|
254 | // --------------------------------------------------------------------------
|
---|
255 | //
|
---|
256 | // What MHCamera needs in order to draw an individual pixel in the camera
|
---|
257 | //
|
---|
258 | void MCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
|
---|
259 | {
|
---|
260 | (*this)[idx].DrawClone();
|
---|
261 | }
|
---|
262 |
|
---|
263 |
|
---|
264 |
|
---|
265 | Bool_t MCalibrationRelTimeCam::GetConversion(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
|
---|
266 | {
|
---|
267 |
|
---|
268 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*this)[ipx];
|
---|
269 |
|
---|
270 | mean = pix.GetMeanConversion();
|
---|
271 | err = pix.GetConversionErr();
|
---|
272 | sigma = pix.GetSigmaConversion();
|
---|
273 |
|
---|
274 | return kTRUE;
|
---|
275 | }
|
---|
276 |
|
---|
277 |
|
---|