1 | #include "MCerPhotEvt.h"
|
---|
2 |
|
---|
3 | #include <math.h>
|
---|
4 | #include <fstream.h>
|
---|
5 |
|
---|
6 | #include <TCanvas.h>
|
---|
7 | #include <TClonesArray.h>
|
---|
8 |
|
---|
9 | #include "MLog.h"
|
---|
10 | #include "MCamNeighbor.h"
|
---|
11 | #include "MCamDisplay.h"
|
---|
12 | #include "MHexagon.h"
|
---|
13 |
|
---|
14 | ClassImp(MCerPhotEvt)
|
---|
15 |
|
---|
16 | MCerPhotEvt::MCerPhotEvt(const char *name, const char *title) : fNumPixels(0)
|
---|
17 | {
|
---|
18 | // the default constructor
|
---|
19 |
|
---|
20 |
|
---|
21 | *fName = name ? name : "MCerPhotEvt";
|
---|
22 | *fTitle = name ? name : "(Number of Photon)-Event Information";
|
---|
23 |
|
---|
24 | fPixels = new TClonesArray ("MCerPhotPix", 577) ;
|
---|
25 |
|
---|
26 | //
|
---|
27 | // FIXME: is this really necessary?
|
---|
28 | //
|
---|
29 | fPixels->Clear();
|
---|
30 | }
|
---|
31 |
|
---|
32 | #include "MGeomCamMagic.h"
|
---|
33 | #include "MGeomCamCT1.h"
|
---|
34 |
|
---|
35 | void MCerPhotEvt::Draw(Option_t* option)
|
---|
36 | {
|
---|
37 | //
|
---|
38 | // FIXME!!! Here the Draw function of the CamDisplay
|
---|
39 | // should be called to add the CamDisplay to the Pad.
|
---|
40 | // The drawing should be done in MCamDisplay::Paint
|
---|
41 | //
|
---|
42 |
|
---|
43 | // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
|
---|
44 | // MCamDisplay *disp = new MCamDisplay(geom);
|
---|
45 | // delete geom;
|
---|
46 | // disp->DrawPhotNum(this);
|
---|
47 | }
|
---|
48 |
|
---|
49 | void MCerPhotEvt::AddPixel(Int_t id, Float_t nph, Float_t err)
|
---|
50 | {
|
---|
51 | //
|
---|
52 | // add a new pixel to the list and increase the number
|
---|
53 | // of valid pixels in the list by one
|
---|
54 | //
|
---|
55 |
|
---|
56 | // TClonesArray -> 'operator new with placement' should be used
|
---|
57 | new ((*fPixels)[fNumPixels++]) MCerPhotPix( id, nph, err);
|
---|
58 | }
|
---|
59 |
|
---|
60 | void MCerPhotEvt::Clear(Option_t *)
|
---|
61 | {
|
---|
62 | //
|
---|
63 | // reset counter and delete netries in list.
|
---|
64 | //
|
---|
65 | fNumPixels = 0 ;
|
---|
66 | fPixels->Clear() ;
|
---|
67 | }
|
---|
68 |
|
---|
69 | void MCerPhotEvt::Print(Option_t *)
|
---|
70 | {
|
---|
71 | const Int_t entries = fPixels->GetEntries();
|
---|
72 |
|
---|
73 | *fLog << "MCerPhotEvt::Print()" << endl
|
---|
74 | << "Number of Pixels: " << fNumPixels
|
---|
75 | << "(" << entries << ")"
|
---|
76 | << endl ;
|
---|
77 |
|
---|
78 | for (Int_t il=0; il<entries; il++ )
|
---|
79 | (*this)[il].Print();
|
---|
80 | }
|
---|
81 |
|
---|
82 | /*
|
---|
83 | void MCerPhotEvt::CleanLevel1()
|
---|
84 | {
|
---|
85 | //
|
---|
86 | // This method looks for all pixels with an entry (photons)
|
---|
87 | // that is three times bigger than the noise of the pixel
|
---|
88 | //
|
---|
89 |
|
---|
90 | const Int_t entries = fPixels->GetEntries();
|
---|
91 |
|
---|
92 | //
|
---|
93 | // check the number of all pixels against the noise level and
|
---|
94 | // set them to 'unused' state if necessary
|
---|
95 | //
|
---|
96 | for (Int_t il=0; il<entries; il++ )
|
---|
97 | {
|
---|
98 | MCerPhotPix &pix = (*this)[il];
|
---|
99 |
|
---|
100 | const Float_t entry = pix.GetNumPhotons();
|
---|
101 | const Float_t noise = pix.GetErrorPhot();
|
---|
102 |
|
---|
103 | if (entry < 3 * noise )
|
---|
104 | pix.SetPixelUnused();
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | void MCerPhotEvt::CleanLevel2()
|
---|
109 | {
|
---|
110 | //
|
---|
111 | // check if the survived pixel have a neighbor, that also
|
---|
112 | // survived
|
---|
113 | //
|
---|
114 |
|
---|
115 | const Int_t entries = fPixels->GetEntries();
|
---|
116 |
|
---|
117 | for (Int_t il=0; il<entries; il++)
|
---|
118 | {
|
---|
119 | //
|
---|
120 | // get entry il from list
|
---|
121 | //
|
---|
122 | MCerPhotPix &pix = (*this)[il];
|
---|
123 |
|
---|
124 | //
|
---|
125 | // check if pixel is in use, if not goto next pixel in list
|
---|
126 | //
|
---|
127 | if (!pix.IsPixelUsed())
|
---|
128 | continue;
|
---|
129 |
|
---|
130 | //
|
---|
131 | // get pixel id of this entry
|
---|
132 | //
|
---|
133 | const Int_t id = pix.GetPixId() ;
|
---|
134 |
|
---|
135 | //
|
---|
136 | // count number of next neighbors of this pixel which
|
---|
137 | // state is 'used'
|
---|
138 | //
|
---|
139 | Int_t itest = 0 ;
|
---|
140 | for (Int_t in=0 ; in < 6; in++ )
|
---|
141 | {
|
---|
142 | const Int_t id2 = fNN.GetNN(id, in) ;
|
---|
143 |
|
---|
144 | if (id2 < 0)
|
---|
145 | continue;
|
---|
146 |
|
---|
147 | if (IsPixelUsed(id2))
|
---|
148 | itest++ ;
|
---|
149 | }
|
---|
150 |
|
---|
151 | //
|
---|
152 | // check if no next neighbor has the state 'used'
|
---|
153 | // set this pixel to 'unused', too.
|
---|
154 | //
|
---|
155 | if (itest==0)
|
---|
156 | pix.SetPixelUnused();
|
---|
157 | }
|
---|
158 |
|
---|
159 | //
|
---|
160 | // now we declare all pixels that survive as CorePixels
|
---|
161 | //
|
---|
162 | for (Int_t il=0; il<entries; il++)
|
---|
163 | {
|
---|
164 | MCerPhotPix &pix = (*this)[il];
|
---|
165 |
|
---|
166 | if (pix.IsPixelUsed())
|
---|
167 | pix.SetCorePixel();
|
---|
168 | }
|
---|
169 |
|
---|
170 | }
|
---|
171 |
|
---|
172 | void MCerPhotEvt::CleanLevel3()
|
---|
173 | {
|
---|
174 | //
|
---|
175 | // Look for the boundary pixels around the core pixels
|
---|
176 | // if a pixel has more than 2.5 sigma, and a core neigbor
|
---|
177 | // it is declared as used.
|
---|
178 | //
|
---|
179 | const Int_t entries = fPixels->GetEntries();
|
---|
180 |
|
---|
181 | for (Int_t il=0; il<entries; il++)
|
---|
182 | {
|
---|
183 | //
|
---|
184 | // get pixel as entry il from list
|
---|
185 | //
|
---|
186 | MCerPhotPix &pix = (*this)[il];
|
---|
187 |
|
---|
188 | //
|
---|
189 | // if pixel is a core pixel go to the next pixel
|
---|
190 | //
|
---|
191 | if (pix.IsCorePixel())
|
---|
192 | continue;
|
---|
193 |
|
---|
194 | //
|
---|
195 | // check the num of photons against the noise level
|
---|
196 | //
|
---|
197 | const Float_t entry = pix.GetNumPhotons();
|
---|
198 | const Float_t noise = pix.GetErrorPhot();
|
---|
199 |
|
---|
200 | if (entry <= 2.5 * noise )
|
---|
201 | continue;
|
---|
202 |
|
---|
203 | //
|
---|
204 | // get pixel id of this entry
|
---|
205 | //
|
---|
206 | const Int_t id = pix.GetPixId();
|
---|
207 |
|
---|
208 | //
|
---|
209 | // check if the pixel's next neighbor is a core pixel.
|
---|
210 | // if it is a core pixel set pixel state to: used.
|
---|
211 | //
|
---|
212 | for (Int_t in=0; in<6 ; in++)
|
---|
213 | {
|
---|
214 | const Int_t id2 = fNN.GetNN(id, in);
|
---|
215 |
|
---|
216 | if (id2 <0)
|
---|
217 | continue;
|
---|
218 |
|
---|
219 | if (!IsPixelCore(id2))
|
---|
220 | continue;
|
---|
221 |
|
---|
222 | pix.SetPixelUsed();
|
---|
223 |
|
---|
224 | break ;
|
---|
225 | }
|
---|
226 | }
|
---|
227 | }
|
---|
228 | */
|
---|
229 |
|
---|
230 | Bool_t MCerPhotEvt::IsPixelExisting(Int_t id)
|
---|
231 | {
|
---|
232 | //
|
---|
233 | // Checks if in the pixel list is an entry with pixel id
|
---|
234 | //
|
---|
235 | const Int_t entries = fPixels->GetEntries();
|
---|
236 |
|
---|
237 | for (Int_t il=0; il<entries; il++)
|
---|
238 | {
|
---|
239 | if (id == (*this)[il].GetPixId())
|
---|
240 | return kTRUE ;
|
---|
241 | }
|
---|
242 |
|
---|
243 | return kFALSE ;
|
---|
244 | }
|
---|
245 |
|
---|
246 | Bool_t MCerPhotEvt::IsPixelUsed(Int_t id)
|
---|
247 | {
|
---|
248 | //
|
---|
249 | // Checks if in the pixel list is an entry with pixel id
|
---|
250 | //
|
---|
251 | const Int_t entries = fPixels->GetEntries();
|
---|
252 |
|
---|
253 | for (Int_t il=0; il<entries; il++ )
|
---|
254 | {
|
---|
255 | MCerPhotPix &pix = (*this)[il];
|
---|
256 |
|
---|
257 | if (id == pix.GetPixId() && pix.IsPixelUsed())
|
---|
258 | return kTRUE ;
|
---|
259 | }
|
---|
260 |
|
---|
261 | return kFALSE ;
|
---|
262 | }
|
---|
263 |
|
---|
264 | Bool_t MCerPhotEvt::IsPixelCore(Int_t id)
|
---|
265 | {
|
---|
266 | //
|
---|
267 | // Checks if in the pixel list is an entry with pixel id
|
---|
268 | //
|
---|
269 | const Int_t entries = fPixels->GetEntries();
|
---|
270 |
|
---|
271 | for (Int_t il=0; il<entries; il++ )
|
---|
272 | {
|
---|
273 | MCerPhotPix &pix = (*this)[il];
|
---|
274 |
|
---|
275 | if ( id == pix.GetPixId() && pix.IsCorePixel())
|
---|
276 | return kTRUE ;
|
---|
277 | }
|
---|
278 |
|
---|
279 | return kFALSE ;
|
---|
280 | }
|
---|
281 |
|
---|
282 | Float_t MCerPhotEvt::GetNumPhotonsMin()
|
---|
283 | {
|
---|
284 | //
|
---|
285 | // get the minimum number of photons of all valid pixels in the list
|
---|
286 | //
|
---|
287 | if (fNumPixels <= 0)
|
---|
288 | return -5. ;
|
---|
289 |
|
---|
290 | Float_t minval = (*this)[0].GetNumPhotons();
|
---|
291 |
|
---|
292 | Float_t testval;
|
---|
293 | for (UInt_t i=1 ; i<fNumPixels; i++ )
|
---|
294 | {
|
---|
295 | testval = (*this)[i].GetNumPhotons();
|
---|
296 |
|
---|
297 | if (testval < minval)
|
---|
298 | minval = testval;
|
---|
299 | }
|
---|
300 |
|
---|
301 | return minval;
|
---|
302 | }
|
---|
303 |
|
---|
304 | Float_t MCerPhotEvt::GetNumPhotonsMax()
|
---|
305 | {
|
---|
306 | //
|
---|
307 | // get the maximum number of photons of all valid pixels in the list
|
---|
308 | //
|
---|
309 | if (fNumPixels <= 0)
|
---|
310 | return 50.;
|
---|
311 |
|
---|
312 | Float_t maxval = (*this)[0].GetNumPhotons();
|
---|
313 |
|
---|
314 | Float_t testval;
|
---|
315 | for (UInt_t i=1; i<fNumPixels; i++)
|
---|
316 | {
|
---|
317 | testval = (*this)[i].GetNumPhotons();
|
---|
318 |
|
---|
319 | if (testval > maxval)
|
---|
320 | maxval = testval;
|
---|
321 | }
|
---|
322 | return maxval;
|
---|
323 | }
|
---|
324 |
|
---|