Changeset 4267 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 06/03/04 10:04:27 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r4189 r4267 678 678 h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()), 679 679 GetBinContent(idx+1)); 680 return h1; 681 } 682 683 684 // ------------------------------------------------------------------------ 685 // 686 // Creates a TH1D which contains the projection of the contents of the 687 // MHCamera onto the azimuth angle in the camera. 688 // 689 // If no name is given the newly allocated histogram is removed from 690 // the current directory calling SetDirectory(0) in any other case 691 // the newly created histogram is removed from the current directory 692 // and added to gROOT such the gROOT->FindObject can find the histogram. 693 // 694 // If the standard name "_azi" is given "_azi" is appended to the name 695 // of the MHCamera and the corresponding histogram is searched using 696 // gROOT->FindObject and updated with the present projection. 697 // 698 // It is the responsibility of the user to make sure, that the newly 699 // created histogram is freed correctly. 700 // 701 // Currently the new histogram is restrictred to 60 bins. 702 // Maybe a optimal number can be calulated from the number of 703 // bins on the x-axis of the MHCamera? 704 // 705 // The code was taken mainly from TH2::ProjectX such the interface 706 // is more or less the same than to TH2-projections. 707 // 708 TProfile *MHCamera::AzimuthProfileA(const TArrayI &aidx, const char *name, const Int_t nbins) const 709 { 710 711 // Create the projection histogram 712 TString pname(name); 713 if (name=="_azi") 714 { 715 pname.Prepend(GetName()); 716 if (aidx.GetSize()>0) 717 { 718 pname += ";"; 719 for (int i=0; i<aidx.GetSize(); i++) 720 pname += aidx[i]; 721 } 722 } 723 724 TProfile *h1=0; 725 726 //check if histogram with identical name exist 727 TObject *h1obj = gROOT->FindObject(pname); 728 if (h1obj && h1obj->InheritsFrom("TProfile")) { 729 h1 = (TProfile*)h1obj; 730 h1->Reset(); 731 } 732 733 if (!h1) 734 { 735 736 Double_t min = -0.5; 737 Double_t max = 359.5; 738 739 Int_t newbins=0; 740 741 THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE); 742 743 h1 = new TProfile(pname, GetTitle(), nbins, min, max); 744 h1->SetDirectory(pname.IsNull() ? NULL : gROOT); 745 h1->SetXTitle("Azimuth in camera [deg]"); 746 h1->SetYTitle(GetYaxis()->GetTitle()); 747 } 748 749 // Fill the projected histogram 750 for (Int_t idx=0; idx<fNcells-2; idx++) 751 { 752 h1->Fill(TMath::ATan2((*fGeomCam)[idx].GetY(),(*fGeomCam)[idx].GetX())*180./TMath::Pi()+180., 753 GetBinContent(idx+1)); 754 755 } 756 680 757 return h1; 681 758 } … … 1853 1930 // -------------------------------------------------------------------------- 1854 1931 // 1932 // Draw a projection of MHCamera vs. the azimuth angle inside the camera. 1933 // 1934 // The inner and outer pixels are drawn separately. 1935 // The general azimuth profile is fitted by a straight line 1936 // 1937 void MHCamera::DrawAzimuthProfile() const 1938 { 1939 1940 TProfile *obj2 = (TProfile*)AzimuthProfile(GetName()); 1941 obj2->SetDirectory(0); 1942 obj2->SetLineColor(kRed); 1943 obj2->Draw(); 1944 obj2->SetBit(kCanDelete); 1945 obj2->Fit("pol0","Q",""); 1946 obj2->GetFunction("pol0")->SetLineColor(kRed); 1947 obj2->GetFunction("pol0")->SetLineWidth(1); 1948 1949 if (GetGeomCam().InheritsFrom("MGeomCamMagic")) 1950 { 1951 1952 TArrayI inner(1); 1953 inner[0] = 0; 1954 1955 TArrayI outer(1); 1956 outer[0] = 1; 1957 1958 // Just to get the right (maximum) binning 1959 TProfile *half[2]; 1960 half[0] = AzimuthProfileA(inner,Form("%s%s",GetName(),"Inner")); 1961 half[1] = AzimuthProfileA(outer,Form("%s%s",GetName(),"Outer")); 1962 1963 for (Int_t i=0; i<2; i++) 1964 { 1965 half[i]->SetLineColor(kRed+i+1); 1966 half[i]->SetDirectory(0); 1967 half[i]->SetBit(kCanDelete); 1968 half[i]->SetMarkerSize(0.5); 1969 half[i]->Draw("same"); 1970 } 1971 } 1972 } 1973 1974 // -------------------------------------------------------------------------- 1975 // 1855 1976 // Draw the MHCamera into the MStatusDisplay: 1856 1977 // … … 1869 1990 // 1870 1991 void MHCamera::CamDraw(TCanvas &c, const Int_t x, const Int_t y, 1871 const Int_t fit, const Int_t rad, TObject *notify) 1992 const Int_t fit, const Int_t rad, const Int_t azi, 1993 TObject *notify) 1872 1994 { 1873 1995 … … 1886 2008 obj1->Draw(); 1887 2009 2010 Int_t cnt = 2; 2011 1888 2012 if (rad) 1889 2013 { … … 1892 2016 gPad->SetTicks(); 1893 2017 DrawRadialProfile(); 2018 cnt++; 2019 } 2020 2021 if (azi) 2022 { 2023 c.cd(x+cnt*y); 2024 gPad->SetBorderMode(0); 2025 gPad->SetTicks(); 2026 DrawAzimuthProfile(); 2027 cnt++; 1894 2028 } 1895 2029 … … 1897 2031 return; 1898 2032 1899 c.cd( rad ? x+3*y : x+2*y);2033 c.cd(x + cnt*y); 1900 2034 gPad->SetBorderMode(0); 1901 2035 gPad->SetTicks(); -
trunk/MagicSoft/Mars/mhist/MHCamera.h
r4189 r4267 195 195 void DrawProjection (Int_t fit=0) const; 196 196 void DrawRadialProfile() const; 197 void DrawAzimuthProfile() const; 197 198 198 199 void SavePrimitive(ofstream &out, Option_t *); … … 253 254 TProfile *RadialProfileS(const TArrayI §or, const TArrayI &aidx, const char *name="_rad", const Int_t nbins=25) const; 254 255 256 TProfile *AzimuthProfile(const char *name="_azi") const { return AzimuthProfileA(TArrayI(), name); } 257 TProfile *AzimuthProfile(Int_t aidx, const char *name="_rad", const Int_t nbins=60) const 258 { 259 return AzimuthProfileA(TArrayI(1, &aidx), name, nbins); 260 } 261 TProfile *AzimuthProfileA(const TArrayI &aidx, const char *name="_rad", const Int_t nbins=60) const; 262 255 263 void CamDraw(TCanvas &c, const Int_t x, const Int_t y, 256 const Int_t fit, const Int_t rad=0, 264 const Int_t fit, const Int_t rad=0, const Int_t azi=0, 257 265 TObject *notify=NULL); 258 266
Note:
See TracChangeset
for help on using the changeset viewer.