source: trunk/MagicSoft/Mars/mcalib/MCalibrationHiLoCam.cc@ 6530

Last change on this file since 6530 was 5946, checked in by mazin, 20 years ago
*** empty log message ***
File size: 7.9 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//
27// MCalibrationHiLoCam
28//
29// Storage container for ratio between higain and logain charge extraction
30// calibration results of the whole camera.
31//
32// Individual pixels have to be cast when retrieved e.g.:
33// MCalibrationHiLoPix &avpix = (MCalibrationHiLoPix&)(*fHiLoCam)[i]
34//
35// The following "calibration" constants can be retrieved from each pixel:
36// - GetHiLoRatio(): The mean signal ratio between high-gain and low-gain
37// - GetHiLoRatioErr(): The Gauss sigma of histogrammed signal ratios
38//
39// Averaged values over one whole area index (e.g. inner or outer pixels for
40// the MAGIC camera), can be retrieved via:
41// MCalibrationHiLoPix &avpix = (MCalibrationHiLoPix&)fRelCam->GetAverageArea(i)
42//
43// Averaged values over one whole camera sector can be retrieved via:
44// MCalibrationHiLoPix &avpix = (MCalibrationHiLoPix&)fRelCam->GetAverageSector(i)
45//
46// Note the averageing has been done on an event-by-event basis. Resulting
47// Sigma's of the Gauss fit have been multiplied with the square root of the number
48// of involved pixels in order to make a direct comparison possible with the mean of
49// sigmas.
50//
51// See also: MHCalibrationHiLoPix, MHCalibrationHiLoCam
52//
53// The calculated values (types of GetPixelContent) are:
54//
55// Fitted values:
56// ==============
57//
58// 0: HiLo Ratio
59// 1: Error of HiLo Ratio
60// 2: Sigma of HiLo Ratio == Resolution
61// 3: Error of Sigma of HiLo Ratio
62//
63// Useful variables derived from the fit results:
64// =============================================
65//
66// 4: Returned probability of Gauss fit to distribution
67//
68/////////////////////////////////////////////////////////////////////////////
69#include "MCalibrationHiLoCam.h"
70#include "MCalibrationCam.h"
71
72#include <TOrdCollection.h>
73
74#include "MLog.h"
75#include "MLogManip.h"
76
77#include "MGeomCam.h"
78#include "MGeomPix.h"
79
80#include "MCalibrationHiLoPix.h"
81
82ClassImp(MCalibrationHiLoCam);
83
84using namespace std;
85
86// --------------------------------------------------------------------------
87//
88// Default constructor.
89//
90MCalibrationHiLoCam::MCalibrationHiLoCam(const char *name, const char *title)
91{
92
93 fName = name ? name : "MCalibrationHiLoCam";
94 fTitle = title ? title : "Container for High Gain vs. Low Gain amplification ratio";
95
96}
97
98void MCalibrationHiLoCam::Add(const UInt_t a, const UInt_t b)
99{
100 for (UInt_t i=a; i<b; i++)
101 fPixels->AddAt(new MCalibrationHiLoPix,i);
102}
103
104
105void MCalibrationHiLoCam::AddArea(const UInt_t a, const UInt_t b)
106{
107 for (UInt_t i=a; i<b; i++)
108 fAverageAreas->AddAt(new MCalibrationHiLoPix,i);
109}
110
111void MCalibrationHiLoCam::AddSector(const UInt_t a, const UInt_t b)
112{
113 for (UInt_t i=a; i<b; i++)
114 fAverageSectors->AddAt(new MCalibrationHiLoPix,i);
115}
116
117// --------------------------------------------------------------------------
118//
119// Print first the well fitted pixels
120// and then the ones which are not Valid
121//
122void MCalibrationHiLoCam::Print(Option_t *o) const
123{
124
125 *fLog << all << GetDescriptor() << ":" << endl;
126 int id = 0;
127
128 *fLog << all << "Calibrated pixels:" << endl;
129 *fLog << all << endl;
130
131 TIter Next(fPixels);
132 MCalibrationHiLoPix *pix;
133 while ((pix=(MCalibrationHiLoPix*)Next()))
134 {
135
136 if (!pix->IsExcluded())
137 {
138
139 *fLog << all
140 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Pix ",pix->GetPixId(),
141 ": Ratio: ",pix->GetHiLoChargeRatio()," +- ",pix->GetHiLoChargeRatioErr(),
142 " Sigma: ",pix->GetHiLoChargeRatioSigma()," +- ",pix->GetHiLoChargeRatioSigmaErr())
143 << endl;
144 id++;
145 }
146 }
147
148 *fLog << all << id << " pixels" << endl;
149 id = 0;
150
151
152 *fLog << all << endl;
153 *fLog << all << "Excluded pixels:" << endl;
154 *fLog << all << endl;
155
156 id = 0;
157
158 TIter Next4(fPixels);
159 while ((pix=(MCalibrationHiLoPix*)Next4()))
160 {
161 if (pix->IsExcluded())
162 {
163 *fLog << all << pix->GetPixId() << endl;
164 id++;
165 }
166 }
167 *fLog << all << id << " Excluded pixels " << endl;
168 *fLog << endl;
169
170 TIter Next5(fAverageAreas);
171 while ((pix=(MCalibrationHiLoPix*)Next5()))
172 {
173 *fLog << all
174 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Area ",pix->GetPixId(),
175 ": Ratio: ",pix->GetHiLoChargeRatio()," +- ",pix->GetHiLoChargeRatioErr(),
176 " Sigma: ",pix->GetHiLoChargeRatioSigma()," +- ",pix->GetHiLoChargeRatioSigmaErr())
177 << endl;
178 }
179
180 TIter Next6(fAverageSectors);
181 while ((pix=(MCalibrationHiLoPix*)Next5()))
182 {
183 *fLog << all
184 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Sector ",pix->GetPixId(),
185 ": Ratio: ",pix->GetHiLoChargeRatio()," +- ",pix->GetHiLoChargeRatioErr(),
186 " Sigma: ",pix->GetHiLoChargeRatioSigma()," +- ",pix->GetHiLoChargeRatioSigmaErr())
187 << endl;
188 }
189}
190
191
192// --------------------------------------------------------------------------
193//
194// The types are as follows:
195//
196// Fitted values:
197// ==============
198//
199// 0: Fitted HiLo
200// 1: Error of fitted HiLo
201// 2: Sigma of fitted HiLo
202// 3: Error of Sigma of fitted HiLo
203//
204// Useful variables derived from the fit results:
205// =============================================
206//
207// 4: Returned probability of Gauss fit to HiLo distribution
208//
209Bool_t MCalibrationHiLoCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
210{
211
212 if (idx > GetSize())
213 return kFALSE;
214
215 Float_t area = cam[idx].GetA();
216
217 if (area == 0)
218 return kFALSE;
219
220 MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)(*this)[idx];
221
222 switch (type)
223 {
224 case 0:
225 if (pix.IsExcluded())
226 return kFALSE;
227 val = pix.GetHiLoChargeRatio();
228 break;
229 case 1:
230 if (pix.IsExcluded())
231 return kFALSE;
232 val = pix.GetHiLoChargeRatioErr();
233 break;
234 case 2:
235 if (pix.IsExcluded())
236 return kFALSE;
237 val = pix.GetHiLoChargeRatioSigma();
238 break;
239 case 3:
240 if (pix.IsExcluded())
241 return kFALSE;
242 val = pix.GetHiLoChargeRatioSigmaErr();
243 break;
244 case 4:
245 if (pix.IsExcluded())
246 return kFALSE;
247 val = pix.GetHiLoChargeRatioProb();
248 break;
249 case 5:
250 if (pix.IsExcluded())
251 return kFALSE;
252 val = pix.GetHiLoTimeDiff();
253 break;
254 case 6:
255 if (pix.IsExcluded())
256 return kFALSE;
257 val = pix.GetHiLoTimeDiffErr();
258 break;
259 case 7:
260 if (pix.IsExcluded())
261 return kFALSE;
262 val = pix.GetHiLoTimeDiffSigma();
263 break;
264 case 8:
265 if (pix.IsExcluded())
266 return kFALSE;
267 val = pix.GetHiLoTimeDiffSigmaErr();
268 break;
269 case 9:
270 if (pix.IsExcluded())
271 return kFALSE;
272 val = pix.GetHiLoTimeDiffProb();
273 break;
274 default:
275 return kFALSE;
276 }
277
278 return val!=-1.;
279
280}
281
Note: See TracBrowser for help on using the repository browser.