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 | // 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 | //
|
---|
65 | MPedestalCam::~MPedestalCam()
|
---|
66 | {
|
---|
67 | delete fArray;
|
---|
68 | }
|
---|
69 |
|
---|
70 | // --------------------------------------------------------------------------
|
---|
71 | //
|
---|
72 | // Set the size of the camera
|
---|
73 | //
|
---|
74 | void MPedestalCam::InitSize(const UInt_t i)
|
---|
75 | {
|
---|
76 | fArray->ExpandCreate(i);
|
---|
77 | }
|
---|
78 |
|
---|
79 | // --------------------------------------------------------------------------
|
---|
80 | //
|
---|
81 | // Get the size of the MPedestalCam
|
---|
82 | //
|
---|
83 | Int_t MPedestalCam::GetSize() const
|
---|
84 | {
|
---|
85 | return fArray->GetEntriesFast();
|
---|
86 | }
|
---|
87 |
|
---|
88 | // --------------------------------------------------------------------------
|
---|
89 | //
|
---|
90 | // Get i-th pixel (pixel number)
|
---|
91 | //
|
---|
92 | MPedestalPix &MPedestalCam::operator[](Int_t i)
|
---|
93 | {
|
---|
94 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
---|
95 | }
|
---|
96 |
|
---|
97 | // --------------------------------------------------------------------------
|
---|
98 | //
|
---|
99 | // Get i-th pixel (pixel number)
|
---|
100 | //
|
---|
101 | MPedestalPix &MPedestalCam::operator[](Int_t i) const
|
---|
102 | {
|
---|
103 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
---|
104 | }
|
---|
105 |
|
---|
106 | // --------------------------------------------------------------------------
|
---|
107 | //
|
---|
108 | // Check if position i is inside bounds
|
---|
109 | //
|
---|
110 | Bool_t MPedestalCam::CheckBounds(Int_t i)
|
---|
111 | {
|
---|
112 | return i < fArray->GetEntriesFast();
|
---|
113 | }
|
---|
114 |
|
---|
115 | void MPedestalCam::Clear(Option_t *o)
|
---|
116 | {
|
---|
117 | fArray->ForEach(TObject, Clear)();
|
---|
118 | }
|
---|
119 |
|
---|
120 | void 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->GetPedestal() << " " << pix->GetPedestalRms() << endl;
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 | Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
|
---|
140 | {
|
---|
141 | if (fArray->GetEntries() <= 0)
|
---|
142 | return 50.;
|
---|
143 |
|
---|
144 | Float_t minval = (*this)[0].GetPedestalRms();
|
---|
145 |
|
---|
146 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
---|
147 | {
|
---|
148 | const MPedestalPix &pix = (*this)[i];
|
---|
149 |
|
---|
150 | Float_t testval = pix.GetPedestalRms();
|
---|
151 |
|
---|
152 | if (geom)
|
---|
153 | testval *= geom->GetPixRatio(i);
|
---|
154 |
|
---|
155 | if (testval < minval)
|
---|
156 | minval = testval;
|
---|
157 | }
|
---|
158 | return minval;
|
---|
159 | }
|
---|
160 |
|
---|
161 | Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
|
---|
162 | {
|
---|
163 | if (fArray->GetEntries() <= 0)
|
---|
164 | return 50.;
|
---|
165 |
|
---|
166 | Float_t maxval = (*this)[0].GetPedestalRms();
|
---|
167 |
|
---|
168 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
---|
169 | {
|
---|
170 | const MPedestalPix &pix = (*this)[i];
|
---|
171 |
|
---|
172 | Float_t testval = pix.GetPedestalRms();
|
---|
173 |
|
---|
174 | if (geom)
|
---|
175 | testval *= geom->GetPixRatio(i);
|
---|
176 |
|
---|
177 | if (testval > maxval)
|
---|
178 | maxval = testval;
|
---|
179 | }
|
---|
180 | return maxval;
|
---|
181 | }
|
---|
182 |
|
---|
183 | Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
184 | {
|
---|
185 | switch (type)
|
---|
186 | {
|
---|
187 | case 0:
|
---|
188 | val = (*this)[idx].GetPedestal();
|
---|
189 | break;
|
---|
190 | case 1:
|
---|
191 | val = (*this)[idx].GetPedestalRms();
|
---|
192 | break;
|
---|
193 | default:
|
---|
194 | return kFALSE;
|
---|
195 | }
|
---|
196 | return val>=0;
|
---|
197 | }
|
---|
198 |
|
---|
199 | void MPedestalCam::DrawPixelContent(Int_t num) const
|
---|
200 | {
|
---|
201 | *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;
|
---|
202 | }
|
---|