Migrating PWG2/SPECTRA/Fit to new PWG structure
[u/mrichter/AliRoot.git] / PWG / Tools / AliPWGHistoTools.h
CommitLineData
4c0d7bc7 1// ----------------------------------------------------------------------
fef6f2b3 2// AliPWGHistoTools
4c0d7bc7 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
19class TF1;
20class TH1D;
21class TH1F;
22class TGraphErrors;
23#endif
24
25
26
fef6f2b3 27class AliPWGHistoTools : public TObject {
4c0d7bc7 28
29public:
30
fef6f2b3 31 AliPWGHistoTools();
32 ~AliPWGHistoTools();
4c0d7bc7 33
3beb22a2 34 static TH1 * GetOneOverPtdNdPt(const TH1 * hPt) ;
35 static TH1 * GetdNdmtFromdNdpt(const TH1 * hpt, Double_t mass);
36 static TH1 * GetdNdPtFromOneOverPt(const TH1 * h1Pt) ;
9ca56c22 37 static TH1 * GetdNdptFromdNdmt(const TH1 * hmt, Double_t mass) ;
3beb22a2 38
39 static TGraphErrors * ConcatenateGraphs(const TGraphErrors * g1,const TGraphErrors * g2);
40 static TH1F * GetHistoFromGraph(const TGraphErrors * g, const TH1F* hTemplate) ;
41 static TGraphErrors * GetGraphFromHisto(const TH1F * h, Bool_t binWidth = kTRUE) ;
ddecf727 42 static void GetMeanDataAndExtrapolation(const TH1 * hData, TF1 * fExtrapolation, Double_t &mean, Double_t &error, Float_t min=0, Float_t max=100);
43
3beb22a2 44 static TH1F * CombineHistos(const TH1 * h1, TH1 * h2, const TH1* htemplate, Float_t renorm1=1.);
45 static TH1F * Combine3HistosWithErrors(const TH1 * h1, const TH1 * h2, const TH1* h3,
3725266c 46 TH1 * he1, TH1 * he2, TH1 * he3,
3beb22a2 47 const TH1* htemplate, Int_t statFrom = 0,
3725266c 48 Float_t renorm1=1., Float_t renorm2=1., Float_t renorm3=1.,
49 TH1 ** hSyst =0, Bool_t errorFromBinContent=kFALSE);
3beb22a2 50 static void GetFromHistoGraphDifferentX(const TH1F * h, TF1 * f, TGraphErrors ** gBarycentre, TGraphErrors ** gXlw);
ddecf727 51 static Float_t GetMean(TH1F * h, Float_t min, Float_t max, Float_t * error = NULL) ;
4c0d7bc7 52
3472a634 53 static void GetMean(TF1 * func, Float_t &mean, Float_t &error, Float_t min=0, Float_t max=100, Int_t normPar = -1);
54 static void GetMeanSquare(TF1 * func, Float_t &mean, Float_t &error, Float_t min=0, Float_t max=100, Int_t normPar = -1) ;
4c0d7bc7 55
56 static Bool_t Fit (TH1 * h, TF1* f, Float_t min, Float_t max) ;
57
3beb22a2 58 static Int_t GetLowestNotEmptyBin(const TH1*h);
59 static Int_t GetHighestNotEmptyBin(const TH1*h);
60 static Float_t GetLowestNotEmptyBinEdge(const TH1*h) { return h->GetBinLowEdge(GetLowestNotEmptyBin(h));}
61 static Float_t GetHighestNotEmptyBinEdge(const TH1*h) { return h->GetBinLowEdge(GetHighestNotEmptyBin(h)+1);}
4c0d7bc7 62
3beb22a2 63 static void GetResiduals(const TGraphErrors * gdata, const TF1 * func, TH1F ** hres, TGraphErrors ** gres) ;
64 static void GetResiduals(const TH1F* hdata, const TF1 * func, TH1F ** hres, TH1F ** hresVsBin) ;
4c0d7bc7 65
66 static void GetYield(TH1* h, TF1 * f, Double_t &yield, Double_t &yieldError, Float_t min = 0,
67 Float_t max = 100, Double_t *partialYields=0, Double_t *partialYieldsErrors=0);
68
3beb22a2 69 static TGraphErrors * DivideGraphByFunc (const TGraphErrors * g, const TF1 * f, Bool_t invert = kFALSE);
70 static TGraphErrors * DivideGraphByHisto(const TGraphErrors * g, TH1 * h, Bool_t invert = kFALSE);
4c0d7bc7 71 static TH1F * DivideHistoByFunc (TH1F * h, TF1 * f, Bool_t invert = kFALSE);
72
ee08b77d 73 static void WeightedMean(Int_t npoints, const Double_t *x, const Double_t *xerr, Double_t &mean, Double_t &meanerr);
74
058137a6 75 static void GetValueAndError(TH1 * hdest, const TH1 * hvalue, const TH1 * herror, Bool_t isPercentError) ;
57b5143c 76 static TH1 * GetRelativeError(TH1 * h);
058137a6 77 static void AddHisto(TH1 * hdest, const TH1* hsource, Bool_t getMirrorBins = kFALSE);
78 static void GetHistoCombinedErrors(TH1 * hdest, const TH1 * h1) ;
d8e6677d 79 static TH1F * DivideHistosDifferentBins(const TH1F* h1, const TH1F* h2);
57b5143c 80 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 ,
81 Option_t *option, Bool_t doError) ;
90421222 82 static TGraphErrors * Divide2Graphs(const TGraphErrors * g1, const TGraphErrors * g2);
fef6f2b3 83 static TGraphErrors * Add2Graphs(const TGraphErrors * g1, const TGraphErrors * g2);
90421222 84
85 static Double_t dMtdptFunction(Double_t *x, Double_t *p) ;
86 static Double_t GetdMtdEta(TH1 *hData, TF1 * fExtrapolation, Double_t mass) ;
87
d8e6677d 88
3725266c 89
4c0d7bc7 90private:
91
fef6f2b3 92 AliPWGHistoTools(const AliPWGHistoTools&); // not implemented
93 AliPWGHistoTools& operator=(const AliPWGHistoTools&); // not implemented
3472a634 94 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) ;
4c0d7bc7 95
90421222 96 static TF1 * fdNdptForETCalc;
97
fef6f2b3 98 ClassDef(AliPWGHistoTools,1);
4c0d7bc7 99
100};
101
102#endif