1 | #include "MNphotEvent.h"
|
---|
2 |
|
---|
3 | #include <math.h>
|
---|
4 | #include <TClonesArray.h>
|
---|
5 | #include <TCanvas.h>
|
---|
6 |
|
---|
7 | #include "MCamGeom.h"
|
---|
8 | #include "MCamNeighbor.h"
|
---|
9 | #include "MCamDisplay.h"
|
---|
10 | #include "MHexagon.h"
|
---|
11 |
|
---|
12 | ClassImp(MNphotPix)
|
---|
13 | ClassImp(MNphotEvent)
|
---|
14 |
|
---|
15 | MNphotPix::MNphotPix(Int_t pix, Float_t phot , Float_t errphot )
|
---|
16 | {
|
---|
17 | // default constructor
|
---|
18 | fPixId = pix ;
|
---|
19 | fIsUsed = kTRUE ;
|
---|
20 | fPhot = phot ;
|
---|
21 | fErrPhot = errphot ;
|
---|
22 | }
|
---|
23 |
|
---|
24 | void MNphotPix::SetPixelContent(Int_t pix, Float_t phot , Float_t errphot)
|
---|
25 | {
|
---|
26 | fPixId = pix ;
|
---|
27 | fIsUsed = kTRUE ;
|
---|
28 | fPhot = phot ;
|
---|
29 | fErrPhot = errphot ;
|
---|
30 | }
|
---|
31 |
|
---|
32 | void MNphotPix::Print()
|
---|
33 | {
|
---|
34 | // information about a pixel
|
---|
35 | cout << "MNphotPix: Pixel: "<< fPixId ;
|
---|
36 |
|
---|
37 | if ( fIsUsed == kTRUE )
|
---|
38 | cout << " Used " ;
|
---|
39 | else
|
---|
40 | if ( fIsUsed == kFALSE )
|
---|
41 | cout << " UnUsed " ;
|
---|
42 |
|
---|
43 | cout << " Nphot= " << fPhot
|
---|
44 | << " Error(Nphot) = " << fErrPhot
|
---|
45 | << endl ;
|
---|
46 | }
|
---|
47 |
|
---|
48 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
---|
49 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
---|
50 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
---|
51 |
|
---|
52 |
|
---|
53 | MNphotEvent::MNphotEvent(const char *name, const char *title )
|
---|
54 | {
|
---|
55 | // the default constructor
|
---|
56 |
|
---|
57 |
|
---|
58 | *fName = name ? name : "MNphotEvent";
|
---|
59 | *fTitle = name ? name : "(Number of Photon)-Event Information";
|
---|
60 |
|
---|
61 | fType = 0 ;
|
---|
62 | fNbPixels = 0 ;
|
---|
63 |
|
---|
64 | fPixels = new TClonesArray ("MNphotPix", 577) ;
|
---|
65 |
|
---|
66 | fNN = new MCamNeighbor() ;
|
---|
67 |
|
---|
68 | fPixels->Clear() ;
|
---|
69 | }
|
---|
70 |
|
---|
71 | void MNphotEvent::Draw(Option_t* option)
|
---|
72 | {
|
---|
73 | // FIXME!!!
|
---|
74 | //
|
---|
75 |
|
---|
76 | MCamDisplay *disp = new MCamDisplay(fType) ;
|
---|
77 |
|
---|
78 | disp->Draw( this ) ;
|
---|
79 |
|
---|
80 | // disp->Draw() ;
|
---|
81 |
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 | Int_t MNphotEvent::GetNbPixels()
|
---|
88 | {
|
---|
89 | return fNbPixels ;
|
---|
90 | }
|
---|
91 |
|
---|
92 | void MNphotEvent::AddPixel(Int_t id, Float_t nph, Float_t err)
|
---|
93 | {
|
---|
94 | TClonesArray &caP = *fPixels ;
|
---|
95 | new ( caP[fNbPixels++] ) MNphotPix( id, nph, err ) ;
|
---|
96 | }
|
---|
97 |
|
---|
98 | void MNphotEvent::Clear()
|
---|
99 | {
|
---|
100 | fNbPixels = 0 ;
|
---|
101 | fPixels->Clear() ;
|
---|
102 | }
|
---|
103 |
|
---|
104 | void MNphotEvent::Print()
|
---|
105 | {
|
---|
106 | cout << "MNphotEvent::Print()"
|
---|
107 | << "Number of Pixels: " << fNbPixels
|
---|
108 | << "(" << fPixels->GetEntries() << ")"
|
---|
109 | << endl ;
|
---|
110 |
|
---|
111 | for (Int_t il=0; il<fPixels->GetEntries(); il++ )
|
---|
112 | {
|
---|
113 | ((MNphotPix *) fPixels->At(il))->Print() ;
|
---|
114 | }
|
---|
115 | }
|
---|
116 |
|
---|
117 | void MNphotEvent::CleanLevel1()
|
---|
118 | {
|
---|
119 | // This method looks for all pixels with an entry (photons)
|
---|
120 | // that is three times bigger than the noise of the pixel
|
---|
121 |
|
---|
122 | Float_t entry, noise ;
|
---|
123 |
|
---|
124 | // first look for pixels above some noise level
|
---|
125 |
|
---|
126 | for (Int_t il=0; il<fPixels->GetEntries(); il++ )
|
---|
127 | {
|
---|
128 | entry = ((MNphotPix *) fPixels->At(il))->GetPhotons() ;
|
---|
129 | noise = 3 * ((MNphotPix *) fPixels->At(il))->GetErrorPhot() ;
|
---|
130 |
|
---|
131 | if (entry < 3 * noise )
|
---|
132 | ((MNphotPix *) fPixels->At(il))->SetPixelUnused() ;
|
---|
133 |
|
---|
134 | }
|
---|
135 | }
|
---|
136 |
|
---|
137 | void MNphotEvent::CleanLevel2()
|
---|
138 | {
|
---|
139 | // check if the survived pixel have a neighbor, that also
|
---|
140 | // survived
|
---|
141 |
|
---|
142 | Int_t id, id2 ;
|
---|
143 | Int_t itest ;
|
---|
144 |
|
---|
145 | for (Int_t il=0; il<fPixels->GetEntries(); il++ )
|
---|
146 | {
|
---|
147 | if ( ((MNphotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE )
|
---|
148 | {
|
---|
149 | id = ((MNphotPix *) fPixels->At(il))->GetPixId() ;
|
---|
150 |
|
---|
151 | itest = 0 ;
|
---|
152 | for (Int_t in=0 ; in < 6 ; in++ ) {
|
---|
153 |
|
---|
154 | id2 = fNN->GetNN(id, in ) ;
|
---|
155 |
|
---|
156 | if ( PixelIsUsed(id2) == kTRUE )
|
---|
157 | cout << " hulibu " << id << "/" << id2 << endl ;
|
---|
158 |
|
---|
159 |
|
---|
160 | }
|
---|
161 | }
|
---|
162 | }
|
---|
163 | }
|
---|
164 |
|
---|
165 | Bool_t MNphotEvent::PixelExist(Int_t id )
|
---|
166 | {
|
---|
167 | // Checks if in the pixel list is an entry with pixel id
|
---|
168 |
|
---|
169 | for (Int_t il=0; il<fPixels->GetEntries(); il++ )
|
---|
170 | {
|
---|
171 | if ( id == ((MNphotPix *) fPixels->At(il))->GetPixId() ) {
|
---|
172 |
|
---|
173 | cout << " PixelExist " << il ;
|
---|
174 | return kTRUE ;
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | return kFALSE ;
|
---|
179 |
|
---|
180 | }
|
---|
181 |
|
---|
182 | Bool_t MNphotEvent::PixelIsUsed(Int_t id )
|
---|
183 | {
|
---|
184 | // Checks if in the pixel list is an entry with pixel id
|
---|
185 |
|
---|
186 | for (Int_t il=0; il<fPixels->GetEntries(); il++ )
|
---|
187 | {
|
---|
188 | if ( id == ((MNphotPix *) fPixels->At(il))->GetPixId() &&
|
---|
189 | ((MNphotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE ) {
|
---|
190 |
|
---|
191 | cout << " PixelIsUsed " << il ;
|
---|
192 | return kTRUE ;
|
---|
193 | }
|
---|
194 | }
|
---|
195 |
|
---|
196 | return kFALSE ;
|
---|
197 |
|
---|
198 | }
|
---|
199 |
|
---|
200 | Int_t MNphotEvent::GetPixelId(Int_t i )
|
---|
201 | {
|
---|
202 | return ( ( (MNphotPix *) fPixels->At(i))->GetPixId() ) ;
|
---|
203 | }
|
---|
204 |
|
---|
205 | Bool_t MNphotEvent::IsPixelUsed(Int_t i )
|
---|
206 | {
|
---|
207 | return ( ( (MNphotPix *) fPixels->At(i))->IsPixelUsed() ) ;
|
---|
208 | }
|
---|
209 |
|
---|
210 | Float_t MNphotEvent::GetPhotons(Int_t i )
|
---|
211 | {
|
---|
212 | return ( ( (MNphotPix *) fPixels->At(i))->GetPhotons() ) ;
|
---|
213 | }
|
---|
214 |
|
---|
215 | Float_t MNphotEvent::GetErrorPhot(Int_t i )
|
---|
216 | {
|
---|
217 | return ( ( (MNphotPix *) fPixels->At(i))->GetErrorPhot() ) ;
|
---|
218 | }
|
---|
219 |
|
---|
220 |
|
---|
221 | Float_t MNphotEvent::GetMinimumPhoton()
|
---|
222 | {
|
---|
223 | if ( fNbPixels <= 0 )
|
---|
224 | return -5. ;
|
---|
225 |
|
---|
226 | Float_t minWert ;
|
---|
227 | minWert = ((MNphotPix *) fPixels->At(0))->GetPhotons() ;
|
---|
228 |
|
---|
229 | Float_t testWert ;
|
---|
230 |
|
---|
231 | for ( Int_t i =0 ; i<fNbPixels ; i++ ) {
|
---|
232 | testWert = ((MNphotPix *) fPixels->At(i))->GetPhotons() ;
|
---|
233 |
|
---|
234 | if ( minWert >= testWert )
|
---|
235 | minWert = testWert ;
|
---|
236 | }
|
---|
237 |
|
---|
238 | return minWert ;
|
---|
239 | }
|
---|
240 |
|
---|
241 | Float_t MNphotEvent::GetMaximumPhoton()
|
---|
242 | {
|
---|
243 | if ( fNbPixels <= 0 )
|
---|
244 | return 50. ;
|
---|
245 |
|
---|
246 | Float_t maxWert ;
|
---|
247 | maxWert = ((MNphotPix *) fPixels->At(0))->GetPhotons() ;
|
---|
248 |
|
---|
249 | Float_t testWert ;
|
---|
250 |
|
---|
251 | for ( Int_t i =0 ; i<fNbPixels ; i++ ) {
|
---|
252 | testWert = ((MNphotPix *) fPixels->At(i))->GetPhotons() ;
|
---|
253 |
|
---|
254 | if ( maxWert <= testWert )
|
---|
255 | maxWert = testWert ;
|
---|
256 | }
|
---|
257 |
|
---|
258 | return maxWert ;
|
---|
259 | }
|
---|
260 |
|
---|