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

Last change on this file since 761 was 749, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 4.5 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): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
19! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.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#include <TClonesArray.h>
33
34#include "MLog.h"
35#include "MHexagon.h"
36#include "MCerPhotPix.h"
37
38ClassImp(MCerPhotEvt)
39
40MCerPhotEvt::MCerPhotEvt(const char *name, const char *title) : fNumPixels(0)
41{
42 // the default constructor
43
44
45 *fName = name ? name : "MCerPhotEvt";
46 *fTitle = name ? name : "(Number of Photon)-Event Information";
47
48 fPixels = new TClonesArray ("MCerPhotPix", 577) ;
49
50 //
51 // FIXME: is this really necessary?
52 //
53 fPixels->Clear();
54}
55
56void MCerPhotEvt::Draw(Option_t* option)
57{
58 //
59 // FIXME!!! Here the Draw function of the CamDisplay
60 // should be called to add the CamDisplay to the Pad.
61 // The drawing should be done in MCamDisplay::Paint
62 //
63
64 // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
65 // MCamDisplay *disp = new MCamDisplay(geom);
66 // delete geom;
67 // disp->DrawPhotNum(this);
68}
69
70void MCerPhotEvt::AddPixel(Int_t id, Float_t nph, Float_t err)
71{
72 //
73 // add a new pixel to the list and increase the number
74 // of valid pixels in the list by one
75 //
76
77 // TClonesArray -> 'operator new with placement' should be used
78 new ((*fPixels)[fNumPixels++]) MCerPhotPix( id, nph, err);
79}
80
81void MCerPhotEvt::Clear(Option_t *)
82{
83 //
84 // reset counter and delete netries in list.
85 //
86 fNumPixels = 0 ;
87 fPixels->Clear() ;
88}
89
90void MCerPhotEvt::Print(Option_t *)
91{
92 const Int_t entries = fPixels->GetEntries();
93
94 *fLog << "MCerPhotEvt::Print()" << endl
95 << "Number of Pixels: " << fNumPixels
96 << "(" << entries << ")"
97 << endl ;
98
99 for (Int_t il=0; il<entries; il++ )
100 (*this)[il].Print();
101}
102
103Bool_t MCerPhotEvt::IsPixelExisting(Int_t id)
104{
105 //
106 // Checks if in the pixel list is an entry with pixel id
107 //
108 const Int_t entries = fPixels->GetEntries();
109
110 for (Int_t il=0; il<entries; il++)
111 {
112 if (id == (*this)[il].GetPixId())
113 return kTRUE ;
114 }
115
116 return kFALSE ;
117}
118
119Bool_t MCerPhotEvt::IsPixelUsed(Int_t id)
120{
121 //
122 // Checks if in the pixel list is an entry with pixel id
123 //
124 const Int_t entries = fPixels->GetEntries();
125
126 for (Int_t il=0; il<entries; il++ )
127 {
128 MCerPhotPix &pix = (*this)[il];
129
130 if (id == pix.GetPixId() && pix.IsPixelUsed())
131 return kTRUE ;
132 }
133
134 return kFALSE ;
135}
136
137Bool_t MCerPhotEvt::IsPixelCore(Int_t id)
138{
139 //
140 // Checks if in the pixel list is an entry with pixel id
141 //
142 const Int_t entries = fPixels->GetEntries();
143
144 for (Int_t il=0; il<entries; il++ )
145 {
146 MCerPhotPix &pix = (*this)[il];
147
148 if ( id == pix.GetPixId() && pix.IsCorePixel())
149 return kTRUE ;
150 }
151
152 return kFALSE ;
153}
154
155Float_t MCerPhotEvt::GetNumPhotonsMin()
156{
157 //
158 // get the minimum number of photons of all valid pixels in the list
159 //
160 if (fNumPixels <= 0)
161 return -5. ;
162
163 Float_t minval = (*this)[0].GetNumPhotons();
164
165 Float_t testval;
166 for (UInt_t i=1 ; i<fNumPixels; i++ )
167 {
168 testval = (*this)[i].GetNumPhotons();
169
170 if (testval < minval)
171 minval = testval;
172 }
173
174 return minval;
175}
176
177Float_t MCerPhotEvt::GetNumPhotonsMax()
178{
179 //
180 // get the maximum number of photons of all valid pixels in the list
181 //
182 if (fNumPixels <= 0)
183 return 50.;
184
185 Float_t maxval = (*this)[0].GetNumPhotons();
186
187 Float_t testval;
188 for (UInt_t i=1; i<fNumPixels; i++)
189 {
190 testval = (*this)[i].GetNumPhotons();
191
192 if (testval > maxval)
193 maxval = testval;
194 }
195 return maxval;
196}
197
Note: See TracBrowser for help on using the repository browser.