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

Last change on this file since 601 was 601, checked in by harald, 24 years ago
At the Barcelona workshop we decided to rename the class MNphotEvent to MCerPhotEvt. This is done now.
File size: 5.2 KB
Line 
1#include "MCerPhotEvt.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
12ClassImp(MCerPhotPix)
13ClassImp(MCerPhotEvt)
14
15MCerPhotPix::MCerPhotPix(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
24void MCerPhotPix::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
32void MCerPhotPix::Print()
33{
34 // information about a pixel
35 cout << "MCerPhotPix: 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
53MCerPhotEvt::MCerPhotEvt(const char *name, const char *title )
54{
55 // the default constructor
56
57
58 *fName = name ? name : "MCerPhotEvt";
59 *fTitle = name ? name : "(Number of Photon)-Event Information";
60
61 fType = 0 ;
62 fNbPixels = 0 ;
63
64 fPixels = new TClonesArray ("MCerPhotPix", 577) ;
65
66 fNN = new MCamNeighbor() ;
67
68 fPixels->Clear() ;
69}
70
71void MCerPhotEvt::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
87Int_t MCerPhotEvt::GetNbPixels()
88{
89 return fNbPixels ;
90}
91
92void MCerPhotEvt::AddPixel(Int_t id, Float_t nph, Float_t err)
93{
94 TClonesArray &caP = *fPixels ;
95 new ( caP[fNbPixels++] ) MCerPhotPix( id, nph, err ) ;
96}
97
98void MCerPhotEvt::Clear()
99{
100 fNbPixels = 0 ;
101 fPixels->Clear() ;
102}
103
104void MCerPhotEvt::Print()
105{
106 cout << "MCerPhotEvt::Print()"
107 << "Number of Pixels: " << fNbPixels
108 << "(" << fPixels->GetEntries() << ")"
109 << endl ;
110
111 for (Int_t il=0; il<fPixels->GetEntries(); il++ )
112 {
113 ((MCerPhotPix *) fPixels->At(il))->Print() ;
114 }
115}
116
117void MCerPhotEvt::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 = ((MCerPhotPix *) fPixels->At(il))->GetPhotons() ;
129 noise = 3 * ((MCerPhotPix *) fPixels->At(il))->GetErrorPhot() ;
130
131 if (entry < 3 * noise )
132 ((MCerPhotPix *) fPixels->At(il))->SetPixelUnused() ;
133
134 }
135}
136
137void MCerPhotEvt::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 ( ((MCerPhotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE )
148 {
149 id = ((MCerPhotPix *) 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
165Bool_t MCerPhotEvt::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 == ((MCerPhotPix *) fPixels->At(il))->GetPixId() ) {
172
173 cout << " PixelExist " << il ;
174 return kTRUE ;
175 }
176 }
177
178 return kFALSE ;
179
180}
181
182Bool_t MCerPhotEvt::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 == ((MCerPhotPix *) fPixels->At(il))->GetPixId() &&
189 ((MCerPhotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE ) {
190
191 cout << " PixelIsUsed " << il ;
192 return kTRUE ;
193 }
194 }
195
196 return kFALSE ;
197
198}
199
200Int_t MCerPhotEvt::GetPixelId(Int_t i )
201{
202 return ( ( (MCerPhotPix *) fPixels->At(i))->GetPixId() ) ;
203}
204
205Bool_t MCerPhotEvt::IsPixelUsed(Int_t i )
206{
207 return ( ( (MCerPhotPix *) fPixels->At(i))->IsPixelUsed() ) ;
208}
209
210Float_t MCerPhotEvt::GetPhotons(Int_t i )
211{
212 return ( ( (MCerPhotPix *) fPixels->At(i))->GetPhotons() ) ;
213}
214
215Float_t MCerPhotEvt::GetErrorPhot(Int_t i )
216{
217 return ( ( (MCerPhotPix *) fPixels->At(i))->GetErrorPhot() ) ;
218}
219
220
221Float_t MCerPhotEvt::GetMinimumPhoton()
222{
223 if ( fNbPixels <= 0 )
224 return -5. ;
225
226 Float_t minWert ;
227 minWert = ((MCerPhotPix *) fPixels->At(0))->GetPhotons() ;
228
229 Float_t testWert ;
230
231 for ( Int_t i =0 ; i<fNbPixels ; i++ ) {
232 testWert = ((MCerPhotPix *) fPixels->At(i))->GetPhotons() ;
233
234 if ( minWert >= testWert )
235 minWert = testWert ;
236 }
237
238 return minWert ;
239}
240
241Float_t MCerPhotEvt::GetMaximumPhoton()
242{
243 if ( fNbPixels <= 0 )
244 return 50. ;
245
246 Float_t maxWert ;
247 maxWert = ((MCerPhotPix *) fPixels->At(0))->GetPhotons() ;
248
249 Float_t testWert ;
250
251 for ( Int_t i =0 ; i<fNbPixels ; i++ ) {
252 testWert = ((MCerPhotPix *) fPixels->At(i))->GetPhotons() ;
253
254 if ( maxWert <= testWert )
255 maxWert = testWert ;
256 }
257
258 return maxWert ;
259}
260
Note: See TracBrowser for help on using the repository browser.