Changeset 2409
- Timestamp:
- 10/20/03 17:44:51 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
r2206 r2409 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>19 ! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)20 ! 21 ! Copyright: MAGIC Software Development, 2000-200 118 ! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! Author(s): Harald Kornmayer, 1/2001 20 ! 21 ! Copyright: MAGIC Software Development, 2000-2003 22 22 ! 23 23 ! 24 24 \* ======================================================================== */ 25 25 26 ///////////////////////////////////////////////////////////////////////////// 27 // 28 // MCerPhotEvt 29 // 30 // Class Version 1: 31 // - first version 32 // 33 // Class Version 2: 34 // - added fLut to accelerate GetPixById a lot 35 // 36 ///////////////////////////////////////////////////////////////////////////// 26 37 #include "MCerPhotEvt.h" 27 38 … … 33 44 34 45 #include "MLog.h" 46 #include "MLogManip.h" 35 47 36 48 #include "MGeomCam.h" … … 56 68 // This is not yet implemented like it should. 57 69 // 70 /* 58 71 void MCerPhotEvt::Draw(Option_t* option) 59 72 { … … 69 82 // disp->DrawPhotNum(this); 70 83 } 84 */ 71 85 72 86 // -------------------------------------------------------------------------- … … 77 91 { 78 92 fNumPixels = 0; 79 // fPixels->Delete(); 93 fLut.Set(0); 94 // fPixels->Delete(); 80 95 } 81 96 … … 109 124 Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const 110 125 { 111 const Int_t entries = fPixels->GetEntries(); 112 113 for (Int_t i=0; i<entries; i++) 114 { 115 if (id == (*this)[i].GetPixId()) 116 return kTRUE; 117 } 118 119 return kFALSE; 126 const MCerPhotPix *pix = GetPixById(id); 127 return pix ? kTRUE : kFALSE; 120 128 } 121 129 … … 126 134 Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const 127 135 { 128 const Int_t entries = fPixels->GetEntries(); 129 130 for (Int_t i=0; i<entries; i++) 131 { 132 const MCerPhotPix &pix = (*this)[i]; 133 if (!pix.IsPixelUsed()) 134 continue; 135 136 if (id == pix.GetPixId() && pix.IsPixelUsed()) 137 return kTRUE; 138 } 139 140 return kFALSE; 136 const MCerPhotPix *pix = GetPixById(id); 137 return pix ? pix->IsPixelUsed() : kFALSE; 141 138 } 142 139 … … 147 144 Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const 148 145 { 149 const Int_t entries = fPixels->GetEntries(); 150 151 for (Int_t i=0; i<entries; i++) 152 { 153 const MCerPhotPix &pix = (*this)[i]; 154 if (!pix.IsPixelUsed()) 155 continue; 156 157 if (id == pix.GetPixId() && pix.IsPixelCore()) 158 return kTRUE; 159 } 160 161 return kFALSE; 146 const MCerPhotPix *pix = GetPixById(id); 147 return pix ? pix->IsPixelCore() : kFALSE; 162 148 } 163 149 … … 350 336 } 351 337 352 // --------------------------------------------------------------------------353 //354 // Return a pointer to the pixel with the requested id. NULL if it doesn't355 // exist.356 //357 MCerPhotPix *MCerPhotEvt::GetPixById(int id) const358 {359 TIter Next(fPixels);360 MCerPhotPix *pix = NULL;361 362 while ((pix=(MCerPhotPix*)Next()))363 if (pix->GetPixId()==id)364 return pix;365 366 return NULL;367 }368 369 void MCerPhotEvt::Scale(Double_t f)370 {371 fPixels->ForEach(MCerPhotPix, Scale)(f);372 }373 374 338 void MCerPhotEvt::RemoveUnusedPixels() 375 339 { … … 383 347 fPixels->Compress(); 384 348 fNumPixels=fPixels->GetEntriesFast(); 349 } 350 351 // -------------------------------------------------------------------------- 352 // 353 // Return a pointer to the pixel with the requested id. NULL if it doesn't 354 // exist. 355 // 356 MCerPhotPix *MCerPhotEvt::GetPixById(int idx) const 357 { 358 if (fLut.GetSize()>0) 359 return idx>=0 && idx<fLut.GetSize() ? (MCerPhotPix*)(fPixels->UncheckedAt(fLut[idx])) : 0; 360 361 TIter Next(fPixels); 362 MCerPhotPix *pix = NULL; 363 364 while ((pix=(MCerPhotPix*)Next())) 365 if (pix->GetPixId()==idx) 366 return pix; 367 368 return NULL; 385 369 } 386 370 … … 425 409 return kTRUE; 426 410 } 411 412 void MCerPhotEvt::DrawPixelContent(Int_t num, TVirtualPad *pad=NULL) const 413 { 414 *fLog << warn << "MCerPhotEvt::DrawPixelContent - not available." << endl; 415 } -
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r2377 r2409 80 80 void MHCamera::Init() 81 81 { 82 UseCurrentStyle(); 83 82 84 SetDirectory(NULL); 83 85 … … 241 243 Int_t MHCamera::Fill(Axis_t x, Axis_t y, Stat_t w) 242 244 { 243 if (fNcells<=1 )245 if (fNcells<=1 || IsFreezed()) 244 246 return -1; 245 247 … … 265 267 mean += fArray[i]; 266 268 267 return mean/(fNcells-2);269 return Profile(mean/(fNcells-2)); 268 270 } 269 271 … … 286 288 sq /= n; 287 289 288 return sqrt(sq-sum*sum);290 return Profile(sqrt(sq-sum*sum)); 289 291 } 290 292 … … 297 299 { 298 300 if (fMinimum != -1111) 299 return fMinimum;301 return Profile(fMinimum); 300 302 301 303 if (fNcells<=1) … … 316 318 minimum = fArray[idx+1]; 317 319 } 318 return minimum;320 return Profile(minimum); 319 321 } 320 322 … … 326 328 Double_t MHCamera::GetMaximum(Bool_t all) const 327 329 { 328 if (fMaximum !=-1111)329 return fMaximum;330 if (fMaximum!=-1111) 331 return Profile(fMaximum); 330 332 331 333 if (fNcells<=1) … … 345 347 maximum = fArray[idx+1]; 346 348 } 347 return maximum;349 return Profile(maximum); 348 350 } 349 351 … … 455 457 gLog << warn << "MHCamera::Update: " << GetName() << " <" << GetTitle() << "> - Pixel Index #" << i << " contents is NaN (Not a Number)..." << endl; 456 458 457 hex.SetFillColor(GetColor( fArray[i+1], min, max, islog));459 hex.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog)); 458 460 } 459 461 else … … 466 468 if (IsUsed(i) && !TMath::IsNaN(fArray[i+1])) 467 469 { 468 Float_t size = pix.GetD()*( fArray[i+1]-min)/(max-min);470 Float_t size = pix.GetD()*(GetBinContent(i+1)-min)/(max-min); 469 471 if (size>pix.GetD()) 470 472 size=pix.GetD(); … … 673 675 void MHCamera::AddCamContent(const MCamEvent &event, Int_t type) 674 676 { 675 if (fNcells<=1 )677 if (fNcells<=1 || IsFreezed()) 676 678 return; 677 679 … … 699 701 void MHCamera::AddCamContent(const MHCamera &d, Int_t type) 700 702 { 701 if (fNcells!=d.fNcells )703 if (fNcells!=d.fNcells || IsFreezed()) 702 704 return; 703 705 … … 733 735 void MHCamera::AddCamContent(const TArrayD &event, const TArrayC *used) 734 736 { 735 if (event.GetSize()!=fNcells-2 )737 if (event.GetSize()!=fNcells-2 || IsFreezed()) 736 738 return; 737 739 … … 756 758 void MHCamera::CntCamContent(const MCamEvent &event, Double_t threshold, Int_t type) 757 759 { 758 if (fNcells<=1 )760 if (fNcells<=1 || IsFreezed()) 759 761 return; 760 762 … … 779 781 void MHCamera::CntCamContent(const TArrayD &event, Double_t threshold, Bool_t ispos) 780 782 { 781 if (event.GetSize()!=fNcells-2 )783 if (event.GetSize()!=fNcells-2 || IsFreezed()) 782 784 return; 783 785 … … 799 801 void MHCamera::FillRandom() 800 802 { 801 if (fNcells<=1 )803 if (fNcells<=1 || IsFreezed()) 802 804 return; 803 805 … … 855 857 void MHCamera::Reset(Option_t *opt) 856 858 { 857 if (fNcells<=1 )859 if (fNcells<=1 || IsFreezed()) 858 860 return; 859 861 … … 1127 1129 cout << "Software Pixel Index: " << idx << endl; 1128 1130 cout << "Hardware Pixel Id: " << idx+1 << endl; 1129 cout << "Contents: " << fArray[idx+1]<< " <";1131 cout << "Contents: " << GetBinContent(idx+1) << " <"; 1130 1132 cout << (IsUsed(idx)?"on":"off"); 1131 1133 cout << ">" << endl; 1132 1134 1133 1135 if (fNotify && fNotify->GetSize()>0) 1134 new TCanvas; 1135 fNotify->ForEach(MCamEvent, DrawPixelContent)(idx); 1136 { 1137 TCanvas *c=new TCanvas; 1138 fNotify->ForEach(MCamEvent, DrawPixelContent)(idx, c); 1139 } 1136 1140 } 1137 1141 … … 1140 1144 return fGeomCam->GetNumPixels(); 1141 1145 } 1146 1147 TH1 *MHCamera::DrawCopy() const 1148 { 1149 gPad=NULL; 1150 return TH1D::DrawCopy(); 1151 } -
trunk/MagicSoft/Mars/mhist/MHCamera.h
r2377 r2409 28 28 class MHCamera : public TH1D 29 29 { 30 public: 31 enum { 32 kProfile = BIT(18), 33 kFreezed = BIT(19) 34 }; 30 35 private: 31 36 MGeomCam *fGeomCam; // pointer to camera geometry (y-axis) … … 35 40 TList *fNotify; //! 36 41 42 Bool_t fFreezed; //! Just a dummy!!!! ([Set,Is]Freezed) 43 37 44 //Int_t fOptStat; 38 39 45 //TGStatusBar *fStatusBar; 46 40 47 void Init(); 48 49 Stat_t Profile(Stat_t val) const 50 { 51 if (!TestBit(kProfile)) 52 return val; 53 54 const Stat_t n = TH1D::GetEntries(); 55 return n>0 ? val/n : val; 56 } 41 57 42 58 Int_t GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog); … … 109 125 virtual void CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE); 110 126 127 Stat_t GetBinContent(Int_t bin) const { return Profile(TH1D::GetBinContent(bin)); } 128 Stat_t GetBinContent(Int_t binx, Int_t biny) const { return GetBinContent(binx); } 129 Stat_t GetBinContent(Int_t binx, Int_t biny, Int_t binz) const { return GetBinContent(binx); } 130 Stat_t GetBinError(Int_t bin) const { return Profile(TH1D::GetBinError(bin)); } 131 Stat_t GetBinError(Int_t binx, Int_t biny) const { return GetBinError(binx); } 132 Stat_t GetBinError(Int_t binx, Int_t biny, Int_t binz) const { return GetBinError(binx); } 133 111 134 Double_t GetMinimum(Bool_t all) const; 112 135 Double_t GetMaximum(Bool_t all) const; … … 126 149 127 150 void PrintInfo() const { Print(""); } // *MENU* 151 void Reset(Option_t *); 152 void Reset() { Reset(""); } // *MENU* 153 TH1 *DrawCopy() const/* { gPad=NULL; return TH1D::DrawCopy(); }*/; // *MENU* 154 128 155 void Print(Option_t *) const; 129 156 void Paint(Option_t *option=""); 130 void Reset(Option_t * = "");131 157 void Draw(Option_t *option=""); 132 158 void SavePrimitive(ofstream &out, Option_t *); … … 141 167 void SetInvDeepBlueSeaPalette(); // *MENU* 142 168 143 void SetAutoScale(); // *MENU* 144 //void SetOptStat(Int_t os=-1); // *MENU* 169 void SetAutoScale() { fMinimum = fMaximum = -1111; } // *MENU* 170 void DisplayAsHistogram() { SetDrawOption("histEP"); } // *MENU* 171 void DisplayAsCamera() { SetDrawOption(""); } // *MENU* 172 173 void SetFreezed(Bool_t f=kTRUE) { f ? SetBit(kFreezed) : ResetBit(kFreezed); } // *TOGGLE* 174 Bool_t IsFreezed() const { return TestBit(kFreezed); } 175 //void SetOptStat(Int_t os=-1) { fOptStat = os; } // *MENU* 145 176 146 177 void SetPix(const Int_t pixnum, const Int_t color, Float_t min, Float_t max); // New function added by M.Lopez in 31-01-03 … … 159 190 ClassDef(MHCamera, 1) // Displays the magic camera 160 191 }; 161 162 inline void MHCamera::SetAutoScale() { fMinimum = fMaximum = -1111; }163 //inline void MHCamera::SetOptStat(Int_t os) { fOptStat = os; }164 192 165 193 #endif
Note:
See TracChangeset
for help on using the changeset viewer.