GFHistManip


class description - source file - inheritance tree

class GFHistManip : public TObject

    private:
static GFHistArray* CreateHistArray1D(TH2* hist2D, const char* varName, const char* histName, Bool_t ignoreUnderFlow, Bool_t ignoreOverFlow, Bool_t projectX, UInt_t mergeNBins) protected:
static Bool_t CheckContent(TCollection* objs, const TClass* cl) public:
GFHistManip() GFHistManip(const GFHistManip&) ~GFHistManip() static Bool_t Add2ndTo1st(TH1* h1, const TH1* h2, Double_t factor) static Bool_t AddProfiles(TProfile* p1, const TProfile* p2, Double_t f1, Double_t f2) static void AddToHistsName(const char* nameAdd, GFHistArray* hists, const char* title = "0") static Bool_t BinsAreSubRange(const TAxis* axis, Int_t firstBin, Int_t lastBin) static void CallSumw2(GFHistArray* hists) static TClass* Class() static GFHistArray* ClearCreateArray(GFHistArray*& array) static void CorrectForBinWidth(TH1* hist, Bool_t correctError = kTRUE) static TH1* CreateAnalog(const TH1* hist, const char* name, Bool_t sumw2, Bool_t fill = kFALSE) static TH1* CreateAnalogHist(const TH1* hBins, const TGraphAsymmErrors* errorsMc, Bool_t upper) static void CreateAnalogHists(GFHistArray* input, GFHistArray*& output, const char* addName, const char* addTitle = "0") static TH1* CreateAverage(GFHistArray* input, const TArrayD& weights, const char* name = "0") static TH1* CreateEff(const GFHistArray* histsCount, const GFHistArray* histsDenom, const TArrayD& lumi, TGraphAsymmErrors** graphPtrPtr = 0) static GFHistArray* CreateHistArray1D(TH2* hist2D, const char* varName, const char* histName = "0", Bool_t noOverUnderFlow = kTRUE, Bool_t projectX = kTRUE, UInt_t mergeNBins = 1) static GFHistArray* CreateHistArray1D(TH2* hist2D, const char* varName, const char* histName, Option_t* option) static TH1* CreateHistDevSquareSum(const GFHistArray* hists, const TH1* hRef, Int_t flagUpLow) static TH2* CreateHistFlipXY(TH2* hist2D) static TH1* CreateHistMinMax(const GFHistArray* hists, Int_t minMax) static TH1* CreateHistXBins(TH2* hist2D, const char* titleAdd = "0", UInt_t merge = 1) static TH1* CreateHistYBins(TH2* hist2D, const char* titleAdd = "0", UInt_t merge = 1) static TH1* CreateMaxRelDiff(TObjArray* hists, const TH1* reference) static TH1D* CreateProjection(const TH2* h2D, const char* name, Int_t bin1, Int_t bin2, Bool_t projectX = kTRUE) static TH1* CreateRatioBinomErrors(const TH1* hCount, const TH1* hDenom, TArrayD* upError = 0, TArrayD* lowError = 0, const TH1* hNoWeightDenom = 0, TGraphAsymmErrors** graphPtrPtr = 0) static TH1* CreateRatioBlobelErrors(const TH1* hCount, const TH1* hDenom) static TH1* CreateRatioGassnerErrors(const TH1* hCount, const TH1* hDenom) static TH1* CreateRelErrorHist(const TH1* hist, Bool_t abs = kTRUE) virtual TClass* IsA() const static Bool_t IsSameBinning(const TH1* h1, const TH1* h2) static void MakeUniqueName(TString& name) static Bool_t MergeBins(TH1*& hist, Int_t bin1, Int_t bin2, Option_t* option) static TH1* MergeHists(const char* name, const TObjArray* dirs) static void MergeOverToUnderFlow(TH1* hist) static Double_t MinMaxOfHist(const TH1* h, Int_t minMax) static Double_t MinMaxOfHists(const GFHistArray* hists, Int_t minMax) static Double_t Normalise(TH1* hist, Option_t* opt) static Double_t Normalise(TH1* h, TObjArray* singleHs) static Double_t Normalise1stTo2nd(TH1* hist1, TH1* hist2, Option_t* opt = "width") static void NormaliseBinsToSum(GFHistArray* hists) static void PrintTable(const TH1* h, const char* title) static Bool_t RadToDegXaxis(TH1*& hist, Bool_t perBinWidth = kFALSE) static Bool_t Rebin(const TH1* hInput, TH1* hOutBins, Option_t* option) static void ReCorrectForBinWidth(TH1* hist, Bool_t correctError = kTRUE) static void RepairStat1(TH1* hist) static Bool_t Scale(TH1* hist, Double_t factor) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members




Class Description

                                                                      
 GFHistManip                                                          

   Author:      Gero Flucke
   Date:        April 2nd, 2003
   last update: $Date: 2005/12/15 11:21:32 $
   by:          $Author: flucke $
                                                                      
 Encapsulate Gero's routines for histogram manipulation.              
                                                                      


TH1* CreateMaxRelDiff(TObjArray* hists, const TH1* reference)

TH1* CreateHistDevSquareSum(const GFHistArray *hists, const TH1 *hRef, Int_t flagUpLow)
 quadaratic adding up of deviations of hists to hRef,
 hists must be above (below) hRef for flagUpLow > 0 (< 0)
 1-D only

TH1* CreateHistMinMax(const GFHistArray *hists, Int_t minMax)
 only 1D!

GFHistArray* CreateHistArray1D(TH2* hist2D, const char* varName, const char* histName, Option_t *option)
 create array of 1D hists projected from hist2D
 var name is for title of 1D hists which tells about bin borders
 if histName is beginning of names of 1D hists (hist2D->GetName() if NULL)
 if 'option' contains 'o', include overflow, if 'u' underflow
 if 'option' contains 'm' followed by a number, merge bins
 (do not add 'm' several times, the first is taken, even if there is
  no number after it!)
 by default projects along x, but if option contains 'y' do it along y

GFHistArray* CreateHistArray1D(TH2* hist2D, const char* varName, const char* histName, Bool_t ignoreOverUnderFlow, Bool_t projectX, UInt_t mergeNBins)
 outdated, use version with 'option'

GFHistArray* CreateHistArray1D(TH2* hist2D, const char* varName, const char* histName, Bool_t ignoreUnderFlow, Bool_t ignoreOverFlow, Bool_t projectX, UInt_t mergeNBins)
 private helper method

TH1D* CreateProjection(const TH2* h2D, const char *name, Int_t bin1, Int_t bin2, Bool_t projectX)
 Create projection of 'h2D' along x/y from 'bin1' to 'bin2', name of new hit is 'name'.
 Error option is selected if h2D has errors stored,
 sumw2 is fixed as in ROOT >= 4.01.

TH1* CreateHistYBins(TH2* hist2D, const char* titleAdd, UInt_t mergeNBins)
 merge 'mergeNBins'

TH1* CreateHistXBins(TH2* hist2D, const char* titleAdd, UInt_t mergeNBins)

TH2* CreateHistFlipXY(TH2* h)
 create a hist with flipped X and Y bin contents (ignore overflow bins...)
 add 'Flip' to name, always use arrays for bins
 stats might be slightly different...

void PrintTable(const TH1* hist, const char* title)
 formated printing the bin content and error, starting with title

void AddToHistsName(const char* nameAdd, GFHistArray* hists, const char* title)
 namAdd is added to hist name, if title is given, adds it to title

void CallSumw2(GFHistArray* hists)

void CreateAnalogHists(GFHistArray* input, GFHistArray*& output, const char* addName, const char* addTitle)
 creates output if not yet existing

TH1* CreateAnalogHist(const TH1* hBins, const TGraphAsymmErrors* errors, Bool_t upper)
 create a hist with borders bins from hBins, fill with errors->GetY() but add
 GetEYhigh() (if upper = kTRUE) or subtract GetEYlow()

TH1* CreateRelErrorHist(const TH1* hist, Bool_t abs)
 create a hist containing the relative errors of hist, if abs = kTRUE only absolute values

TH1* CreateAverage(GFHistArray* input, const TArrayD& weights, const char* name)

TH1* CreateAnalog(const TH1* h, const char* name, Bool_t sumw2, Bool_t fill)
 create a hist with the same bin borders as 'h', setting 'name', copy title from 'h',
 if(sumw2) call Sumw2(), if(fill) fill content (and errors if sumw2) from 'h'
 currently only for 1D hists, TH1D and TH1F,
 axis titles will be copied
 do not create profiles...

GFHistArray* ClearCreateArray(GFHistArray*& array)
 array is created as new GFHistArray which OWNS all hists that will be filled into it
 array is also returned...
 if array existed: content will be cleared!
 array is set to be owner of all hists in it!

Double_t Normalise(TH1* hist, Option_t* opt)
 scales histogram to be normalised,
 if opt == "width": taking into account the bin width
 returns scale factor

Double_t Normalise(TH1* hist, TObjArray* singleHs)
 normalise hist 'hist' and multiply all hists in 'singleHs' by the same factor used to
 normalise 'hist'

Double_t Normalise1stTo2nd(TH1* hist1, TH1* hist2, Option_t* opt)
 if opt == "width" (default) integrals take into account the binwidth

void NormaliseBinsToSum(GFHistArray* hists)
 normalises the 'hists' such that for each bin the sum of all gives one,
 must be 1D and must have same number of bins
 errors will be correctly calculated assuming that the input histograms' errors
 are uncorrelated, but you'll not have access to the correlations of the

void CorrectForBinWidth(TH1* hist, Bool_t correctError)
 divides all bins content and error through the binwidth
 for 1D only
 under-/overflow untouched (what else...?)

void ReCorrectForBinWidth(TH1* hist, Bool_t correctError)
 multiply all bins' content and error with the binwidth
 for 1D only
 under-/overflow untouched (what else...?)

TH1* CreateRatioGassnerErrors(const TH1* hCount, const TH1* hDenom)
 cf. appendix E of Johannes Gassner's thesis (from 2002)

TH1* CreateRatioBlobelErrors(const TH1* hCount, const TH1* hDenom)

TH1* CreateRatioBinomErrors(const TH1* hCount, const TH1* hDenom, TArrayD* upError, TArrayD* lowError, const TH1* hNoWeightDenom, TGraphAsymmErrors** graphPtrPtr)
 Create a hist hCount/hDenom and set errors as mean of lower and upper error from
 binomial distribution via GFMath::BinomialError.
 If upError or lowError are given, they are filled with the correct errors
 (including over/underflow bins, so lowError[1] is for bin 1, not bin 0).
 If graphPtrPtr is given, it is dereferenced and filled with a pointer to a newly
 created TGraphAysmmErrors that contains the correct asymmetric errors.

 If the histograms are weighted, the number of entries (= sum of weights) in each bin
 is scaled to the number of effective entries in the denominater:

 N_eff = (sum w_i)^2/sum(w_i^2)    (cf. LOOK manual)

 If N_eff/N < 0.66 (N number of 'filling actions') this method may not be applicable. So
 if(hNoWeightDenom)
    check for each bin N_eff/hNoWeightDenom->GetBinContent
 else
    check the quantity of the total hDenom (from GetStats and GetEntries())

 If any of the checked rations is below 0.66: return NULL
 if any of the given hists

TH1* CreateEff(const GFHistArray* histsCount,const GFHistArray* histsDenom, const TArrayD& lumi, TGraphAsymmErrors** graphPtrPtr)
 add histsCount and histsDenom lumi weighted and create efficiency hist via
 CreateRatioBinomErrors (so check for NULL!),
 graphPtrPtr is also passed to that routine.

Bool_t Scale(TH1* hist, Double_t factor)
 due to a bug in ROOT (fixed in 4.00_0?), the histogram's sum of squares of weights
 is not properly adjusted when scaling a histogram

Bool_t Add2ndTo1st(TH1* h1, const TH1* h2, Double_t factor)
 similar to GFHistManip::Scale

Bool_t AddProfiles(TProfile *p1, const TProfile *p2, Double_t f1, Double_t f2)
 there is a bug in TProfile::Add(...) which makes the error bars wrong,
 fixed by the ROOT team (Rene Brun) on August 9th, 2005
 this fix is not yet tested or does not seem to work...

TH1* MergeHists(const char *name, const TObjArray *dirs)
 dirs is assumed to be an array of TDirectory
 return a hist which is the sum of all hists with 'name'

void RepairStat1(TH1* hist)
 ROOT versions before 4.01_xx calculate a wrong sumw2 if hist is result of a projection...

Bool_t Rebin(const TH1 *input, TH1 *output, Option_t *option)
 tries to fill the content of the input histogram into the output
 if possible. If not (inconsistent boundaries) returns false
 if option contains 'e', errors are calculated
 If false is returned, output may be only partially manipulated.

Double_t MinMaxOfHist(const TH1* h, Int_t minMax)
 max or min of hist 'h' (max if minMax > 0, min if < 0, else result is 0.)
 If hist's option contains 'e' or it has weights stored and not option HIST,
 error bars are taken into account.

Double_t MinMaxOfHists(const GFHistArray* hists, Int_t minMax)

Bool_t IsSameBinning(const TH1 *h1, const TH1 *h2)

Bool_t CheckContent(TCollection *hists, const TClass *cl)
 true if all inherit from type cl

Bool_t BinsAreSubRange(const TAxis *axis, Int_t firstBin, Int_t lastBin)

void MakeUniqueName(TString& name)
 remove all special letters
 if 'name' is found by gROOT->FindObject(name), '_<unique_number>' is added

Bool_t RadToDegXaxis(TH1 *&hist, Bool_t perBinWidth)

Bool_t MergeBins(TH1 *&hist, Int_t bin1, Int_t bin2, Option_t *option)
 replacing 'hist' by a histogram where bins 'bin1' to 'bin2' are merged
 If they are both negative, they are counted backwards from the last
 bin (merge last two bins is (-1, -2)
 options: 'width': if hist is 'per bin width'
          'e'    : if the new hist should have calculated errors

void MergeOverToUnderFlow(TH1 *hist)



Inline Functions


            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void Streamer(TBuffer& b)
               void StreamerNVirtual(TBuffer& b)
        GFHistManip GFHistManip()
        GFHistManip GFHistManip(const GFHistManip&)
               void ~GFHistManip()


Last update: Wed Jan 11 14:06:04 2006


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.