Changeset 3528
- Timestamp:
- 03/16/04 21:45:15 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r3527 r3528 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2004/03/16: Markus Gaug 22 23 * mhist/MHCamera.[h,cc] 24 - added function RadialProfile which returns a TProfile of the 25 value along the radius from the camera center 26 20 27 21 28 2004/03/16: Oscar Blanch Bigas -
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r3516 r3528 18 18 ! Author(s): Thomas Bretz, 05/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! Author(s): Harald Kornmayer, 1/2001 20 ! Author(s): Markus Gaug, 03/2004 <mailto:markus@ifae.es> 20 21 ! 21 ! Copyright: MAGIC Software Development, 2000-200 322 ! Copyright: MAGIC Software Development, 2000-2004 22 23 ! 23 24 ! … … 55 56 #include <THistPainter.h> 56 57 #include <THLimitsFinder.h> 58 #include <TProfile.h> 57 59 58 60 #include "MLog.h" … … 562 564 // ------------------------------------------------------------------------ 563 565 // 566 // Creates a TH1D which contains the projection of the contents of the 567 // MHCamera onto the radius from the camera center. 568 // The maximum and minimum are calculated 569 // such that a slighly wider range than (GetMinimum(), GetMaximum()) is 570 // displayed using THLimitsFinder::OptimizeLimits. 571 // 572 // If no name is given the newly allocated histogram is removed from 573 // the current directory calling SetDirectory(0) in any other case 574 // the newly created histogram is removed from the current directory 575 // and added to gROOT such the gROOT->FindObject can find the histogram. 576 // 577 // If the standard name "_rad" is given "_rad" is appended to the name 578 // of the MHCamera and the corresponding histogram is searched using 579 // gROOT->FindObject and updated with the present projection. 580 // 581 // It is the responsibility of the user to make sure, that the newly 582 // created histogram is freed correctly. 583 // 584 // Currently the new histogram is restrictred to 50 bins. 585 // Maybe a optimal number can be calulated from the number of 586 // bins on the x-axis of the MHCamera? 587 // 588 // The code was taken mainly from TH2::ProjectX such the interface 589 // is more or less the same than to TH2-projections. 590 // 591 // If sector>=0 only entries with matching sector index are taken 592 // into account. 593 // 594 TProfile *MHCamera::RadialProfileS(const TArrayI §or, const TArrayI &aidx, const char *name, const Int_t nbins) const 595 { 596 597 // Create the projection histogram 598 TString pname(name); 599 if (name=="_rad") 600 { 601 pname.Prepend(GetName()); 602 if (sector.GetSize()>0) 603 { 604 pname += ";"; 605 for (int i=0; i<sector.GetSize(); i++) 606 pname += sector[i]; 607 } 608 if (aidx.GetSize()>0) 609 { 610 pname += ";"; 611 for (int i=0; i<aidx.GetSize(); i++) 612 pname += aidx[i]; 613 } 614 } 615 616 TProfile *h1=0; 617 618 //check if histogram with identical name exist 619 TObject *h1obj = gROOT->FindObject(pname); 620 if (h1obj && h1obj->InheritsFrom("TProfile")) { 621 h1 = (TProfile*)h1obj; 622 h1->Reset(); 623 } 624 625 if (!h1) 626 { 627 628 Double_t min = 0.; 629 Double_t max = fGeomCam->GetMaxRadius(); 630 631 Int_t newbins=0; 632 633 THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE); 634 635 h1 = new TProfile(pname, GetTitle(), nbins, min, max); 636 h1->SetDirectory(pname.IsNull() ? NULL : gROOT); 637 h1->SetXTitle("Radius from camera center [mm]"); 638 h1->SetYTitle(GetYaxis()->GetTitle()); 639 } 640 641 // Fill the projected histogram 642 for (Int_t idx=0; idx<fNcells-2; idx++) 643 if (IsUsed(idx) && MatchSector(idx, sector, aidx)) 644 h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()), 645 GetBinContent(idx+1)); 646 return h1; 647 } 648 649 650 // ------------------------------------------------------------------------ 651 // 564 652 // Resizes the current pad so that the camera is displayed in its 565 653 // correct aspect ratio -
trunk/MagicSoft/Mars/mhist/MHCamera.h
r3514 r3528 19 19 20 20 class TPaveStats; 21 class TProfile; 21 22 22 23 class MGeomCam; … … 234 235 TH1D *ProjectionS(const TArrayI §or, const TArrayI &aidx, const char *name="_py") const; 235 236 237 TProfile *RadialProfile(const char *name="_rad") const { return RadialProfileS(TArrayI(), TArrayI(), name);} 238 TProfile *RadialProfileS(Int_t sector, Int_t aidx, const char *name="_rad", const Int_t nbins=20) const 239 { 240 return RadialProfileS(TArrayI(1, §or), TArrayI(1, &aidx), name, nbins); 241 } 242 TProfile *RadialProfileS(const TArrayI §or, const TArrayI &aidx, const char *name="_rad", const Int_t nbins=20) const; 243 236 244 const MGeomCam &GetGeomCam() const { return *fGeomCam; } 237 245
Note:
See TracChangeset
for help on using the changeset viewer.