Changeset 8489 for trunk/MagicSoft/Mars/msignal
- Timestamp:
- 05/10/07 16:33:01 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/msignal
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MSignalCam.cc
r7876 r8489 18 18 ! Author(s): Thomas Bretz, 03/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 520 ! Copyright: MAGIC Software Development, 2000-2007 21 21 ! 22 22 ! … … 38 38 #include <fstream> 39 39 40 #include <TArrayI.h> 40 41 #include <TArrayD.h> 41 #include <TCanvas.h>42 42 43 43 #include "MLog.h" … … 68 68 // -------------------------------------------------------------------------- 69 69 // 70 // This is not yet implemented like it should.71 //72 /*73 void MSignalCam::Draw(Option_t* option)74 {75 //76 // FIXME!!! Here the Draw function of the CamDisplay77 // should be called to add the CamDisplay to the Pad.78 // The drawing should be done in MCamDisplay::Paint79 //80 81 // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;82 // MCamDisplay *disp = new MCamDisplay(geom);83 // delete geom;84 // disp->DrawPhotNum(this);85 }86 */87 88 // --------------------------------------------------------------------------89 //90 70 // reset counter and delete netries in list. 91 71 // 92 72 void MSignalCam::Reset() 93 73 { 94 //fNumPixels = 0;95 74 fNumSinglePixels = 0; 96 75 fSizeSinglePixels = 0; 97 76 fSizeSubIslands = 0; 98 77 fSizeMainIsland = 0; 99 //fMaxIndex = -1;100 78 fNumIslands = -1; 101 //fLut.Set(0);102 79 103 80 fNumPixelsSaturatedHiGain = -1; … … 106 83 fPixels->R__FOR_EACH(TObject, Clear)(); 107 84 } 108 /*109 void MSignalCam::FixSize()110 {111 fLut.Set(fMaxIndex+1);112 113 if (fPixels->GetEntriesFast() == (Int_t)fNumPixels)114 return;115 116 fPixels->ExpandCreateFast(fNumPixels);117 }*/118 85 119 86 // -------------------------------------------------------------------------- … … 134 101 // -------------------------------------------------------------------------- 135 102 // 136 // Checks if in the pixel list is an entry with pixel id 137 // 138 Bool_t MSignalCam::IsPixelExisting(Int_t id) const 139 { 140 return GetPixById(id) ? kTRUE : kFALSE; 141 } 142 143 // -------------------------------------------------------------------------- 144 // 145 // Checks if in the pixel list is an entry with pixel id 146 // 147 Bool_t MSignalCam::IsPixelUsed(Int_t id) const 148 { 149 const MSignalPix *pix = GetPixById(id); 150 return pix ? pix->IsPixelUsed() : kFALSE; 151 } 152 153 // -------------------------------------------------------------------------- 154 // 155 // Checks if in the pixel list is an entry with pixel id 156 // 157 Bool_t MSignalCam::IsPixelCore(Int_t id) const 158 { 159 const MSignalPix *pix = GetPixById(id); 160 return pix ? pix->IsPixelCore() : kFALSE; 161 } 103 // Count and return the number of unmapped pixels 104 // 105 Int_t MSignalCam::GetNumPixelsUnmapped() const 106 { 107 const UInt_t n = GetNumPixels(); 108 109 if (n <= 0) 110 return -1; 111 112 Int_t cnt=0; 113 for (UInt_t i=0; i<n; i++) 114 { 115 if ((*this)[i].IsPixelUnmapped()) 116 cnt++; 117 } 118 119 return cnt; 120 } 162 121 163 122 // -------------------------------------------------------------------------- … … 169 128 Float_t MSignalCam::GetNumPhotonsMin(const MGeomCam *geom) const 170 129 { 171 if (GetNumPixels() <= 0) 130 const UInt_t n = GetNumPixels(); 131 132 if (n <= 0) 172 133 return -5.; 173 134 174 const UInt_t n = GetNumPixels();175 176 135 Float_t minval = FLT_MAX; 177 136 … … 181 140 if (!pix.IsPixelUsed()) 182 141 continue; 183 184 //const UInt_t id = pix.GetPixId();185 //if (id<0 || id>=n)186 // continue;187 142 188 143 Float_t testval = pix.GetNumPhotons(); … … 206 161 Float_t MSignalCam::GetNumPhotonsMax(const MGeomCam *geom) const 207 162 { 208 if (GetNumPixels() <= 0) 163 const UInt_t n = GetNumPixels(); 164 165 if (n <= 0) 209 166 return 50.; 210 167 211 const UInt_t n = GetNumPixels();212 213 168 Float_t maxval = -FLT_MAX; 214 169 … … 218 173 if (!pix.IsPixelUsed()) 219 174 continue; 220 221 //const UInt_t id = pix.GetPixId();222 //if (id<0 || id>=n)223 // continue;224 175 225 176 Float_t testval = pix.GetNumPhotons(); … … 239 190 Float_t MSignalCam::GetRatioMin(const MGeomCam *geom) const 240 191 { 241 if (GetNumPixels() <= 0) 192 const UInt_t n = GetNumPixels(); 193 194 if (n <= 0) 242 195 return -5.; 243 196 244 197 Float_t minval = FLT_MAX; 245 198 246 for (UInt_t i=0; i< GetNumPixels(); i++)199 for (UInt_t i=0; i<n; i++) 247 200 { 248 201 const MSignalPix &pix = (*this)[i]; … … 252 205 Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot(); 253 206 if (geom) 254 testval *= geom->GetPixRatioSqrt(i /*pix.GetPixId()*/);207 testval *= geom->GetPixRatioSqrt(i); 255 208 256 209 if (testval < minval) … … 267 220 Float_t MSignalCam::GetRatioMax(const MGeomCam *geom) const 268 221 { 269 if (GetNumPixels() <= 0) 222 const UInt_t n = GetNumPixels(); 223 224 if (n <= 0) 270 225 return -5.; 271 226 272 227 Float_t maxval = -FLT_MAX; 273 228 274 for (UInt_t i=0; i< GetNumPixels(); i++)229 for (UInt_t i=0; i<n; i++) 275 230 { 276 231 const MSignalPix &pix = (*this)[i]; … … 280 235 Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot(); 281 236 if (geom) 282 testval *= geom->GetPixRatioSqrt(i /*pix.GetPixId()*/);237 testval *= geom->GetPixRatioSqrt(i); 283 238 284 239 if (testval > maxval) … … 297 252 Float_t MSignalCam::GetErrorPhotMin(const MGeomCam *geom) const 298 253 { 299 if (GetNumPixels() <= 0) 254 const UInt_t n = GetNumPixels(); 255 256 if (n <= 0) 300 257 return 50.; 301 258 302 259 Float_t minval = FLT_MAX; 303 260 304 for (UInt_t i=0; i< GetNumPixels(); i++)261 for (UInt_t i=0; i<n; i++) 305 262 { 306 263 const MSignalPix &pix = (*this)[i]; … … 311 268 312 269 if (geom) 313 testval *= geom->GetPixRatio(i /*pix.GetPixId()*/);270 testval *= geom->GetPixRatio(i); 314 271 315 272 if (testval < minval) … … 327 284 Float_t MSignalCam::GetErrorPhotMax(const MGeomCam *geom) const 328 285 { 329 if (GetNumPixels() <= 0) 286 const UInt_t n = GetNumPixels(); 287 288 if (n <= 0) 330 289 return 50.; 331 290 332 291 Float_t maxval = -FLT_MAX; 333 292 334 for (UInt_t i=0; i< GetNumPixels(); i++)293 for (UInt_t i=0; i<n; i++) 335 294 { 336 295 const MSignalPix &pix = (*this)[i]; … … 341 300 342 301 if (geom) 343 testval *= geom->GetPixRatio(i /*pix.GetPixId()*/);302 testval *= geom->GetPixRatio(i); 344 303 345 304 if (testval > maxval) … … 348 307 return maxval; 349 308 } 350 /*351 void MSignalCam::RemoveUnusedPixels()352 {353 // Create iterator354 TIter Next(fPixels);355 MSignalPix *pix = NULL;356 357 fMaxIndex = -1;358 359 // Remove all unused pixels from list, calculate new fMaxIndex360 while ((pix=(MSignalPix*)Next()))361 {362 if (!pix->IsPixelUsed())363 fPixels->Remove(pix);364 else365 fMaxIndex = TMath::Max(fMaxIndex, pix->GetPixId());366 }367 368 // Crompress array369 fPixels->Compress();370 371 // Get new number of entries in array372 fNumPixels=fPixels->GetEntriesFast();373 374 // Rebuild lookup table375 RebuildLut();376 }377 */378 // --------------------------------------------------------------------------379 //380 // Return a pointer to the pixel with the requested idx. NULL if it doesn't381 // exist. The Look-up-table fLut is used. If its size is zero (according382 // to Rene this will happen if an old class object is loaded) we still383 // try to search in the array.384 //385 MSignalPix *MSignalCam::GetPixById(Int_t idx) const386 {387 return (MSignalPix*)(fPixels->UncheckedAt(idx));388 /*389 if (idx<0)390 return 0;391 392 if (fLut.GetSize()>0)393 {394 if (idx>=fLut.GetSize())395 return 0;396 return fLut[idx]<0 ? 0 : (MSignalPix*)(fPixels->UncheckedAt(fLut[idx]));397 }398 399 TIter Next(fPixels);400 MSignalPix *pix = NULL;401 402 while ((pix=(MSignalPix*)Next()))403 if (pix->GetPixId()==idx)404 return pix;405 406 return NULL;*/407 }408 309 409 310 MSignalPix *MSignalCam::AddPixel(Int_t idx, Float_t nph, Float_t er) 410 311 { 411 /*412 //413 // If this is too slow or takes to much space we might use414 // MGeomApply and an InitSize member function instead.415 //416 if (idx>=fLut.GetSize())417 {418 const Int_t n = fLut.GetSize();419 fLut.Set(idx*2+1); //idx+1 is slower than idx*2+1420 for (int i=n; i<idx*2+1; i++)421 fLut[i] = -1;422 }423 424 fLut[idx] = fNumPixels;425 if (idx>fMaxIndex)426 fMaxIndex=idx;427 428 return new ((*fPixels)[fNumPixels++]) MSignalPix(idx, nph, er);429 */430 //return new ((*fPixels)[idx]) MSignalPix(nph, er);431 432 312 MSignalPix *pix = static_cast<MSignalPix*>((*fPixels)[idx]); 433 313 pix->Set(nph, er); … … 452 332 Double_t MSignalCam::CalcIsland(const MGeomCam &geom, Int_t idx, Int_t num) 453 333 { 454 // Try to get the pixel information of a pixel with this index455 MSignalPix *pix = GetPixById(idx);456 457 // If a pixel with this index is not existing... do nothing.458 if ( !pix)334 // Get the pixel information of a pixel with this index 335 MSignalPix &pix = (*this)[idx]; 336 337 // If an island number was already assigned to this pixel... do nothing. 338 if (pix.GetIdxIsland()>=0) 459 339 return 0; 460 340 461 // If an island number was already assigned to thispixel... do nothing.462 if ( pix->GetIdxIsland()>=0)341 // If the pixel is an unused pixel... do nothing. 342 if (!pix.IsPixelUsed()) 463 343 return 0; 464 344 465 // If the pixel is an unused pixel... do nothing.466 if (!pix->IsPixelUsed())467 return 0;468 469 345 // Assign the new island number num to this used pixel 470 pix ->SetIdxIsland(num);346 pix.SetIdxIsland(num); 471 347 472 348 // Get the geometry information (neighbors) of this pixel … … 474 350 475 351 // Get the size of this pixel 476 Double_t size = pix ->GetNumPhotons();352 Double_t size = pix.GetNumPhotons(); 477 353 478 354 // Now do the same with all its neighbors and sum the … … 603 479 Bool_t MSignalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const 604 480 { 605 MSignalPix *pix = GetPixById(idx); 606 if (!pix) 481 if (idx<0 || (UInt_t)idx>GetNumPixels()) 607 482 return kFALSE; 608 483 484 const MSignalPix &pix = (*this)[idx]; 485 609 486 // Used inlcudes status unampped 610 if (!pix ->IsPixelUsed() && (type<6 || type==8))487 if (!pix.IsPixelUsed() && (type<6 || type==8)) 611 488 return kFALSE; 612 489 … … 616 493 { 617 494 case 1: // scaled error of phtoons 618 val = pix ->GetErrorPhot()*TMath::Sqrt(ratio);495 val = pix.GetErrorPhot()*TMath::Sqrt(ratio); 619 496 return kTRUE; 620 497 621 498 case 2: // significance of number of photons 622 if (pix ->GetErrorPhot()<=0)499 if (pix.GetErrorPhot()<=0) 623 500 return kFALSE; 624 val = pix ->GetNumPhotons()*TMath::Sqrt(ratio)/pix->GetErrorPhot();501 val = pix.GetNumPhotons()*TMath::Sqrt(ratio)/pix.GetErrorPhot(); 625 502 return kTRUE; 626 503 627 504 case 3: // number of photo electrons 628 val = pix ->GetNumPhotons();505 val = pix.GetNumPhotons(); 629 506 break; 630 507 631 508 case 4: // error of signal 632 val = pix ->GetErrorPhot();509 val = pix.GetErrorPhot(); 633 510 break; 634 511 635 512 case 5: // index of island 636 val = pix ->GetIdxIsland();513 val = pix.GetIdxIsland(); 637 514 break; 638 515 639 516 case 6: // arrival time of mapped pixels only 640 if (pix ->IsPixelUnmapped())517 if (pix.IsPixelUnmapped()) 641 518 return kFALSE; 642 val = pix ->GetArrivalTime();519 val = pix.GetArrivalTime(); 643 520 break; 644 521 … … 647 524 // otherwise to many large pixels survive (maybe because the 648 525 // fluctuations scale different than expected) 649 if (pix ->IsPixelUnmapped() || pix->GetNumPhotons()<50)526 if (pix.IsPixelUnmapped() || pix.GetNumPhotons()<50) 650 527 return kFALSE; 651 val = pix ->GetArrivalTime();528 val = pix.GetArrivalTime(); 652 529 break; 653 530 654 531 case 8: // arrival time 655 val = pix ->GetArrivalTime();532 val = pix.GetArrivalTime(); 656 533 break; 657 534 658 535 /* 659 536 case 10: // lo gain time 660 if (pix ->IsPixelUnmapped() || !pix->IsLoGainUsed() ||661 pix ->GetNumPhotons()<320)537 if (pix.IsPixelUnmapped() || !pix.IsLoGainUsed() || 538 pix.GetNumPhotons()<320) 662 539 return kFALSE; 663 val = pix ->GetArrivalTime();540 val = pix.GetArrivalTime(); 664 541 return kTRUE; 665 542 … … 668 545 // otherwise to many large pixels survive (maybe because the 669 546 // fluctuations scale different than expected) 670 if (pix ->IsPixelUnmapped() || pix->IsLoGainUsed() ||671 pix ->GetNumPhotons()<50)547 if (pix.IsPixelUnmapped() || pix.IsLoGainUsed() || 548 pix.GetNumPhotons()<50) 672 549 return kFALSE; 673 val = pix ->GetArrivalTime();550 val = pix.GetArrivalTime(); 674 551 return kTRUE; 675 552 */ 676 553 677 554 default: 678 val = pix ->GetNumPhotons()*ratio;555 val = pix.GetNumPhotons()*ratio; 679 556 return kTRUE; 680 557 } -
trunk/MagicSoft/Mars/msignal/MSignalCam.h
r8391 r8489 4 4 #ifndef ROOT_TClonesArray 5 5 #include <TClonesArray.h> 6 #endif7 #ifndef ROOT_TArrayI8 #include <TArrayI.h>9 6 #endif 10 7 #ifndef MARS_MCamEvent … … 60 57 Int_t GetNumPixelsSaturatedLoGain() const { return fNumPixelsSaturatedLoGain; } 61 58 62 Bool_t IsPixelExisting(Int_t id) const; 63 Bool_t IsPixelUsed (Int_t id) const; 64 Bool_t IsPixelCore (Int_t id) const; 59 Int_t GetNumPixelsUnmapped() const; 65 60 66 61 Float_t GetNumPhotonsMin(const MGeomCam *geom=NULL) const; … … 77 72 MSignalPix &operator[](int i) const { return *(MSignalPix*)(fPixels->UncheckedAt(i)); } 78 73 79 MSignalPix *GetPixById(Int_t idx) const;80 81 74 // Functions to change the contained data 82 //void Scale(Double_t f) { fPixels->ForEach(MSignalPix, Scale)(f); }83 75 Int_t CalcIslands(const MGeomCam &geom); 84 76
Note:
See TracChangeset
for help on using the changeset viewer.