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 "MHexagon.h"
|
---|
11 | #include "MCerPhotPix.h"
|
---|
12 |
|
---|
13 | ClassImp(MCerPhotEvt)
|
---|
14 |
|
---|
15 | MCerPhotEvt::MCerPhotEvt(const char *name, const char *title) : fNumPixels(0)
|
---|
16 | {
|
---|
17 | // the default constructor
|
---|
18 |
|
---|
19 |
|
---|
20 | *fName = name ? name : "MCerPhotEvt";
|
---|
21 | *fTitle = name ? name : "(Number of Photon)-Event Information";
|
---|
22 |
|
---|
23 | fPixels = new TClonesArray ("MCerPhotPix", 577) ;
|
---|
24 |
|
---|
25 | //
|
---|
26 | // FIXME: is this really necessary?
|
---|
27 | //
|
---|
28 | fPixels->Clear();
|
---|
29 | }
|
---|
30 |
|
---|
31 | void MCerPhotEvt::Draw(Option_t* option)
|
---|
32 | {
|
---|
33 | //
|
---|
34 | // FIXME!!! Here the Draw function of the CamDisplay
|
---|
35 | // should be called to add the CamDisplay to the Pad.
|
---|
36 | // The drawing should be done in MCamDisplay::Paint
|
---|
37 | //
|
---|
38 |
|
---|
39 | // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
|
---|
40 | // MCamDisplay *disp = new MCamDisplay(geom);
|
---|
41 | // delete geom;
|
---|
42 | // disp->DrawPhotNum(this);
|
---|
43 | }
|
---|
44 |
|
---|
45 | void MCerPhotEvt::AddPixel(Int_t id, Float_t nph, Float_t err)
|
---|
46 | {
|
---|
47 | //
|
---|
48 | // add a new pixel to the list and increase the number
|
---|
49 | // of valid pixels in the list by one
|
---|
50 | //
|
---|
51 |
|
---|
52 | // TClonesArray -> 'operator new with placement' should be used
|
---|
53 | new ((*fPixels)[fNumPixels++]) MCerPhotPix( id, nph, err);
|
---|
54 | }
|
---|
55 |
|
---|
56 | void MCerPhotEvt::Clear(Option_t *)
|
---|
57 | {
|
---|
58 | //
|
---|
59 | // reset counter and delete netries in list.
|
---|
60 | //
|
---|
61 | fNumPixels = 0 ;
|
---|
62 | fPixels->Clear() ;
|
---|
63 | }
|
---|
64 |
|
---|
65 | void MCerPhotEvt::Print(Option_t *)
|
---|
66 | {
|
---|
67 | const Int_t entries = fPixels->GetEntries();
|
---|
68 |
|
---|
69 | *fLog << "MCerPhotEvt::Print()" << endl
|
---|
70 | << "Number of Pixels: " << fNumPixels
|
---|
71 | << "(" << entries << ")"
|
---|
72 | << endl ;
|
---|
73 |
|
---|
74 | for (Int_t il=0; il<entries; il++ )
|
---|
75 | (*this)[il].Print();
|
---|
76 | }
|
---|
77 |
|
---|
78 | Bool_t MCerPhotEvt::IsPixelExisting(Int_t id)
|
---|
79 | {
|
---|
80 | //
|
---|
81 | // Checks if in the pixel list is an entry with pixel id
|
---|
82 | //
|
---|
83 | const Int_t entries = fPixels->GetEntries();
|
---|
84 |
|
---|
85 | for (Int_t il=0; il<entries; il++)
|
---|
86 | {
|
---|
87 | if (id == (*this)[il].GetPixId())
|
---|
88 | return kTRUE ;
|
---|
89 | }
|
---|
90 |
|
---|
91 | return kFALSE ;
|
---|
92 | }
|
---|
93 |
|
---|
94 | Bool_t MCerPhotEvt::IsPixelUsed(Int_t id)
|
---|
95 | {
|
---|
96 | //
|
---|
97 | // Checks if in the pixel list is an entry with pixel id
|
---|
98 | //
|
---|
99 | const Int_t entries = fPixels->GetEntries();
|
---|
100 |
|
---|
101 | for (Int_t il=0; il<entries; il++ )
|
---|
102 | {
|
---|
103 | MCerPhotPix &pix = (*this)[il];
|
---|
104 |
|
---|
105 | if (id == pix.GetPixId() && pix.IsPixelUsed())
|
---|
106 | return kTRUE ;
|
---|
107 | }
|
---|
108 |
|
---|
109 | return kFALSE ;
|
---|
110 | }
|
---|
111 |
|
---|
112 | Bool_t MCerPhotEvt::IsPixelCore(Int_t id)
|
---|
113 | {
|
---|
114 | //
|
---|
115 | // Checks if in the pixel list is an entry with pixel id
|
---|
116 | //
|
---|
117 | const Int_t entries = fPixels->GetEntries();
|
---|
118 |
|
---|
119 | for (Int_t il=0; il<entries; il++ )
|
---|
120 | {
|
---|
121 | MCerPhotPix &pix = (*this)[il];
|
---|
122 |
|
---|
123 | if ( id == pix.GetPixId() && pix.IsCorePixel())
|
---|
124 | return kTRUE ;
|
---|
125 | }
|
---|
126 |
|
---|
127 | return kFALSE ;
|
---|
128 | }
|
---|
129 |
|
---|
130 | Float_t MCerPhotEvt::GetNumPhotonsMin()
|
---|
131 | {
|
---|
132 | //
|
---|
133 | // get the minimum number of photons of all valid pixels in the list
|
---|
134 | //
|
---|
135 | if (fNumPixels <= 0)
|
---|
136 | return -5. ;
|
---|
137 |
|
---|
138 | Float_t minval = (*this)[0].GetNumPhotons();
|
---|
139 |
|
---|
140 | Float_t testval;
|
---|
141 | for (UInt_t i=1 ; i<fNumPixels; i++ )
|
---|
142 | {
|
---|
143 | testval = (*this)[i].GetNumPhotons();
|
---|
144 |
|
---|
145 | if (testval < minval)
|
---|
146 | minval = testval;
|
---|
147 | }
|
---|
148 |
|
---|
149 | return minval;
|
---|
150 | }
|
---|
151 |
|
---|
152 | Float_t MCerPhotEvt::GetNumPhotonsMax()
|
---|
153 | {
|
---|
154 | //
|
---|
155 | // get the maximum number of photons of all valid pixels in the list
|
---|
156 | //
|
---|
157 | if (fNumPixels <= 0)
|
---|
158 | return 50.;
|
---|
159 |
|
---|
160 | Float_t maxval = (*this)[0].GetNumPhotons();
|
---|
161 |
|
---|
162 | Float_t testval;
|
---|
163 | for (UInt_t i=1; i<fNumPixels; i++)
|
---|
164 | {
|
---|
165 | testval = (*this)[i].GetNumPhotons();
|
---|
166 |
|
---|
167 | if (testval > maxval)
|
---|
168 | maxval = testval;
|
---|
169 | }
|
---|
170 | return maxval;
|
---|
171 | }
|
---|
172 |
|
---|