source: trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc@ 2970

Last change on this file since 2970 was 2970, checked in by gaug, 21 years ago
*** empty log message ***
File size: 7.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): 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// MPedestalCam //
28// //
29// Hold the Pedestal information for all pixels in the camera //
30// //
31/////////////////////////////////////////////////////////////////////////////
32#include "MPedestalCam.h"
33#include "MPedestalPix.h"
34
35#include <TClonesArray.h>
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40#include "MGeomCam.h"
41
42ClassImp(MPedestalCam);
43
44using namespace std;
45
46// --------------------------------------------------------------------------
47//
48// Default constructor. Creates a MPedestalPix object for each pixel
49//
50MPedestalCam::MPedestalCam(const char *name, const char *title)
51 : fNumTotSlices(0), fNumExtractSlices(0), fUseHists(kFALSE)
52{
53 fName = name ? name : "MPedestalCam";
54 fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
55
56 fArray = new TClonesArray("MPedestalPix", 1);
57
58}
59
60// --------------------------------------------------------------------------
61//
62// Delete the array conatining the pixel pedest information
63//
64MPedestalCam::~MPedestalCam()
65{
66 delete fArray;
67}
68
69// --------------------------------------------------------------------------
70//
71// Set the size of the camera
72//
73void MPedestalCam::InitSize(const UInt_t i)
74{
75 fArray->ExpandCreate(i);
76}
77
78// --------------------------------------------------------------------------
79//
80// This function returns the current size of the TClonesArray
81// independently if the MPedestalPix is filled with values or not.
82//
83// Get the size of the MPedestalCam
84//
85Int_t MPedestalCam::GetSize() const
86{
87 return fArray->GetEntriesFast();
88}
89
90// --------------------------------------------------------------------------
91//
92// Get i-th pixel (pixel number)
93//
94MPedestalPix &MPedestalCam::operator[](Int_t i)
95{
96 return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
97}
98
99// --------------------------------------------------------------------------
100//
101// Get i-th pixel (pixel number)
102//
103MPedestalPix &MPedestalCam::operator[](Int_t i) const
104{
105 return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
106}
107
108void MPedestalCam::Clear(Option_t *o)
109{
110 fArray->ForEach(TObject, Clear)();
111
112 fNumTotSlices = 0;
113 fNumExtractSlices = 0;
114}
115
116void MPedestalCam::InitUseHists()
117{
118 fArray->ForEach(MPedestalPix, InitUseHists)();
119
120 fUseHists = kTRUE;
121}
122
123void MPedestalCam::Print(Option_t *o) const
124{
125 *fLog << all << GetDescriptor() << ":" << endl;
126 int id = 0;
127
128 TIter Next(fArray);
129 MPedestalPix *pix;
130 while ((pix=(MPedestalPix*)Next()))
131 {
132 id++;
133
134 if (!pix->IsValid())
135 continue;
136
137 *fLog << id-1 << ": ";
138 *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
139 }
140}
141
142Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
143{
144 if (fArray->GetEntries() <= 0)
145 return 50.;
146
147 Float_t minval = (*this)[0].GetPedestalRms();
148
149 for (Int_t i=1; i<fArray->GetEntries(); i++)
150 {
151 const MPedestalPix &pix = (*this)[i];
152
153 Float_t testval = pix.GetPedestalRms();
154
155 if (geom)
156 testval *= geom->GetPixRatio(i);
157
158 if (testval < minval)
159 minval = testval;
160 }
161 return minval;
162}
163
164Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
165{
166 if (fArray->GetEntries() <= 0)
167 return 50.;
168
169 Float_t maxval = (*this)[0].GetPedestalRms();
170
171 for (Int_t i=1; i<fArray->GetEntries(); i++)
172 {
173 const MPedestalPix &pix = (*this)[i];
174
175 Float_t testval = pix.GetPedestalRms();
176
177 if (geom)
178 testval *= geom->GetPixRatio(i);
179
180 if (testval > maxval)
181 maxval = testval;
182 }
183 return maxval;
184}
185
186Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
187{
188
189 if (!(*this)[idx].IsValid())
190 return kFALSE;
191
192 if (idx == 559)
193 return kFALSE;
194
195 const Float_t pederr = (*this)[idx].GetPedestalRms()/TMath::Sqrt((Float_t)fNumTotSlices);
196 const Float_t rmserr = (*this)[idx].GetPedestalRms()/TMath::Sqrt((Float_t)fNumTotSlices/2.);
197
198 const Float_t mean = (*this)[idx].GetMean() / (Float_t)fNumExtractSlices;
199 const Float_t meanerr = (*this)[idx].GetMeanErr() / (Float_t)fNumExtractSlices;
200 const Float_t sigma = (*this)[idx].GetSigma() / TMath::Sqrt((Float_t) fNumExtractSlices);
201 const Float_t sigmaerr = (*this)[idx].GetSigmaErr() / TMath::Sqrt((Float_t) fNumExtractSlices);
202
203 switch (type)
204 {
205 case 0:
206 val = (*this)[idx].GetPedestal();
207 break;
208 case 1:
209 val = pederr;
210 break;
211 case 2:
212 val = (*this)[idx].GetPedestalRms();
213 break;
214 case 3:
215 val = rmserr;
216 break;
217 case 4:
218 // if ((*this)[idx].IsFitValid())
219 val = mean;
220 // else
221 // return kFALSE;
222 break;
223 case 5:
224 // if ((*this)[idx].IsFitValid())
225 val = meanerr;
226 // else
227 // return kFALSE;
228 break;
229 case 6:
230 // if ((*this)[idx].IsFitValid())
231 val = sigma;
232 // else
233 // return kFALSE;
234 break;
235 case 7:
236 // if ((*this)[idx].IsFitValid())
237 val = sigmaerr;
238 // else
239 // return kFALSE;
240 break;
241 case 8:
242 // if ((*this)[idx].IsFitValid())
243 val = (*this)[idx].GetProb();
244 // else
245 // return kFALSE;
246 break;
247 case 9:
248 // if ((*this)[idx].IsFitValid())
249 val = ((*this)[idx].GetPedestal()-mean);
250 // else
251 // return kFALSE;
252 break;
253 case 10:
254 val = TMath::Sqrt(pederr*pederr + meanerr*meanerr);
255 break;
256 case 11:
257 val = (*this)[idx].GetPedestalRms()-sigma;
258 break;
259 case 12:
260 val = TMath::Sqrt(rmserr*rmserr + sigmaerr*sigmaerr);
261 break;
262 default:
263 return kFALSE;
264 }
265 return kTRUE;
266}
267
268void MPedestalCam::DrawPixelContent(Int_t idx) const
269{
270 (*this)[idx].Draw();
271}
Note: See TracBrowser for help on using the repository browser.