Changeset 5143 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 09/28/04 12:25:50 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
r2893 r5143 30 30 // currents or enything else derived from MCamEvent 31 31 // 32 // To plot the variance instead of the rms use: 33 // MHCamEvent::SetBit(MHCamera::kVariance); 34 // 35 // Axis titles 36 // =========== 37 // 38 // 1) If no other title is given 'a.u.' is used. 39 // 2) If the title of MHCamEvent is different from the default, 40 // it is used as histogram title. You can use this to set the 41 // axis title, too. For more information see TH1::SetTitle, eg. 42 // SetTitle("MyHist;;y[cm];Counts"); 43 // Make sure to set an empty x-axis title. 44 // 45 // 46 // For example: 47 // MHCamEvent myhist("Titele;;y [cm]"); 48 // 49 // 32 50 ///////////////////////////////////////////////////////////////////////////// 33 51 #include "MHCamEvent.h" 34 52 35 53 #include <TCanvas.h> 54 #include <TPaveStats.h> 36 55 37 56 #include "MLog.h" … … 48 67 using namespace std; 49 68 50 // -------------------------------------------------------------------------- 51 // 52 // Initialize the name and title of the task. 53 // Resets the sum histogram 54 // 55 MHCamEvent::MHCamEvent(const char *name, const char *title) 56 : fSum(NULL), fRms(NULL), fEvt(NULL), fType(0) 69 const TString MHCamEvent::gsDefName = "MHCamEvent"; 70 const TString MHCamEvent::gsDefTitle = "Average of MCamEvents"; 71 72 // -------------------------------------------------------------------------- 73 // 74 // Initialize the name and title of the task 75 // 76 void MHCamEvent::Init(const char *name, const char *title) 57 77 { 58 78 // 59 79 // set the name and title of this object 60 80 // 61 fName = name ? name : "MHCamEvent"; 62 fTitle = title ? title : "Average of MCamEvents"; 81 fName = name ? name : gsDefName.Data(); 82 fTitle = title ? title : gsDefTitle.Data(); 83 } 84 85 // -------------------------------------------------------------------------- 86 // 87 // Initialize the name and title of the task. Set fType to 0 88 // 89 MHCamEvent::MHCamEvent(const char *name, const char *title) 90 : fSum(NULL), fEvt(NULL), fType(0) 91 { 92 Init(name, title); 93 } 94 95 // -------------------------------------------------------------------------- 96 // 97 // Initialize the name and title of the task. Set fType to type 98 // 99 MHCamEvent::MHCamEvent(Int_t type, const char *name, const char *title) 100 : fSum(NULL), fEvt(NULL), fType(type) 101 { 102 Init(name, title); 63 103 } 64 104 … … 71 111 if (fSum) 72 112 delete fSum; 73 if (fRms)74 delete fRms;75 113 } 76 114 … … 104 142 if (fSum) 105 143 delete (fSum); 106 if (fRms)107 delete (fRms);108 144 109 145 const TString name = fNameEvt.IsNull() ? fName : fNameEvt; 110 146 111 fSum = new MHCamera(*cam, name+";avg", fTitle); 112 fSum->SetYTitle("a.u."); 147 fSum = new MHCamera(*cam, name+";avg"); 148 if (fTitle!=gsDefTitle) 149 fSum->SetTitle(fTitle); 150 if (!fTitle.Contains(";")) 151 fSum->SetYTitle("a.u."); 113 152 fSum->SetBit(MHCamera::kProfile); 114 if(TestBit(MHCamera::kVariance)) 115 fSum->SetBit(MHCamera::kVariance); 116 117 fRms = new MHCamera(*cam, name+";rms", fTitle); 118 fRms->SetYTitle("a.u."); 153 if (TestBit(MHCamera::kVariance)) 154 fSum->SetBit(MHCamera::kVariance); 119 155 120 156 return kTRUE; … … 134 170 } 135 171 fSum->AddCamContent(*evt, fType); 136 fRms->SetCamContent(*fSum, 1);137 return kTRUE;138 }139 140 // --------------------------------------------------------------------------141 //142 // Scale the sum container with the number of entries143 //144 Bool_t MHCamEvent::Finalize()145 {146 //fRms->AddCamContent(*fSum, 1);147 172 return kTRUE; 148 173 } … … 176 201 TH1 *MHCamEvent::GetHistByName(const TString name) 177 202 { 178 // name.ToLower(); 179 180 if (name=="sum") 181 return fSum; 182 if (name=="rms") 183 return fRms; 184 185 return NULL; 203 return fSum; 204 } 205 206 void MHCamEvent::Paint(Option_t *) 207 { 208 TVirtualPad *pad = gPad; 209 210 pad->cd(2); 211 if (gPad->FindObject(Form("Proj_%p", this))) 212 { 213 TH1 *h=fSum->Projection(Form("Proj_%p", this)); 214 if (h->GetMaximum()>0) 215 gPad->SetLogy(); 216 } 217 218 pad->cd(5); 219 if (gPad->FindObject(Form("ProfR_%p", this))) 220 fSum->RadialProfile(Form("ProfR_%p", this)); 221 222 pad->cd(6); 223 if (gPad->FindObject(Form("ProfA_%p", this))) 224 fSum->AzimuthProfile(Form("ProfA_%p", this)); 225 226 pad->cd(4); 227 gPad->cd(1); 228 MHCamera *cam = (MHCamera*)gPad->FindObject(Form("Err_%p", this)); 229 if (cam) 230 cam->SetCamContent(*fSum, 1); 186 231 } 187 232 … … 191 236 pad->SetBorderMode(0); 192 237 193 pad->Divide(1,2); 238 AppendPad(); 239 240 TString name = Form("%s_5", pad->GetName()); 241 TPad *p = new TPad(name,name,6./8,0.25,0.99,0.5,pad->GetFillColor(),0,0); 242 p->SetNumber(5); 243 p->Draw(); 244 245 name = Form("%s_6", pad->GetName()); 246 p = new TPad(name,name,6./8,0.01,0.99,0.25,pad->GetFillColor(),0,0); 247 p->SetNumber(6); 248 p->Draw(); 249 250 pad->Divide(2,2); 194 251 195 252 pad->cd(1); 196 253 gPad->SetBorderMode(0); 254 gPad->SetPad(0.01, 0.5, 0.66, 0.99); 197 255 fSum->Draw("EPhist"); 198 256 199 257 pad->cd(2); 200 258 gPad->SetBorderMode(0); 201 gPad->Divide(2, 1); 202 pad = gPad; 203 204 pad->cd(1); 259 gPad->SetPad(0.66, 0.5, 0.99, 0.99); 260 TH1 *h = fSum->Projection(Form("Proj_%p", this), 50); 261 h->SetTitle("Projection"); 262 h->SetBit(kCanDelete); 263 h->Draw(); 264 265 pad->cd(3); 266 gPad->SetPad(0.01, 0.01, 3./8, 0.5); 205 267 gPad->SetBorderMode(0); 206 268 fSum->Draw(); 207 269 208 pad->cd(2); 209 gPad->SetBorderMode(0); 210 fRms->Draw(); 211 } 270 pad->cd(4); 271 gPad->SetPad(3./8, 0.01, 6./8, 0.5); 272 gPad->SetBorderMode(0); 273 274 MHCamera *cam = new MHCamera(*fSum->GetGeometry()); 275 cam->SetName(Form("Err_%p", this)); 276 cam->SetTitle(TestBit(MHCamera::kVariance)?"Variance":"Root Mean Squared (rms)"); 277 cam->SetYTitle(fSum->GetYaxis()->GetTitle()); 278 cam->SetCamContent(*fSum, 1); 279 cam->SetBit(kCanDelete); 280 cam->Draw(); 281 282 pad->cd(5); 283 h = (TH1*)fSum->RadialProfile(Form("ProfR_%p", this), 20); 284 h->SetTitle("Radial Profile"); 285 h->SetBit(kCanDelete|TH1::kNoStats); 286 h->Draw(); 287 288 pad->cd(6); 289 h = (TH1*)fSum->AzimuthProfile(Form("ProfA_%p", this), 30); 290 h->SetTitle("Azimuth Profile"); 291 h->SetBit(kCanDelete|TH1::kNoStats); 292 h->Draw(); 293 } -
trunk/MagicSoft/Mars/mhist/MHCamEvent.h
r2550 r5143 12 12 { 13 13 private: 14 static const TString gsDefName; 15 static const TString gsDefTitle; 16 14 17 MHCamera *fSum; // storing the sum 15 MHCamera *fRms; // storing the rms16 18 MCamEvent *fEvt; //! the current event 17 19 … … 20 22 Int_t fType; 21 23 24 void Init(const char *name, const char *title); 25 22 26 Bool_t SetupFill(const MParList *pList); 23 27 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 24 Bool_t Finalize();25 28 26 29 public: 27 30 MHCamEvent(const char *name=NULL, const char *title=NULL); 31 MHCamEvent(Int_t type, const char *name=NULL, const char *title=NULL); 28 32 ~MHCamEvent(); 29 33 … … 33 37 TH1 *GetHistByName(const TString name=""); 34 38 39 void Paint(Option_t *o=""); 35 40 void Draw(Option_t *o=""); 36 41 -
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r4915 r5143 75 75 76 76 #include "MH.h" 77 #include "MBinning.h" 77 78 #include "MHexagon.h" 78 79 … … 576 577 if (!h1) 577 578 { 578 Double_t min = GetMinimumSectors(sector, aidx); 579 Double_t max = GetMaximumSectors(sector, aidx); 580 581 Int_t newbins=0; 582 583 THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE); 584 585 h1 = new TH1D(pname, GetTitle(), nbins, min, max); 586 h1->SetDirectory(pname.IsNull() ? NULL : gROOT); 579 h1 = new TH1D; 580 h1->UseCurrentStyle(); 581 h1->SetName(pname); 582 h1->SetTitle(GetTitle()); 583 h1->SetDirectory(0); 587 584 h1->SetXTitle(GetYaxis()->GetTitle()); 588 585 h1->SetYTitle("Counts"); 589 586 //h1->Sumw2(); 590 587 } 588 589 Double_t min = GetMinimumSectors(sector, aidx); 590 Double_t max = GetMaximumSectors(sector, aidx); 591 592 if (min==max && max>0) 593 min=0; 594 if (min==max && min<0) 595 max=0; 596 597 Int_t newbins=0; 598 THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE); 599 600 MBinning bins(nbins, min, max); 601 bins.Apply(*h1); 591 602 592 603 // Fill the projected histogram … … 630 641 TProfile *MHCamera::RadialProfileS(const TArrayI §or, const TArrayI &aidx, const char *name, const Int_t nbins) const 631 642 { 643 // Create the projection histogram 644 TString pname(name); 645 if (name=="_rad") 646 { 647 pname.Prepend(GetName()); 648 if (sector.GetSize()>0) 649 { 650 pname += ";"; 651 for (int i=0; i<sector.GetSize(); i++) 652 pname += sector[i]; 653 } 654 if (aidx.GetSize()>0) 655 { 656 pname += ";"; 657 for (int i=0; i<aidx.GetSize(); i++) 658 pname += aidx[i]; 659 } 660 } 661 662 TProfile *h1=0; 663 664 //check if histogram with identical name exist 665 TObject *h1obj = gROOT->FindObject(pname); 666 if (h1obj && h1obj->InheritsFrom("TProfile")) { 667 h1 = (TProfile*)h1obj; 668 h1->Reset(); 669 } 670 671 if (!h1) 672 { 673 h1 = new TProfile; 674 h1->UseCurrentStyle(); 675 h1->SetName(pname); 676 h1->SetTitle(GetTitle()); 677 h1->SetDirectory(0); 678 h1->SetXTitle("Radius from camera center [mm]"); 679 h1->SetYTitle(GetYaxis()->GetTitle()); 680 } 681 682 Double_t min = 0.; 683 Double_t max = fGeomCam->GetMaxRadius(); 684 685 Int_t newbins=0; 686 687 THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE); 688 689 MBinning bins(nbins, min, max); 690 bins.Apply(*h1); 632 691 633 // Create the projection histogram 634 TString pname(name); 635 if (name=="_rad") 636 { 637 pname.Prepend(GetName()); 638 if (sector.GetSize()>0) 639 { 640 pname += ";"; 641 for (int i=0; i<sector.GetSize(); i++) 642 pname += sector[i]; 643 } 644 if (aidx.GetSize()>0) 645 { 646 pname += ";"; 647 for (int i=0; i<aidx.GetSize(); i++) 648 pname += aidx[i]; 649 } 650 } 651 652 TProfile *h1=0; 653 654 //check if histogram with identical name exist 655 TObject *h1obj = gROOT->FindObject(pname); 656 if (h1obj && h1obj->InheritsFrom("TProfile")) { 657 h1 = (TProfile*)h1obj; 658 h1->Reset(); 659 } 660 661 if (!h1) 662 { 663 664 Double_t min = 0.; 665 Double_t max = fGeomCam->GetMaxRadius(); 666 667 Int_t newbins=0; 668 669 THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE); 670 671 h1 = new TProfile(pname, GetTitle(), nbins, min, max); 672 h1->SetDirectory(pname.IsNull() ? NULL : gROOT); 673 h1->SetXTitle("Radius from camera center [mm]"); 674 h1->SetYTitle(GetYaxis()->GetTitle()); 675 } 676 677 // Fill the projected histogram 678 for (Int_t idx=0; idx<fNcells-2; idx++) 679 if (IsUsed(idx) && MatchSector(idx, sector, aidx)) 680 h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()), 681 GetBinContent(idx+1)); 682 return h1; 692 // Fill the projected histogram 693 for (Int_t idx=0; idx<fNcells-2; idx++) 694 if (IsUsed(idx) && MatchSector(idx, sector, aidx)) 695 h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()), 696 GetBinContent(idx+1)); 697 return h1; 683 698 } 684 699 … … 710 725 TProfile *MHCamera::AzimuthProfileA(const TArrayI &aidx, const char *name, const Int_t nbins) const 711 726 { 712 713 // Create the projection histogram 714 TString pname(name); 715 if (name=="_azi") 716 { 717 pname.Prepend(GetName()); 718 if (aidx.GetSize()>0) 727 // Create the projection histogram 728 TString pname(name); 729 if (name=="_azi") 730 { 731 pname.Prepend(GetName()); 732 if (aidx.GetSize()>0) 719 733 { 720 pname += ";";721 for (int i=0; i<aidx.GetSize(); i++)722 pname += aidx[i];734 pname += ";"; 735 for (int i=0; i<aidx.GetSize(); i++) 736 pname += aidx[i]; 723 737 } 724 738 } 725 726 TProfile *h1=0; 727 728 //check if histogram with identical name exist 729 TObject *h1obj = gROOT->FindObject(pname); 730 if (h1obj && h1obj->InheritsFrom("TProfile")) { 731 h1 = (TProfile*)h1obj; 732 h1->Reset(); 733 } 734 735 if (!h1) 736 { 737 738 Double_t min = -0.5; 739 Double_t max = 359.5; 740 741 Int_t newbins=0; 742 743 THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE); 744 745 h1 = new TProfile(pname, GetTitle(), nbins, min, max); 746 h1->SetDirectory(pname.IsNull() ? NULL : gROOT); 747 h1->SetXTitle("Azimuth in camera [deg]"); 748 h1->SetYTitle(GetYaxis()->GetTitle()); 749 } 750 751 // Fill the projected histogram 752 for (Int_t idx=0; idx<fNcells-2; idx++) 753 { 754 if (IsUsed(idx) && MatchSector(idx, TArrayI(), aidx)) 755 h1->Fill(TMath::ATan2((*fGeomCam)[idx].GetY(),(*fGeomCam)[idx].GetX())*180./TMath::Pi()+180., 756 GetPixContent(idx)); 757 758 } 759 760 return h1; 739 740 TProfile *h1=0; 741 742 //check if histogram with identical name exist 743 TObject *h1obj = gROOT->FindObject(pname); 744 if (h1obj && h1obj->InheritsFrom("TProfile")) { 745 h1 = (TProfile*)h1obj; 746 h1->Reset(); 747 } 748 749 if (!h1) 750 { 751 752 h1 = new TProfile; 753 h1->UseCurrentStyle(); 754 h1->SetName(pname); 755 h1->SetTitle(GetTitle()); 756 h1->SetDirectory(0); 757 h1->SetXTitle("Azimuth in camera [deg]"); 758 h1->SetYTitle(GetYaxis()->GetTitle()); 759 } 760 761 Double_t min = 0; 762 Double_t max = 360; 763 764 Int_t newbins=0; 765 THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE); 766 767 MBinning bins(nbins, min, max); 768 bins.Apply(*h1); 769 770 // Fill the projected histogram 771 for (Int_t idx=0; idx<fNcells-2; idx++) 772 { 773 if (IsUsed(idx) && MatchSector(idx, TArrayI(), aidx)) 774 h1->Fill(TMath::ATan2((*fGeomCam)[idx].GetY(),(*fGeomCam)[idx].GetX())*TMath::RadToDeg()+180, 775 GetPixContent(idx)); 776 777 } 778 779 return h1; 761 780 } 762 781 … … 1599 1618 return TObject::GetObjectInfo(px, py); 1600 1619 1601 sprintf(info, "Software Pixel Index: %d (Hardware Id=%d)", idx, idx+1); 1620 sprintf(info, "Software Pixel Idx: %d (Hardware Id=%d) c=%.1f <%s>", 1621 idx, idx+1, GetBinContent(idx+1), IsUsed(idx)?"on":"off"); 1602 1622 return info; 1603 1623 } -
trunk/MagicSoft/Mars/mhist/MHCamera.h
r4883 r5143 262 262 TH1D *ProjectionS(const TArrayI §or, const TArrayI &aidx, const char *name="_py", const Int_t nbins=50) const; 263 263 264 TProfile *RadialProfile(const char *name="_rad" ) const { return RadialProfileS(TArrayI(), TArrayI(), name);}264 TProfile *RadialProfile(const char *name="_rad", Int_t nbins=25) const { return RadialProfileS(TArrayI(), TArrayI(), name, nbins);} 265 265 TProfile *RadialProfileS(Int_t sector, Int_t aidx, const char *name="_rad", const Int_t nbins=25) const 266 266 { … … 269 269 TProfile *RadialProfileS(const TArrayI §or, const TArrayI &aidx, const char *name="_rad", const Int_t nbins=25) const; 270 270 271 TProfile *AzimuthProfile(const char *name="_azi" ) const { return AzimuthProfileA(TArrayI(), name); }271 TProfile *AzimuthProfile(const char *name="_azi", Int_t nbins=25) const { return AzimuthProfileA(TArrayI(), name, nbins); } 272 272 TProfile *AzimuthProfile(Int_t aidx, const char *name="_rad", const Int_t nbins=25) const 273 273 {
Note:
See TracChangeset
for help on using the changeset viewer.