]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/vertexingHF/AliHFPtSpectrum.h
Fixed memory leak (Renu)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliHFPtSpectrum.h
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
7 //***********************************************************************
8 // Class AliHFPtSpectrum
9 // Base class for feed-down corrections on heavy-flavour decays
10 // computes the cross-section via one of the three implemented methods:
11 //   0) Consider no feed-down prediction 
12 //   1) Subtract the feed-down with the "fc" method 
13 //       Yield = Reco * fc;  where fc = 1 / ( 1 + (eff_b/eff_c)*(N_b/N_c) ) ;
14 //   2) Subtract the feed-down with the "Nb" method
15 //       Yield = Reco - Feed-down (exact formula on the function implementation)
16 //
17 // Author: Z.Conesa, zconesa@in2p3.fr
18 //***********************************************************************
19
20 #include "TNamed.h"
21 #include "TH1.h"
22 #include "TGraphAsymmErrors.h"
23
24 class AliHFPtSpectrum: public TNamed
25 {
26
27  public:
28   
29   // Constructor
30   AliHFPtSpectrum(const char* name="AliHFPtSpectrum", const char* title="HF feed down correction class", Int_t option=1);
31   // Copy constructor
32   AliHFPtSpectrum(const AliHFPtSpectrum &rhs);
33   // Assignment operator
34   AliHFPtSpectrum& operator=(const AliHFPtSpectrum &source);
35   // Destructor
36   virtual ~AliHFPtSpectrum();
37
38   //
39   // Setters
40   //
41   // Set the theoretical direct & feeddown pt spectrum
42   void SetMCptSpectra(TH1 *hDirect, TH1 *hFeedDown);
43   // Set the theoretical feeddown pt spectrum
44   void SetFeedDownMCptSpectra(TH1 *hFeedDown);
45   // Set the theoretical direct & feeddown pt spectrum upper and lower bounds
46   void SetMCptDistributionsBounds(TH1 *hDirectMax, TH1 *hDirectMin, TH1 *hFeedDownMax, TH1 *hFeedDownMin);
47   // Set the theoretical feeddown pt spectrum upper and lower bounds
48   void SetFeedDownMCptDistributionsBounds(TH1 *hFeedDownMax, TH1 *hFeedDownMin);
49   // Set the acceptance and efficiency corrections for direct  
50   void SetDirectAccEffCorrection(TH1 *hDirectEff);
51   // Set the acceptance and efficiency corrections for direct & feeddown 
52   void SetAccEffCorrection(TH1 *hDirectEff, TH1 *hFeedDownEff);
53   // Set the reconstructed spectrum
54   void SetReconstructedSpectrum(TH1 *hRec);
55   // Set the calculation option flag for feed-down correction: 0=none, 1=fc , 2=Nb 
56   void SetFeedDownCalculationOption(Int_t option){ fFeedDownOption = option; }
57   // Set if the calculation has to consider asymmetric uncertaInt_ties or not
58   void SetComputeAsymmetricUncertainties(Bool_t flag){ fAsymUncertainties = flag; }
59   // Set the luminosity and its uncertainty
60   void SetLuminosity(Double_t luminosity, Double_t unc){
61     fLuminosity[0]=luminosity;  fLuminosity[1]=unc;
62   }
63   // Set the trigger efficiency and its uncertainty
64   void SetTriggerEfficiency(Double_t efficiency, Double_t unc){
65     fTrigEfficiency[0]=efficiency; fTrigEfficiency[1]=unc;
66   }
67
68   //
69   // Getters
70   //
71   // Return the TGraphAsymmErrors of the feed-down correction
72   TGraphAsymmErrors * GetFeedDownCorrectionFc() { return (fgFc ?  fgFc : NULL); }
73   // Return the histogram of the feed-down correction
74   TH1 * GetHistoFeedDownCorrectionFc() { return (fhFc ?  fhFc : NULL); }
75   // Return the histograms of the feed-down correction bounds
76   TH1 * GetHistoUpperLimitFeedDownCorrectionFc() { return (fhFcMax ? fhFcMax : NULL); }
77   TH1 * GetHistoLowerLimitFeedDownCorrectionFc() { return (fhFcMin ? fhFcMin : NULL); }
78   // Return the TGraphAsymmErrors of the yield after feed-down correction 
79   TGraphAsymmErrors * GetFeedDownCorrectedSpectrum() { return (fgYieldCorr ? fgYieldCorr : NULL); }
80   // Return the histogram of the yield after feed-down correction 
81   TH1 * GetHistoFeedDownCorrectedSpectrum() { return (fhYieldCorr ? fhYieldCorr : NULL); }
82   // Return the histogram of the yield after feed-down correction bounds
83   TH1 * GetHistoUpperLimitFeedDownCorrectedSpectrum() { return (fhYieldCorrMax ? fhYieldCorrMax : NULL); }
84   TH1 * GetHistoLowerLimitFeedDownCorrectedSpectrum() { return (fhYieldCorrMin ? fhYieldCorrMin : NULL); }
85   // Return the equivalent invariant cross-section TGraphAsymmErrors
86   TGraphAsymmErrors * GetCrossSectionFromYieldSpectrum() { return (fgSigmaCorr ? fgSigmaCorr : NULL); }
87   // Return the equivalent invariant cross-section histogram
88   TH1 * GetHistoCrossSectionFromYieldSpectrum() { return (fhSigmaCorr ? fhSigmaCorr : NULL); }
89   // Return the equivalent invariant cross-section histogram bounds
90   TH1 * GetHistoUpperLimitCrossSectionFromYieldSpectrum() { return (fhSigmaCorrMax ? fhSigmaCorrMax : NULL); }
91   TH1 * GetHistoLowerLimitCrossSectionFromYieldSpectrum() { return (fhSigmaCorrMin ? fhSigmaCorrMin : NULL); }
92
93   //
94   // Main function:
95   //    Compute the invariant cross-section from the yield (correct it)
96   // variables : analysed delta_y, BR for the final correction, BR b --> decay (relative to the input theoretical prediction)
97   void ComputeHFPtSpectrum(Double_t deltaY=1.0, Double_t branchingRatioC=1.0, Double_t branchingRatioBintoFinalDecay=1.0);
98
99   //
100   // Functions to  reweight histograms for testing purposes: 
101   //   to reweight the simulation: hToReweight is reweighted as hReference/hToReweight
102   TH1 * ReweightHisto(TH1 *hToReweight, TH1 *hReference);
103   //   to reweight the reco-histos: hRecToReweight is reweighted as hReference/hMCToReweight
104   TH1 * ReweightRecHisto(TH1 *hRecToReweight, TH1 *hMCToReweight, TH1 *hMCReference);
105
106
107  protected:
108
109   // Initialization 
110   Bool_t Initialize();
111   
112   // Basic functions
113   //
114   // Compute the feed-down correction via fc-method
115   void CalculateFeedDownCorrectionFc(); 
116   // Correct the yield for feed-down correction via fc-method
117   void CalculateFeedDownCorrectedSpectrumFc(); 
118   // Correct the yield for feed-down correction via Nb-method
119   void CalculateFeedDownCorrectedSpectrumNb(Double_t deltaY, Double_t branchingRatioBintoFinalDecay); 
120
121   // Check histograms consistency function
122   Bool_t CheckHistosConsistency(TH1 *h1, TH1 *h2);
123
124   //
125   // Input spectra
126   //
127   TH1 *fhDirectMCpt;            // Input MC c-->D spectra
128   TH1 *fhFeedDownMCpt;          // Input MC b-->D spectra
129   TH1 *fhDirectMCptMax;         // Input MC maximum c-->D spectra
130   TH1 *fhDirectMCptMin;         // Input MC minimum c-->D spectra
131   TH1 *fhFeedDownMCptMax;       // Input MC maximum b-->D spectra
132   TH1 *fhFeedDownMCptMin;       // Input MC minimum b-->D spectra
133   TH1 *fhDirectEffpt;           // c-->D Acceptance and efficiency correction
134   TH1 *fhFeedDownEffpt;         // b-->D Acceptance and efficiency correction
135   TH1 *fhRECpt;                 // all reconstructed D
136   //
137   // Normalization factors
138   Double_t fLuminosity[2];           // analyzed luminosity & uncertainty
139   Double_t fTrigEfficiency[2];       // trigger efficiency & uncertainty
140
141   //
142   // Output spectra
143   //
144   TH1 *fhFc;                            // Correction histo fc = 1 / ( 1 + (eff_b/eff_c)*(N_b/N_c) ) 
145   TH1 *fhFcMax;                         // Maximum fc histo
146   TH1 *fhFcMin;                         // Minimum fc histo
147   TGraphAsymmErrors * fgFc;             // Correction as TGraphAsymmErrors
148   TH1 *fhYieldCorr;                     // Corrected yield  
149   TH1 *fhYieldCorrMax;                  // Maximum corrected yield  
150   TH1 *fhYieldCorrMin;                  // Minimum corrected yield  
151   TGraphAsymmErrors * fgYieldCorr;      // Corrected yield as TGraphAsymmErrors
152   TH1 *fhSigmaCorr;                     // Corrected cross-section  
153   TH1 *fhSigmaCorrMax;                  // Maximum corrected cross-section  
154   TH1 *fhSigmaCorrMin;                  // Minimum corrected cross-section
155   TGraphAsymmErrors * fgSigmaCorr;      // Corrected cross-section as TGraphAsymmErrors
156
157   //
158   Int_t fFeedDownOption;            // feed-down correction flag: 0=none, 1=fc, 2=Nb 
159   Bool_t fAsymUncertainties;        // flag: asymmetric uncertainties are (1) or not (0) considered
160
161
162   ClassDef(AliHFPtSpectrum,1) // Class for Heavy Flavor spectra corrections
163 };
164
165 #endif