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

Last change on this file since 5729 was 5660, checked in by gaug, 20 years ago
*** empty log message ***
File size: 8.1 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// MCalibrationIntensityRelTimeCam
27//
28// Storage container for intensity charge calibration results.
29//
30// Individual MCalibrationRelTimeCam's can be retrieved with:
31// - GetCam() yielding the current cam.
32// - GetCam("name") yielding the current camera with name "name".
33// - GetCam(i) yielding the i-th camera.
34//
35// See also: MCalibrationIntensityCam, MCalibrationRelTimeCam,
36// MCalibrationRelTimePix, MCalibrationRelTimeCalc, MCalibrationQECam
37// MHCalibrationRelTimePix, MHCalibrationRelTimeCam
38//
39/////////////////////////////////////////////////////////////////////////////
40#include "MCalibrationIntensityRelTimeCam.h"
41#include "MCalibrationRelTimeCam.h"
42#include "MCalibrationChargeCam.h"
43#include "MCalibrationRelTimePix.h"
44#include "MCalibrationChargePix.h"
45
46#include "MGeomCam.h"
47#include "MGeomPix.h"
48
49#include "MLogManip.h"
50
51#include <TOrdCollection.h>
52#include <TGraphErrors.h>
53
54ClassImp(MCalibrationIntensityRelTimeCam);
55
56using namespace std;
57
58// --------------------------------------------------------------------------
59//
60// Default constructor.
61//
62MCalibrationIntensityRelTimeCam::MCalibrationIntensityRelTimeCam(const char *name, const char *title)
63{
64
65 fName = name ? name : "MCalibrationIntensityRelTimeCam";
66 fTitle = title ? title : "Results of the Intensity Calibration";
67
68 InitSize(1);
69}
70
71// -------------------------------------------------------------------
72//
73// Add MCalibrationRelTimeCam's in the ranges from - to.
74//
75void MCalibrationIntensityRelTimeCam::Add(const UInt_t from, const UInt_t to)
76{
77 for (UInt_t i=from; i<to; i++)
78 fCams->AddAt(new MCalibrationRelTimeCam,i);
79}
80
81TGraphErrors *MCalibrationIntensityRelTimeCam::GetTimeResVsCharge( const UInt_t pixid, const MCalibrationIntensityChargeCam &chargecam,
82 const MCalibrationCam::PulserColor_t col)
83{
84
85 if (chargecam.GetSize() != GetSize())
86 {
87 *fLog << err << GetDescriptor() << ": Size mismatch between MCalibrationIntensityRelTimeCam "
88 << "and MCalibrationIntensityChargeCam. " << endl;
89 return NULL;
90 }
91
92 Int_t size = CountNumEntries(col);
93
94 if (size == 0)
95 return NULL;
96
97 if (size != chargecam.CountNumEntries(col))
98 {
99 *fLog << err << GetDescriptor() << ": Size mismatch in colour between MCalibrationIntensityRelTimeCam "
100 << "and MCalibrationIntensityChargeCam. " << endl;
101 return NULL;
102 }
103
104 const Int_t nvalid = chargecam.CountNumValidEntries(pixid,col);
105
106 if (nvalid == 0)
107 {
108 *fLog << err << GetDescriptor() << ": Only un-calibrated events in pixel: " << pixid << endl;
109 return NULL;
110 }
111
112 TArrayF res(nvalid);
113 TArrayF reserr(nvalid);
114 TArrayF sig(nvalid);
115 TArrayF sigerr(nvalid);
116
117 const Float_t sqrt2 = 1.414;
118 const Float_t fadc2ns = 3.333;
119
120 Int_t cnt = 0;
121
122 for (Int_t i=0;i<GetSize();i++)
123 {
124 //
125 // Get the calibration cam from the intensity cam
126 //
127 MCalibrationChargeCam *cam = (MCalibrationChargeCam*)chargecam.GetCam(i);
128 MCalibrationRelTimeCam *relcam = (MCalibrationRelTimeCam*)GetCam(i);
129
130 if (col != MCalibrationCam::kNONE)
131 if (relcam->GetPulserColor() != col)
132 continue;
133 //
134 // Get the calibration pix from the calibration cam
135 //
136 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[pixid];
137 MCalibrationRelTimePix &relpix = (MCalibrationRelTimePix&)(*relcam)[pixid];
138 //
139 // Don't use bad pixels
140 //
141 if (!pix.IsFFactorMethodValid())
142 continue;
143 //
144 res[cnt] = relpix.GetTimePrecision() / sqrt2 * fadc2ns;
145 reserr[cnt] = relpix.GetTimePrecisionErr() / sqrt2 * fadc2ns;
146 //
147 sig [cnt] = pix.GetPheFFactorMethod();
148 sigerr[cnt] = pix.GetPheFFactorMethodErr();
149 cnt++;
150 }
151
152 TGraphErrors *gr = new TGraphErrors(nvalid,
153 sig.GetArray(),res.GetArray(),
154 sigerr.GetArray(),reserr.GetArray());
155 gr->SetTitle(Form("%s%3i","Pixel ",pixid));
156 gr->GetXaxis()->SetTitle("<Photo-electrons> [1]");
157 gr->GetYaxis()->SetTitle("Time Resolution [ns]");
158 return gr;
159}
160
161
162TGraphErrors *MCalibrationIntensityRelTimeCam::GetTimeResVsChargePerArea( const Int_t aidx,const MCalibrationIntensityChargeCam &chargecam, const MGeomCam &geom, const MCalibrationCam::PulserColor_t col)
163{
164
165 Int_t size = CountNumEntries(col);
166
167 if (size == 0)
168 return NULL;
169
170 if (size != chargecam.CountNumEntries(col))
171 {
172 *fLog << err << GetDescriptor() << ": Size mismatch in colour between MCalibrationIntensityRelTimeCam "
173 << "and MCalibrationIntensityChargeCam. " << endl;
174 return NULL;
175 }
176
177 const Float_t sqrt2 = 1.414;
178 const Float_t fadc2ns = 3.333;
179
180 TArrayF res(size);
181 TArrayF reserr(size);
182 TArrayF sig(size);
183 TArrayF sigerr(size);
184
185 Int_t cnt = 0;
186
187 for (Int_t i=0;i<GetSize();i++)
188 {
189 //
190 // Get the calibration cam from the intensity cam
191 //
192 MCalibrationRelTimeCam *relcam = (MCalibrationRelTimeCam*)GetCam(i);
193 MCalibrationChargeCam *cam = (MCalibrationChargeCam*)chargecam.GetCam(i);
194
195 if (col != MCalibrationCam::kNONE)
196 if (relcam->GetPulserColor() != col)
197 continue;
198
199 const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx);
200 const Float_t phe = apix.GetPheFFactorMethod();
201 const Float_t pheerr = apix.GetPheFFactorMethodErr();
202
203 sig[cnt] = phe;
204 sigerr[cnt] = pheerr;
205
206 Double_t resol = 0.;
207 Double_t resol2 = 0.;
208 Double_t var = 0.;
209 Int_t num = 0;
210 //
211 // Get the area calibration pix from the calibration cam
212 //
213 for (Int_t i=0; i<cam->GetSize(); i++)
214 {
215 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[i];
216 const MCalibrationRelTimePix &relpix = (MCalibrationRelTimePix&)(*relcam)[i];
217 //
218 // Don't use bad pixels
219 //
220 if (!pix.IsFFactorMethodValid())
221 continue;
222 //
223 //
224 if (aidx != geom[i].GetAidx())
225 continue;
226
227 resol += relpix.GetTimePrecision();
228 resol2 += relpix.GetTimePrecision()*relpix.GetTimePrecision();
229 num++;
230 }
231
232 if (num > 1)
233 {
234 resol /= num;
235 var = (resol2 - resol*resol*num) / (num-1);
236
237 res[cnt] = resol * fadc2ns / sqrt2;
238 if (var > 0.)
239 reserr[cnt] = TMath::Sqrt(var)/ sqrt2 * fadc2ns;
240 else
241 reserr[cnt] = 0.;
242 }
243 else
244 {
245 res[cnt] = -1.;
246 reserr[cnt] = 0.;
247 }
248 cnt++;
249 }
250
251 TGraphErrors *gr = new TGraphErrors(size,
252 sig.GetArray(),res.GetArray(),
253 sigerr.GetArray(),reserr.GetArray());
254 gr->SetTitle(Form("%s%3i","Area Index ",aidx));
255 gr->GetXaxis()->SetTitle("<phes> [1]");
256 gr->GetYaxis()->SetTitle("Time Resolution [ns]");
257 return gr;
258}
Note: See TracBrowser for help on using the repository browser.