]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/vertexingHF/AliHFPtSpectrum.h
Added Init() for AliNormalizationCounter
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliHFPtSpectrum.h
CommitLineData
65e55bbd 1#ifndef ALIHFPTSPECTRUM_H
2#define ALIHFPTSPECTRUM_H
3
4/* Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
27de2dfb 7/* $Id$ */
8
65e55bbd 9//***********************************************************************
10// Class AliHFPtSpectrum
11// Base class for feed-down corrections on heavy-flavour decays
12// computes the cross-section via one of the three implemented methods:
13// 0) Consider no feed-down prediction
14// 1) Subtract the feed-down with the "fc" method
15// Yield = Reco * fc; where fc = 1 / ( 1 + (eff_b/eff_c)*(N_b/N_c) ) ;
16// 2) Subtract the feed-down with the "Nb" method
17// Yield = Reco - Feed-down (exact formula on the function implementation)
18//
bb427707 19// (the corrected yields per bin are divided by the bin-width)
20//
4d4e48c7 21//
22// In HIC you can also evaluate how the feed-down correction is influenced by an energy loss hypothesis:
23// Raa(c-->D) / Raa(b-->D) defined here as Rcb for the "fc" method
24// Raa(b-->D) defined here as Rb for the "Nb" method
25//
65e55bbd 26// Author: Z.Conesa, zconesa@in2p3.fr
27//***********************************************************************
28
29#include "TNamed.h"
86bdcd8c 30#include "TMath.h"
e52da743 31
32class TH1;
4d4e48c7 33class TH2;
34class TNtuple;
e52da743 35class TGraphAsymmErrors;
36
65e55bbd 37
38class AliHFPtSpectrum: public TNamed
39{
40
41 public:
42
43 // Constructor
44 AliHFPtSpectrum(const char* name="AliHFPtSpectrum", const char* title="HF feed down correction class", Int_t option=1);
45 // Copy constructor
46 AliHFPtSpectrum(const AliHFPtSpectrum &rhs);
47 // Assignment operator
48 AliHFPtSpectrum& operator=(const AliHFPtSpectrum &source);
49 // Destructor
50 virtual ~AliHFPtSpectrum();
51
52 //
53 // Setters
54 //
55 // Set the theoretical direct & feeddown pt spectrum
86bdcd8c 56 void SetMCptSpectra(TH1D *hDirect, TH1D *hFeedDown);
65e55bbd 57 // Set the theoretical feeddown pt spectrum
86bdcd8c 58 void SetFeedDownMCptSpectra(TH1D *hFeedDown);
65e55bbd 59 // Set the theoretical direct & feeddown pt spectrum upper and lower bounds
86bdcd8c 60 void SetMCptDistributionsBounds(TH1D *hDirectMax, TH1D *hDirectMin, TH1D *hFeedDownMax, TH1D *hFeedDownMin);
65e55bbd 61 // Set the theoretical feeddown pt spectrum upper and lower bounds
86bdcd8c 62 void SetFeedDownMCptDistributionsBounds(TH1D *hFeedDownMax, TH1D *hFeedDownMin);
65e55bbd 63 // Set the acceptance and efficiency corrections for direct
86bdcd8c 64 void SetDirectAccEffCorrection(TH1D *hDirectEff);
65e55bbd 65 // Set the acceptance and efficiency corrections for direct & feeddown
86bdcd8c 66 void SetAccEffCorrection(TH1D *hDirectEff, TH1D *hFeedDownEff);
65e55bbd 67 // Set the reconstructed spectrum
86bdcd8c 68 void SetReconstructedSpectrum(TH1D *hRec);
69 void SetReconstructedSpectrumSystematics(TGraphAsymmErrors *gRec);
65e55bbd 70 // Set the calculation option flag for feed-down correction: 0=none, 1=fc , 2=Nb
71 void SetFeedDownCalculationOption(Int_t option){ fFeedDownOption = option; }
72 // Set if the calculation has to consider asymmetric uncertaInt_ties or not
a17b17dd 73 void SetComputeAsymmetricUncertainties(Bool_t flag){ fAsymUncertainties = flag; }
4d4e48c7 74 // Set if the calculation has to consider Ratio(c/b eloss) hypothesis
75 void SetComputeElossHypothesis(Bool_t flag){ fPbPbElossHypothesis = flag; }
65e55bbd 76 // Set the luminosity and its uncertainty
77 void SetLuminosity(Double_t luminosity, Double_t unc){
78 fLuminosity[0]=luminosity; fLuminosity[1]=unc;
79 }
80 // Set the trigger efficiency and its uncertainty
81 void SetTriggerEfficiency(Double_t efficiency, Double_t unc){
82 fTrigEfficiency[0]=efficiency; fTrigEfficiency[1]=unc;
83 }
8998180c 84 // Set global acceptance x efficiency correction uncertainty (in percentages)
85 void SetAccEffPercentageUncertainty(Double_t globalEffUnc, Double_t globalBCEffRatioUnc){
86 fGlobalEfficiencyUncertainties[0] = globalEffUnc;
87 fGlobalEfficiencyUncertainties[1] = globalBCEffRatioUnc;
88 }
86bdcd8c 89 // Set the normalization factors
90 void SetNormalization(Double_t normalization){
4d4e48c7 91 fLuminosity[0]=normalization;
86bdcd8c 92 }
4d4e48c7 93 void SetNormalization(Int_t nevents, Double_t sigma){
94 fLuminosity[0]=nevents/sigma;
95 fNevts = nevents;
86bdcd8c 96 }
4d4e48c7 97 void SetNormalization(Int_t nevents, Double_t sigma, Double_t sigmaunc){
86bdcd8c 98 fLuminosity[0] = nevents/sigma;
86bdcd8c 99 fLuminosity[1] = fLuminosity[0] * TMath::Sqrt( (1/nevents) + (sigmaunc/sigma)*(sigmaunc/sigma) );
4d4e48c7 100 fNevts = nevents;
101 }
102 //
103 // Set the Tab parameter and its uncertainty
104 void SetTabParameter(Double_t tabvalue, Double_t uncertainty){
105 fTab[0] = tabvalue;
106 fTab[1] = uncertainty;
86bdcd8c 107 }
65e55bbd 108
4d4e48c7 109
65e55bbd 110 //
111 // Getters
112 //
5f3c1b97 113 // Return the theoretical predictions used for the calculation (rebinned if needed)
e52da743 114 TH1D * GetDirectTheoreticalSpectrum() const { return (fhDirectMCpt ? (TH1D*)fhDirectMCpt : NULL); }
115 TH1D * GetDirectTheoreticalUpperLimitSpectrum() const { return (fhDirectMCptMax ? (TH1D*)fhDirectMCptMax : NULL); }
116 TH1D * GetDirectTheoreticalLowerLimitSpectrum() const { return (fhDirectMCptMin ? (TH1D*)fhDirectMCptMin : NULL); }
117 TH1D * GetFeedDownTheoreticalSpectrum() const { return (fhFeedDownMCpt ? (TH1D*)fhFeedDownMCpt : NULL); }
118 TH1D * GetFeedDownTheoreticalUpperLimitSpectrum() const { return (fhFeedDownMCptMax ? (TH1D*)fhFeedDownMCptMax : NULL); }
119 TH1D * GetFeedDownTheoreticalLowerLimitSpectrum() const { return (fhFeedDownMCptMin ? (TH1D*)fhFeedDownMCptMin : NULL); }
5f3c1b97 120 // Return the acceptance and efficiency corrections (rebinned if needed)
e52da743 121 TH1D * GetDirectAccEffCorrection() const { return (fhDirectEffpt ? (TH1D*)fhDirectEffpt : NULL); }
122 TH1D * GetFeedDownAccEffCorrection() const { return (fhFeedDownEffpt ? (TH1D*)fhFeedDownEffpt : NULL); }
4d4e48c7 123 // Return whether the Ratio(c/b eloss) hypothesis has been considered
124 Bool_t IsElossHypothesisCalculated(){ return fPbPbElossHypothesis; }
86bdcd8c 125 // Return the TGraphAsymmErrors of the feed-down correction (extreme systematics)
e52da743 126 TGraphAsymmErrors * GetFeedDownCorrectionFcExtreme() const { return (fgFcExtreme ? fgFcExtreme : NULL); }
86bdcd8c 127 // Return the TGraphAsymmErrors of the feed-down correction (conservative systematics)
e52da743 128 TGraphAsymmErrors * GetFeedDownCorrectionFcConservative() const { return (fgFcConservative ? fgFcConservative : NULL); }
65e55bbd 129 // Return the histogram of the feed-down correction
e52da743 130 TH1D * GetHistoFeedDownCorrectionFc() const { return (fhFc ? (TH1D*)fhFc : NULL); }
65e55bbd 131 // Return the histograms of the feed-down correction bounds
e52da743 132 TH1D * GetHistoUpperLimitFeedDownCorrectionFc() const { return (fhFcMax ? (TH1D*)fhFcMax : NULL); }
133 TH1D * GetHistoLowerLimitFeedDownCorrectionFc() const { return (fhFcMin ? (TH1D*)fhFcMin : NULL); }
4d4e48c7 134 // Return the histogram of the feed-down correction times the Ratio(c/b eloss)
135 TH2D * GetHistoFeedDownCorrectionFcVsEloss() const { return (fhFcRcb ? (TH2D*)fhFcRcb : NULL); }
86bdcd8c 136 // Return the TGraphAsymmErrors of the yield after feed-down correction (systematics but feed-down)
e52da743 137 TGraphAsymmErrors * GetFeedDownCorrectedSpectrum() const { return (fgYieldCorr ? fgYieldCorr : NULL); }
86bdcd8c 138 // Return the TGraphAsymmErrors of the yield after feed-down correction (feed-down extreme systematics)
e52da743 139 TGraphAsymmErrors * GetFeedDownCorrectedSpectrumExtreme() const { return (fgYieldCorrExtreme ? fgYieldCorrExtreme : NULL); }
86bdcd8c 140 // Return the TGraphAsymmErrors of the yield after feed-down correction (feed-down conservative systematics)
e52da743 141 TGraphAsymmErrors * GetFeedDownCorrectedSpectrumConservative() const { return (fgYieldCorrConservative ? fgYieldCorrConservative : NULL); }
65e55bbd 142 // Return the histogram of the yield after feed-down correction
e52da743 143 TH1D * GetHistoFeedDownCorrectedSpectrum() const { return (fhYieldCorr ? (TH1D*)fhYieldCorr : NULL); }
65e55bbd 144 // Return the histogram of the yield after feed-down correction bounds
e52da743 145 TH1D * GetHistoUpperLimitFeedDownCorrectedSpectrum() const { return (fhYieldCorrMax ? (TH1D*)fhYieldCorrMax : NULL); }
146 TH1D * GetHistoLowerLimitFeedDownCorrectedSpectrum() const { return (fhYieldCorrMin ? (TH1D*)fhYieldCorrMin : NULL); }
4d4e48c7 147 // Return the histogram of the yield after feed-down correction vs the Ratio(c/b eloss)
148 TH2D * GetHistoFeedDownCorrectedSpectrumVsEloss() const { return (fhYieldCorrRcb ? (TH2D*)fhYieldCorrRcb : NULL); }
86bdcd8c 149 // Return the equivalent invariant cross-section TGraphAsymmErrors (systematics but feed-down)
e52da743 150 TGraphAsymmErrors * GetCrossSectionFromYieldSpectrum() const { return (fgSigmaCorr ? fgSigmaCorr : NULL); }
86bdcd8c 151 // Return the equivalent invariant cross-section TGraphAsymmErrors (feed-down extreme systematics)
e52da743 152 TGraphAsymmErrors * GetCrossSectionFromYieldSpectrumExtreme() const { return (fgSigmaCorrExtreme ? fgSigmaCorrExtreme : NULL); }
86bdcd8c 153 // Return the equivalent invariant cross-section TGraphAsymmErrors (feed-down conservative systematics)
e52da743 154 TGraphAsymmErrors * GetCrossSectionFromYieldSpectrumConservative() const { return (fgSigmaCorrConservative ? fgSigmaCorrConservative : NULL); }
65e55bbd 155 // Return the equivalent invariant cross-section histogram
e52da743 156 TH1D * GetHistoCrossSectionFromYieldSpectrum() const { return (fhSigmaCorr ? (TH1D*)fhSigmaCorr : NULL); }
65e55bbd 157 // Return the equivalent invariant cross-section histogram bounds
e52da743 158 TH1D * GetHistoUpperLimitCrossSectionFromYieldSpectrum() const { return (fhSigmaCorrMax ? (TH1D*)fhSigmaCorrMax : NULL); }
159 TH1D * GetHistoLowerLimitCrossSectionFromYieldSpectrum() const { return (fhSigmaCorrMin ? (TH1D*)fhSigmaCorrMin : NULL); }
4d4e48c7 160 // Return the cross section systematics from data systematics
161 TH1D * GetHistoCrossSectionDataSystematics() const { return (fhSigmaCorrDataSyst ? (TH1D*)fhSigmaCorrDataSyst : NULL); }
162 //
163 // PbPb special calculations
164 // Return the equivalent invariant cross-section histogram vs the Ratio(c/b eloss)
165 TH2D * GetHistoCrossSectionFromYieldSpectrumVsEloss() const { return (fhSigmaCorrRcb ? (TH2D*)fhSigmaCorrRcb : NULL); }
166 // Return the ntuple of the calculation vs the Ratio(c/b eloss)
167 TNtuple * GetNtupleCrossSectionVsEloss() { return (fnSigma ? (TNtuple*)fnSigma : NULL); }
168 //
169 //
170 // Histograms to keep track of the influence of the efficiencies statistical uncertainty on the cross-section
171 TH1D * GetDirectStatEffUncOnSigma() const { return (TH1D*)fhStatUncEffcSigma; }
172 TH1D * GetFeedDownStatEffUncOnSigma() const { return (TH1D*)fhStatUncEffbSigma; }
173 // Histograms to keep track of the influence of the efficiencies statistical uncertainty on the feed-down correction factor
174 TH1D * GetDirectStatEffUncOnFc() const { return (TH1D*)fhStatUncEffcFD; }
175 TH1D * GetFeedDownStatEffUncOnFc() const { return (TH1D*)fhStatUncEffbFD; }
176
65e55bbd 177
178 //
179 // Main function:
180 // Compute the invariant cross-section from the yield (correct it)
a17b17dd 181 // variables : analysed delta_y, BR for the final correction, BR b --> decay (relative to the input theoretical prediction)
182 void ComputeHFPtSpectrum(Double_t deltaY=1.0, Double_t branchingRatioC=1.0, Double_t branchingRatioBintoFinalDecay=1.0);
65e55bbd 183
8998180c 184 // Compute the systematic uncertainties
185 // taking as input the AliHFSystErr uncertainties
5541b811 186 void ComputeSystUncertainties(AliHFSystErr *systematics, Bool_t combineFeedDown);
8998180c 187 //
188 // Drawing the corrected spectrum comparing to theoretical prediction
189 void DrawSpectrum(TGraphAsymmErrors *gPrediction);
190
bb427707 191 //
192 // Basic functions
193 //
86bdcd8c 194 void EstimateAndSetDirectEfficiencyRecoBin(TH1D *hSimu, TH1D *hReco);
195 void EstimateAndSetFeedDownEfficiencyRecoBin(TH1D *hSimu, TH1D *hReco);
bb427707 196
65e55bbd 197 //
198 // Functions to reweight histograms for testing purposes:
199 // to reweight the simulation: hToReweight is reweighted as hReference/hToReweight
86bdcd8c 200 TH1D * ReweightHisto(TH1D *hToReweight, TH1D *hReference);
65e55bbd 201 // to reweight the reco-histos: hRecToReweight is reweighted as hReference/hMCToReweight
86bdcd8c 202 TH1D * ReweightRecHisto(TH1D *hRecToReweight, TH1D *hMCToReweight, TH1D *hMCReference);
4d4e48c7 203 // Functionality to find the y-axis bin of a TH2 for a given y-value
204 Int_t FindTH2YBin(TH2D *histo, Float_t yvalue);
65e55bbd 205
206
207 protected:
208
209 // Initialization
210 Bool_t Initialize();
211
212 // Basic functions
213 //
214 // Compute the feed-down correction via fc-method
a17b17dd 215 void CalculateFeedDownCorrectionFc();
65e55bbd 216 // Correct the yield for feed-down correction via fc-method
a17b17dd 217 void CalculateFeedDownCorrectedSpectrumFc();
65e55bbd 218 // Correct the yield for feed-down correction via Nb-method
a17b17dd 219 void CalculateFeedDownCorrectedSpectrumNb(Double_t deltaY, Double_t branchingRatioBintoFinalDecay);
65e55bbd 220
221 // Check histograms consistency function
86bdcd8c 222 Bool_t CheckHistosConsistency(TH1D *h1, TH1D *h2);
5f3c1b97 223 // Function to rebin the theoretical spectra in the data-reconstructed spectra binning
86bdcd8c 224 TH1D * RebinTheoreticalSpectra(TH1D *hTheory, const char *name);
5f3c1b97 225 // Function to estimate the efficiency in the data-reconstructed spectra binning
86bdcd8c 226 TH1D * EstimateEfficiencyRecoBin(TH1D *hSimu, TH1D *hReco, const char *name);
227
65e55bbd 228
229 //
230 // Input spectra
231 //
86bdcd8c 232 TH1D *fhDirectMCpt; // Input MC c-->D spectra
233 TH1D *fhFeedDownMCpt; // Input MC b-->D spectra
234 TH1D *fhDirectMCptMax; // Input MC maximum c-->D spectra
235 TH1D *fhDirectMCptMin; // Input MC minimum c-->D spectra
236 TH1D *fhFeedDownMCptMax; // Input MC maximum b-->D spectra
237 TH1D *fhFeedDownMCptMin; // Input MC minimum b-->D spectra
238 TH1D *fhDirectEffpt; // c-->D Acceptance and efficiency correction
239 TH1D *fhFeedDownEffpt; // b-->D Acceptance and efficiency correction
240 TH1D *fhRECpt; // all reconstructed D
241 //
242 TGraphAsymmErrors *fgRECSystematics; // all reconstructed D Systematic uncertainties
65e55bbd 243 //
244 // Normalization factors
4d4e48c7 245 Int_t fNevts; // nb of analyzed events
65e55bbd 246 Double_t fLuminosity[2]; // analyzed luminosity & uncertainty
247 Double_t fTrigEfficiency[2]; // trigger efficiency & uncertainty
8998180c 248 Double_t fGlobalEfficiencyUncertainties[2]; // uncertainties on the efficiency [0]=c, b, [1]=b/c
4d4e48c7 249 Double_t fTab[2]; // Tab parameter and its uncertainty
65e55bbd 250
251 //
252 // Output spectra
253 //
86bdcd8c 254 TH1D *fhFc; // Correction histo fc = 1 / ( 1 + (eff_b/eff_c)*(N_b/N_c) )
255 TH1D *fhFcMax; // Maximum fc histo
256 TH1D *fhFcMin; // Minimum fc histo
4d4e48c7 257 TH2D *fhFcRcb; // Correction histo fc vs the Ratio(c/b eloss)
86bdcd8c 258 TGraphAsymmErrors * fgFcExtreme; // Extreme correction as TGraphAsymmErrors
259 TGraphAsymmErrors * fgFcConservative; // Extreme correction as TGraphAsymmErrors
260 TH1D *fhYieldCorr; // Corrected yield (stat unc. only)
261 TH1D *fhYieldCorrMax; // Maximum corrected yield
262 TH1D *fhYieldCorrMin; // Minimum corrected yield
4d4e48c7 263 TH2D *fhYieldCorrRcb; // Corrected yield (stat unc. only) vs the Ratio(c/b eloss)
86bdcd8c 264 TGraphAsymmErrors * fgYieldCorr; // Corrected yield as TGraphAsymmErrors (syst but feed-down)
265 TGraphAsymmErrors * fgYieldCorrExtreme; // Extreme corrected yield as TGraphAsymmErrors (syst from feed-down)
266 TGraphAsymmErrors * fgYieldCorrConservative; // Conservative corrected yield as TGraphAsymmErrors (syst from feed-down)
267 TH1D *fhSigmaCorr; // Corrected cross-section (stat unc. only)
268 TH1D *fhSigmaCorrMax; // Maximum corrected cross-section
269 TH1D *fhSigmaCorrMin; // Minimum corrected cross-section
4d4e48c7 270 TH1D *fhSigmaCorrDataSyst; // Corrected cross-section (syst. unc. from data only)
271 TH2D *fhSigmaCorrRcb; // Corrected cross-section (stat unc. only) vs the Ratio(c/b eloss)
86bdcd8c 272 TGraphAsymmErrors * fgSigmaCorr; // Corrected cross-section as TGraphAsymmErrors (syst but feed-down)
273 TGraphAsymmErrors * fgSigmaCorrExtreme; // Extreme corrected cross-section as TGraphAsymmErrors (syst from feed-down)
274 TGraphAsymmErrors * fgSigmaCorrConservative; // Conservative corrected cross-section as TGraphAsymmErrors (syst from feed-down)
4d4e48c7 275 //
276 TNtuple *fnSigma; // Ntuple of the calculation vs the Ratio(c/b eloss)
65e55bbd 277
278 //
279 Int_t fFeedDownOption; // feed-down correction flag: 0=none, 1=fc, 2=Nb
280 Bool_t fAsymUncertainties; // flag: asymmetric uncertainties are (1) or not (0) considered
4d4e48c7 281 Bool_t fPbPbElossHypothesis; // flag: whether to do estimates vs Ratio(c/b eloss) hypothesis
65e55bbd 282
4d4e48c7 283 //
284 TH1D *fhStatUncEffcSigma; // Uncertainty on the cross-section due to the prompt efficiency statistical uncertainty
285 TH1D *fhStatUncEffbSigma; // Uncertainty on the cross-section due to the feed-down efficiency statistical uncertainty
286 TH1D *fhStatUncEffcFD; // Uncertainty on the feed-down correction due to the prompt efficiency statistical uncertainty
287 TH1D *fhStatUncEffbFD; // Uncertainty on the feed-down correction due to the feed-down efficiency statistical uncertainty
65e55bbd 288
4d4e48c7 289 ClassDef(AliHFPtSpectrum,2) // Class for Heavy Flavor spectra corrections
65e55bbd 290};
291
292#endif