Changeset 2153 for trunk/MagicSoft/Mars
- Timestamp:
- 06/03/03 10:27:05 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2152 r2153 1 1 -*-*- END OF LINE -*-*- 2 3 2003/06/03: Thomas Bretz 4 5 * macros/readcurrents.C: 6 - display currents in Log-Scale 7 8 * mgui/MCamDisplay.[h,cc]: 9 - introduced fMinimum 10 - introduced fMaximum 11 - introduced fData 12 - removed Set-functions 13 - introduced Update() 14 - introduced Log-Scale 15 16 * macros/readCT1.C: 17 - fixed a typo 18 19 2 20 3 21 2003/06/03: Wolfgang Wittek … … 45 63 * mhist/MH.[h,cc]: 46 64 - added usescreenfactor to MakeDefCanvas 47 48 65 49 66 -
trunk/MagicSoft/Mars/macros/readcurrents.C
r2147 r2153 79 79 MCamDisplay display(&geomcam); 80 80 display.Draw(); 81 gPad->SetLogz(); 81 82 82 83 int gifcnt = 0; -
trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
r2147 r2153 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 19 ! Author(s): Harald Kornmayer 1/200118 ! Author(s): Thomas Bretz, 05/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! Author(s): Harald Kornmayer, 1/2001 20 20 ! 21 ! Copyright: MAGIC Software Development, 2000-200 221 ! Copyright: MAGIC Software Development, 2000-2003 22 22 ! 23 23 ! … … 30 30 // Camera Display. The Pixels are displayed in 31 31 // contents/area [somthing/mm^2] 32 // 33 // To change the scale to a logarithmic scale SetLogz() of the Pad. 34 // 32 35 // 33 36 //////////////////////////////////////////////////////////////////////////// … … 72 75 // 73 76 MCamDisplay::MCamDisplay() 74 : fGeomCam(NULL), fAutoScale(kTRUE) , fW(0), fH(0)77 : fGeomCam(NULL), fAutoScale(kTRUE) 75 78 { 76 79 fNumPixels = 0; … … 84 87 fLegRadius = NULL; 85 88 fLegDegree = NULL; 89 90 fMinimum = 0; 91 fMaximum = 1; 92 93 //fData.Set(0); 86 94 } 87 95 … … 91 99 // 92 100 MCamDisplay::MCamDisplay(MGeomCam *geom) 93 : fGeomCam(NULL), fAutoScale(kTRUE), f W(0), fH(0)101 : fGeomCam(NULL), fAutoScale(kTRUE), fData(geom->GetNumPixels()), fMinimum(0), fMaximum(1) 94 102 { 95 103 fGeomCam = (MGeomCam*)geom->Clone(); … … 119 127 #endif 120 128 pix.SetFillColor(16); 129 pix.ResetBit(kIsUsed); 121 130 } 122 131 … … 176 185 SetPalette(51, 0); 177 186 #endif 178 179 187 } 180 188 … … 204 212 } 205 213 206 inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const UInt_t i, Float_t min, Float_t max)207 {208 if (i>=fNumPixels)209 return;210 211 //212 // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.213 //214 const Float_t ratio = fGeomCam->GetPixRatio(i);215 const Float_t pnum = ratio*pix.GetNumPhotons();216 217 (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max));218 }219 220 inline void MCamDisplay::SetPixColorPedestal(const MPedestalPix &pix, const UInt_t i, Float_t min, Float_t max)221 {222 if (i>=fNumPixels)223 return;224 225 //226 // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.227 //228 const Float_t ratio = fGeomCam->GetPixRatio(i);229 const Float_t pnum = ratio*pix.GetMean();230 231 (*this)[i].SetFillColor(GetColor(pnum, min, max));232 }233 234 inline void MCamDisplay::SetPixColorError(const MCerPhotPix &pix, const UInt_t i, Float_t min, Float_t max)235 {236 if (i>=fNumPixels)237 return;238 239 //240 // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.241 //242 const Float_t ratio = fGeomCam->GetPixRatio(i);243 const Float_t pnum = sqrt(ratio)*pix.GetErrorPhot();244 245 (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max));246 }247 248 inline void MCamDisplay::SetPixColorRatio(const MCerPhotPix &pix, Float_t min, Float_t max)249 {250 //251 // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.252 //253 // *OLD* const Float_t r = pix.GetNumPhotons()/pix.GetErrorPhot();254 // if (entry * ratio <= fCleanLvl1 * noise)255 256 const Float_t entry = pix.GetNumPhotons();257 const Float_t noise = pix.GetErrorPhot();258 const Double_t ratio = TMath::Sqrt(fGeomCam->GetPixRatio(pix.GetPixId()));259 260 const Float_t r = entry*ratio/noise;261 //const Float_t pnum = pix.GetNumPhotons()/pix.GetErrorPhot();262 263 (*this)[pix.GetPixId()].SetFillColor(GetColor(r, min, max));264 }265 266 inline void MCamDisplay::SetPixColorLevel(const MCerPhotPix &pix, Float_t lvl1, Float_t lvl2)267 {268 const Int_t maxcolidx = kItemsLegend-1;269 270 MHexagon &hex = (*this)[pix.GetPixId()];271 272 // *OLD* const Float_t r = pix.GetNumPhotons()/pix.GetErrorPhot();273 // if (entry * ratio <= fCleanLvl1 * noise)274 275 const Float_t entry = pix.GetNumPhotons();276 const Float_t noise = pix.GetErrorPhot();277 const Double_t ratio = TMath::Sqrt(fGeomCam->GetPixRatio(pix.GetPixId()));278 279 const Float_t r = entry*ratio/noise;280 281 if (r>lvl1)282 hex.SetFillColor(fColors[4*maxcolidx/5]);283 else284 if (r>lvl2)285 hex.SetFillColor(fColors[maxcolidx/2]);286 else287 hex.SetFillColor(fColors[maxcolidx/5]);288 }289 290 214 // ------------------------------------------------------------------------ 291 215 // … … 300 224 // gPad->SetFixedAspectRatio() 301 225 302 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 750, 600);226 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 656, 600); 303 227 pad->SetBorderMode(0); 304 228 pad->SetFillColor(16); … … 326 250 } 327 251 252 void MCamDisplay::Update(Bool_t islog) 253 { 254 // FIXME: Don't do this if nothing changed! 255 if (fAutoScale) 256 { 257 fMinimum = FLT_MAX; 258 fMaximum = -FLT_MAX; 259 260 for (UInt_t i=0; i<fNumPixels; i++) 261 { 262 if (!(*this)[i].TestBit(kIsUsed)) 263 continue; 264 265 if (fData[i]<fMinimum) 266 fMinimum = fData[i]; 267 if (fData[i]>fMaximum) 268 fMaximum = fData[i]; 269 } 270 } 271 272 if (fMinimum==fMaximum) 273 fMaximum = fMinimum + 1; 274 275 UpdateLegend(fMinimum, fMaximum, islog); 276 277 for (UInt_t i=0; i<fNumPixels; i++) 278 { 279 if ((*this)[i].TestBit(kIsUsed)) 280 (*this)[i].SetFillColor(GetColor(fData[i], fMinimum, fMaximum, islog)); 281 else 282 (*this)[i].SetFillColor(10); 283 284 } 285 } 286 328 287 // ------------------------------------------------------------------------ 329 288 // … … 337 296 return; 338 297 339 //340 298 // Maintain aspect ratio 341 //342 299 SetRange(); 343 300 344 //345 301 // Maintain colors 346 //347 302 SetPalette(); 348 303 349 // 304 // Update Contents of the pixels 305 Update(gPad->GetLogz()); 306 350 307 // Paint Legend 351 //352 308 fArrowX->Paint(">"); 353 309 fArrowY->Paint(">"); … … 356 312 fLegDegree->Paint(); 357 313 358 //359 314 // Paint primitives (pixels, color legend, photons, ...) 360 //361 315 { fPixels->ForEach(TObject, Paint)(); } 362 316 { fLegend->ForEach(TObject, Paint)(); } … … 495 449 void MCamDisplay::FillPhotNum(const MCerPhotEvt &event) 496 450 { 497 //498 // Reset pixel colors to default value499 //500 451 Reset(); 501 452 502 //503 // if the autoscale is true, set the values for the range for504 // each event505 //506 Float_t min = 0;507 Float_t max = 50;508 if (fAutoScale)509 {510 min = event.GetNumPhotonsMin(fGeomCam);511 max = event.GetNumPhotonsMax(fGeomCam);512 513 if (max==min)514 max = min +1;515 516 UpdateLegend(min, max);517 }518 519 //520 // update the colors in the picture521 //522 453 const Int_t entries = event.GetNumPixels(); 523 454 … … 525 456 { 526 457 const MCerPhotPix &pix = event[i]; 527 528 458 if (!pix.IsPixelUsed()) 529 459 continue; 530 460 531 SetPixColor(pix, i, min, max); 461 const Int_t id = pix.GetPixId(); 462 463 fData[id] = pix.GetNumPhotons()*fGeomCam->GetPixRatio(id); 464 (*this)[id].SetBit(kIsUsed); 532 465 } 533 466 } … … 540 473 void MCamDisplay::FillPedestals(const MPedestalCam &event) 541 474 { 542 //543 // Reset pixel colors to default value544 //545 475 Reset(); 546 476 547 //548 // if the autoscale is true, set the values for the range for549 // each event550 //551 Float_t min = 0;552 Float_t max = 50;553 if (fAutoScale)554 {555 min = event.GetMeanMin(fGeomCam);556 max = event.GetMeanMax(fGeomCam);557 558 if (max==min)559 max = min +1;560 561 UpdateLegend(min, max);562 }563 564 //565 // update the colors in the picture566 //567 477 const Int_t entries = event.GetSize(); 568 569 478 for (Int_t i=0; i<entries; i++) 570 SetPixColorPedestal(event[i], i, min, max); 479 { 480 fData[i] = event[i].GetMean()*fGeomCam->GetPixRatio(i); 481 (*this)[i].SetBit(kIsUsed); 482 } 571 483 } 572 484 … … 578 490 void MCamDisplay::FillErrorPhot(const MCerPhotEvt &event) 579 491 { 580 //581 // Reset pixel colors to default value582 //583 492 Reset(); 584 493 585 //586 // if the autoscale is true, set the values for the range for587 // each event588 //589 Float_t min = 0;590 Float_t max = 50;591 if (fAutoScale)592 {593 min = event.GetErrorPhotMin(fGeomCam);594 max = event.GetErrorPhotMax(fGeomCam);595 596 if (max==min)597 max = min +1;598 599 UpdateLegend(min, max);600 }601 602 //603 // update the colors in the picture604 //605 494 const Int_t entries = event.GetNumPixels(); 606 495 … … 608 497 { 609 498 const MCerPhotPix &pix = event[i]; 610 611 499 if (!pix.IsPixelUsed()) 612 500 continue; 613 501 614 SetPixColorError(pix, i, min, max); 502 const Int_t id = pix.GetPixId(); 503 504 fData[id] = pix.GetErrorPhot()*sqrt(fGeomCam->GetPixRatio(id)); 505 (*this)[id].SetBit(kIsUsed); 615 506 } 616 507 } … … 623 514 void MCamDisplay::FillRatio(const MCerPhotEvt &event) 624 515 { 625 //626 // Reset pixel colors to default value627 //628 516 Reset(); 629 517 630 //631 // if the autoscale is true, set the values for the range for632 // each event633 //634 Float_t min = 0;635 Float_t max = 20;636 if (fAutoScale)637 {638 min = event.GetRatioMin(fGeomCam);639 max = event.GetRatioMax(fGeomCam);640 641 UpdateLegend(min, max);642 }643 644 //645 // update the colors in the picture646 //647 518 const Int_t entries = event.GetNumPixels(); 648 519 … … 654 525 continue; 655 526 656 SetPixColorRatio(pix, min, max); 527 const Int_t id = pix.GetPixId(); 528 529 const Float_t entry = pix.GetNumPhotons(); 530 const Float_t noise = pix.GetErrorPhot(); 531 const Double_t ratio = TMath::Sqrt(fGeomCam->GetPixRatio(id)); 532 533 fData[id] = entry*ratio/noise; 534 (*this)[id].SetBit(kIsUsed); 657 535 } 658 536 } … … 664 542 void MCamDisplay::FillCurrents(const MCurrents &event) 665 543 { 666 //667 // Reset pixel colors to default value668 //669 544 Reset(); 670 545 671 //672 // if the autoscale is true, set the values for the range for673 // each event674 //675 Float_t min = 0;676 Float_t max = 20;677 if (fAutoScale)678 {679 min = event.GetMin();680 max = event.GetMax();681 682 UpdateLegend(min, max);683 }684 685 //686 // update the colors in the picture687 //688 546 // FIXME: Security check missing! 689 547 for (UInt_t i=0; i<fNumPixels; i++) 690 548 { 691 //const Float_t pnum = pix.GetNumPhotons()/pix.GetErrorPhot(); 692 (*this)[i].SetFillColor(GetColor(event[i], min, max)); 549 if (event[i]<=0) 550 continue; 551 552 (*this)[i].SetBit(kIsUsed); 553 fData[i] = event[i]; 693 554 } 694 555 } … … 700 561 void MCamDisplay::FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2) 701 562 { 702 // 703 // Reset pixel colors to default value 704 // 705 Reset(); 706 707 // 708 // update the colors in the picture 709 // 710 const Int_t entries = event.GetNumPixels(); 711 712 for (Int_t i=0; i<entries; i++) 713 { 714 const MCerPhotPix &pix = event[i]; 715 716 if (!pix.IsPixelUsed()) 563 FillRatio(event); 564 565 for (UInt_t i=0; i<fNumPixels; i++) 566 { 567 if (!(*this)[i].TestBit(kIsUsed)) 717 568 continue; 718 569 719 SetPixColorLevel(pix, lvl1, lvl2); 570 if (fData[i]>lvl1) 571 fData[i] = 0; 572 else 573 if (fData[i]>lvl2) 574 fData[i] = 1; 575 else 576 fData[i] = 2; 720 577 } 721 578 } … … 775 632 const Int_t entries = event.GetNumPhotons(); 776 633 777 TArrayF arr(fNumPixels);778 634 for (Int_t i=0; i<entries; i++) 779 635 { … … 789 645 continue; 790 646 791 arr[id] += 1; 792 } 793 794 // 795 // Scale with the area and determin maximum 796 // 797 Float_t max = 0; 647 fData[id] += fGeomCam->GetPixRatio(id); 648 } 649 650 // 651 // Set color of pixels 652 // 798 653 for (UInt_t id=0; id<fNumPixels; id++) 799 { 800 arr[id] *= fGeomCam->GetPixRatio(id); 801 if (arr[id]>max) 802 max = arr[id]; 803 } 804 805 // 806 // Update legend 807 // 654 if (fData[id]>0) 655 (*this)[id].SetBit(kIsUsed); 656 } 657 658 // ------------------------------------------------------------------------ 659 // 660 // Reset the all pixel colors to a default value 661 // 662 void MCamDisplay::Reset() 663 { 664 for (UInt_t i=0; i<fNumPixels; i++) 665 (*this)[i].ResetBit(kIsUsed); 666 808 667 if (fAutoScale) 809 UpdateLegend(0, max==0 ? 1 : max); 810 811 // 812 // Set color of pixels 813 // 814 for (UInt_t id=0; id<fNumPixels; id++) 815 if (arr[id]>0) 816 (*this)[id].SetFillColor(GetColor(arr[id], 0, max)); 817 } 818 819 // ------------------------------------------------------------------------ 820 // 821 // Reset the all pixel colors to a default value 822 // 823 void MCamDisplay::Reset() 824 { 825 for (UInt_t i=0; i<fNumPixels; i++) 826 (*this)[i].SetFillColor(10); 668 { 669 fMinimum = 0; 670 fMaximum = 0; 671 } 827 672 } 828 673 … … 838 683 // with 0 up to 49. 839 684 // 840 Int_t MCamDisplay::GetColor(Float_t val, Float_t min, Float_t max )685 Int_t MCamDisplay::GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog) 841 686 { 842 687 // … … 854 699 // calculate the color index 855 700 // 856 const Float_t ratio = (val-min) / (max-min); 857 const Int_t colidx = (Int_t)(ratio*maxcolidx + .5); 858 701 Float_t ratio; 702 if (islog && min>0) 703 ratio = log10(val/min) / log10(max/min); 704 else 705 ratio = (val-min) / (max-min); 706 const Int_t colidx = (Int_t)(ratio*maxcolidx + .5); 859 707 return fColors[colidx]; 860 708 } … … 864 712 // Change the text on the legend according to the range of the Display 865 713 // 866 void MCamDisplay::UpdateLegend(Float_t minphe, Float_t maxphe )714 void MCamDisplay::UpdateLegend(Float_t minphe, Float_t maxphe, Bool_t islog) 867 715 { 868 716 for (Int_t i=0; i<kItemsLegend; i+=3) 869 717 { 870 const Float_t val = minphe + (Float_t)i/kItemsLegend * (maxphe-minphe) ; 718 const Float_t pos = (Float_t)i/kItemsLegend; 719 720 Float_t val; 721 if (islog && minphe>0) 722 val = pow(10, log10(maxphe/minphe)*pos) * minphe; 723 else 724 val = minphe + pos * (maxphe-minphe); 871 725 872 726 TText &txt = *GetText(i); … … 928 782 // ------------------------------------------------------------------------ 929 783 // 930 // Function introduced (31-01-03) 784 // Function introduced (31-01-03) WILL BE REMOVED IN THE FUTURE! DON'T 785 // USE IT! 931 786 // 932 787 void MCamDisplay::SetPix(const Int_t pixnum, const Int_t color, Float_t min, Float_t max) 933 { 934 (*this)[pixnum].SetFillColor(GetColor(color, min, max)); 788 { 789 fData[pixnum] = color; 790 (*this)[pixnum].SetBit(kIsUsed); 791 (*this)[pixnum].SetFillColor(GetColor(color, min, max, 0)); 935 792 } 936 793 -
trunk/MagicSoft/Mars/mgui/MCamDisplay.h
r2147 r2153 8 8 #include <Gtypes.h> 9 9 #endif 10 #ifndef ROOT_TArrayF 11 #include <TArrayF.h> 12 #endif 10 13 #ifndef ROOT_TClonesArray 11 14 #include <TClonesArray.h> 12 15 #endif 16 13 17 14 18 class TBox; … … 49 53 TClonesArray *fPhotons; // array of reflector photons 50 54 51 UInt_t fW; // Width of canvas 52 UInt_t fH; // Height of canvas 55 TArrayF fData; 56 Float_t fMinimum; 57 Float_t fMaximum; 53 58 54 59 TBox *GetBox(Int_t i) { return (TBox*) fLegend->At(i); } … … 57 62 MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); } 58 63 59 void SetPixColor(const MCerPhotPix &pix, const UInt_t i, Float_t min, Float_t max); 60 void SetPixColorRatio(const MCerPhotPix &pix, Float_t min, Float_t max); 61 void SetPixColorLevel(const MCerPhotPix &pix, Float_t lvl1, Float_t lvl2); 62 void SetPixColorError(const MCerPhotPix &pix, const UInt_t i, Float_t min, Float_t max); 63 void SetPixColorPedestal(const MPedestalPix &pix, const UInt_t i, Float_t min, Float_t max); 64 Int_t GetColor(Float_t val, Float_t min, Float_t max); 64 Int_t GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog); 65 65 66 void UpdateLegend(Float_t min, Float_t max); 67 void SetRange(); 68 void SetPalette(); 66 void Update(Bool_t islog); 67 void UpdateLegend(Float_t min, Float_t max, Bool_t islog); 68 void SetRange(); 69 void SetPalette(); 70 71 enum { 72 kIsUsed = BIT(14) 73 }; 69 74 70 75 public: … … 73 78 ~MCamDisplay(); 74 79 75 void SetAutoScale(Bool_t input=kTRUE) { fAutoScale = input; }76 void FillPhotNum(const MCerPhotEvt &event);77 void FillRatio(const MCerPhotEvt &event);78 void FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2);79 void FillErrorPhot(const MCerPhotEvt &event);80 void FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean);81 void FillPedestals(const MPedestalCam &event);82 void FillRflEvent(const MRflEvtData &event);83 void FillCurrents(const MCurrents &event);84 void ShowRflEvent(const MRflEvtData *event=NULL, EMarkerStyle m=kFullDotMedium);80 void SetAutoScale(Bool_t input=kTRUE) { fAutoScale = input; } 81 void FillPhotNum(const MCerPhotEvt &event); 82 void FillRatio(const MCerPhotEvt &event); 83 void FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2); 84 void FillErrorPhot(const MCerPhotEvt &event); 85 void FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean); 86 void FillPedestals(const MPedestalCam &event); 87 void FillRflEvent(const MRflEvtData &event); 88 void FillCurrents(const MCurrents &event); 89 void ShowRflEvent(const MRflEvtData *event=NULL, EMarkerStyle m=kFullDotMedium); 85 90 86 void DrawPixelNumbers();91 void DrawPixelNumbers(); 87 92 88 93 void Paint(Option_t *option=""); … … 94 99 //virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py); 95 100 96 void SetPalette(Int_t ncolors, Int_t *colors);101 void SetPalette(Int_t ncolors, Int_t *colors); 97 102 98 void SetPrettyPalette(); // *MENU*99 void SetDeepBlueSeaPalette(); // *MENU*100 void SetInvDeepBlueSeaPalette(); // *MENU*103 void SetPrettyPalette(); // *MENU* 104 void SetDeepBlueSeaPalette(); // *MENU* 105 void SetInvDeepBlueSeaPalette(); // *MENU* 101 106 102 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 107 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 108 109 void SetMinimum(Float_t m) { fMinimum = m; } 110 void SetMaximum(Float_t m) { fMaximum = m; } 103 111 104 112 ClassDef(MCamDisplay, 0) // Displays the magic camera
Note:
See TracChangeset
for help on using the changeset viewer.