Changeset 3151 for trunk


Ignore:
Timestamp:
02/14/04 17:43:35 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3150 r3151  
    1212   * mhbase/MH.cc
    1313     - included call to FindGoodLimits(..) in CutEdges()
    14 
     14     - axe from pointer to reference
     15 
    1516
    1617 2004/02/14: Thomas Bretz
  • trunk/MagicSoft/Mars/mhbase/MH.cc

    r3112 r3151  
    894894Int_t MH::CutEdges(TH1 *h, Int_t nbins)
    895895{
    896     TAxis* axe = h->GetXaxis();
    897 
    898     const Int_t min1   = axe->GetFirst();
    899     const Int_t max1   = axe->GetLast();
     896    TAxis &axe = *h->GetXaxis();
     897
     898    const Int_t min1   = axe.GetFirst();
     899    const Int_t max1   = axe.GetLast();
    900900    const Int_t range1 = max1-min1;
    901901
     
    929929
    930930    //
    931     // Check for rebinning
    932     //
    933     if (nbins < 1)
    934     {
    935         axe->SetRange(min2,max2);
    936         return axe->GetLast()-axe->GetFirst();
    937     }
    938 
    939     //
    940931    // Appying TAxis->SetRange before ReBin does not work ...
    941932    // But this workaround helps quite fine
    942933    //
    943     const Axis_t min = h->GetBinLowEdge(min2);
    944     const Axis_t max = h->GetBinLowEdge(max2)+h->GetBinWidth(max2);
    945 
    946     const Int_t ngroup = (int)((max2-min2)*h->GetNbinsX()/nbins/(max1-min1));
    947 
    948     if (ngroup > 1)
    949         h->Rebin(ngroup);
    950 
    951     axe->SetRangeUser(min,max);
    952 
    953     return axe->GetLast()-axe->GetFirst();
     934    Axis_t min = h->GetBinLowEdge(min2);
     935    Axis_t max = h->GetBinLowEdge(max2)+h->GetBinWidth(max2);
     936
     937    Int_t nbins2 = max2-min2;
     938    //
     939    // Check for rebinning
     940    //
     941    if (nbins > 0)
     942      {
     943        const Int_t ngroup = (int)(nbins2*h->GetNbinsX()/nbins/(max1-min1));
     944        if (ngroup > 1)
     945          {
     946            h->Rebin(ngroup);
     947            nbins2 /= ngroup;
     948          }
     949      }
     950   
     951    Int_t newbins = 0;
     952    FindGoodLimits(nbins2, newbins, min, max, kFALSE);
     953    axe.SetRangeUser(min,max);
     954    return axe.GetLast()-axe.GetFirst();
    954955}
    955956
Note: See TracChangeset for help on using the changeset viewer.