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 |
|
---|
42 | ClassImp(MPedestalCam);
|
---|
43 |
|
---|
44 | using namespace std;
|
---|
45 |
|
---|
46 | // --------------------------------------------------------------------------
|
---|
47 | //
|
---|
48 | // Default constructor. Creates a MPedestalPix object for each pixel
|
---|
49 | //
|
---|
50 | MPedestalCam::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", 1);
|
---|
56 |
|
---|
57 | }
|
---|
58 |
|
---|
59 | // --------------------------------------------------------------------------
|
---|
60 | //
|
---|
61 | // Delete the array conatining the pixel pedest information
|
---|
62 | //
|
---|
63 | MPedestalCam::~MPedestalCam()
|
---|
64 | {
|
---|
65 | delete fArray;
|
---|
66 | }
|
---|
67 |
|
---|
68 | // --------------------------------------------------------------------------
|
---|
69 | //
|
---|
70 | // Set the size of the camera
|
---|
71 | //
|
---|
72 | void MPedestalCam::InitSize(const UInt_t i)
|
---|
73 | {
|
---|
74 | fArray->ExpandCreate(i);
|
---|
75 | }
|
---|
76 |
|
---|
77 | // --------------------------------------------------------------------------
|
---|
78 | //
|
---|
79 | // This function returns the current size of the TClonesArray
|
---|
80 | // independently if the MPedestalPix is filled with values or not.
|
---|
81 | //
|
---|
82 | // Get the size of the MPedestalCam
|
---|
83 | //
|
---|
84 | Int_t MPedestalCam::GetSize() const
|
---|
85 | {
|
---|
86 | return fArray->GetEntriesFast();
|
---|
87 | }
|
---|
88 |
|
---|
89 | // --------------------------------------------------------------------------
|
---|
90 | //
|
---|
91 | // Get i-th pixel (pixel number)
|
---|
92 | //
|
---|
93 | MPedestalPix &MPedestalCam::operator[](Int_t i)
|
---|
94 | {
|
---|
95 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
---|
96 | }
|
---|
97 |
|
---|
98 | // --------------------------------------------------------------------------
|
---|
99 | //
|
---|
100 | // Get i-th pixel (pixel number)
|
---|
101 | //
|
---|
102 | MPedestalPix &MPedestalCam::operator[](Int_t i) const
|
---|
103 | {
|
---|
104 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
---|
105 | }
|
---|
106 |
|
---|
107 | void MPedestalCam::Clear(Option_t *o)
|
---|
108 | {
|
---|
109 | fArray->ForEach(TObject, Clear)();
|
---|
110 | }
|
---|
111 |
|
---|
112 | void MPedestalCam::InitUseHists()
|
---|
113 | {
|
---|
114 | fArray->ForEach(MPedestalPix, InitUseHists)();
|
---|
115 | }
|
---|
116 |
|
---|
117 | void MPedestalCam::Print(Option_t *o) const
|
---|
118 | {
|
---|
119 | *fLog << all << GetDescriptor() << ":" << endl;
|
---|
120 | int id = 0;
|
---|
121 |
|
---|
122 | TIter Next(fArray);
|
---|
123 | MPedestalPix *pix;
|
---|
124 | while ((pix=(MPedestalPix*)Next()))
|
---|
125 | {
|
---|
126 | id++;
|
---|
127 |
|
---|
128 | if (!pix->IsValid())
|
---|
129 | continue;
|
---|
130 |
|
---|
131 | *fLog << id-1 << ": ";
|
---|
132 | *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
|
---|
133 | }
|
---|
134 | }
|
---|
135 |
|
---|
136 | Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
|
---|
137 | {
|
---|
138 | if (fArray->GetEntries() <= 0)
|
---|
139 | return 50.;
|
---|
140 |
|
---|
141 | Float_t minval = (*this)[0].GetPedestalRms();
|
---|
142 |
|
---|
143 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
---|
144 | {
|
---|
145 | const MPedestalPix &pix = (*this)[i];
|
---|
146 |
|
---|
147 | Float_t testval = pix.GetPedestalRms();
|
---|
148 |
|
---|
149 | if (geom)
|
---|
150 | testval *= geom->GetPixRatio(i);
|
---|
151 |
|
---|
152 | if (testval < minval)
|
---|
153 | minval = testval;
|
---|
154 | }
|
---|
155 | return minval;
|
---|
156 | }
|
---|
157 |
|
---|
158 | Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
|
---|
159 | {
|
---|
160 | if (fArray->GetEntries() <= 0)
|
---|
161 | return 50.;
|
---|
162 |
|
---|
163 | Float_t maxval = (*this)[0].GetPedestalRms();
|
---|
164 |
|
---|
165 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
---|
166 | {
|
---|
167 | const MPedestalPix &pix = (*this)[i];
|
---|
168 |
|
---|
169 | Float_t testval = pix.GetPedestalRms();
|
---|
170 |
|
---|
171 | if (geom)
|
---|
172 | testval *= geom->GetPixRatio(i);
|
---|
173 |
|
---|
174 | if (testval > maxval)
|
---|
175 | maxval = testval;
|
---|
176 | }
|
---|
177 | return maxval;
|
---|
178 | }
|
---|
179 |
|
---|
180 | Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
181 | {
|
---|
182 |
|
---|
183 | switch (type)
|
---|
184 | {
|
---|
185 | case 0:
|
---|
186 | if ((*this)[idx].IsValid())
|
---|
187 | val = (*this)[idx].GetPedestal();
|
---|
188 | else
|
---|
189 | return kFALSE;
|
---|
190 | break;
|
---|
191 | case 1:
|
---|
192 | if ((*this)[idx].IsValid())
|
---|
193 | val = (*this)[idx].GetPedestalRms();
|
---|
194 | else
|
---|
195 | return kFALSE;
|
---|
196 | break;
|
---|
197 | case 2:
|
---|
198 | // if ((*this)[idx].IsFitValid())
|
---|
199 | val = (*this)[idx].GetMean();
|
---|
200 | // else
|
---|
201 | // return kFALSE;
|
---|
202 | break;
|
---|
203 | case 3:
|
---|
204 | // if ((*this)[idx].IsFitValid())
|
---|
205 | val = (*this)[idx].GetMeanErr();
|
---|
206 | // else
|
---|
207 | // return kFALSE;
|
---|
208 | break;
|
---|
209 | case 4:
|
---|
210 | // if ((*this)[idx].IsFitValid())
|
---|
211 | val = (*this)[idx].GetSigma();
|
---|
212 | // else
|
---|
213 | // return kFALSE;
|
---|
214 | break;
|
---|
215 | case 5:
|
---|
216 | // if ((*this)[idx].IsFitValid())
|
---|
217 | val = (*this)[idx].GetSigmaErr();
|
---|
218 | // else
|
---|
219 | // return kFALSE;
|
---|
220 | break;
|
---|
221 | case 6:
|
---|
222 | // if ((*this)[idx].IsFitValid())
|
---|
223 | val = (*this)[idx].GetProb();
|
---|
224 | // else
|
---|
225 | // return kFALSE;
|
---|
226 | break;
|
---|
227 | case 7:
|
---|
228 | // if ((*this)[idx].IsFitValid())
|
---|
229 | val = ((*this)[idx].GetPedestal()-(*this)[idx].GetMean());
|
---|
230 | // else
|
---|
231 | // return kFALSE;
|
---|
232 | break;
|
---|
233 | case 8:
|
---|
234 | // if ((*this)[idx].IsFitValid())
|
---|
235 | val = ((*this)[idx].GetPedestalRms()-(*this)[idx].GetSigma());
|
---|
236 | // else
|
---|
237 | // return kFALSE;
|
---|
238 | break;
|
---|
239 | default:
|
---|
240 | return kFALSE;
|
---|
241 | }
|
---|
242 | return kTRUE;
|
---|
243 | }
|
---|
244 |
|
---|
245 | void MPedestalCam::DrawPixelContent(Int_t idx) const
|
---|
246 | {
|
---|
247 | (*this)[idx].Draw();
|
---|
248 | }
|
---|