source: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc@ 1683

Last change on this file since 1683 was 1574, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 8.1 KB
Line 
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! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
20!
21! Copyright: MAGIC Software Development, 2000-2001
22!
23!
24\* ======================================================================== */
25
26#include "MCerPhotEvt.h"
27
28#include <math.h>
29#include <fstream.h>
30
31#include <TCanvas.h>
32
33#include "MLog.h"
34
35#include "MGeomCam.h"
36
37ClassImp(MCerPhotEvt);
38
39// --------------------------------------------------------------------------
40//
41// Creates a MCerPhotPix object for each pixel in the event
42//
43MCerPhotEvt::MCerPhotEvt(const char *name, const char *title) : fNumPixels(0)
44{
45 fName = name ? name : "MCerPhotEvt";
46 fTitle = title ? title : "(Number of Photon)-Event Information";
47
48 fPixels = new TClonesArray("MCerPhotPix", 0);
49}
50
51// --------------------------------------------------------------------------
52//
53// This is not yet implemented like it should.
54//
55void MCerPhotEvt::Draw(Option_t* option)
56{
57 //
58 // FIXME!!! Here the Draw function of the CamDisplay
59 // should be called to add the CamDisplay to the Pad.
60 // The drawing should be done in MCamDisplay::Paint
61 //
62
63 // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
64 // MCamDisplay *disp = new MCamDisplay(geom);
65 // delete geom;
66 // disp->DrawPhotNum(this);
67}
68
69// --------------------------------------------------------------------------
70//
71// reset counter and delete netries in list.
72//
73void MCerPhotEvt::Reset()
74{
75 fNumPixels = 0;
76 fPixels->Delete();
77}
78
79// --------------------------------------------------------------------------
80//
81// Dump the cerenkov photon event to *fLog
82//
83void MCerPhotEvt::Print(Option_t *) const
84{
85 const Int_t entries = fPixels->GetEntries();
86
87 *fLog << GetDescriptor() << dec << endl;
88 *fLog << " Number of Pixels: " << fNumPixels << "(" << entries << ")" << endl;
89
90 for (Int_t i=0; i<entries; i++ )
91 (*this)[i].Print();
92}
93
94// --------------------------------------------------------------------------
95//
96// Checks if in the pixel list is an entry with pixel id
97//
98Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const
99{
100 const Int_t entries = fPixels->GetEntries();
101
102 for (Int_t i=0; i<entries; i++)
103 {
104 if (id == (*this)[i].GetPixId())
105 return kTRUE;
106 }
107
108 return kFALSE;
109}
110
111// --------------------------------------------------------------------------
112//
113// Checks if in the pixel list is an entry with pixel id
114//
115Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const
116{
117 const Int_t entries = fPixels->GetEntries();
118
119 for (Int_t i=0; i<entries; i++)
120 {
121 const MCerPhotPix &pix = (*this)[i];
122
123 if (id == pix.GetPixId() && pix.IsPixelUsed())
124 return kTRUE;
125 }
126
127 return kFALSE;
128}
129
130// --------------------------------------------------------------------------
131//
132// Checks if in the pixel list is an entry with pixel id
133//
134Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const
135{
136 const Int_t entries = fPixels->GetEntries();
137
138 for (Int_t i=0; i<entries; i++)
139 {
140 const MCerPhotPix &pix = (*this)[i];
141
142 if (id == pix.GetPixId() && pix.IsPixelCore())
143 return kTRUE;
144 }
145
146 return kFALSE;
147}
148
149// --------------------------------------------------------------------------
150//
151// get the minimum number of photons of all valid pixels in the list
152// If you specify a geometry the number of photons is weighted with the
153// area of the pixel
154//
155Float_t MCerPhotEvt::GetNumPhotonsMin(const MGeomCam *geom) const
156{
157 if (fNumPixels <= 0)
158 return -5.;
159
160 Float_t minval = (*this)[0].GetNumPhotons();
161
162 for (UInt_t i=1; i<fNumPixels; i++)
163 {
164 const MCerPhotPix &pix = (*this)[i];
165
166 Float_t testval = pix.GetNumPhotons();
167
168 if (geom)
169 testval *= geom->GetPixRatio(pix.GetPixId());
170
171 if (testval < minval)
172 minval = testval;
173 }
174
175 return minval;
176}
177
178// --------------------------------------------------------------------------
179//
180// get the maximum number of photons of all valid pixels in the list
181// If you specify a geometry the number of photons is weighted with the
182// area of the pixel
183//
184Float_t MCerPhotEvt::GetNumPhotonsMax(const MGeomCam *geom) const
185{
186 if (fNumPixels <= 0)
187 return 50.;
188
189 Float_t maxval = (*this)[0].GetNumPhotons();
190
191 for (UInt_t i=1; i<fNumPixels; i++)
192 {
193 const MCerPhotPix &pix = (*this)[i];
194
195 Float_t testval = pix.GetNumPhotons();
196
197 if (geom)
198 testval *= geom->GetPixRatio(pix.GetPixId());
199
200 if (testval > maxval)
201 maxval = testval;
202 }
203 return maxval;
204}
205
206// --------------------------------------------------------------------------
207//
208// get the minimum ratio of photons/error
209//
210Float_t MCerPhotEvt::GetRatioMin() const
211{
212 if (fNumPixels <= 0)
213 return -5.;
214
215 Float_t minval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
216
217 for (UInt_t i=1; i<fNumPixels; i++)
218 {
219 const MCerPhotPix &pix = (*this)[i];
220
221 Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
222 if (testval < minval)
223 minval = testval;
224 }
225
226 return minval;
227}
228
229// --------------------------------------------------------------------------
230//
231// get the maximum ratio of photons/error
232//
233Float_t MCerPhotEvt::GetRatioMax() const
234{
235 if (fNumPixels <= 0)
236 return -5.;
237
238 Float_t maxval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
239
240 for (UInt_t i=1; i<fNumPixels; i++)
241 {
242 const MCerPhotPix &pix = (*this)[i];
243
244 Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
245 if (testval > maxval)
246 maxval = testval;
247 }
248
249 return maxval;
250}
251
252// --------------------------------------------------------------------------
253//
254// get the minimum of error
255// If you specify a geometry the number of photons is weighted with the
256// area of the pixel
257//
258Float_t MCerPhotEvt::GetErrorPhotMin(const MGeomCam *geom) const
259{
260 if (fNumPixels <= 0)
261 return 50.;
262
263 Float_t minval = (*this)[0].GetErrorPhot();
264
265 for (UInt_t i=1; i<fNumPixels; i++)
266 {
267 const MCerPhotPix &pix = (*this)[i];
268
269 Float_t testval = pix.GetErrorPhot();
270
271 if (geom)
272 testval *= geom->GetPixRatio(pix.GetPixId());
273
274 if (testval < minval)
275 minval = testval;
276 }
277 return minval;
278}
279
280// --------------------------------------------------------------------------
281//
282// get the maximum ratio of photons/error
283// If you specify a geometry the number of photons is weighted with the
284// area of the pixel
285//
286Float_t MCerPhotEvt::GetErrorPhotMax(const MGeomCam *geom) const
287{
288 if (fNumPixels <= 0)
289 return 50.;
290
291 Float_t maxval = (*this)[0].GetErrorPhot();
292
293 for (UInt_t i=1; i<fNumPixels; i++)
294 {
295 const MCerPhotPix &pix = (*this)[i];
296
297 Float_t testval = pix.GetErrorPhot();
298
299 if (geom)
300 testval *= geom->GetPixRatio(pix.GetPixId());
301
302 if (testval > maxval)
303 maxval = testval;
304 }
305 return maxval;
306}
307
308// --------------------------------------------------------------------------
309//
310// Return a pointer to the pixel with the requested id. NULL if it doesn't
311// exist.
312//
313MCerPhotPix *MCerPhotEvt::GetPixById(int id) const
314{
315 TIter Next(fPixels);
316 MCerPhotPix *pix = NULL;
317
318 while ((pix=(MCerPhotPix*)Next()))
319 if (pix->GetPixId()==id)
320 return pix;
321
322 return NULL;
323}
Note: See TracBrowser for help on using the repository browser.