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 | ! Markus Gaug 02/2004 <mailto:markus@ifae.es>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | // //
|
---|
28 | // MPedestalCam //
|
---|
29 | // //
|
---|
30 | // Hold the Pedestal information for all pixels in the camera //
|
---|
31 | // //
|
---|
32 | /////////////////////////////////////////////////////////////////////////////
|
---|
33 | #include "MPedestalCam.h"
|
---|
34 | #include "MPedestalPix.h"
|
---|
35 |
|
---|
36 | #include <TClonesArray.h>
|
---|
37 |
|
---|
38 | #include "MLog.h"
|
---|
39 | #include "MLogManip.h"
|
---|
40 |
|
---|
41 | #include "MParList.h"
|
---|
42 |
|
---|
43 | #include "MGeomCam.h"
|
---|
44 |
|
---|
45 | ClassImp(MPedestalCam);
|
---|
46 |
|
---|
47 | using namespace std;
|
---|
48 |
|
---|
49 | // --------------------------------------------------------------------------
|
---|
50 | //
|
---|
51 | // Default constructor. Creates a MPedestalPix object for each pixel
|
---|
52 | //
|
---|
53 | MPedestalCam::MPedestalCam(const char *name, const char *title)
|
---|
54 | : fTotalEntries(0)
|
---|
55 | {
|
---|
56 | fName = name ? name : "MPedestalCam";
|
---|
57 | fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
|
---|
58 |
|
---|
59 | fArray = new TClonesArray("MPedestalPix", 1);
|
---|
60 |
|
---|
61 | }
|
---|
62 |
|
---|
63 | // --------------------------------------------------------------------------
|
---|
64 | //
|
---|
65 | // Delete the array conatining the pixel pedest information
|
---|
66 | //
|
---|
67 | MPedestalCam::~MPedestalCam()
|
---|
68 | {
|
---|
69 | delete fArray;
|
---|
70 | }
|
---|
71 |
|
---|
72 | // --------------------------------------------------------------------------
|
---|
73 | //
|
---|
74 | // Set the size of the camera
|
---|
75 | //
|
---|
76 | void MPedestalCam::InitSize(const UInt_t i)
|
---|
77 | {
|
---|
78 | fArray->ExpandCreate(i);
|
---|
79 | }
|
---|
80 |
|
---|
81 | // --------------------------------------------------------------------------
|
---|
82 | //
|
---|
83 | // This function returns the current size of the TClonesArray
|
---|
84 | // independently if the MPedestalPix is filled with values or not.
|
---|
85 | //
|
---|
86 | // Get the size of the MPedestalCam
|
---|
87 | //
|
---|
88 | UInt_t MPedestalCam::GetSize() const
|
---|
89 | {
|
---|
90 | return fArray->GetEntriesFast();
|
---|
91 | }
|
---|
92 |
|
---|
93 | // --------------------------------------------------------------------------
|
---|
94 | //
|
---|
95 | // Get i-th pixel (pixel number)
|
---|
96 | //
|
---|
97 | MPedestalPix &MPedestalCam::operator[](Int_t i)
|
---|
98 | {
|
---|
99 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
---|
100 | }
|
---|
101 |
|
---|
102 | // --------------------------------------------------------------------------
|
---|
103 | //
|
---|
104 | // Get i-th pixel (pixel number)
|
---|
105 | //
|
---|
106 | const MPedestalPix &MPedestalCam::operator[](Int_t i) const
|
---|
107 | {
|
---|
108 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
---|
109 | }
|
---|
110 |
|
---|
111 | // -------------------------------------------------------------------------
|
---|
112 | //
|
---|
113 | void MPedestalCam::Clear(Option_t *o)
|
---|
114 | {
|
---|
115 |
|
---|
116 | fArray->ForEach(TObject, Clear)();
|
---|
117 |
|
---|
118 | fTotalEntries = 0;
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 | void 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 |
|
---|
142 | Float_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 |
|
---|
164 | Float_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 |
|
---|
186 | Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
187 | {
|
---|
188 |
|
---|
189 | if (GetSize() <= idx)
|
---|
190 | return kFALSE;
|
---|
191 |
|
---|
192 | const Float_t ped = (*this)[idx].GetPedestal();
|
---|
193 | const Float_t rms = (*this)[idx].GetPedestalRms();
|
---|
194 |
|
---|
195 | const Float_t pederr = rms/TMath::Sqrt((Float_t)fTotalEntries);
|
---|
196 | const Float_t rmserr = rms/TMath::Sqrt((Float_t)fTotalEntries)/2.;
|
---|
197 |
|
---|
198 | switch (type)
|
---|
199 | {
|
---|
200 | case 0:
|
---|
201 | val = ped;
|
---|
202 | break;
|
---|
203 | case 1:
|
---|
204 | val = pederr;
|
---|
205 | break;
|
---|
206 | case 2:
|
---|
207 | val = rms;
|
---|
208 | break;
|
---|
209 | case 3:
|
---|
210 | val = rmserr;
|
---|
211 | break;
|
---|
212 | default:
|
---|
213 | return kFALSE;
|
---|
214 | }
|
---|
215 | return kTRUE;
|
---|
216 | }
|
---|
217 |
|
---|
218 | void MPedestalCam::DrawPixelContent(Int_t idx) const
|
---|
219 | {
|
---|
220 | *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;
|
---|
221 | }
|
---|