Changeset 653 for trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
- Timestamp:
- 03/01/01 15:42:32 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
r603 r653 2 2 3 3 #include <math.h> 4 #include <fstream.h> 5 6 #include <TCanvas.h> 4 7 #include <TClonesArray.h> 5 #include <TCanvas.h> 6 7 #include "M CamGeom.h"8 9 #include "MLog.h" 10 #include "MGeomCam.h" 8 11 #include "MCamNeighbor.h" 9 12 #include "MCamDisplay.h" 10 13 #include "MHexagon.h" 11 14 12 ClassImp(MCerPhotPix)13 15 ClassImp(MCerPhotEvt) 14 16 15 MCerPhotPix::MCerPhotPix(Int_t pix, Float_t phot , Float_t errphot ) 16 { 17 // default constructor 18 fPixId = pix ; 19 fIsUsed = kTRUE ; 20 fIsCore = kFALSE ; 21 fPhot = phot ; 22 fErrPhot = errphot ; 23 } 24 25 void MCerPhotPix::SetPixelContent(Int_t pix, Float_t phot , Float_t errphot) 26 { 27 fPixId = pix ; 28 fIsUsed = kTRUE ; 29 fIsUsed = kFALSE ; 30 fPhot = phot ; 31 fErrPhot = errphot ; 32 } 33 34 void MCerPhotPix::Print() 35 { 36 // information about a pixel 37 cout << "MCerPhotPix: Pixel: "<< fPixId ; 38 39 if ( fIsUsed == kTRUE ) 40 cout << " Used " ; 41 else 42 if ( fIsUsed == kFALSE ) 43 cout << " UnUsed " ; 44 45 if ( fIsCore == kTRUE ) 46 cout << " Core " ; 47 else 48 if ( fIsCore == kFALSE ) 49 cout << " " ; 50 51 cout << " Nphot= " << fPhot 52 << " Error(Nphot) = " << fErrPhot 53 << endl ; 54 } 55 56 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 57 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 58 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 59 60 61 MCerPhotEvt::MCerPhotEvt(const char *name, const char *title ) 17 MCerPhotEvt::MCerPhotEvt(const char *name, const char *title ) : fType(0), fNbPixels(0) 62 18 { 63 19 // the default constructor … … 67 23 *fTitle = name ? name : "(Number of Photon)-Event Information"; 68 24 69 fType = 0 ;70 fNbPixels = 0 ;71 72 25 fPixels = new TClonesArray ("MCerPhotPix", 577) ; 73 74 fNN = new MCamNeighbor() ; 75 76 fPixels->Clear() ; 26 27 // 28 // FIXME: is this really necessary? 29 // 30 fPixels->Clear(); 77 31 } 78 32 … … 84 38 MCamDisplay *disp = new MCamDisplay(fType) ; 85 39 86 disp->Draw( this ) ; 87 88 // disp->Draw() ; 89 90 } 91 92 93 40 disp->DrawPhotNum(this) ; 41 } 94 42 95 43 Int_t MCerPhotEvt::GetNbPixels() 96 44 { 97 return fNbPixels ;45 return fNbPixels; 98 46 } 99 47 100 48 void MCerPhotEvt::AddPixel(Int_t id, Float_t nph, Float_t err) 101 49 { 102 TClonesArray &caP = *fPixels ; 103 new ( caP[fNbPixels++] ) MCerPhotPix( id, nph, err ) ; 104 } 105 106 void MCerPhotEvt::Clear() 107 { 108 fNbPixels = 0 ; 109 fPixels->Clear() ; 110 } 111 112 void MCerPhotEvt::Print() 113 { 114 cout << "MCerPhotEvt::Print()" 115 << "Number of Pixels: " << fNbPixels 116 << "(" << fPixels->GetEntries() << ")" 117 << endl ; 118 119 for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 120 { 121 ((MCerPhotPix *) fPixels->At(il))->Print() ; 122 } 50 // 51 // add a new pixel to the list and increase the number 52 // of valid pixels in the list by one 53 // 54 (*fPixels)[fNbPixels++] = new MCerPhotPix( id, nph, err); 55 } 56 57 void MCerPhotEvt::Clear(Option_t *) 58 { 59 // 60 // reset counter and delete netries in list. 61 // 62 fNbPixels = 0 ; 63 fPixels->Clear() ; 64 } 65 66 void MCerPhotEvt::Print(Option_t *) 67 { 68 const Int_t entries = fPixels->GetEntries(); 69 70 *fLog << "MCerPhotEvt::Print()" << endl 71 << "Number of Pixels: " << fNbPixels 72 << "(" << entries << ")" 73 << endl ; 74 75 for (Int_t il=0; il<entries; il++ ) 76 (*this)[il].Print(); 123 77 } 124 78 125 79 void MCerPhotEvt::CleanLevel1() 126 { 127 // This method looks for all pixels with an entry (photons) 128 // that is three times bigger than the noise of the pixel 129 130 Float_t entry, noise ; 131 132 // first look for pixels above some noise level 133 134 for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 135 { 136 entry = ((MCerPhotPix *) fPixels->At(il))->GetPhotons() ; 137 noise = ((MCerPhotPix *) fPixels->At(il))->GetErrorPhot() ; 138 139 if (entry < 3 * noise ) 140 ((MCerPhotPix *) fPixels->At(il))->SetPixelUnused() ; 141 142 } 143 } 80 { 81 // 82 // This method looks for all pixels with an entry (photons) 83 // that is three times bigger than the noise of the pixel 84 // 85 86 const Int_t entries = fPixels->GetEntries(); 87 88 // 89 // check the number of all pixels against the noise level and 90 // set them to 'unused' state if necessary 91 // 92 for (Int_t il=0; il<entries; il++ ) 93 { 94 MCerPhotPix &pix = (*this)[il]; 95 96 const Float_t entry = pix.GetNumPhotons(); 97 const Float_t noise = pix.GetErrorPhot(); 98 99 if (entry < 3 * noise ) 100 pix.SetPixelUnused(); 101 } 102 } 144 103 145 104 void MCerPhotEvt::CleanLevel2() 146 105 { 147 // check if the survived pixel have a neighbor, that also 148 // survived 149 150 Int_t id, id2 ; 151 Int_t itest ; 152 153 for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 154 { 155 if ( ((MCerPhotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE ) 156 { 157 id = ((MCerPhotPix *) fPixels->At(il))->GetPixId() ; 158 159 itest = 0 ; 160 for (Int_t in=0 ; in < 6 ; in++ ) { 161 162 id2 = fNN->GetNN(id, in ) ; 163 164 if (id2 >=0 ) { 165 if ( PixelIsUsed(id2) == kTRUE ) 166 itest++ ; 167 } 168 } 169 170 // 171 // check if no neighbor, then set unused 172 // 173 if ( itest == 0 ) 174 { 175 ((MCerPhotPix *) fPixels->At(il))->SetPixelUnused() ; 176 } 177 178 } 106 // 107 // check if the survived pixel have a neighbor, that also 108 // survived 109 // 110 111 const Int_t entries = fPixels->GetEntries(); 112 113 for (Int_t il=0; il<entries; il++) 114 { 115 // 116 // get entry il from list 117 // 118 MCerPhotPix &pix = (*this)[il]; 119 120 // 121 // check if pixel is in use, if not goto next pixel in list 122 // 123 if (!pix.IsPixelUsed()) 124 continue; 125 126 // 127 // get pixel id of this entry 128 // 129 const Int_t id = pix.GetPixId() ; 130 131 // 132 // count number of next neighbors of this pixel which 133 // state is 'used' 134 // 135 Int_t itest = 0 ; 136 for (Int_t in=0 ; in < 6; in++ ) 137 { 138 const Int_t id2 = fNN.GetNN(id, in) ; 139 140 if (id2 < 0) 141 continue; 142 143 if (IsPixelUsed(id2)) 144 itest++ ; 145 } 146 147 // 148 // check if no next neighbor has the state 'used' 149 // set this pixel to 'unused', too. 150 // 151 if (itest==0) 152 pix.SetPixelUnused(); 153 } 154 155 // 156 // now we declare all pixels that survive as CorePixels 157 // 158 for (Int_t il=0; il<entries; il++) 159 { 160 MCerPhotPix &pix = (*this)[il]; 161 162 if (pix.IsPixelUsed()) 163 pix.SetCorePixel(); 164 } 165 166 } 167 168 void MCerPhotEvt::CleanLevel3() 169 { 170 // 171 // Look for the boundary pixels around the core pixels 172 // if a pixel has more than 2.5 sigma, and a core neigbor 173 // it is declared as used. 174 // 175 const Int_t entries = fPixels->GetEntries(); 176 177 for (Int_t il=0; il<entries; il++) 178 { 179 // 180 // get pixel as entry il from list 181 // 182 MCerPhotPix &pix = (*this)[il]; 183 184 // 185 // if pixel is a core pixel go to the next pixel 186 // 187 if (pix.IsCorePixel()) 188 continue; 189 190 // 191 // check the num of photons against the noise level 192 // 193 const Float_t entry = pix.GetNumPhotons(); 194 const Float_t noise = pix.GetErrorPhot(); 195 196 if (entry <= 2.5 * noise ) 197 continue; 198 199 // 200 // get pixel id of this entry 201 // 202 const Int_t id = pix.GetPixId(); 203 204 // 205 // check if the pixel's next neighbor is a core pixel. 206 // if it is a core pixel set pixel state to: used. 207 // 208 for (Int_t in=0; in<6 ; in++) 209 { 210 const Int_t id2 = fNN.GetNN(id, in); 211 212 if (id2 <0) 213 continue; 214 215 if (!IsPixelCore(id2)) 216 continue; 217 218 pix.SetPixelUsed(); 219 220 break ; 221 } 222 } 223 } 224 225 226 Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) 227 { 228 // 229 // Checks if in the pixel list is an entry with pixel id 230 // 231 const Int_t entries = fPixels->GetEntries(); 232 233 for (Int_t il=0; il<entries; il++) 234 { 235 if (id == (*this)[il].GetPixId()) 236 return kTRUE ; 237 } 238 239 return kFALSE ; 240 } 241 242 Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) 243 { 244 // 245 // Checks if in the pixel list is an entry with pixel id 246 // 247 const Int_t entries = fPixels->GetEntries(); 248 249 for (Int_t il=0; il<entries; il++ ) 250 { 251 MCerPhotPix &pix = (*this)[il]; 252 253 if (id == pix.GetPixId() && pix.IsPixelUsed()) 254 return kTRUE ; 255 } 256 257 return kFALSE ; 258 } 259 260 Bool_t MCerPhotEvt::IsPixelCore(Int_t id) 261 { 262 // 263 // Checks if in the pixel list is an entry with pixel id 264 // 265 const Int_t entries = fPixels->GetEntries(); 266 267 for (Int_t il=0; il<entries; il++ ) 268 { 269 MCerPhotPix &pix = (*this)[il]; 270 271 if ( id == pix.GetPixId() && pix.IsCorePixel()) 272 return kTRUE ; 179 273 } 180 181 // now we declare all pixels that survive as CorePixels 182 183 for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 184 { 185 if ( ((MCerPhotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE ) 186 { 187 ((MCerPhotPix *) fPixels->At(il))->SetCorePixel() ; 188 } 189 } 190 191 } 192 193 void MCerPhotEvt::CleanLevel3() 194 { 195 // Look for the boundary pixels around the core pixels 196 // if a pixel has more than 2.5 sigma, and a core neigbor 197 // it is declared as used. 198 199 Float_t entry, noise ; 200 Int_t id, id2 ; 201 for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 202 { 203 if ( ((MCerPhotPix *) fPixels->At(il))->IsCorePixel() == kFALSE ) 204 { 205 entry = ((MCerPhotPix *) fPixels->At(il))->GetPhotons() ; 206 noise = ((MCerPhotPix *) fPixels->At(il))->GetErrorPhot() ; 207 208 if (entry > 2.5 * noise ) { 209 id = ((MCerPhotPix *) fPixels->At(il))->GetPixId() ; 210 for (Int_t in=0 ; in < 6 ; in++ ) 211 { 212 id2 = fNN->GetNN(id, in ) ; 213 if (id2 >=0 ) 214 { 215 if ( PixelIsCore(id2) == kTRUE ) { 216 ((MCerPhotPix *) fPixels->At(il))->SetPixelUsed() ; 217 break ; 218 } 219 } 220 } 221 } 222 } 223 } 224 } 225 226 227 228 229 Bool_t MCerPhotEvt::PixelExist(Int_t id ) 230 { 231 // Checks if in the pixel list is an entry with pixel id 232 233 for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 234 { 235 if ( id == ((MCerPhotPix *) fPixels->At(il))->GetPixId() ) { 236 237 // cout << " PixelExist " << il ; 238 return kTRUE ; 239 } 240 } 241 242 return kFALSE ; 243 244 } 245 246 Bool_t MCerPhotEvt::PixelIsUsed(Int_t id ) 247 { 248 // Checks if in the pixel list is an entry with pixel id 249 250 for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 251 { 252 if ( id == ((MCerPhotPix *) fPixels->At(il))->GetPixId() && 253 ((MCerPhotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE ) { 254 255 // cout << " PixelIsUsed " << il ; 256 return kTRUE ; 257 } 258 } 259 260 return kFALSE ; 261 262 } 263 264 Bool_t MCerPhotEvt::PixelIsCore(Int_t id ) 265 { 266 // Checks if in the pixel list is an entry with pixel id 267 268 for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 269 { 270 if ( id == ((MCerPhotPix *) fPixels->At(il))->GetPixId() && 271 ((MCerPhotPix *) fPixels->At(il))->IsCorePixel() == kTRUE ) { 272 273 return kTRUE ; 274 } 275 } 276 277 return kFALSE ; 278 279 } 280 281 Int_t MCerPhotEvt::GetPixelId(Int_t i ) 282 { 283 return ( ( (MCerPhotPix *) fPixels->At(i))->GetPixId() ) ; 284 } 285 286 Bool_t MCerPhotEvt::IsPixelUsed(Int_t i ) 287 { 288 return ( ( (MCerPhotPix *) fPixels->At(i))->IsPixelUsed() ) ; 289 } 290 291 Float_t MCerPhotEvt::GetPhotons(Int_t i ) 292 { 293 return ( ( (MCerPhotPix *) fPixels->At(i))->GetPhotons() ) ; 294 } 295 296 Float_t MCerPhotEvt::GetErrorPhot(Int_t i ) 297 { 298 return ( ( (MCerPhotPix *) fPixels->At(i))->GetErrorPhot() ) ; 299 } 300 301 302 Float_t MCerPhotEvt::GetMinimumPhoton() 303 { 304 if ( fNbPixels <= 0 ) 305 return -5. ; 306 307 Float_t minWert ; 308 minWert = ((MCerPhotPix *) fPixels->At(0))->GetPhotons() ; 309 310 Float_t testWert ; 311 312 for ( Int_t i =0 ; i<fNbPixels ; i++ ) { 313 testWert = ((MCerPhotPix *) fPixels->At(i))->GetPhotons() ; 314 315 if ( minWert >= testWert ) 316 minWert = testWert ; 317 } 318 319 return minWert ; 320 } 321 322 Float_t MCerPhotEvt::GetMaximumPhoton() 323 { 324 if ( fNbPixels <= 0 ) 325 return 50. ; 326 327 Float_t maxWert ; 328 maxWert = ((MCerPhotPix *) fPixels->At(0))->GetPhotons() ; 329 330 Float_t testWert ; 331 332 for ( Int_t i =0 ; i<fNbPixels ; i++ ) { 333 testWert = ((MCerPhotPix *) fPixels->At(i))->GetPhotons() ; 334 335 if ( maxWert <= testWert ) 336 maxWert = testWert ; 337 } 338 339 return maxWert ; 340 } 341 274 275 return kFALSE ; 276 } 277 278 Float_t MCerPhotEvt::GetMinNumPhotons() 279 { 280 // 281 // get the minimum number of photons of all valid pixels in the list 282 // 283 if (fNbPixels <= 0) 284 return -5. ; 285 286 Float_t minval = (*this)[0].GetNumPhotons(); 287 288 Float_t testval; 289 for (Int_t i=1 ; i<fNbPixels; i++ ) 290 { 291 testval = (*this)[i].GetNumPhotons(); 292 293 if (testval < minval) 294 minval = testval; 295 } 296 297 return minval; 298 } 299 300 Float_t MCerPhotEvt::GetMaxNumPhotons() 301 { 302 // 303 // get the maximum number of photons of all valid pixels in the list 304 // 305 if (fNbPixels <= 0) 306 return 50.; 307 308 Float_t maxval = (*this)[0].GetNumPhotons(); 309 310 Float_t testval; 311 for (Int_t i=1; i<fNbPixels; i++) 312 { 313 testval = (*this)[i].GetNumPhotons(); 314 315 if (testval > maxval) 316 maxval = testval; 317 } 318 return maxval; 319 } 320
Note:
See TracChangeset
for help on using the changeset viewer.