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

Last change on this file since 1958 was 1715, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 9.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 const UInt_t n = geom->GetNumPixels();
161
162 Float_t minval = (*this)[0].GetNumPhotons();
163
164 for (UInt_t i=1; i<fNumPixels; i++)
165 {
166 const MCerPhotPix &pix = (*this)[i];
167
168 const UInt_t id = pix.GetPixId();
169 if (id>=n)
170 continue;
171
172 Float_t testval = pix.GetNumPhotons();
173
174 if (geom)
175 testval *= geom->GetPixRatio(id);
176
177 if (testval < minval)
178 minval = testval;
179 }
180
181 return minval;
182}
183
184// --------------------------------------------------------------------------
185//
186// get the maximum number of photons of all valid pixels in the list
187// If you specify a geometry the number of photons is weighted with the
188// area of the pixel
189//
190Float_t MCerPhotEvt::GetNumPhotonsMax(const MGeomCam *geom) const
191{
192 if (fNumPixels <= 0)
193 return 50.;
194
195 const UInt_t n = geom->GetNumPixels();
196
197 Float_t maxval = (*this)[0].GetNumPhotons();
198
199 for (UInt_t i=1; i<fNumPixels; i++)
200 {
201 const MCerPhotPix &pix = (*this)[i];
202
203 const UInt_t id = pix.GetPixId();
204 if (id>=n)
205 continue;
206
207 Float_t testval = pix.GetNumPhotons();
208 if (geom)
209 testval *= geom->GetPixRatio(id);
210
211 if (testval > maxval)
212 maxval = testval;
213 }
214 return maxval;
215}
216
217// --------------------------------------------------------------------------
218//
219// get the minimum ratio of photons/error
220//
221Float_t MCerPhotEvt::GetRatioMin() const
222{
223 if (fNumPixels <= 0)
224 return -5.;
225
226 Float_t minval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
227
228 for (UInt_t i=1; i<fNumPixels; i++)
229 {
230 const MCerPhotPix &pix = (*this)[i];
231
232 Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
233 if (testval < minval)
234 minval = testval;
235 }
236
237 return minval;
238}
239
240// --------------------------------------------------------------------------
241//
242// get the maximum ratio of photons/error
243//
244Float_t MCerPhotEvt::GetRatioMax() const
245{
246 if (fNumPixels <= 0)
247 return -5.;
248
249 Float_t maxval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
250
251 for (UInt_t i=1; i<fNumPixels; i++)
252 {
253 const MCerPhotPix &pix = (*this)[i];
254
255 Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
256 if (testval > maxval)
257 maxval = testval;
258 }
259
260 return maxval;
261}
262
263// --------------------------------------------------------------------------
264//
265// get the minimum of error
266// If you specify a geometry the number of photons is weighted with the
267// area of the pixel
268//
269Float_t MCerPhotEvt::GetErrorPhotMin(const MGeomCam *geom) const
270{
271 if (fNumPixels <= 0)
272 return 50.;
273
274 Float_t minval = (*this)[0].GetErrorPhot();
275
276 for (UInt_t i=1; i<fNumPixels; i++)
277 {
278 const MCerPhotPix &pix = (*this)[i];
279
280 Float_t testval = pix.GetErrorPhot();
281
282 if (geom)
283 testval *= geom->GetPixRatio(pix.GetPixId());
284
285 if (testval < minval)
286 minval = testval;
287 }
288 return minval;
289}
290
291// --------------------------------------------------------------------------
292//
293// get the maximum ratio of photons/error
294// If you specify a geometry the number of photons is weighted with the
295// area of the pixel
296//
297Float_t MCerPhotEvt::GetErrorPhotMax(const MGeomCam *geom) const
298{
299 if (fNumPixels <= 0)
300 return 50.;
301
302 Float_t maxval = (*this)[0].GetErrorPhot();
303
304 for (UInt_t i=1; i<fNumPixels; i++)
305 {
306 const MCerPhotPix &pix = (*this)[i];
307
308 Float_t testval = pix.GetErrorPhot();
309
310 if (geom)
311 testval *= geom->GetPixRatio(pix.GetPixId());
312
313 if (testval > maxval)
314 maxval = testval;
315 }
316 return maxval;
317}
318
319// --------------------------------------------------------------------------
320//
321// Return a pointer to the pixel with the requested id. NULL if it doesn't
322// exist.
323//
324MCerPhotPix *MCerPhotEvt::GetPixById(int id) const
325{
326 TIter Next(fPixels);
327 MCerPhotPix *pix = NULL;
328
329 while ((pix=(MCerPhotPix*)Next()))
330 if (pix->GetPixId()==id)
331 return pix;
332
333 return NULL;
334}
335
336/*
337// --------------------------------------------------------------------------
338//
339// Use this function to sum photons in events together.
340//
341Bool_t MCerPhotEvt::AddEvent(const MCerPhotEvt &evt)
342{
343 if (evt.fNumPixels<=0)
344 {
345 *fLog << "Warning - Event to be added has no pixels." << endl;
346 return kFALSE;
347 }
348 if (fNumPixels<=0)
349 {
350 *fLog << "Warning - Event to add pixels to has no pixels." << endl;
351 return kFALSE;
352 }
353
354 for (UInt_t i=0; i<evt.fNumPixels; i++)
355 {
356 const UInt_t id = evt[i].GetPixId();
357
358 MCerPhotPix *pix2 = GetPixById(id);
359 if (!pix2)
360 {
361 *fLog << "Error - Pixel#" << dec << id << " does not exist in this event!" << endl;
362 return kFALSE;
363 }
364
365 pix2->AddNumPhotons(evt[i].GetNumPhotons());
366 }
367 return kTRUE;
368}
369*/
Note: See TracBrowser for help on using the repository browser.