source: trunk/MagicSoft/Mars/mcalib/MCalibrationTestCam.cc@ 5729

Last change on this file since 5729 was 5047, checked in by gaug, 20 years ago
*** empty log message ***
File size: 7.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): 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
46ClassImp(MCalibrationTestCam);
47
48using 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//
70MCalibrationTestCam::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//
85void 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//
97void 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//
107void 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//
117void 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// Print first the well fitted pixels
127// and then the ones which are not FitValid
128//
129void MCalibrationTestCam::Print(Option_t *o) const
130{
131
132 *fLog << all << GetDescriptor() << ":" << endl;
133 int id = 0;
134
135 *fLog << all << "Calibrated (or interpolated) pixels:" << endl;
136 *fLog << all << endl;
137
138 TIter Next(fPixels);
139 MCalibrationTestPix *pix;
140 while ((pix=(MCalibrationTestPix*)Next()))
141 {
142
143 if (!pix->IsExcluded())
144 {
145
146 *fLog << all
147 << Form("%s%3i","Pixel: ",pix->GetPixId())
148 << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
149 << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
150 ,"+-",pix->GetNumPhotonsPerAreaErr())
151 << endl;
152 id++;
153 }
154 }
155
156 *fLog << all << id << " pixels" << endl;
157 id = 0;
158
159
160 *fLog << all << endl;
161 *fLog << all << "Not interpolated pixels:" << endl;
162 *fLog << all << endl;
163
164 id = 0;
165
166 TIter Next4(fPixels);
167 while ((pix=(MCalibrationTestPix*)Next4()))
168 {
169 if (pix->IsExcluded())
170 {
171 *fLog << all << pix->GetPixId() << " ";
172 id++;
173
174 if (!(id % 25))
175 *fLog << endl;
176 }
177 }
178
179 *fLog << endl;
180 *fLog << all << id << " Excluded pixels " << endl;
181 *fLog << endl;
182
183 *fLog << all << endl;
184 *fLog << all << "Averaged Areas:" << endl;
185 *fLog << all << endl;
186
187 TIter Next5(fAverageAreas);
188 while ((pix=(MCalibrationTestPix*)Next5()))
189 {
190 *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
191 << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
192 << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
193 ,"+-",pix->GetNumPhotonsPerAreaErr())
194 << endl;
195 }
196
197 *fLog << all << endl;
198 *fLog << all << "Averaged Sectors:" << endl;
199 *fLog << all << endl;
200
201 TIter Next6(fAverageSectors);
202 while ((pix=(MCalibrationTestPix*)Next6()))
203 {
204 *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
205 << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
206 << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
207 ,"+-",pix->GetNumPhotonsPerAreaErr())
208 << endl;
209 }
210 *fLog << all << endl;
211}
212
213
214// --------------------------------------------------------------------------
215//
216// The types are as follows:
217//
218// 0: Number Photons
219// 1: Error Number Photons
220// 2: Number photons per area
221// 3: Error Number Photons per area
222// 4: Pixels which are not interpolateable
223//
224Bool_t MCalibrationTestCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
225{
226
227 if (idx > GetSize())
228 return kFALSE;
229
230 Float_t area = cam[idx].GetA();
231
232 if (area == 0)
233 return kFALSE;
234
235 MCalibrationTestPix &pix = (MCalibrationTestPix&)(*this)[idx];
236
237 switch (type)
238 {
239 case 0:
240 if (pix.IsExcluded())
241 return kFALSE;
242 val = pix.GetNumPhotons();
243 break;
244 case 1:
245 if (pix.IsExcluded())
246 return kFALSE;
247 val = pix.GetNumPhotonsErr();
248 break;
249 case 2:
250 if (pix.IsExcluded())
251 return kFALSE;
252 val = pix.GetNumPhotonsPerArea();
253 break;
254 case 3:
255 if (pix.IsExcluded())
256 return kFALSE;
257 val = pix.GetNumPhotonsPerAreaErr();
258 break;
259 case 4:
260 if (!pix.IsExcluded())
261 return kFALSE;
262 val = 1;
263 break;
264 default:
265 return kFALSE;
266 }
267
268 return val!=-1.;
269}
270
271void MCalibrationTestCam::SetNumUninterpolated( const UInt_t i, const Int_t aidx )
272{
273
274 if (aidx < 0)
275 return;
276
277 if (aidx < fNumUninterpolated.GetSize())
278 fNumUninterpolated[aidx] = i;
279}
280
Note: See TracBrowser for help on using the repository browser.