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

Last change on this file since 2178 was 2178, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.9 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{
52 fName = name ? name : "MPedestalCam";
53 fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
54
55 fArray = new TClonesArray("MPedestalPix", 577);
56
57 for (int i=0; i<577; i++)
58 new ((*fArray)[i]) MPedestalPix;
59}
60
61// --------------------------------------------------------------------------
62//
63// Delete the array conatining the pixel pedest information
64//
65MPedestalCam::~MPedestalCam()
66{
67 delete fArray;
68}
69
70// --------------------------------------------------------------------------
71//
72// Set the size of the camera
73//
74void MPedestalCam::InitSize(const UInt_t i)
75{
76 fArray->ExpandCreate(i);
77}
78
79// --------------------------------------------------------------------------
80//
81// Get the size of the MPedestalCam
82//
83Int_t MPedestalCam::GetSize() const
84{
85 return fArray->GetEntriesFast();
86}
87
88// --------------------------------------------------------------------------
89//
90// Get i-th pixel (pixel number)
91//
92MPedestalPix &MPedestalCam::operator[](Int_t i)
93{
94 return *(MPedestalPix*)fArray->UncheckedAt(i);
95}
96
97// --------------------------------------------------------------------------
98//
99// Get i-th pixel (pixel number)
100//
101MPedestalPix &MPedestalCam::operator[](Int_t i) const
102{
103 return *(MPedestalPix*)fArray->UncheckedAt(i);
104}
105
106// --------------------------------------------------------------------------
107//
108// Check if position i is inside bounds
109//
110Bool_t MPedestalCam::CheckBounds(Int_t i)
111{
112 return i < fArray->GetEntriesFast();
113}
114
115void MPedestalCam::Clear(Option_t *o)
116{
117 fArray->ForEach(TObject, Clear)();
118}
119
120void MPedestalCam::Print(Option_t *o) const
121{
122 *fLog << all << GetDescriptor() << ":" << endl;
123 int id = 0;
124
125 TIter Next(fArray);
126 MPedestalPix *pix;
127 while ((pix=(MPedestalPix*)Next()))
128 {
129 id++;
130
131 if (!pix->IsValid())
132 continue;
133
134 *fLog << id-1 << ": ";
135 *fLog << pix->GetMean() << " " << pix->GetSigma() << " ";
136 *fLog << pix->GetMeanRms() << " " << pix->GetSigmaRms() << endl;
137 }
138}
139
140Float_t MPedestalCam::GetMeanMin(const MGeomCam *geom) const
141{
142 if (fArray->GetEntries() <= 0)
143 return 50.;
144
145 Float_t minval = (*this)[0].GetMean();
146
147 for (Int_t i=1; i<fArray->GetEntries(); i++)
148 {
149 const MPedestalPix &pix = (*this)[i];
150
151 Float_t testval = pix.GetMean();
152
153 if (geom)
154 testval *= geom->GetPixRatio(i);
155
156 if (testval < minval)
157 minval = testval;
158 }
159 return minval;
160}
161
162Float_t MPedestalCam::GetMeanMax(const MGeomCam *geom) const
163{
164 if (fArray->GetEntries() <= 0)
165 return 50.;
166
167 Float_t maxval = (*this)[0].GetMean();
168
169 for (Int_t i=1; i<fArray->GetEntries(); i++)
170 {
171 const MPedestalPix &pix = (*this)[i];
172
173 Float_t testval = pix.GetMean();
174
175 if (geom)
176 testval *= geom->GetPixRatio(i);
177
178 if (testval > maxval)
179 maxval = testval;
180 }
181 return maxval;
182}
183
184Bool_t MPedestalCam::GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const
185{
186 val = (*this)[idx].GetMean()*ratio;
187 return kTRUE;
188}
Note: See TracBrowser for help on using the repository browser.