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

Last change on this file since 2673 was 2666, checked in by gaug, 22 years ago
*** empty log message ***
File size: 5.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-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
114 else
115 *fLog << warn << "Cannot set lower fit range to suppress cosmics: Pedestals not available" << endl;
116
117
118 if (fHist->UseLoGain())
119 {
120
121 SetHiGainSaturation();
122
123 if(!fHist->FitChargeLoGain())
124 {
125 *fLog << warn << "Could not fit Lo Gain charges of pixel " << fPixId << endl;
126 fHist->PrintChargeFitResult();
127 // return kFALSE;
128 }
129 }
130 else
131 {
132 if(!fHist->FitChargeHiGain())
133 {
134 *fLog << warn << "Could not fit Hi Gain charges of pixel " << fPixId << endl;
135 fHist->PrintChargeFitResult();
136 // return kFALSE;
137 }
138 }
139
140
141 fCharge = fHist->GetChargeMean();
142 fErrCharge = fHist->GetChargeMeanErr();
143 fSigmaCharge = fHist->GetChargeSigma();
144 fErrSigmaCharge = fHist->GetChargeSigmaErr();
145 fChargeProb = fHist->GetChargeProb();
146
147 if ((fPed > 0.) && (fPedRms > 0.))
148 {
149
150 if (fHiGainSaturation)
151 {
152
153 Float_t nsb = TMath::Sqrt(fPedRms*fPedRms - fElectronicPedRms*fElectronicPedRms);
154 // Float_t logainrms = fElectronicPedRms + (TMath::Sqrt(fPedRms*fPedRms - fElectronicPedRms*fElectronicPedRms));
155
156 if (nsb > 0.)
157 {
158 Float_t logainrms = (TMath::Sqrt(nsb*nsb + 100.*fElectronicPedRms*fElectronicPedRms));
159 fRSigmaSquare = (fSigmaCharge*fSigmaCharge) - (logainrms*logainrms);
160 }
161 else
162 fRSigmaSquare = fSigmaCharge*fSigmaCharge - (100.*fElectronicPedRms*fElectronicPedRms);
163 }
164 else
165 fRSigmaSquare = (fSigmaCharge*fSigmaCharge) - (fPedRms*fPedRms);
166
167 if (fRSigmaSquare > 0. )
168 {
169 fPheFFactorMethod = fFactor * fCharge*fCharge / fRSigmaSquare;
170 fConversionFFactorMethod = fPheFFactorMethod / fCharge ;
171 }
172 else
173 {
174 *fLog << warn << "Cannot apply F-Factor method: Reduced Sigmas are smaller than 0 in pixel: "
175 << fPixId << endl;
176 }
177
178 }
179
180 return kTRUE;
181
182}
183
184
185void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
186{
187
188 fPed = ped;
189 fPedRms = pedrms;
190
191}
192
193Bool_t MCalibrationPix::FitTime()
194{
195
196 if (fHiGainSaturation)
197 {
198 if(!fHist->FitTimeLoGain())
199 {
200 *fLog << warn << "Could not fit Lo Gain times of pixel " << fPixId << endl;
201 fHist->PrintTimeFitResult();
202 return kFALSE;
203 }
204 }
205 else
206 {
207 if(!fHist->FitTimeHiGain())
208 {
209 *fLog << warn << "Could not fit Hi Gain times of pixel " << fPixId << endl;
210 fHist->PrintTimeFitResult();
211 return kFALSE;
212 }
213 }
214
215 fTime = fHist->GetTimeMean();
216 fSigmaTime = fHist->GetTimeSigma();
217 fTimeChiSquare = fHist->GetTimeChiSquare();
218
219 return kTRUE;
220}
221
Note: See TracBrowser for help on using the repository browser.