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

Last change on this file since 2692 was 2679, checked in by gaug, 21 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 else
114 *fLog << warn << "Cannot set lower fit range to suppress cosmics: 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 if (fHiGainSaturation)
149 {
150
151 Float_t nsb = TMath::Sqrt(fPedRms*fPedRms - fElectronicPedRms*fElectronicPedRms);
152 // Float_t logainrms = fElectronicPedRms + (TMath::Sqrt(fPedRms*fPedRms - fElectronicPedRms*fElectronicPedRms));
153
154 if (nsb > 0.)
155 {
156 Float_t logainrms = (TMath::Sqrt(nsb*nsb + 100.*fElectronicPedRms*fElectronicPedRms));
157 fRSigmaSquare = (fSigmaCharge*fSigmaCharge) - (logainrms*logainrms);
158 }
159 else
160 fRSigmaSquare = fSigmaCharge*fSigmaCharge - (100.*fElectronicPedRms*fElectronicPedRms);
161 }
162 else
163 fRSigmaSquare = (fSigmaCharge*fSigmaCharge) - (fPedRms*fPedRms);
164
165 if (fRSigmaSquare > 0. )
166 {
167 fPheFFactorMethod = fFactor * fCharge*fCharge / fRSigmaSquare;
168 fConversionFFactorMethod = fPheFFactorMethod / fCharge ;
169 }
170 else
171 {
172 *fLog << warn << "Cannot apply F-Factor method: Reduced Sigmas are smaller than 0 in pixel: "
173 << fPixId << endl;
174 }
175
176 }
177
178 return kTRUE;
179
180}
181
182
183void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
184{
185
186 fPed = ped;
187 fPedRms = pedrms;
188
189}
190
191Bool_t MCalibrationPix::FitTime()
192{
193
194 if (fHiGainSaturation)
195 {
196 if(!fHist->FitTimeLoGain())
197 {
198 *fLog << warn << "Could not fit Lo Gain times of pixel " << fPixId << endl;
199 fHist->PrintTimeFitResult();
200 return kFALSE;
201 }
202 }
203 else
204 {
205 if(!fHist->FitTimeHiGain())
206 {
207 *fLog << warn << "Could not fit Hi Gain times of pixel " << fPixId << endl;
208 fHist->PrintTimeFitResult();
209 return kFALSE;
210 }
211 }
212
213 fTime = fHist->GetTimeMean();
214 fSigmaTime = fHist->GetTimeSigma();
215 fTimeChiSquare = fHist->GetTimeChiSquare();
216
217 return kTRUE;
218}
219
Note: See TracBrowser for help on using the repository browser.