source: trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc@ 2715

Last change on this file since 2715 was 2699, checked in by gaug, 22 years ago
*** empty log message ***
File size: 5.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-2001
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MCalibrationPix //
28// //
29// This is the storage container to hold informations about the pedestal //
30// (offset) value of one Pixel (PMT). //
31// //
32/////////////////////////////////////////////////////////////////////////////
33#include "MCalibrationPix.h"
34
35#include "MLog.h"
36#include "MLogManip.h"
37
38ClassImp(MCalibrationPix);
39
40using namespace std;
41
42// --------------------------------------------------------------------------
43//
44// Default Constructor.
45//
46MCalibrationPix::MCalibrationPix(const char *name, const char *title)
47 : fPixId(-1),
48 fCharge(-1.),
49 fErrCharge(-1.),
50 fSigmaCharge(-1.),
51 fErrSigmaCharge(-1.),
52 fRSigmaSquare(-1.),
53 fChargeProb(-1.),
54 fPed(-1.),
55 fPedRms(-1.),
56 fTime(-1.),
57 fSigmaTime(-1.),
58 fTimeChiSquare(-1.),
59 fFactor(1.3),
60 fPheFFactorMethod(-1.),
61 fConversionFFactorMethod(-1.),
62 fConversionBlindPixelMethod(-1.),
63 fConversionPINDiodeMethod(-1.),
64 fConversionErrorFFactorMethod(-1.),
65 fConversionErrorBlindPixelMethod(-1.),
66 fConversionErrorPINDiodeMethod(-1.),
67 fConversionSigmaFFactorMethod(-1.),
68 fConversionSigmaBlindPixelMethod(-1.),
69 fConversionSigmaPINDiodeMethod(-1.),
70 fHiGainSaturation(kFALSE),
71 fElectronicPedRms(1.5)
72{
73
74 fName = name ? name : "MCalibrationPixel";
75 fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
76
77 fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
78
79}
80
81MCalibrationPix::~MCalibrationPix()
82{
83 delete fHist;
84}
85
86
87void MCalibrationPix::DefinePixId(Int_t i)
88{
89
90 fPixId = i;
91 fHist->ChangeHistId(i);
92
93}
94
95
96// ------------------------------------------------------------------------
97//
98// Invalidate values
99//
100void MCalibrationPix::Clear(Option_t *o)
101{
102 fHist->Reset();
103}
104
105Bool_t MCalibrationPix::FitCharge()
106{
107
108 if (fHist->IsFitOK())
109 return kTRUE;
110
111 if (fPed && fPedRms)
112 fHist->SetLowerFitRange(1.5*fPedRms);
113 else
114 *fLog << warn << "Cannot set lower fit range: Pedestals not available" << endl;
115
116 if (fHist->UseLoGain())
117 {
118
119 SetHiGainSaturation();
120
121 if(!fHist->FitChargeLoGain())
122 {
123 *fLog << warn << "Could not fit Lo Gain charges of pixel " << fPixId << endl;
124 fHist->PrintChargeFitResult();
125 // return kFALSE;
126 }
127 }
128 else
129 {
130 if(!fHist->FitChargeHiGain())
131 {
132 *fLog << warn << "Could not fit Hi Gain charges of pixel " << fPixId << endl;
133 fHist->PrintChargeFitResult();
134 // return kFALSE;
135 }
136 }
137
138
139 fCharge = fHist->GetChargeMean();
140 fErrCharge = fHist->GetChargeMeanErr();
141 fSigmaCharge = fHist->GetChargeSigma();
142 fErrSigmaCharge = fHist->GetChargeSigmaErr();
143 fChargeProb = fHist->GetChargeProb();
144
145 if ((fPed > 0.) && (fPedRms > 0.))
146 {
147
148 Float_t pedrmssquare = fPedRms*fPedRms;
149 Float_t sigmasquare = fSigmaCharge*fSigmaCharge;
150
151 if (fHiGainSaturation)
152 {
153
154 Float_t logainrmssquare = fElectronicPedRms*fElectronicPedRms;
155 Float_t nsbsquare = pedrmssquare - logainrmssquare;
156 // Float_t logainrms = fElectronicPedRms + (TMath::Sqrt(fPedRms*fPedRms - fElectronicPedRms*fElectronicPedRms));
157
158 if (nsbsquare > 0.)
159 logainrmssquare = nsbsquare/100. + logainrmssquare;
160
161 fRSigmaSquare = sigmasquare - logainrmssquare;
162
163 if (fRSigmaSquare > 0.)
164 fPheFFactorMethod = fFactor*(fCharge*fCharge/100.) / fRSigmaSquare;
165
166 }
167 else /* if (fHiGainSaturation) */
168 {
169 fRSigmaSquare = sigmasquare - pedrmssquare;
170 fPheFFactorMethod = fFactor * fCharge*fCharge / fRSigmaSquare;
171 }
172
173
174 if (fCharge > 0.)
175 fConversionFFactorMethod = fPheFFactorMethod / fCharge ;
176
177 else
178 *fLog << warn << "Cannot apply F-Factor method: Reduced Sigmas are smaller than 0 in pixel: "
179 << fPixId << endl;
180
181 } /* if ((fPed > 0.) && (fPedRms > 0.)) */
182
183 return kTRUE;
184
185}
186
187
188void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
189{
190
191 fPed = ped;
192 fPedRms = pedrms;
193
194}
195
196Bool_t MCalibrationPix::FitTime()
197{
198
199 if (fHiGainSaturation)
200 {
201 if(!fHist->FitTimeLoGain())
202 {
203 *fLog << warn << "Could not fit Lo Gain times of pixel " << fPixId << endl;
204 fHist->PrintTimeFitResult();
205 return kFALSE;
206 }
207 }
208 else
209 {
210 if(!fHist->FitTimeHiGain())
211 {
212 *fLog << warn << "Could not fit Hi Gain times of pixel " << fPixId << endl;
213 fHist->PrintTimeFitResult();
214 return kFALSE;
215 }
216 }
217
218 fTime = fHist->GetTimeMean();
219 fSigmaTime = fHist->GetTimeSigma();
220 fTimeChiSquare = fHist->GetTimeChiSquare();
221
222 return kTRUE;
223}
224
Note: See TracBrowser for help on using the repository browser.