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 02/2004 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 | /////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // MHCalibrationChargeCam
|
---|
27 | //
|
---|
28 | // Fills the extracted signals of MExtractedSignalCam into the MHGausEvents-classes
|
---|
29 | // MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
|
---|
30 | //
|
---|
31 | // - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray and
|
---|
32 | // MHCalibrationCam::fLoGainArray
|
---|
33 | //
|
---|
34 | // - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
|
---|
35 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
|
---|
36 | // MHCalibrationCam::fAverageLoGainAreas
|
---|
37 | //
|
---|
38 | // - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
|
---|
39 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors and
|
---|
40 | // MHCalibrationCam::fAverageLoGainSectors
|
---|
41 | //
|
---|
42 | // Every signal is taken from MExtractedSignalCam and filled into a histogram and
|
---|
43 | // an array, in order to perform a Fourier analysis (see MHGausEvents).
|
---|
44 | // The signals are moreover averaged on an event-by-event basis and written into
|
---|
45 | // the corresponding average pixels.
|
---|
46 | //
|
---|
47 | // Additionally, the (FADC slice) position of the maximum is stored in an Absolute
|
---|
48 | // Arrival Time histogram. This histogram serves for a rough cross-check if the
|
---|
49 | // signal does not lie at or outside the edges of the extraction window.
|
---|
50 | //
|
---|
51 | // The Charge histograms are fitted to a Gaussian, mean and sigma with its errors
|
---|
52 | // and the fit probability are extracted. If none of these values are NaN's and
|
---|
53 | // if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
|
---|
54 | // the fit is declared valid.
|
---|
55 | // Otherwise, the fit is repeated within ranges of the previous mean
|
---|
56 | // +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
|
---|
57 | // In case this does not make the fit valid, the histogram means and RMS's are
|
---|
58 | // taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
|
---|
59 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or
|
---|
60 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and
|
---|
61 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
62 | //
|
---|
63 | // Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas
|
---|
64 | // from the mean are counted as Pickup events (stored in MHGausEvents::fPickup)
|
---|
65 | //
|
---|
66 | // Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
|
---|
67 | // slices show saturation, the following flag is set:
|
---|
68 | // - MCalibrationChargePix::SetHiGainSaturation();
|
---|
69 | // In that case, the calibration constants are derived from the low-gain results.
|
---|
70 | //
|
---|
71 | // If more than fNumLoGainSaturationLimit (default: 1%) of the overall
|
---|
72 | // low-gain FADC slices saturate, the following flags are set:
|
---|
73 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
|
---|
74 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnsuitableRun )
|
---|
75 | //
|
---|
76 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
---|
77 | // spectrum and investigates if the projected fourier components follow an exponential
|
---|
78 | // distribution. In case that the probability of the exponential fit is less than
|
---|
79 | // MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
|
---|
80 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
|
---|
81 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
|
---|
82 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
83 | //
|
---|
84 | // This same procedure is performed for the average pixels.
|
---|
85 | //
|
---|
86 | // The following results are written into MCalibrationChargeCam:
|
---|
87 | //
|
---|
88 | // - MCalibrationPix::SetHiGainSaturation()
|
---|
89 | // - MCalibrationPix::SetHiGainMean()
|
---|
90 | // - MCalibrationPix::SetHiGainMeanErr()
|
---|
91 | // - MCalibrationPix::SetHiGainSigma()
|
---|
92 | // - MCalibrationPix::SetHiGainSigmaErr()
|
---|
93 | // - MCalibrationPix::SetHiGainProb()
|
---|
94 | // - MCalibrationPix::SetHiGainNumPickup()
|
---|
95 | //
|
---|
96 | // - MCalibrationPix::SetLoGainMean()
|
---|
97 | // - MCalibrationPix::SetLoGainMeanErr()
|
---|
98 | // - MCalibrationPix::SetLoGainSigma()
|
---|
99 | // - MCalibrationPix::SetLoGainSigmaErr()
|
---|
100 | // - MCalibrationPix::SetLoGainProb()
|
---|
101 | // - MCalibrationPix::SetLoGainNumPickup()
|
---|
102 | //
|
---|
103 | // - MCalibrationChargePix::SetAbsTimeMean()
|
---|
104 | // - MCalibrationChargePix::SetAbsTimeRms()
|
---|
105 | //
|
---|
106 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
---|
107 | // the number involved pixels in order to be able to compare it to the average of
|
---|
108 | // sigmas in the camera.
|
---|
109 | //
|
---|
110 | /////////////////////////////////////////////////////////////////////////////
|
---|
111 | #include "MHCalibrationChargeCam.h"
|
---|
112 | #include "MHCalibrationCam.h"
|
---|
113 |
|
---|
114 | #include "MLog.h"
|
---|
115 | #include "MLogManip.h"
|
---|
116 |
|
---|
117 | #include "MParList.h"
|
---|
118 |
|
---|
119 | #include "MHCalibrationChargeHiGainPix.h"
|
---|
120 | #include "MHCalibrationChargeLoGainPix.h"
|
---|
121 | #include "MHCalibrationChargePix.h"
|
---|
122 |
|
---|
123 | #include "MCalibrationCam.h"
|
---|
124 |
|
---|
125 | #include "MCalibrationChargeCam.h"
|
---|
126 | #include "MCalibrationChargePix.h"
|
---|
127 |
|
---|
128 | #include "MGeomCam.h"
|
---|
129 | #include "MGeomPix.h"
|
---|
130 |
|
---|
131 | #include "MHGausEvents.h"
|
---|
132 |
|
---|
133 | #include "MBadPixelsCam.h"
|
---|
134 | #include "MBadPixelsPix.h"
|
---|
135 |
|
---|
136 | #include "MRawEvtData.h"
|
---|
137 | #include "MRawEvtPixelIter.h"
|
---|
138 |
|
---|
139 | #include "MExtractedSignalCam.h"
|
---|
140 | #include "MExtractedSignalPix.h"
|
---|
141 |
|
---|
142 | #include "MArrayI.h"
|
---|
143 | #include "MArrayD.h"
|
---|
144 |
|
---|
145 | #include <TPad.h>
|
---|
146 | #include <TVirtualPad.h>
|
---|
147 | #include <TCanvas.h>
|
---|
148 | #include <TStyle.h>
|
---|
149 | #include <TF1.h>
|
---|
150 | #include <TH2D.h>
|
---|
151 | #include <TLine.h>
|
---|
152 | #include <TLatex.h>
|
---|
153 | #include <TLegend.h>
|
---|
154 |
|
---|
155 | ClassImp(MHCalibrationChargeCam);
|
---|
156 |
|
---|
157 | using namespace std;
|
---|
158 |
|
---|
159 | const Int_t MHCalibrationChargeCam::fgAverageNbinsHiGain = 3300;
|
---|
160 | const Int_t MHCalibrationChargeCam::fgAverageNbinsLoGain = 1950;
|
---|
161 | const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
|
---|
162 | const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
|
---|
163 | const Float_t MHCalibrationChargeCam::fgTimeLowerLimit = 1.;
|
---|
164 | const Float_t MHCalibrationChargeCam::fgTimeUpperLimit = 2.;
|
---|
165 | // 1Led Green, 1 LED blue, 5 LEDs blue, 10 LEDs blue, 10 LEDs UV, CT1, 5Leds Green
|
---|
166 | const Float_t MHCalibrationChargeCam::gkHiGainInnerRefLines[7] = { 245., 323. , 1065., 1467., 180., 211. , 533.5};
|
---|
167 | const Float_t MHCalibrationChargeCam::gkHiGainOuterRefLines[7] = { 217., 307.5, 932. , 1405., 167., 183.5, 405.5};
|
---|
168 | const Float_t MHCalibrationChargeCam::gkLoGainInnerRefLines[7] = { 20.8, 28.0 , 121. , 200.2, 16.5, 13.5 , 41.7 };
|
---|
169 | const Float_t MHCalibrationChargeCam::gkLoGainOuterRefLines[7] = { 18.9, 26.0 , 108.3, 198. , 14.0, 11. , 42. };
|
---|
170 | // --------------------------------------------------------------------------
|
---|
171 | //
|
---|
172 | // Default Constructor.
|
---|
173 | //
|
---|
174 | // Sets:
|
---|
175 | // - all pointers to NULL
|
---|
176 | //
|
---|
177 | // Initializes:
|
---|
178 | // - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
|
---|
179 | // - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
|
---|
180 | // - fTimeLowerLimit to fgTimeLowerLimit
|
---|
181 | // - fTimeUpperLimit to fgTimeUpperLimit
|
---|
182 | // - fAverageNbins to fgAverageNbinsHiGain
|
---|
183 | //
|
---|
184 | MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
|
---|
185 | : fRawEvt(NULL)
|
---|
186 | {
|
---|
187 |
|
---|
188 | fName = name ? name : "MHCalibrationChargeCam";
|
---|
189 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
---|
190 |
|
---|
191 | SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
|
---|
192 | SetNumLoGainSaturationLimit(fgNumLoGainSaturationLimit);
|
---|
193 | SetTimeLowerLimit();
|
---|
194 | SetTimeUpperLimit();
|
---|
195 |
|
---|
196 | SetAverageNbins(fgAverageNbinsHiGain);
|
---|
197 | }
|
---|
198 |
|
---|
199 | // --------------------------------------------------------------------------
|
---|
200 | //
|
---|
201 | // Gets the pointers to:
|
---|
202 | // - MRawEvtData
|
---|
203 | //
|
---|
204 | Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
|
---|
205 | {
|
---|
206 |
|
---|
207 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
---|
208 | if (!fRawEvt)
|
---|
209 | {
|
---|
210 | *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
|
---|
211 | return kFALSE;
|
---|
212 | }
|
---|
213 |
|
---|
214 | return kTRUE;
|
---|
215 | }
|
---|
216 |
|
---|
217 | // --------------------------------------------------------------------------
|
---|
218 | //
|
---|
219 | // Gets or creates the pointers to:
|
---|
220 | // - MExtractedSignalCam
|
---|
221 | // - MCalibrationChargeCam
|
---|
222 | // - MBadPixelsCam
|
---|
223 | //
|
---|
224 | // Initializes the number of used FADC slices from MExtractedSignalCam
|
---|
225 | // into MCalibrationChargeCam and test for changes in that variable
|
---|
226 | //
|
---|
227 | // Initializes, if empty to MGeomCam::GetNumPixels():
|
---|
228 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
229 | // - MHCalibrationCam::fHiGainOverflow, MHCalibrationCam::fLoGainOverflow
|
---|
230 | //
|
---|
231 | // Initializes, if empty to MGeomCam::GetNumAreas() for:
|
---|
232 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
233 | //
|
---|
234 | // Initializes, if empty to MGeomCam::GetNumSectors() for:
|
---|
235 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
236 | //
|
---|
237 | // Calls MHCalibrationCam::InitHists() for every entry in:
|
---|
238 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
239 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
240 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
241 | //
|
---|
242 | // Sets Titles and Names for the Charge Histograms:
|
---|
243 | // - MHCalibrationCam::fAverageHiGainAreas
|
---|
244 | // - MHCalibrationCam::fAverageHiGainSectors
|
---|
245 | //
|
---|
246 | // Sets number of bins to MHCalibrationCam::fAverageNbins for:
|
---|
247 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
248 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
249 | //
|
---|
250 | Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
|
---|
251 | {
|
---|
252 |
|
---|
253 | MExtractedSignalCam *signal =
|
---|
254 | (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
|
---|
255 | if (!signal)
|
---|
256 | {
|
---|
257 | *fLog << err << "MExtractedSignalCam not found... abort." << endl;
|
---|
258 | return kFALSE;
|
---|
259 | }
|
---|
260 |
|
---|
261 | fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
|
---|
262 | if (!fCam)
|
---|
263 | {
|
---|
264 | fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
|
---|
265 | if (!fCam)
|
---|
266 | {
|
---|
267 | gLog << err << "Cannot find nor create MCalibrationChargeCam ... abort." << endl;
|
---|
268 | return kFALSE;
|
---|
269 | }
|
---|
270 | else
|
---|
271 | fCam->Init(*fGeom);
|
---|
272 | }
|
---|
273 |
|
---|
274 | fFirstHiGain = signal->GetFirstUsedSliceHiGain();
|
---|
275 | fLastHiGain = signal->GetLastUsedSliceHiGain();
|
---|
276 | fFirstLoGain = signal->GetFirstUsedSliceLoGain();
|
---|
277 | fLastLoGain = signal->GetLastUsedSliceLoGain();
|
---|
278 |
|
---|
279 | const Float_t numhigain = signal->GetNumUsedHiGainFADCSlices();
|
---|
280 | const Float_t numlogain = signal->GetNumUsedLoGainFADCSlices();
|
---|
281 |
|
---|
282 | if (fCam->GetNumHiGainFADCSlices() == 0.)
|
---|
283 | fCam->SetNumHiGainFADCSlices ( numhigain );
|
---|
284 | else if (fCam->GetNumHiGainFADCSlices() != numhigain)
|
---|
285 | {
|
---|
286 | *fLog << err << GetDescriptor()
|
---|
287 | << ": Number of High Gain FADC extraction slices has changed, abort..." << endl;
|
---|
288 | return kFALSE;
|
---|
289 | }
|
---|
290 |
|
---|
291 | if (fCam->GetNumLoGainFADCSlices() == 0.)
|
---|
292 | fCam->SetNumLoGainFADCSlices ( numlogain );
|
---|
293 | else if (fCam->GetNumLoGainFADCSlices() != numlogain)
|
---|
294 | {
|
---|
295 | *fLog << err << GetDescriptor()
|
---|
296 | << ": Number of Low Gain FADC extraction slices has changes, abort..." << endl;
|
---|
297 | return kFALSE;
|
---|
298 | }
|
---|
299 |
|
---|
300 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
301 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
302 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
303 |
|
---|
304 | if (fHiGainArray->GetEntries()==0)
|
---|
305 | {
|
---|
306 | fHiGainArray->Expand(npixels);
|
---|
307 | for (Int_t i=0; i<npixels; i++)
|
---|
308 | {
|
---|
309 | (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
|
---|
310 | InitHists((*this)[i],(*fBadPixels)[i],i);
|
---|
311 | }
|
---|
312 | fHiGainOverFlow.Set(npixels);
|
---|
313 | }
|
---|
314 |
|
---|
315 | if (fLoGainArray->GetEntries()==0)
|
---|
316 | {
|
---|
317 | fLoGainArray->Expand(npixels);
|
---|
318 |
|
---|
319 | for (Int_t i=0; i<npixels; i++)
|
---|
320 | {
|
---|
321 | (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
|
---|
322 | MHGausEvents &lopix = (*this)(i);
|
---|
323 | //
|
---|
324 | // Adapt the range for the case, the intense blue is used:
|
---|
325 | // FIXME: this is a nasty workaround, but for the moment necessary
|
---|
326 | // in order to avoid default memory space.
|
---|
327 | //
|
---|
328 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
329 | {
|
---|
330 | if ( fColor == MCalibrationCam::kBLUE)
|
---|
331 | {
|
---|
332 | lopix.SetLast(999.5);
|
---|
333 | lopix.SetNbins(1150);
|
---|
334 | }
|
---|
335 | }
|
---|
336 | InitHists(lopix,(*fBadPixels)[i],i);
|
---|
337 | }
|
---|
338 | fLoGainOverFlow.Set(npixels);
|
---|
339 | }
|
---|
340 |
|
---|
341 | if (fAverageHiGainAreas->GetEntries()==0)
|
---|
342 | {
|
---|
343 | fAverageHiGainAreas->Expand(nareas);
|
---|
344 |
|
---|
345 | for (Int_t j=0; j<nareas; j++)
|
---|
346 | {
|
---|
347 | (*fAverageHiGainAreas)[j] =
|
---|
348 | new MHCalibrationChargeHiGainPix("AverageHiGainArea",
|
---|
349 | "Average HiGain FADC sums area idx ");
|
---|
350 |
|
---|
351 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
---|
352 |
|
---|
353 | hist.SetNbins(fAverageNbins);
|
---|
354 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
|
---|
355 |
|
---|
356 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
357 | {
|
---|
358 | hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
|
---|
359 | j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
|
---|
360 | hist.InitBins();
|
---|
361 | hist.SetEventFrequency(fPulserFrequency);
|
---|
362 | }
|
---|
363 | else
|
---|
364 | {
|
---|
365 | hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
|
---|
366 | InitHists(hist,fCam->GetAverageBadArea(j),j);
|
---|
367 | }
|
---|
368 | }
|
---|
369 | }
|
---|
370 |
|
---|
371 |
|
---|
372 | if (fAverageLoGainAreas->GetEntries()==0)
|
---|
373 | {
|
---|
374 | fAverageLoGainAreas->Expand(nareas);
|
---|
375 |
|
---|
376 | for (Int_t j=0; j<nareas; j++)
|
---|
377 | {
|
---|
378 | (*fAverageLoGainAreas)[j] =
|
---|
379 | new MHCalibrationChargeLoGainPix("AverageLoGainArea",
|
---|
380 | "Average LoGain FADC sums of pixel area idx ");
|
---|
381 |
|
---|
382 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
---|
383 | hist.SetNbins(fgAverageNbinsLoGain);
|
---|
384 |
|
---|
385 | //
|
---|
386 | // Adapt the range for the case, the intense blue is used:
|
---|
387 | // FIXME: this is a nasty workaround, but for the moment necessary
|
---|
388 | // in order to avoid default memory space.
|
---|
389 | //
|
---|
390 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
391 | {
|
---|
392 | if ( fColor == MCalibrationCam::kBLUE)
|
---|
393 | {
|
---|
394 | hist.SetFirst(-10.5);
|
---|
395 | hist.SetLast(999.5);
|
---|
396 | hist.SetNbins(3030);
|
---|
397 | }
|
---|
398 | }
|
---|
399 |
|
---|
400 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
|
---|
401 |
|
---|
402 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
403 | {
|
---|
404 | hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
|
---|
405 | j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
|
---|
406 | hist.InitBins();
|
---|
407 | hist.SetEventFrequency(fPulserFrequency);
|
---|
408 | }
|
---|
409 | else
|
---|
410 | {
|
---|
411 | hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
|
---|
412 | InitHists(hist,fCam->GetAverageBadArea(j),j);
|
---|
413 | }
|
---|
414 | }
|
---|
415 | }
|
---|
416 |
|
---|
417 | if (fAverageHiGainSectors->GetEntries()==0)
|
---|
418 | {
|
---|
419 | fAverageHiGainSectors->Expand(nsectors);
|
---|
420 |
|
---|
421 | for (Int_t j=0; j<nsectors; j++)
|
---|
422 | {
|
---|
423 | (*fAverageHiGainSectors)[j] =
|
---|
424 | new MHCalibrationChargeHiGainPix("AverageHiGainSector",
|
---|
425 | "Average HiGain FADC sums of pixel sector ");
|
---|
426 |
|
---|
427 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
---|
428 |
|
---|
429 | hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
|
---|
430 | hist.SetNbins(fAverageNbins);
|
---|
431 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
|
---|
432 |
|
---|
433 | InitHists(hist,fCam->GetAverageBadSector(j),j);
|
---|
434 |
|
---|
435 | }
|
---|
436 | }
|
---|
437 |
|
---|
438 | if (fAverageLoGainSectors->GetEntries()==0)
|
---|
439 | {
|
---|
440 | fAverageLoGainSectors->Expand(nsectors);
|
---|
441 |
|
---|
442 | for (Int_t j=0; j<nsectors; j++)
|
---|
443 | {
|
---|
444 | (*fAverageLoGainSectors)[j] =
|
---|
445 | new MHCalibrationChargeLoGainPix("AverageLoGainSector",
|
---|
446 | "Average LoGain FADC sums of pixel sector ");
|
---|
447 |
|
---|
448 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
---|
449 |
|
---|
450 | hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
|
---|
451 | hist.SetNbins(fgAverageNbinsLoGain);
|
---|
452 |
|
---|
453 | //
|
---|
454 | // Adapt the range for the case, the intense blue is used:
|
---|
455 | // FIXME: this is a nasty workaround, but for the moment necessary
|
---|
456 | // in order to avoid default memory space.
|
---|
457 | //
|
---|
458 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
459 | {
|
---|
460 | if ( fColor == MCalibrationCam::kBLUE)
|
---|
461 | {
|
---|
462 | hist.SetFirst(-10.5);
|
---|
463 | hist.SetLast(999.5);
|
---|
464 | hist.SetNbins(3030);
|
---|
465 | }
|
---|
466 | }
|
---|
467 |
|
---|
468 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
|
---|
469 |
|
---|
470 | InitHists(hist,fCam->GetAverageBadSector(j),j);
|
---|
471 | }
|
---|
472 | }
|
---|
473 |
|
---|
474 | fSumhiarea .Set(nareas);
|
---|
475 | fSumloarea .Set(nareas);
|
---|
476 | fTimehiarea .Set(nareas);
|
---|
477 | fTimeloarea .Set(nareas);
|
---|
478 | fSumhisector.Set(nsectors);
|
---|
479 | fSumlosector.Set(nsectors);
|
---|
480 | fTimehisector.Set(nsectors);
|
---|
481 | fTimelosector.Set(nsectors);
|
---|
482 |
|
---|
483 | fSathiarea .Set(nareas);
|
---|
484 | fSatloarea .Set(nareas);
|
---|
485 | fSathisector.Set(nsectors);
|
---|
486 | fSatlosector.Set(nsectors);
|
---|
487 |
|
---|
488 | return kTRUE;
|
---|
489 | }
|
---|
490 |
|
---|
491 |
|
---|
492 | // --------------------------------------------------------------------------
|
---|
493 | //
|
---|
494 | // Retrieves from MExtractedSignalCam:
|
---|
495 | // - first used LoGain FADC slice
|
---|
496 | //
|
---|
497 | // Retrieves from MGeomCam:
|
---|
498 | // - number of pixels
|
---|
499 | // - number of pixel areas
|
---|
500 | // - number of sectors
|
---|
501 | //
|
---|
502 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
---|
503 | //
|
---|
504 | // 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
|
---|
505 | // - MExtractedSignalPix::GetExtractedSignalHiGain();
|
---|
506 | // - MExtractedSignalPix::GetExtractedSignalLoGain();
|
---|
507 | //
|
---|
508 | // 2) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:
|
---|
509 | // - MExtractedSignalPix::GetNumHiGainSaturated();
|
---|
510 | // - MExtractedSignalPix::GetNumLoGainSaturated();
|
---|
511 | //
|
---|
512 | // 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
|
---|
513 | // - MRawEvtPixelIter::GetIdxMaxHiGainSample();
|
---|
514 | // - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
|
---|
515 | //
|
---|
516 | Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
|
---|
517 | {
|
---|
518 |
|
---|
519 | MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
|
---|
520 | if (!signal)
|
---|
521 | {
|
---|
522 | *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
|
---|
523 | return kFALSE;
|
---|
524 | }
|
---|
525 |
|
---|
526 | const UInt_t npixels = fGeom->GetNumPixels();
|
---|
527 | const UInt_t nareas = fGeom->GetNumAreas();
|
---|
528 | const UInt_t nsectors = fGeom->GetNumSectors();
|
---|
529 | const UInt_t lofirst = signal->GetFirstUsedSliceLoGain();
|
---|
530 |
|
---|
531 | fSumhiarea .Reset();
|
---|
532 | fSumloarea .Reset();
|
---|
533 | fTimehiarea .Reset();
|
---|
534 | fTimeloarea .Reset();
|
---|
535 | fSumhisector.Reset();
|
---|
536 | fSumlosector.Reset();
|
---|
537 | fTimehisector.Reset();
|
---|
538 | fTimelosector.Reset();
|
---|
539 |
|
---|
540 | fSathiarea .Reset();
|
---|
541 | fSatloarea .Reset();
|
---|
542 | fSathisector.Reset();
|
---|
543 | fSatlosector.Reset();
|
---|
544 |
|
---|
545 | for (UInt_t i=0; i<npixels; i++)
|
---|
546 | {
|
---|
547 |
|
---|
548 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
|
---|
549 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
|
---|
550 |
|
---|
551 | if (histhi.IsExcluded())
|
---|
552 | continue;
|
---|
553 |
|
---|
554 | const MExtractedSignalPix &pix = (*signal)[i];
|
---|
555 |
|
---|
556 | const Float_t sumhi = pix.GetExtractedSignalHiGain();
|
---|
557 | const Float_t sumlo = pix.GetExtractedSignalLoGain();
|
---|
558 |
|
---|
559 | if (!histhi.FillHistAndArray(sumhi))
|
---|
560 | fHiGainOverFlow[i]++;
|
---|
561 |
|
---|
562 | if (!histlo.FillHistAndArray(sumlo))
|
---|
563 | fLoGainOverFlow[i]++;
|
---|
564 |
|
---|
565 | const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
|
---|
566 | const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
|
---|
567 |
|
---|
568 | histhi.SetSaturated(sathi);
|
---|
569 | histlo.SetSaturated(satlo);
|
---|
570 |
|
---|
571 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
---|
572 | const Int_t sector = (*fGeom)[i].GetSector();
|
---|
573 |
|
---|
574 | fSumhiarea[aidx] += sumhi;
|
---|
575 | fSumloarea[aidx] += sumlo;
|
---|
576 | fSathiarea[aidx] += sathi;
|
---|
577 | fSatloarea[aidx] += satlo;
|
---|
578 |
|
---|
579 | fSumhisector[sector] += sumhi;
|
---|
580 | fSumlosector[sector] += sumlo;
|
---|
581 | fSathisector[sector] += sathi;
|
---|
582 | fSatlosector[sector] += satlo;
|
---|
583 | }
|
---|
584 |
|
---|
585 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
586 | while (pixel.Next())
|
---|
587 | {
|
---|
588 |
|
---|
589 | const UInt_t pixid = pixel.GetPixelId();
|
---|
590 |
|
---|
591 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
|
---|
592 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
|
---|
593 |
|
---|
594 | if (histhi.IsExcluded())
|
---|
595 | continue;
|
---|
596 |
|
---|
597 | const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
|
---|
598 | const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
|
---|
599 |
|
---|
600 | histhi.FillAbsTime(timehi);
|
---|
601 | histlo.FillAbsTime(timelo);
|
---|
602 |
|
---|
603 | const Int_t aidx = (*fGeom)[pixid].GetAidx();
|
---|
604 | const Int_t sector = (*fGeom)[pixid].GetSector();
|
---|
605 |
|
---|
606 | fTimehiarea[aidx] += timehi;
|
---|
607 | fTimeloarea[aidx] += timelo;
|
---|
608 |
|
---|
609 | fTimehisector[sector] += timehi;
|
---|
610 | fTimelosector[sector] += timelo;
|
---|
611 | }
|
---|
612 |
|
---|
613 | for (UInt_t j=0; j<nareas; j++)
|
---|
614 | {
|
---|
615 |
|
---|
616 | const Int_t npix = fAverageAreaNum[j];
|
---|
617 |
|
---|
618 | if (npix == 0)
|
---|
619 | continue;
|
---|
620 |
|
---|
621 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
---|
622 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
---|
623 |
|
---|
624 | hipix.FillHistAndArray(fSumhiarea[j]/npix);
|
---|
625 | lopix.FillHistAndArray(fSumloarea[j]/npix);
|
---|
626 |
|
---|
627 | hipix.SetSaturated(fSathiarea[j]/npix);
|
---|
628 | lopix.SetSaturated(fSatloarea[j]/npix);
|
---|
629 |
|
---|
630 | hipix.FillAbsTime(fTimehiarea[j]/npix);
|
---|
631 | lopix.FillAbsTime(fTimeloarea[j]/npix);
|
---|
632 |
|
---|
633 | }
|
---|
634 |
|
---|
635 | for (UInt_t j=0; j<nsectors; j++)
|
---|
636 | {
|
---|
637 |
|
---|
638 | const Int_t npix = fAverageSectorNum[j];
|
---|
639 |
|
---|
640 | if (npix == 0)
|
---|
641 | continue;
|
---|
642 |
|
---|
643 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
---|
644 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
---|
645 |
|
---|
646 | hipix.FillHistAndArray(fSumhisector[j]/npix);
|
---|
647 | lopix.FillHistAndArray(fSumlosector[j]/npix);
|
---|
648 |
|
---|
649 | hipix.SetSaturated(fSathisector[j]/npix);
|
---|
650 | lopix.SetSaturated(fSatlosector[j]/npix);
|
---|
651 |
|
---|
652 | hipix.FillAbsTime(fTimehisector[j]/npix);
|
---|
653 | lopix.FillAbsTime(fTimelosector[j]/npix);
|
---|
654 |
|
---|
655 | }
|
---|
656 |
|
---|
657 | return kTRUE;
|
---|
658 | }
|
---|
659 |
|
---|
660 | // --------------------------------------------------------------------------
|
---|
661 | //
|
---|
662 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
---|
663 | //
|
---|
664 | // 1) Returns if the pixel is excluded.
|
---|
665 | // 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
|
---|
666 | // or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
|
---|
667 | // 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
|
---|
668 | // MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
|
---|
669 | // otherwise the Hi-Gain ones.
|
---|
670 | // 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
|
---|
671 | // with the flags:
|
---|
672 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
|
---|
673 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
|
---|
674 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
|
---|
675 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
|
---|
676 | //
|
---|
677 | Bool_t MHCalibrationChargeCam::FinalizeHists()
|
---|
678 | {
|
---|
679 |
|
---|
680 | *fLog << endl;
|
---|
681 |
|
---|
682 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
---|
683 | {
|
---|
684 |
|
---|
685 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
|
---|
686 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
---|
687 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
688 |
|
---|
689 | if (histhi.IsExcluded())
|
---|
690 | continue;
|
---|
691 |
|
---|
692 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
693 | {
|
---|
694 | pix.SetHiGainSaturation();
|
---|
695 | histhi.CreateFourierSpectrum();
|
---|
696 | continue;
|
---|
697 | }
|
---|
698 |
|
---|
699 | if (fHiGainOverFlow[i])
|
---|
700 | {
|
---|
701 | *fLog << warn << GetDescriptor()
|
---|
702 | << ": Hi-Gain Histogram Overflow occurred " << fHiGainOverFlow[i]
|
---|
703 | << " times in pixel: " << i << " (without saturation!) " << endl;
|
---|
704 | bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
|
---|
705 | }
|
---|
706 |
|
---|
707 | FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
|
---|
708 | }
|
---|
709 |
|
---|
710 | for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
|
---|
711 | {
|
---|
712 |
|
---|
713 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
|
---|
714 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
715 |
|
---|
716 | if (histlo.IsExcluded())
|
---|
717 | continue;
|
---|
718 |
|
---|
719 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
---|
720 | {
|
---|
721 | *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
|
---|
722 | bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
|
---|
723 | histlo.CreateFourierSpectrum();
|
---|
724 | continue;
|
---|
725 | }
|
---|
726 |
|
---|
727 | if (fLoGainOverFlow[i])
|
---|
728 | {
|
---|
729 | *fLog << warn << GetDescriptor()
|
---|
730 | << ": Lo-Gain Histogram Overflow occurred " << fLoGainOverFlow[i]
|
---|
731 | << " times in pixel: " << i << " (without saturation!) " << endl;
|
---|
732 | bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow );
|
---|
733 | }
|
---|
734 |
|
---|
735 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
---|
736 |
|
---|
737 | if (pix.IsHiGainSaturation())
|
---|
738 | FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
|
---|
739 | }
|
---|
740 |
|
---|
741 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
---|
742 | {
|
---|
743 |
|
---|
744 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
---|
745 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
|
---|
746 | MBadPixelsPix &bad = fCam->GetAverageBadArea(j);
|
---|
747 |
|
---|
748 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
749 | {
|
---|
750 | pix.SetHiGainSaturation();
|
---|
751 | histhi.CreateFourierSpectrum();
|
---|
752 | continue;
|
---|
753 | }
|
---|
754 |
|
---|
755 | FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
|
---|
756 | }
|
---|
757 |
|
---|
758 | for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
|
---|
759 | {
|
---|
760 |
|
---|
761 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
---|
762 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
|
---|
763 | MBadPixelsPix &bad = fCam->GetAverageBadArea(j);
|
---|
764 |
|
---|
765 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
---|
766 | {
|
---|
767 | *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
|
---|
768 | histlo.CreateFourierSpectrum();
|
---|
769 | continue;
|
---|
770 | }
|
---|
771 |
|
---|
772 | if (pix.IsHiGainSaturation())
|
---|
773 | FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
|
---|
774 | }
|
---|
775 |
|
---|
776 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
---|
777 | {
|
---|
778 |
|
---|
779 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
---|
780 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
|
---|
781 | MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
|
---|
782 |
|
---|
783 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
784 | {
|
---|
785 | pix.SetHiGainSaturation();
|
---|
786 | histhi.CreateFourierSpectrum();
|
---|
787 | continue;
|
---|
788 | }
|
---|
789 |
|
---|
790 | FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
|
---|
791 | }
|
---|
792 |
|
---|
793 | for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
|
---|
794 | {
|
---|
795 |
|
---|
796 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
---|
797 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
|
---|
798 | MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
|
---|
799 |
|
---|
800 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
---|
801 | {
|
---|
802 | *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
|
---|
803 | bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
|
---|
804 | histlo.CreateFourierSpectrum();
|
---|
805 | continue;
|
---|
806 | }
|
---|
807 |
|
---|
808 | if (pix.IsHiGainSaturation())
|
---|
809 | FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
|
---|
810 | }
|
---|
811 |
|
---|
812 | //
|
---|
813 | // Perform the fitting for the High Gain (done in MHCalibrationCam)
|
---|
814 | //
|
---|
815 | FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
|
---|
816 | MBadPixelsPix::kHiGainNotFitted,
|
---|
817 | MBadPixelsPix::kHiGainOscillating);
|
---|
818 | //
|
---|
819 | // Perform the fitting for the Low Gain (done in MHCalibrationCam)
|
---|
820 | //
|
---|
821 | FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
|
---|
822 | MBadPixelsPix::kLoGainNotFitted,
|
---|
823 | MBadPixelsPix::kLoGainOscillating);
|
---|
824 |
|
---|
825 | return kTRUE;
|
---|
826 | }
|
---|
827 |
|
---|
828 | // --------------------------------------------------------------------------------
|
---|
829 | //
|
---|
830 | // Fill the absolute time results into MCalibrationChargePix
|
---|
831 | //
|
---|
832 | // Check absolute time validity:
|
---|
833 | // - Mean arrival time is at least fTimeLowerLimit slices from the lower edge
|
---|
834 | // - Mean arrival time is at least fUpperLimit slices from the upper edge
|
---|
835 | //
|
---|
836 | void MHCalibrationChargeCam::FinalizeAbsTimes(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
|
---|
837 | Byte_t first, Byte_t last)
|
---|
838 | {
|
---|
839 |
|
---|
840 | const Float_t mean = hist.GetAbsTimeMean();
|
---|
841 | const Float_t rms = hist.GetAbsTimeRms();
|
---|
842 |
|
---|
843 | pix.SetAbsTimeMean ( mean );
|
---|
844 | pix.SetAbsTimeRms ( rms );
|
---|
845 |
|
---|
846 | const Float_t lowerlimit = (Float_t)first + fTimeLowerLimit;
|
---|
847 | const Float_t upperlimit = (Float_t)last + fTimeUpperLimit;
|
---|
848 |
|
---|
849 | if ( mean < lowerlimit)
|
---|
850 | {
|
---|
851 | *fLog << warn << GetDescriptor()
|
---|
852 | << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," smaller than ",fTimeLowerLimit,
|
---|
853 | " FADC slices from lower edge in pixel ",hist.GetPixId()) << endl;
|
---|
854 | bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
|
---|
855 | }
|
---|
856 |
|
---|
857 | if ( mean > upperlimit )
|
---|
858 | {
|
---|
859 | *fLog << warn << GetDescriptor()
|
---|
860 | << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," greater than ",fTimeUpperLimit,
|
---|
861 | " FADC slices from upper edge in pixel ",hist.GetPixId()) << endl;
|
---|
862 | bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
|
---|
863 | }
|
---|
864 | }
|
---|
865 |
|
---|
866 | // --------------------------------------------------------------------------
|
---|
867 | //
|
---|
868 | // Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
|
---|
869 | // - MBadPixelsPix::kLoGainSaturation
|
---|
870 | //
|
---|
871 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
---|
872 | // - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
|
---|
873 | // - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
|
---|
874 | // - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
|
---|
875 | // - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
|
---|
876 | //
|
---|
877 | void MHCalibrationChargeCam::FinalizeBadPixels()
|
---|
878 | {
|
---|
879 |
|
---|
880 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
881 | {
|
---|
882 |
|
---|
883 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
884 | MCalibrationPix &pix = (*fCam)[i];
|
---|
885 |
|
---|
886 | if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
|
---|
887 | if (!pix.IsHiGainSaturation())
|
---|
888 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
889 |
|
---|
890 | if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
|
---|
891 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
892 |
|
---|
893 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
|
---|
894 | if (pix.IsHiGainSaturation())
|
---|
895 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
896 |
|
---|
897 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
|
---|
898 | if (pix.IsHiGainSaturation())
|
---|
899 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
900 |
|
---|
901 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
|
---|
902 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
---|
903 | }
|
---|
904 | }
|
---|
905 |
|
---|
906 | // --------------------------------------------------------------------------
|
---|
907 | //
|
---|
908 | // Dummy, needed by MCamEvent
|
---|
909 | //
|
---|
910 | Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
911 | {
|
---|
912 | return kTRUE;
|
---|
913 | }
|
---|
914 |
|
---|
915 | // --------------------------------------------------------------------------
|
---|
916 | //
|
---|
917 | // Calls MHGausEvents::DrawClone() for pixel idx
|
---|
918 | //
|
---|
919 | void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
|
---|
920 | {
|
---|
921 | (*this)[idx].DrawClone();
|
---|
922 | }
|
---|
923 |
|
---|
924 |
|
---|
925 | // -----------------------------------------------------------------------------
|
---|
926 | //
|
---|
927 | // Default draw:
|
---|
928 | //
|
---|
929 | // Displays the averaged areas, both High Gain and Low Gain
|
---|
930 | //
|
---|
931 | // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
|
---|
932 | //
|
---|
933 | void MHCalibrationChargeCam::Draw(const Option_t *opt)
|
---|
934 | {
|
---|
935 |
|
---|
936 | const Int_t nareas = fAverageHiGainAreas->GetEntries();
|
---|
937 | if (nareas == 0)
|
---|
938 | return;
|
---|
939 |
|
---|
940 | TString option(opt);
|
---|
941 | option.ToLower();
|
---|
942 |
|
---|
943 | if (!option.Contains("datacheck"))
|
---|
944 | {
|
---|
945 | MHCalibrationCam::Draw(opt);
|
---|
946 | return;
|
---|
947 | }
|
---|
948 |
|
---|
949 | //
|
---|
950 | // From here on , the datacheck - Draw
|
---|
951 | //
|
---|
952 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
---|
953 | pad->SetBorderMode(0);
|
---|
954 | pad->Divide(1,nareas);
|
---|
955 |
|
---|
956 | //
|
---|
957 | // Loop over inner and outer pixels
|
---|
958 | //
|
---|
959 | for (Int_t i=0; i<nareas;i++)
|
---|
960 | {
|
---|
961 |
|
---|
962 | pad->cd(i+1);
|
---|
963 |
|
---|
964 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(i);
|
---|
965 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
|
---|
966 | //
|
---|
967 | // Ask for Hi-Gain saturation
|
---|
968 | //
|
---|
969 | if (hipix.GetSaturated() > fNumHiGainSaturationLimit*hipix.GetHGausHist()->GetEntries())
|
---|
970 | DrawDataCheckPixel(lopix,i ? gkLoGainOuterRefLines : gkLoGainInnerRefLines);
|
---|
971 | else
|
---|
972 | DrawDataCheckPixel(hipix,i ? gkHiGainOuterRefLines : gkHiGainInnerRefLines);
|
---|
973 | }
|
---|
974 | }
|
---|
975 |
|
---|
976 |
|
---|
977 | // --------------------------------------------------------------------------
|
---|
978 | //
|
---|
979 | // Our own clone function is necessary since root 3.01/06 or Mars 0.4
|
---|
980 | // I don't know the reason.
|
---|
981 | //
|
---|
982 | // Creates new MHCalibrationCam
|
---|
983 | //
|
---|
984 | TObject *MHCalibrationChargeCam::Clone(const char *name) const
|
---|
985 | {
|
---|
986 |
|
---|
987 | const Int_t navhi = fAverageHiGainAreas->GetEntries();
|
---|
988 | const Int_t navlo = fAverageLoGainAreas->GetEntries();
|
---|
989 | const Int_t nsehi = fAverageHiGainSectors->GetEntries();
|
---|
990 | const Int_t nselo = fAverageLoGainSectors->GetEntries();
|
---|
991 |
|
---|
992 | //
|
---|
993 | // FIXME, this might be done faster and more elegant, by direct copy.
|
---|
994 | //
|
---|
995 | MHCalibrationChargeCam *cam = new MHCalibrationChargeCam();
|
---|
996 |
|
---|
997 | cam->fAverageHiGainAreas->Expand(navhi);
|
---|
998 | cam->fAverageLoGainAreas->Expand(navlo);
|
---|
999 | cam->fAverageHiGainSectors->Expand(nsehi);
|
---|
1000 | cam->fAverageLoGainSectors->Expand(nselo);
|
---|
1001 |
|
---|
1002 | cam->fAverageHiGainAreas->Expand(navhi);
|
---|
1003 | cam->fAverageLoGainAreas->Expand(navlo);
|
---|
1004 | cam->fAverageHiGainSectors->Expand(nsehi);
|
---|
1005 | cam->fAverageLoGainSectors->Expand(nselo);
|
---|
1006 |
|
---|
1007 | for (int i=0; i<navhi; i++)
|
---|
1008 | (*cam->fAverageHiGainAreas) [i] = (*fAverageHiGainAreas) [i]->Clone();
|
---|
1009 | for (int i=0; i<navlo; i++)
|
---|
1010 | (*cam->fAverageLoGainAreas) [i] = (*fAverageLoGainAreas) [i]->Clone();
|
---|
1011 | for (int i=0; i<nsehi; i++)
|
---|
1012 | (*cam->fAverageHiGainSectors)[i] = (*fAverageHiGainSectors)[i]->Clone();
|
---|
1013 | for (int i=0; i<nselo; i++)
|
---|
1014 | (*cam->fAverageLoGainSectors)[i] = (*fAverageLoGainSectors)[i]->Clone();
|
---|
1015 |
|
---|
1016 | cam->fAverageAreaNum = fAverageAreaNum;
|
---|
1017 | cam->fAverageAreaSat = fAverageAreaSat;
|
---|
1018 | cam->fAverageAreaSigma = fAverageAreaSigma;
|
---|
1019 | cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
|
---|
1020 | cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
|
---|
1021 | cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
|
---|
1022 | cam->fAverageSectorNum = fAverageSectorNum;
|
---|
1023 | cam->fRunNumbers = fRunNumbers;
|
---|
1024 |
|
---|
1025 | cam->fColor = fColor;
|
---|
1026 | cam->fPulserFrequency = fPulserFrequency;
|
---|
1027 | cam->fAverageNbins = fAverageNbins;
|
---|
1028 |
|
---|
1029 | return cam;
|
---|
1030 |
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 | void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[])
|
---|
1034 | {
|
---|
1035 |
|
---|
1036 | TVirtualPad *newpad = gPad;
|
---|
1037 | newpad->Divide(1,2);
|
---|
1038 | newpad->cd(1);
|
---|
1039 |
|
---|
1040 | gPad->SetTicks();
|
---|
1041 | if (!pix.IsEmpty() && !pix.IsOnlyOverflow())
|
---|
1042 | gPad->SetLogy();
|
---|
1043 |
|
---|
1044 | TH1F *hist = pix.GetHGausHist();
|
---|
1045 |
|
---|
1046 | TH2D *null = new TH2D("Null",hist->GetTitle(),100,pix.GetFirst() > -1. ? 0. : 100.,pix.GetLast()/2.,
|
---|
1047 | 100,0.,hist->GetEntries()/10.);
|
---|
1048 |
|
---|
1049 | null->SetDirectory(NULL);
|
---|
1050 | null->SetBit(kCanDelete);
|
---|
1051 | //
|
---|
1052 | // set the labels bigger
|
---|
1053 | //
|
---|
1054 | TAxis *xaxe = null->GetXaxis();
|
---|
1055 | TAxis *yaxe = null->GetYaxis();
|
---|
1056 | xaxe->CenterTitle();
|
---|
1057 | yaxe->CenterTitle();
|
---|
1058 | xaxe->SetTitleSize(0.07);
|
---|
1059 | yaxe->SetTitleSize(0.07);
|
---|
1060 | xaxe->SetTitleOffset(0.7);
|
---|
1061 | yaxe->SetTitleOffset(0.55);
|
---|
1062 | xaxe->SetLabelSize(0.06);
|
---|
1063 | yaxe->SetLabelSize(0.06);
|
---|
1064 |
|
---|
1065 | xaxe->SetTitle(hist->GetXaxis()->GetTitle());
|
---|
1066 | yaxe->SetTitle(hist->GetYaxis()->GetTitle());
|
---|
1067 | null->Draw();
|
---|
1068 | hist->Draw("same");
|
---|
1069 |
|
---|
1070 | gStyle->SetOptFit();
|
---|
1071 |
|
---|
1072 | if (pix.GetFGausFit())
|
---|
1073 | {
|
---|
1074 | switch ( fColor )
|
---|
1075 | {
|
---|
1076 | case MCalibrationCam::kGREEN:
|
---|
1077 | pix.GetFGausFit()->SetLineColor(kGreen);
|
---|
1078 | break;
|
---|
1079 | case MCalibrationCam::kBLUE:
|
---|
1080 | pix.GetFGausFit()->SetLineColor(kBlue);
|
---|
1081 | break;
|
---|
1082 | case MCalibrationCam::kUV:
|
---|
1083 | pix.GetFGausFit()->SetLineColor(106);
|
---|
1084 | break;
|
---|
1085 | case MCalibrationCam::kCT1:
|
---|
1086 | pix.GetFGausFit()->SetLineColor(006);
|
---|
1087 | break;
|
---|
1088 | default:
|
---|
1089 | pix.GetFGausFit()->SetLineColor(kRed);
|
---|
1090 | }
|
---|
1091 | pix.GetFGausFit()->Draw("same");
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | DisplayRefLines(null,refline);
|
---|
1095 |
|
---|
1096 | newpad->cd(2);
|
---|
1097 | gPad->SetTicks();
|
---|
1098 |
|
---|
1099 | pix.DrawEvents();
|
---|
1100 | return;
|
---|
1101 |
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 |
|
---|
1105 | void MHCalibrationChargeCam::DisplayRefLines(const TH2D *hist, const Float_t refline[]) const
|
---|
1106 | {
|
---|
1107 |
|
---|
1108 | TLine *green1 = new TLine(refline[0],0.,refline[0],hist->GetYaxis()->GetXmax());
|
---|
1109 | green1->SetBit(kCanDelete);
|
---|
1110 | green1->SetLineColor(kGreen);
|
---|
1111 | green1->SetLineStyle(2);
|
---|
1112 | green1->SetLineWidth(3);
|
---|
1113 | green1->Draw();
|
---|
1114 |
|
---|
1115 | TLine *green5 = new TLine(refline[6],0.,refline[6],hist->GetYaxis()->GetXmax());
|
---|
1116 | green5->SetBit(kCanDelete);
|
---|
1117 | green5->SetLineColor(8);
|
---|
1118 | green5->SetLineStyle(2);
|
---|
1119 | green5->SetLineWidth(3);
|
---|
1120 | green5->Draw();
|
---|
1121 |
|
---|
1122 | TLine *blue1 = new TLine(refline[1],0.,refline[1],hist->GetYaxis()->GetXmax());
|
---|
1123 | blue1->SetBit(kCanDelete);
|
---|
1124 | blue1->SetLineColor(227);
|
---|
1125 | blue1->SetLineStyle(2);
|
---|
1126 | blue1->SetLineWidth(3);
|
---|
1127 | blue1->Draw();
|
---|
1128 |
|
---|
1129 | TLine *blue5 = new TLine(refline[2],0.,refline[2],hist->GetYaxis()->GetXmax());
|
---|
1130 | blue5->SetBit(kCanDelete);
|
---|
1131 | blue5->SetLineColor(68);
|
---|
1132 | blue5->SetLineStyle(2);
|
---|
1133 | blue5->SetLineWidth(3);
|
---|
1134 | blue5->Draw();
|
---|
1135 |
|
---|
1136 | TLine *blue10 = new TLine(refline[3],0.,refline[3],hist->GetYaxis()->GetXmax());
|
---|
1137 | blue10->SetBit(kCanDelete);
|
---|
1138 | blue10->SetLineColor(4);
|
---|
1139 | blue10->SetLineStyle(2);
|
---|
1140 | blue10->SetLineWidth(3);
|
---|
1141 | blue10->Draw();
|
---|
1142 |
|
---|
1143 | TLine *uv10 = new TLine(refline[4],0.,refline[4],hist->GetYaxis()->GetXmax());
|
---|
1144 | uv10->SetBit(kCanDelete);
|
---|
1145 | uv10->SetLineColor(106);
|
---|
1146 | uv10->SetLineStyle(2);
|
---|
1147 | uv10->SetLineWidth(3);
|
---|
1148 | uv10->Draw();
|
---|
1149 |
|
---|
1150 | TLine *ct1 = new TLine(refline[5],0.,refline[5],hist->GetYaxis()->GetXmax());
|
---|
1151 | ct1->SetBit(kCanDelete);
|
---|
1152 | ct1->SetLineColor(6);
|
---|
1153 | ct1->SetLineStyle(2);
|
---|
1154 | ct1->SetLineWidth(3);
|
---|
1155 | ct1->Draw();
|
---|
1156 |
|
---|
1157 | TLegend *leg = new TLegend(0.7,0.35,0.9,0.99);
|
---|
1158 | leg->SetBit(kCanDelete);
|
---|
1159 | leg->AddEntry(green1,"1 Led GREEN","l");
|
---|
1160 | leg->AddEntry(green5,"5 Leds GREEN","l");
|
---|
1161 | leg->AddEntry(blue1,"1 Led BLUE","l");
|
---|
1162 | leg->AddEntry(blue5,"5 Leds BLUE","l");
|
---|
1163 | leg->AddEntry(blue10,"10 Leds BLUE","l");
|
---|
1164 | leg->AddEntry(uv10,"10 Leds UV","l");
|
---|
1165 | leg->AddEntry(ct1,"CT1-Pulser","l");
|
---|
1166 |
|
---|
1167 | leg->Draw();
|
---|
1168 | }
|
---|