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 | // MCalibrationTestCam
|
---|
27 | //
|
---|
28 | // Storage container for calibrated photons, with calibration applied on the
|
---|
29 | // same calibration run (see MHCalibrationTestCam and MHCalibrationTestPix).
|
---|
30 | //
|
---|
31 | // See also: MCalibrationTestPix, MCalibrationTestCalc, MCalibrationQECam
|
---|
32 | // MHCalibrationTestPix, MHCalibrationTestCam
|
---|
33 | //
|
---|
34 | /////////////////////////////////////////////////////////////////////////////
|
---|
35 | #include "MCalibrationTestCam.h"
|
---|
36 | #include "MCalibrationTestPix.h"
|
---|
37 |
|
---|
38 | #include <TOrdCollection.h>
|
---|
39 |
|
---|
40 | #include "MLog.h"
|
---|
41 | #include "MLogManip.h"
|
---|
42 |
|
---|
43 | #include "MGeomCam.h"
|
---|
44 | #include "MGeomPix.h"
|
---|
45 |
|
---|
46 | ClassImp(MCalibrationTestCam);
|
---|
47 |
|
---|
48 | using namespace std;
|
---|
49 | // --------------------------------------------------------------------------
|
---|
50 | //
|
---|
51 | // Default constructor.
|
---|
52 | //
|
---|
53 | // Sets all pointers to 0
|
---|
54 | //
|
---|
55 | // Creates a TClonesArray of MCalibrationTestPix containers, initialized to 1 entry, destinated
|
---|
56 | // to hold one container per pixel. Later, a call to MCalibrationTestCam::InitSize()
|
---|
57 | // has to be performed (in MGeomApply).
|
---|
58 | //
|
---|
59 | // Creates a TClonesArray of MCalibrationTestPix containers, initialized to 1 entry, destinated
|
---|
60 | // to hold one container per pixel AREA. Later, a call to MCalibrationTestCam::InitAreas()
|
---|
61 | // has to be performed (in MGeomApply).
|
---|
62 | //
|
---|
63 | // Creates a TClonesArray of MCalibrationTestPix containers, initialized to 1 entry, destinated
|
---|
64 | // to hold one container per camera SECTOR. Later, a call to MCalibrationTestCam::InitSectors()
|
---|
65 | // has to be performed (in MGeomApply).
|
---|
66 | //
|
---|
67 | // Calls:
|
---|
68 | // - Clear()
|
---|
69 | //
|
---|
70 | MCalibrationTestCam::MCalibrationTestCam(const char *name, const char *title)
|
---|
71 | {
|
---|
72 |
|
---|
73 | fName = name ? name : "MCalibrationTestCam";
|
---|
74 | fTitle = title ? title : "Storage container for the Calibration Test Information in the camera";
|
---|
75 |
|
---|
76 | Clear();
|
---|
77 | }
|
---|
78 |
|
---|
79 | // --------------------------------------
|
---|
80 | //
|
---|
81 | // Sets all variable to 0.
|
---|
82 | // Sets all flags to kFALSE
|
---|
83 | // Calls MCalibrationCam::Clear()
|
---|
84 | //
|
---|
85 | void MCalibrationTestCam::Clear(Option_t *o)
|
---|
86 | {
|
---|
87 |
|
---|
88 | fNumUninterpolatedInMaxCluster = 0;
|
---|
89 |
|
---|
90 | return;
|
---|
91 | }
|
---|
92 |
|
---|
93 | // -------------------------------------------------------------------
|
---|
94 | //
|
---|
95 | // Add MCalibrationTestPix's in the ranges from - to to fPixels
|
---|
96 | //
|
---|
97 | void MCalibrationTestCam::Add(const UInt_t a, const UInt_t b)
|
---|
98 | {
|
---|
99 | for (UInt_t i=a; i<b; i++)
|
---|
100 | fPixels->AddAt(new MCalibrationTestPix,i);
|
---|
101 | }
|
---|
102 |
|
---|
103 | // -------------------------------------------------------------------
|
---|
104 | //
|
---|
105 | // Add MCalibrationTestPix's in the ranges from - to to fAverageAreas
|
---|
106 | //
|
---|
107 | void MCalibrationTestCam::AddArea(const UInt_t a, const UInt_t b)
|
---|
108 | {
|
---|
109 | for (UInt_t i=a; i<b; i++)
|
---|
110 | fAverageAreas->AddAt(new MCalibrationTestPix,i);
|
---|
111 | }
|
---|
112 |
|
---|
113 | // -------------------------------------------------------------------
|
---|
114 | //
|
---|
115 | // Add MCalibrationTestPix's in the ranges from - to to fAverageSectors
|
---|
116 | //
|
---|
117 | void MCalibrationTestCam::AddSector(const UInt_t a, const UInt_t b)
|
---|
118 | {
|
---|
119 | for (UInt_t i=a; i<b; i++)
|
---|
120 | fAverageSectors->AddAt(new MCalibrationTestPix,i);
|
---|
121 | }
|
---|
122 |
|
---|
123 |
|
---|
124 | // -------------------------------------------------------------------
|
---|
125 | //
|
---|
126 | // Initialize the objects inside the TOrdCollections
|
---|
127 | // - fAverageAreas
|
---|
128 | // - fAverageBadAreas
|
---|
129 | // using the virtual function Add().
|
---|
130 | //
|
---|
131 | // InitSize can only increase the size, but not shrink.
|
---|
132 | //
|
---|
133 | // It can be called more than one time. New Containers are
|
---|
134 | // added only from the current size to the argument i.
|
---|
135 | //
|
---|
136 | void MCalibrationTestCam::InitAverageAreas(const UInt_t i)
|
---|
137 | {
|
---|
138 |
|
---|
139 | const UInt_t save = GetAverageAreas();
|
---|
140 |
|
---|
141 | if (i==save)
|
---|
142 | return;
|
---|
143 |
|
---|
144 | fNumUninterpolated.Set(i);
|
---|
145 |
|
---|
146 | MCalibrationCam::InitAverageAreas(i);
|
---|
147 |
|
---|
148 | return;
|
---|
149 |
|
---|
150 | }
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 | // --------------------------------------------------------------------------
|
---|
155 | //
|
---|
156 | // Print first the well fitted pixels
|
---|
157 | // and then the ones which are not FitValid
|
---|
158 | //
|
---|
159 | void MCalibrationTestCam::Print(Option_t *o) const
|
---|
160 | {
|
---|
161 |
|
---|
162 | *fLog << all << GetDescriptor() << ":" << endl;
|
---|
163 | int id = 0;
|
---|
164 |
|
---|
165 | *fLog << all << "Calibrated (or interpolated) pixels:" << endl;
|
---|
166 | *fLog << all << endl;
|
---|
167 |
|
---|
168 | TIter Next(fPixels);
|
---|
169 | MCalibrationTestPix *pix;
|
---|
170 | while ((pix=(MCalibrationTestPix*)Next()))
|
---|
171 | {
|
---|
172 |
|
---|
173 | if (!pix->IsExcluded())
|
---|
174 | {
|
---|
175 |
|
---|
176 | *fLog << all
|
---|
177 | << Form("%s%3i","Pixel: ",pix->GetPixId())
|
---|
178 | << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
|
---|
179 | << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
|
---|
180 | ,"+-",pix->GetNumPhotonsPerAreaErr())
|
---|
181 | << endl;
|
---|
182 | id++;
|
---|
183 | }
|
---|
184 | }
|
---|
185 |
|
---|
186 | *fLog << all << id << " pixels" << endl;
|
---|
187 | id = 0;
|
---|
188 |
|
---|
189 |
|
---|
190 | *fLog << all << endl;
|
---|
191 | *fLog << all << "Not interpolated pixels:" << endl;
|
---|
192 | *fLog << all << endl;
|
---|
193 |
|
---|
194 | id = 0;
|
---|
195 |
|
---|
196 | TIter Next4(fPixels);
|
---|
197 | while ((pix=(MCalibrationTestPix*)Next4()))
|
---|
198 | {
|
---|
199 | if (pix->IsExcluded())
|
---|
200 | {
|
---|
201 | *fLog << all << pix->GetPixId() << " ";
|
---|
202 | id++;
|
---|
203 |
|
---|
204 | if (!(id % 25))
|
---|
205 | *fLog << endl;
|
---|
206 | }
|
---|
207 | }
|
---|
208 |
|
---|
209 | *fLog << endl;
|
---|
210 | *fLog << all << id << " Excluded pixels " << endl;
|
---|
211 | *fLog << endl;
|
---|
212 |
|
---|
213 | *fLog << all << endl;
|
---|
214 | *fLog << all << "Averaged Areas:" << endl;
|
---|
215 | *fLog << all << endl;
|
---|
216 |
|
---|
217 | TIter Next5(fAverageAreas);
|
---|
218 | while ((pix=(MCalibrationTestPix*)Next5()))
|
---|
219 | {
|
---|
220 | *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
|
---|
221 | << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
|
---|
222 | << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
|
---|
223 | ,"+-",pix->GetNumPhotonsPerAreaErr())
|
---|
224 | << endl;
|
---|
225 | }
|
---|
226 |
|
---|
227 | *fLog << all << endl;
|
---|
228 | *fLog << all << "Averaged Sectors:" << endl;
|
---|
229 | *fLog << all << endl;
|
---|
230 |
|
---|
231 | TIter Next6(fAverageSectors);
|
---|
232 | while ((pix=(MCalibrationTestPix*)Next6()))
|
---|
233 | {
|
---|
234 | *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
|
---|
235 | << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
|
---|
236 | << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
|
---|
237 | ,"+-",pix->GetNumPhotonsPerAreaErr())
|
---|
238 | << endl;
|
---|
239 | }
|
---|
240 | *fLog << all << endl;
|
---|
241 | }
|
---|
242 |
|
---|
243 |
|
---|
244 | // --------------------------------------------------------------------------
|
---|
245 | //
|
---|
246 | // The types are as follows:
|
---|
247 | //
|
---|
248 | // 0: Number Photons
|
---|
249 | // 1: Error Number Photons
|
---|
250 | // 2: Number photons per area
|
---|
251 | // 3: Error Number Photons per area
|
---|
252 | // 4: Pixels which are not interpolateable
|
---|
253 | //
|
---|
254 | Bool_t MCalibrationTestCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
255 | {
|
---|
256 |
|
---|
257 | if (idx > GetSize())
|
---|
258 | return kFALSE;
|
---|
259 |
|
---|
260 | Float_t area = cam[idx].GetA();
|
---|
261 |
|
---|
262 | if (area == 0)
|
---|
263 | return kFALSE;
|
---|
264 |
|
---|
265 | MCalibrationTestPix &pix = (MCalibrationTestPix&)(*this)[idx];
|
---|
266 |
|
---|
267 | switch (type)
|
---|
268 | {
|
---|
269 | case 0:
|
---|
270 | if (pix.IsExcluded())
|
---|
271 | return kFALSE;
|
---|
272 | val = pix.GetNumPhotons();
|
---|
273 | break;
|
---|
274 | case 1:
|
---|
275 | if (pix.IsExcluded())
|
---|
276 | return kFALSE;
|
---|
277 | val = pix.GetNumPhotonsErr();
|
---|
278 | break;
|
---|
279 | case 2:
|
---|
280 | if (pix.IsExcluded())
|
---|
281 | return kFALSE;
|
---|
282 | val = pix.GetNumPhotonsPerArea();
|
---|
283 | break;
|
---|
284 | case 3:
|
---|
285 | if (pix.IsExcluded())
|
---|
286 | return kFALSE;
|
---|
287 | val = pix.GetNumPhotonsPerAreaErr();
|
---|
288 | break;
|
---|
289 | case 4:
|
---|
290 | if (!pix.IsExcluded())
|
---|
291 | return kFALSE;
|
---|
292 | val = 1;
|
---|
293 | break;
|
---|
294 | default:
|
---|
295 | return kFALSE;
|
---|
296 | }
|
---|
297 |
|
---|
298 | return val!=-1.;
|
---|
299 | }
|
---|
300 |
|
---|
301 | void MCalibrationTestCam::SetNumUninterpolated( const UInt_t i, const Int_t aidx )
|
---|
302 | {
|
---|
303 |
|
---|
304 | if (aidx < 0)
|
---|
305 | return;
|
---|
306 |
|
---|
307 | if (aidx < fNumUninterpolated.GetSize())
|
---|
308 | fNumUninterpolated[aidx] = i;
|
---|
309 | }
|
---|
310 |
|
---|