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

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