AliPhysics  fb6b143 (fb6b143)
AliPWGHistoTools.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 // AliPWGHistoTools
3 //
4 // This class provides some tools which can be useful in the analsis
5 // of spectra, to fit or transform histograms. See the comments of the
6 // individual methods for details
7 //
8 // Author: M. Floris (CERN)
9 // ----------------------------------------------------------------------
10 
11 #ifndef ALIBWTOOLS_H
12 #define ALIBWTOOLS_H
13 
14 #if !defined(__CINT__) || defined(__MAKECINT__)
15 
16 #include "TObject.h"
17 #include "TH1.h"
18 
19 class TF1;
20 class TH1D;
21 class TH1F;
22 class TGraphErrors;
23 class TGraph;
24 #endif
25 
26 
27 
28 class AliPWGHistoTools : public TObject {
29 
30 public:
31 
34 
35  static TH1 * GetOneOverPtdNdPt(const TH1 * hPt) ;
36  static TH1 * GetdNdmtFromdNdpt(const TH1 * hpt, Double_t mass);
37  static TH1 * GetdNdPtFromOneOverPt(const TH1 * h1Pt) ;
38  static TH1 * GetdNdptFromdNdmt(const TH1 * hmt, Double_t mass) ;
39 
40  static TGraphErrors * ConcatenateGraphs(const TGraphErrors * g1,const TGraphErrors * g2);
41  static TH1F * GetHistoFromGraph(const TGraphErrors * g, const TH1F* hTemplate) ;
42  static TGraphErrors * GetGraphFromHisto(const TH1F * h, Bool_t binWidth = kTRUE) ;
43  static void GetMeanDataAndExtrapolation(const TH1 * hData, TF1 * fExtrapolation, Double_t &mean, Double_t &error, Float_t min=0, Float_t max=100);
44 
45  static TH1F * CombineHistos(const TH1 * h1, TH1 * h2, const TH1* htemplate, Float_t renorm1=1.);
46  static TH1F * Combine3HistosWithErrors(const TH1 * h1, const TH1 * h2, const TH1* h3,
47  TH1 * he1, TH1 * he2, TH1 * he3,
48  const TH1* htemplate, Int_t statFrom = 0,
49  Float_t renorm1=1., Float_t renorm2=1., Float_t renorm3=1.,
50  TH1 ** hSyst =0, Bool_t errorFromBinContent=kFALSE);
51  static void GetFromHistoGraphDifferentX(const TH1F * h, TF1 * f, TGraphErrors ** gBarycentre, TGraphErrors ** gXlw);
52  static Float_t GetMean(TH1F * h, Float_t min, Float_t max, Float_t * error = NULL) ;
53 
54  static void GetMean(TF1 * func, Float_t &mean, Float_t &error, Float_t min=0, Float_t max=100, Int_t normPar = -1);
55  static void GetMeanSquare(TF1 * func, Float_t &mean, Float_t &error, Float_t min=0, Float_t max=100, Int_t normPar = -1) ;
56 
57  static Bool_t Fit (TH1 * h, TF1* f, Float_t min, Float_t max) ;
58 
59  static Int_t GetLowestNotEmptyBin(const TH1*h);
60  static Int_t GetHighestNotEmptyBin(const TH1*h);
61  static Float_t GetLowestNotEmptyBinEdge(const TH1*h) { return h->GetBinLowEdge(GetLowestNotEmptyBin(h));}
62  static Float_t GetHighestNotEmptyBinEdge(const TH1*h) { return h->GetBinLowEdge(GetHighestNotEmptyBin(h)+1);}
63 
64  static void GetResiduals(const TGraphErrors * gdata, const TF1 * func, TH1F ** hres, TGraphErrors ** gres) ;
65  static void GetResiduals(const TH1F* hdata, const TF1 * func, TH1F ** hres, TH1F ** hresVsBin) ;
66 
67  static void GetYield(TH1* h, TF1 * f, Double_t &yield, Double_t &yieldError, Float_t min = 0,
68  Float_t max = 100, Double_t *partialYields=0, Double_t *partialYieldsErrors=0);
69 
70  static TGraphErrors * DivideGraphByFunc (const TGraphErrors * g, const TF1 * f, Bool_t invert = kFALSE);
71  static TGraphErrors * DivideGraphByHisto(const TGraphErrors * g, TH1 * h, Bool_t invert = kFALSE);
72  static TH1F * DivideHistoByFunc (TH1F * h, TF1 * f, Bool_t invert = kFALSE);
73 
74  static void WeightedMean(Int_t npoints, const Double_t *x, const Double_t *xerr, Double_t &mean, Double_t &meanerr);
75 
76  static void GetValueAndError(TH1 * hdest, const TH1 * hvalue, const TH1 * herror, Bool_t isPercentError) ;
77  static TH1 * GetRelativeError(TH1 * h);
78  static void AddHisto(TH1 * hdest, const TH1* hsource, Bool_t getMirrorBins = kFALSE);
79  static void GetHistoCombinedErrors(TH1 * hdest, const TH1 * h1) ;
80  static TH1F * DivideHistosDifferentBins(const TH1F* h1, const TH1F* h2);
81  static Double_t DoIntegral(TH1* h, Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Int_t binz1, Int_t binz2, Double_t & error ,
82  Option_t *option, Bool_t doError) ;
83  static TGraphErrors * Divide2Graphs(const TGraph * g1, const TGraph * g2, Int_t strategy);
84  static TGraphErrors * Add2Graphs(const TGraphErrors * g1, const TGraphErrors * g2);
85  static void ScaleGraph (TGraph * g1, Double_t scale);
86 
87 
88  static Double_t dMtdptFunction(Double_t *x, Double_t *p) ;
89  static Double_t GetdMtdEta(TH1 *hData, TF1 * fExtrapolation, Double_t mass) ;
90 
91  // static Bool_t Compare2Plots(TObject * obj1, TObject * obj2);
92 
93 
94 private:
95 
96  AliPWGHistoTools(const AliPWGHistoTools&); // not implemented
97  AliPWGHistoTools& operator=(const AliPWGHistoTools&); // not implemented
98  static void GetMoment(TString name, TString var, TF1 * func, Float_t &mean, Float_t &error, Float_t min, Float_t max, Int_t normPar = -1) ;
99 
100  static TF1 * fdNdptForETCalc;
101 
102  ClassDef(AliPWGHistoTools,1);
103 
104 };
105 
106 #endif
static void GetValueAndError(TH1 *hdest, const TH1 *hvalue, const TH1 *herror, Bool_t isPercentError)
static TH1 * GetdNdPtFromOneOverPt(const TH1 *h1Pt)
static TGraphErrors * ConcatenateGraphs(const TGraphErrors *g1, const TGraphErrors *g2)
static void GetMeanDataAndExtrapolation(const TH1 *hData, TF1 *fExtrapolation, Double_t &mean, Double_t &error, Float_t min=0, Float_t max=100)
double Double_t
Definition: External.C:58
static Float_t GetHighestNotEmptyBinEdge(const TH1 *h)
static Int_t GetLowestNotEmptyBin(const TH1 *h)
static TH1 * GetRelativeError(TH1 *h)
static Bool_t Fit(TH1 *h, TF1 *f, Float_t min, Float_t max)
Double_t mass
static TGraphErrors * Divide2Graphs(const TGraph *g1, const TGraph *g2, Int_t strategy)
static Int_t GetHighestNotEmptyBin(const TH1 *h)
static Double_t DoIntegral(TH1 *h, Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Int_t binz1, Int_t binz2, Double_t &error, Option_t *option, Bool_t doError)
static TH1 * GetdNdmtFromdNdpt(const TH1 *hpt, Double_t mass)
static void GetMoment(TString name, TString var, TF1 *func, Float_t &mean, Float_t &error, Float_t min, Float_t max, Int_t normPar=-1)
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
static Float_t GetLowestNotEmptyBinEdge(const TH1 *h)
Definition: External.C:212
static void GetMeanSquare(TF1 *func, Float_t &mean, Float_t &error, Float_t min=0, Float_t max=100, Int_t normPar=-1)
static void AddHisto(TH1 *hdest, const TH1 *hsource, Bool_t getMirrorBins=kFALSE)
static TH1F * DivideHistosDifferentBins(const TH1F *h1, const TH1F *h2)
static TH1F * CombineHistos(const TH1 *h1, TH1 *h2, const TH1 *htemplate, Float_t renorm1=1.)
static void GetResiduals(const TGraphErrors *gdata, const TF1 *func, TH1F **hres, TGraphErrors **gres)
AliPWGHistoTools & operator=(const AliPWGHistoTools &)
static TH1 * GetOneOverPtdNdPt(const TH1 *hPt)
static TGraphErrors * GetGraphFromHisto(const TH1F *h, Bool_t binWidth=kTRUE)
static void GetFromHistoGraphDifferentX(const TH1F *h, TF1 *f, TGraphErrors **gBarycentre, TGraphErrors **gXlw)
static TH1F * GetHistoFromGraph(const TGraphErrors *g, const TH1F *hTemplate)
static Double_t dMtdptFunction(Double_t *x, Double_t *p)
static TGraphErrors * DivideGraphByFunc(const TGraphErrors *g, const TF1 *f, Bool_t invert=kFALSE)
static void WeightedMean(Int_t npoints, const Double_t *x, const Double_t *xerr, Double_t &mean, Double_t &meanerr)
static TH1F * DivideHistoByFunc(TH1F *h, TF1 *f, Bool_t invert=kFALSE)
static void GetYield(TH1 *h, TF1 *f, Double_t &yield, Double_t &yieldError, Float_t min=0, Float_t max=100, Double_t *partialYields=0, Double_t *partialYieldsErrors=0)
static TGraphErrors * Add2Graphs(const TGraphErrors *g1, const TGraphErrors *g2)
static TH1F * Combine3HistosWithErrors(const TH1 *h1, const TH1 *h2, const TH1 *h3, TH1 *he1, TH1 *he2, TH1 *he3, const TH1 *htemplate, Int_t statFrom=0, Float_t renorm1=1., Float_t renorm2=1., Float_t renorm3=1., TH1 **hSyst=0, Bool_t errorFromBinContent=kFALSE)
const char Option_t
Definition: External.C:48
static void ScaleGraph(TGraph *g1, Double_t scale)
bool Bool_t
Definition: External.C:53
static TGraphErrors * DivideGraphByHisto(const TGraphErrors *g, TH1 *h, Bool_t invert=kFALSE)
static TF1 * fdNdptForETCalc
static void GetHistoCombinedErrors(TH1 *hdest, const TH1 *h1)
static TH1 * GetdNdptFromdNdmt(const TH1 *hmt, Double_t mass)
Definition: External.C:196
static Double_t GetdMtdEta(TH1 *hData, TF1 *fExtrapolation, Double_t mass)
static Float_t GetMean(TH1F *h, Float_t min, Float_t max, Float_t *error=NULL)