source: trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc@ 3012

Last change on this file since 3012 was 2951, checked in by gaug, 21 years ago
*** empty log message ***
File size: 4.0 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): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MPedestalPix //
28// //
29// This is the storage container to hold informations about the pedestal //
30// (offset) value of one Pixel (PMT). //
31// //
32/////////////////////////////////////////////////////////////////////////////
33#include "MPedestalPix.h"
34
35#include "MLog.h"
36#include "MLogManip.h"
37
38ClassImp(MPedestalPix);
39
40using namespace std;
41
42MPedestalPix::MPedestalPix() : fHist(NULL), fFlags(0)
43{
44 Clear();
45}
46
47MPedestalPix::~MPedestalPix()
48{
49 if (fHist)
50 delete fHist;
51}
52
53
54// ------------------------------------------------------------------------
55//
56// Invalidate values
57//
58void MPedestalPix::Clear(Option_t *o)
59{
60 fPedestal = -1.;
61 fPedestalRms = -1.;
62
63 fMean = -1.;
64 fMeanErr = -1.;
65 fSigma = -1.;
66 fProb = -1.;
67
68 CLRBIT(fFlags,kFitted);
69 CLRBIT(fFlags,kFitValid);
70
71}
72
73void MPedestalPix::InitUseHists()
74{
75 fPedestal = 0.;
76 fPedestalRms = 0.;
77
78 fHist = new MHPedestalPixel("MHPedestalPixel","Pedestal Histograms Pixel ");
79
80 if (!fHist)
81 *fLog << warn << dbginf << " Could not create MHCalibrationPixel " << endl;
82
83}
84
85void MPedestalPix::FillHists(const Float_t f)
86{
87
88 if (!fHist)
89 return;
90
91 fHist->FillCharge(f);
92 fHist->FillChargevsN(f);
93}
94
95
96void MPedestalPix::Set(Float_t m, Float_t r)
97{
98 fPedestal = m;
99 fPedestalRms = r;
100}
101
102Bool_t MPedestalPix::IsValid() const
103{
104 return fPedestal>=0||fPedestalRms>=0;
105}
106
107Bool_t MPedestalPix::IsFitted() const
108{
109 return TESTBIT(fFlags,kFitted);
110}
111
112Bool_t MPedestalPix::IsFitValid() const
113{
114 return TESTBIT(fFlags,kFitValid);
115}
116
117// --------------------------------------------------------------------------
118//
119// 1) Return if the charge distribution is already succesfully fitted
120// or if the histogram is empty
121// 2) Cut the histograms empty edges
122// 3) Fit the histograms with a Gaussian
123// 4) In case of failure print out the fit results
124// 5) Retrieve the results and store them in this class
125//
126void MPedestalPix::FitCharge()
127{
128
129 //
130 // 1) Return if the charge distribution is already succesfully fitted
131 // or if the histogram is empty
132 //
133 if (fHist->IsFitOK() || fHist->IsEmpty())
134 return;
135
136
137 fHist->CutAllEdges();
138
139 //
140 // 2) Fit the Lo Gain histograms with a Gaussian
141 //
142 if(fHist->FitCharge())
143 SETBIT(fFlags,kFitted);
144 else
145 CLRBIT(fFlags,kFitted);
146
147 //
148 // 6) Retrieve the results and store them in this class
149 //
150 fMean = fHist->GetChargeMean();
151 fMeanErr = fHist->GetChargeMeanErr();
152 fSigma = fHist->GetChargeSigma();
153 fSigmaErr = fHist->GetChargeSigmaErr();
154 fProb = fHist->GetChargeProb();
155
156 if (CheckFitValidity())
157 SETBIT(fFlags,kFitValid);
158 else
159 CLRBIT(fFlags,kFitValid);
160
161 return;
162}
163
164Bool_t MPedestalPix::CheckFitValidity()
165{
166
167 if (fProb < 0.001)
168 return kFALSE;
169
170 return kTRUE;
171
172}
Note: See TracBrowser for help on using the repository browser.