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

Last change on this file since 2658 was 2658, checked in by gaug, 21 years ago
*** empty log message ***
File size: 5.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-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 fTimeProb(-1.),
59 fFactor(1.3),
60 fPheFFactorMethod(-1.),
61 fConversionFFactorMethod(-1.),
62 fHiGainSaturation(kFALSE),
63 fElectronicPedRms(3.67)
64{
65
66 fName = name ? name : "MCalibrationPixel";
67 fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
68
69 fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
70
71}
72
73MCalibrationPix::~MCalibrationPix()
74{
75 delete fHist;
76}
77
78
79void MCalibrationPix::DefinePixId(Int_t i)
80{
81
82 fPixId = i;
83 fHist->ChangeHistId(i);
84
85}
86
87
88// ------------------------------------------------------------------------
89//
90// Invalidate values
91//
92void MCalibrationPix::Clear(Option_t *o)
93{
94 fHist->Reset();
95}
96
97Bool_t MCalibrationPix::FitCharge()
98{
99
100 if (fHist->IsFitOK())
101 return kTRUE;
102
103 if (fPed && fPedRms)
104 fHist->SetLowerFitRange(1.5*fPedRms);
105
106 else
107 *fLog << warn << "Cannot set lower fit range to suppress cosmics: Pedestals not available" << endl;
108
109
110 if (fHist->UseLoGain())
111 {
112
113 SetHiGainSaturation();
114
115 if(!fHist->FitChargeLoGain())
116 {
117 *fLog << warn << "Could not fit Lo Gain charges of pixel " << fPixId << endl;
118 fHist->PrintChargeFitResult();
119 // return kFALSE;
120 }
121 }
122 else
123 {
124 if(!fHist->FitChargeHiGain())
125 {
126 *fLog << warn << "Could not fit Hi Gain charges of pixel " << fPixId << endl;
127 fHist->PrintChargeFitResult();
128 // return kFALSE;
129 }
130 }
131
132
133 fCharge = fHist->GetChargeMean();
134 fErrCharge = fHist->GetChargeMeanErr();
135 fSigmaCharge = fHist->GetChargeSigma();
136 fErrSigmaCharge = fHist->GetChargeSigmaErr();
137 fChargeProb = fHist->GetChargeProb();
138
139 if ((fPed > 0.) && (fPedRms > 0.))
140 {
141
142 if (fHiGainSaturation)
143 {
144
145 Float_t logainrms = fElectronicPedRms + (TMath::Sqrt(fPedRms*fPedRms - fElectronicPedRms*fElectronicPedRms));
146 if (logainrms > 0.)
147 fRSigmaSquare = (fSigmaCharge*fSigmaCharge) - (logainrms*logainrms);
148 else
149 fRSigmaSquare = fSigmaCharge*fSigmaCharge;
150
151 }
152 else
153 fRSigmaSquare = (fSigmaCharge*fSigmaCharge) - (fPedRms*fPedRms);
154
155 if (fRSigmaSquare > 0. )
156 {
157 fPheFFactorMethod = fFactor * fCharge*fCharge / fRSigmaSquare;
158 fConversionFFactorMethod = fPheFFactorMethod / fCharge ;
159 }
160 else
161 {
162 *fLog << warn << "Cannot apply F-Factor method: Reduced Sigmas are smaller than 0 in pixel: "
163 << fPixId << endl;
164 }
165
166 }
167
168 return kTRUE;
169
170}
171
172
173void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
174{
175
176 fPed = ped;
177 fPedRms = pedrms;
178
179}
180
181Bool_t MCalibrationPix::FitTime()
182{
183
184 if (fHiGainSaturation)
185 {
186 if(!fHist->FitTimeLoGain())
187 {
188 *fLog << warn << "Could not fit Lo Gain times of pixel " << fPixId << endl;
189 fHist->PrintTimeFitResult();
190 return kFALSE;
191 }
192 }
193 else
194 {
195 if(!fHist->FitTimeHiGain())
196 {
197 *fLog << warn << "Could not fit Hi Gain times of pixel " << fPixId << endl;
198 fHist->PrintTimeFitResult();
199 return kFALSE;
200 }
201 }
202
203 fTime = fHist->GetTimeMean();
204 fSigmaTime = fHist->GetTimeSigma();
205 fTimeProb = fHist->GetTimeProb();
206
207 return kTRUE;
208}
209
Note: See TracBrowser for help on using the repository browser.