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 | // Delete the array conatining the pixel pedest information
|
---|
65 | //
|
---|
66 | MPedestalCam::~MPedestalCam()
|
---|
67 | {
|
---|
68 | delete fArray;
|
---|
69 | }
|
---|
70 |
|
---|
71 | // --------------------------------------------------------------------------
|
---|
72 | //
|
---|
73 | // Set the size of the camera
|
---|
74 | //
|
---|
75 | void MPedestalCam::InitSize(const UInt_t i)
|
---|
76 | {
|
---|
77 | fArray->ExpandCreate(i);
|
---|
78 | }
|
---|
79 |
|
---|
80 | // --------------------------------------------------------------------------
|
---|
81 | //
|
---|
82 | // This function returns the current size of the TClonesArray
|
---|
83 | // independently if the MPedestalPix is filled with values or not.
|
---|
84 | //
|
---|
85 | // Get the size of the MPedestalCam
|
---|
86 | //
|
---|
87 | Int_t MPedestalCam::GetSize() const
|
---|
88 | {
|
---|
89 | return fArray->GetEntriesFast();
|
---|
90 | }
|
---|
91 |
|
---|
92 | // --------------------------------------------------------------------------
|
---|
93 | //
|
---|
94 | // Get i-th pixel (pixel number)
|
---|
95 | //
|
---|
96 | MPedestalPix &MPedestalCam::operator[](Int_t i)
|
---|
97 | {
|
---|
98 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
---|
99 | }
|
---|
100 |
|
---|
101 | // --------------------------------------------------------------------------
|
---|
102 | //
|
---|
103 | // Get i-th pixel (pixel number)
|
---|
104 | //
|
---|
105 | const MPedestalPix &MPedestalCam::operator[](Int_t i) const
|
---|
106 | {
|
---|
107 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
---|
108 | }
|
---|
109 |
|
---|
110 | // -------------------------------------------------------------------------
|
---|
111 | //
|
---|
112 | void MPedestalCam::Clear(Option_t *o)
|
---|
113 | {
|
---|
114 | fArray->ForEach(TObject, Clear)();
|
---|
115 |
|
---|
116 | fTotalEntries = 0;
|
---|
117 | }
|
---|
118 |
|
---|
119 | void MPedestalCam::Print(Option_t *o) const
|
---|
120 | {
|
---|
121 | *fLog << all << GetDescriptor() << ":" << endl;
|
---|
122 | int id = 0;
|
---|
123 |
|
---|
124 | TIter Next(fArray);
|
---|
125 | MPedestalPix *pix;
|
---|
126 | while ((pix=(MPedestalPix*)Next()))
|
---|
127 | {
|
---|
128 | id++;
|
---|
129 |
|
---|
130 | if (!pix->IsValid())
|
---|
131 | continue;
|
---|
132 |
|
---|
133 | *fLog << id-1 << ": ";
|
---|
134 | *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
|
---|
139 | {
|
---|
140 | if (fArray->GetEntries() <= 0)
|
---|
141 | return 50.;
|
---|
142 |
|
---|
143 | Float_t minval = (*this)[0].GetPedestalRms();
|
---|
144 |
|
---|
145 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
---|
146 | {
|
---|
147 | const MPedestalPix &pix = (*this)[i];
|
---|
148 |
|
---|
149 | Float_t testval = pix.GetPedestalRms();
|
---|
150 |
|
---|
151 | if (geom)
|
---|
152 | testval *= geom->GetPixRatio(i);
|
---|
153 |
|
---|
154 | if (testval < minval)
|
---|
155 | minval = testval;
|
---|
156 | }
|
---|
157 | return minval;
|
---|
158 | }
|
---|
159 |
|
---|
160 | Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
|
---|
161 | {
|
---|
162 | if (fArray->GetEntries() <= 0)
|
---|
163 | return 50.;
|
---|
164 |
|
---|
165 | Float_t maxval = (*this)[0].GetPedestalRms();
|
---|
166 |
|
---|
167 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
---|
168 | {
|
---|
169 | const MPedestalPix &pix = (*this)[i];
|
---|
170 |
|
---|
171 | Float_t testval = pix.GetPedestalRms();
|
---|
172 |
|
---|
173 | if (geom)
|
---|
174 | testval *= geom->GetPixRatio(i);
|
---|
175 |
|
---|
176 | if (testval > maxval)
|
---|
177 | maxval = testval;
|
---|
178 | }
|
---|
179 | return maxval;
|
---|
180 | }
|
---|
181 |
|
---|
182 | Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
183 | {
|
---|
184 |
|
---|
185 | if (GetSize() <= idx)
|
---|
186 | return kFALSE;
|
---|
187 |
|
---|
188 | const Float_t ped = (*this)[idx].GetPedestal();
|
---|
189 | const Float_t rms = (*this)[idx].GetPedestalRms();
|
---|
190 |
|
---|
191 | const Float_t pederr = rms/TMath::Sqrt((Float_t)fTotalEntries);
|
---|
192 | const Float_t rmserr = rms/TMath::Sqrt((Float_t)fTotalEntries)/2.;
|
---|
193 |
|
---|
194 | switch (type)
|
---|
195 | {
|
---|
196 | case 0:
|
---|
197 | val = ped;
|
---|
198 | break;
|
---|
199 | case 1:
|
---|
200 | val = pederr;
|
---|
201 | break;
|
---|
202 | case 2:
|
---|
203 | val = rms;
|
---|
204 | break;
|
---|
205 | case 3:
|
---|
206 | val = rmserr;
|
---|
207 | break;
|
---|
208 | default:
|
---|
209 | return kFALSE;
|
---|
210 | }
|
---|
211 | return kTRUE;
|
---|
212 | }
|
---|
213 |
|
---|
214 | void MPedestalCam::DrawPixelContent(Int_t idx) const
|
---|
215 | {
|
---|
216 | *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;
|
---|
217 | }
|
---|