Changeset 1540 for trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
- Timestamp:
- 10/15/02 17:02:46 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
r1426 r1540 28 28 // MCamDisplay 29 29 // 30 // Camera Display 30 // Camera Display. The Pixels are displayed in 31 // contents/area [somthing/mm^2] 31 32 // 32 33 //////////////////////////////////////////////////////////////////////////// … … 38 39 #include <TBox.h> 39 40 #include <TText.h> 41 #include <TArrow.h> 40 42 #include <TStyle.h> 41 43 #include <TCanvas.h> … … 45 47 #include "MHexagon.h" 46 48 47 #include "MGeomPix.h"48 49 #include "MGeomCam.h" 49 50 … … 51 52 #include "MCerPhotEvt.h" 52 53 54 #include "MPedestalPix.h" 55 #include "MPedestalCam.h" 56 57 #include "MImgCleanStd.h" 58 53 59 #define kItemsLegend 50 // see SetPalette(1,0) 54 60 … … 60 66 // 61 67 MCamDisplay::MCamDisplay(MGeomCam *geom) 62 : fAutoScale(kTRUE), f MinPhe(-2), fMaxPhe(50), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)68 : fAutoScale(kTRUE), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE) 63 69 { 64 70 fGeomCam = (MGeomCam*)geom; // FIXME: Clone doesn't work! (MGeomCam*)geom->Clone(); … … 108 114 newtxt->SetTextAlign(12); 109 115 } 116 117 fArrowX = new TArrow(-fRange*.9, -fRange*.9, -fRange*.6, -fRange*.9, 0.025); 118 fArrowY = new TArrow(-fRange*.9, -fRange*.9, -fRange*.9, -fRange*.6, 0.025); 119 120 TString text; 121 text += (int)(fRange*.3); 122 text += "mm"; 123 124 fLegRadius = new TText(-fRange*.85, -fRange*.85, text); 125 text = ""; 126 text += (float)((int)(fRange*.3*geom->GetConvMm2Deg()*10))/10; 127 text += "°"; 128 text = text.Strip(TString::kLeading); 129 fLegDegree = new TText(-fRange*.85, -fRange*.75, text); 130 fLegRadius->SetTextSize(0.04); 131 fLegDegree->SetTextSize(0.04); 110 132 } 111 133 … … 124 146 delete fLegText; 125 147 148 delete fArrowX; 149 delete fArrowY; 150 151 delete fLegRadius; 152 delete fLegDegree; 153 126 154 // delete fGeomCam; 127 155 128 if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this &&129 fIsAllocated)156 // Maybe harmfull! Don't exchange the order! 157 if (fIsAllocated && fDrawingPad->GetListOfPrimitives()->FindObject(this)==this) 130 158 { 131 159 fDrawingPad->RecursiveRemove(this); … … 134 162 } 135 163 136 inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const Int_t i )137 { 138 // 139 // Fixme: Divide pnum by the (real) area of the pixel140 // 141 const Float_t ratio = (*fGeomCam)[0].GetA()/(*fGeomCam)[i].GetA();164 inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max) 165 { 166 // 167 // Fixme: Use absolute value per mm^2. Needs another scaling algorithm. 168 // 169 const Float_t ratio = fGeomCam->GetPixRatio(i); 142 170 const Float_t pnum = ratio*pix.GetNumPhotons(); 143 171 144 (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum)); 172 (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max)); 173 } 174 175 inline void MCamDisplay::SetPixColorPedestal(const MPedestalPix &pix, const Int_t i, Float_t min, Float_t max) 176 { 177 // 178 // Fixme: Use absolute value per mm^2. Needs another scaling algorithm. 179 // 180 const Float_t ratio = fGeomCam->GetPixRatio(i); 181 const Float_t pnum = ratio*pix.GetMean(); 182 183 (*this)[i].SetFillColor(GetColor(pnum, min, max)); 184 } 185 186 inline void MCamDisplay::SetPixColorError(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max) 187 { 188 // 189 // Fixme: Use absolute value per mm^2. Needs another scaling algorithm. 190 // 191 const Float_t ratio = fGeomCam->GetPixRatio(i); 192 const Float_t pnum = ratio*pix.GetErrorPhot(); 193 194 (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max)); 195 } 196 197 inline void MCamDisplay::SetPixColorRatio(const MCerPhotPix &pix, Float_t min, Float_t max) 198 { 199 // 200 // Fixme: Use absolute value per mm^2. Needs another scaling algorithm. 201 // 202 const Float_t pnum = pix.GetNumPhotons()/pix.GetErrorPhot(); 203 (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max)); 204 } 205 206 inline void MCamDisplay::SetPixColorLevel(const MCerPhotPix &pix, Float_t lvl1, Float_t lvl2) 207 { 208 const Int_t maxcolidx = kItemsLegend-1; 209 210 MHexagon &hex = (*this)[pix.GetPixId()]; 211 212 const Float_t r = pix.GetNumPhotons()/pix.GetErrorPhot(); 213 214 if (r>lvl1) 215 hex.SetFillColor(fColors[4*maxcolidx/5]); 216 else 217 if (r>lvl2) 218 hex.SetFillColor(fColors[maxcolidx/2]); 219 else 220 hex.SetFillColor(fColors[maxcolidx/5]); 145 221 } 146 222 … … 189 265 // 190 266 gPad->Range(-fRange, -y, x, y); 267 268 // 269 // Make sure, that the correct aspect is always displayed also 270 // if - by chance - there is not update for the pad after the 271 // Paint function was called. 272 // 273 gPad->Update(); 191 274 } 192 275 … … 359 442 } 360 443 444 fArrowX->Draw(); 445 fArrowY->Draw(); 446 447 fLegRadius->Draw(); 448 fLegDegree->Draw(); 449 361 450 // 362 451 // initialize and draw legend … … 433 522 return; 434 523 524 Draw(); 525 526 fDrawingPad->cd(); 527 528 for (int i=0; i<kItemsLegend; i++) 529 GetBox(i)->SetFillColor(fColors[i]); 530 531 // 532 // Reset pixel colors to default value 533 // 534 Reset(); 535 536 // 537 // if the autoscale is true, set the values for the range for 538 // each event 539 // 540 Float_t min = 0; 541 Float_t max = 50; 542 if (fAutoScale) 543 { 544 min = event->GetNumPhotonsMin(fGeomCam); 545 max = event->GetNumPhotonsMax(fGeomCam); 546 547 if (max < 20.) 548 max = 20.; 549 550 UpdateLegend(min, max); 551 } 552 553 // 554 // update the colors in the picture 555 // 556 const Int_t entries = event->GetNumPixels(); 557 558 for (Int_t i=0; i<entries; i++) 559 { 560 const MCerPhotPix &pix = (*event)[i]; 561 562 if (!pix.IsPixelUsed()) 563 continue; 564 565 SetPixColor(pix, i, min, max); 566 } 567 568 // 569 // Update display physically 570 // 571 fDrawingPad->Modified(); 572 fDrawingPad->Update(); 573 } 574 575 // ------------------------------------------------------------------------ 576 // 577 // Call this function to draw the number of photo electron into the 578 // camera. 579 // 580 void MCamDisplay::DrawPedestals(const MPedestalCam *event) 581 { 582 if (!event) 583 return; 584 585 Draw(); 586 587 fDrawingPad->cd(); 588 589 for (int i=0; i<kItemsLegend; i++) 590 GetBox(i)->SetFillColor(fColors[i]); 591 592 // 593 // Reset pixel colors to default value 594 // 595 Reset(); 596 597 // 598 // if the autoscale is true, set the values for the range for 599 // each event 600 // 601 Float_t min = 0; 602 Float_t max = 50; 603 if (fAutoScale) 604 { 605 min = event->GetMeanMin(fGeomCam); 606 max = event->GetMeanMax(fGeomCam); 607 608 if (max < 20.) 609 max = 20.; 610 611 UpdateLegend(min, max); 612 } 613 614 // 615 // update the colors in the picture 616 // 617 const Int_t entries = event->GetSize(); 618 619 for (Int_t i=0; i<entries; i++) 620 SetPixColorPedestal((*event)[i], i, min, max); 621 622 // 623 // Update display physically 624 // 625 fDrawingPad->Modified(); 626 fDrawingPad->Update(); 627 } 628 629 // ------------------------------------------------------------------------ 630 // 631 // Call this function to draw the error of number of photo electron 632 // into the camera. 633 // 634 void MCamDisplay::DrawErrorPhot(const MCerPhotEvt *event) 635 { 636 if (!event) 637 return; 638 435 639 if (!fDrawingPad) 436 640 Draw(); … … 450 654 // each event 451 655 // 656 Float_t min = 0; 657 Float_t max = 50; 452 658 if (fAutoScale) 453 659 { 454 fMinPhe = event->GetNumPhotonsMin(fGeomCam);455 fMaxPhe = event->GetNumPhotonsMax(fGeomCam);456 457 if ( fMaxPhe< 20.)458 fMaxPhe= 20.;459 460 UpdateLegend( );660 min = event->GetErrorPhotMin(fGeomCam); 661 max = event->GetErrorPhotMax(fGeomCam); 662 663 if (max < 20.) 664 max = 20.; 665 666 UpdateLegend(min, max); 461 667 } 462 668 … … 473 679 continue; 474 680 475 SetPixColor (pix, i);681 SetPixColorError(pix, i, min, max); 476 682 } 477 683 … … 481 687 fDrawingPad->Modified(); 482 688 fDrawingPad->Update(); 689 } 690 691 // ------------------------------------------------------------------------ 692 // 693 // Call this function to draw the ratio of the number of photons 694 // divided by its error 695 // 696 void MCamDisplay::DrawRatio(const MCerPhotEvt *event) 697 { 698 if (!event) 699 return; 700 701 if (!fDrawingPad) 702 Draw(); 703 704 fDrawingPad->cd(); 705 706 for (int i=0; i<kItemsLegend; i++) 707 GetBox(i)->SetFillColor(fColors[i]); 708 709 // 710 // Reset pixel colors to default value 711 // 712 Reset(); 713 714 // 715 // if the autoscale is true, set the values for the range for 716 // each event 717 // 718 Float_t min = 0; 719 Float_t max = 20; 720 if (fAutoScale) 721 { 722 min = event->GetRatioMin(); 723 max = event->GetRatioMax(); 724 725 UpdateLegend(min, max); 726 } 727 728 // 729 // update the colors in the picture 730 // 731 const Int_t entries = event->GetNumPixels(); 732 733 for (Int_t i=0; i<entries; i++) 734 { 735 const MCerPhotPix &pix = (*event)[i]; 736 737 if (!pix.IsPixelUsed()) 738 continue; 739 740 SetPixColorRatio(pix, min, max); 741 } 742 743 // 744 // Update display physically 745 // 746 fDrawingPad->Modified(); 747 fDrawingPad->Update(); 748 } 749 750 // ------------------------------------------------------------------------ 751 // 752 // Draw the colors in respect to the cleaning levels 753 // 754 void MCamDisplay::DrawLevels(const MCerPhotEvt *event, Float_t lvl1, Float_t lvl2) 755 { 756 if (!event) 757 return; 758 759 if (!fDrawingPad) 760 Draw(); 761 762 fDrawingPad->cd(); 763 764 for (int i=0; i<kItemsLegend; i++) 765 GetBox(i)->SetFillColor(fColors[i]); 766 767 // 768 // Reset pixel colors to default value 769 // 770 Reset(); 771 772 // 773 // update the colors in the picture 774 // 775 const Int_t entries = event->GetNumPixels(); 776 777 for (Int_t i=0; i<entries; i++) 778 { 779 const MCerPhotPix &pix = (*event)[i]; 780 781 if (!pix.IsPixelUsed()) 782 continue; 783 784 SetPixColorLevel(pix, lvl1, lvl2); 785 } 786 787 // 788 // Update display physically 789 // 790 fDrawingPad->Modified(); 791 fDrawingPad->Update(); 792 } 793 794 // ------------------------------------------------------------------------ 795 // 796 // Draw the colors in respect to the cleaning levels 797 // 798 void MCamDisplay::DrawLevels(const MCerPhotEvt *event, const MImgCleanStd &clean) 799 { 800 DrawLevels(event, clean.GetCleanLvl1(), clean.GetCleanLvl2()); 483 801 } 484 802 … … 504 822 // with 0 up to 49. 505 823 // 506 Int_t MCamDisplay::GetColor(Float_t val )824 Int_t MCamDisplay::GetColor(Float_t val, Float_t min, Float_t max) 507 825 { 508 826 // … … 511 829 const Int_t maxcolidx = kItemsLegend-1; 512 830 513 if (val >= fMaxPhe)831 if (val >= max) 514 832 return fColors[maxcolidx]; 515 833 516 if (val <= fMinPhe)834 if (val <= min) 517 835 return fColors[0]; 518 836 … … 520 838 // calculate the color index 521 839 // 522 const Float_t ratio = (val- fMinPhe) / (fMaxPhe-fMinPhe);840 const Float_t ratio = (val-min) / (max-min); 523 841 const Int_t colidx = (Int_t)(ratio*maxcolidx + .5); 524 842 … … 531 849 // Display 532 850 // 533 void MCamDisplay::UpdateLegend( )851 void MCamDisplay::UpdateLegend(Float_t minphe, Float_t maxphe) 534 852 { 535 853 char text[10]; … … 537 855 for (Int_t i=0; i<kItemsLegend; i+=3) 538 856 { 539 const Float_t val = fMinPhe + (Float_t)i/kItemsLegend * (fMaxPhe-fMinPhe) ;857 const Float_t val = minphe + (Float_t)i/kItemsLegend * (maxphe-minphe) ; 540 858 541 859 sprintf(text, "%5.1f", val);
Note:
See TracChangeset
for help on using the changeset viewer.