]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/AliHFEspectrum.h
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEspectrum.h
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15 //
16 // Class for spectrum correction
17 // Subtraction of hadronic background, Unfolding of the data and
18 // Renormalization done here
19 // For more information see the implementation file
20 //
21 #ifndef ALIHFESPECTRUM_H
22 #define ALIHFESPECTRUM_H
23
24 #ifndef ROOT_TNamed
25 #include <TNamed.h>
26 #endif
27
28 class TGraphErrors;
29 class TObject;
30 class TH1;
31 class TF1;
32 class TList;
33 class TObjArray;
34 class AliCFContainer;
35 class AliHFEcontainer;
36 class AliCFDataGrid;
37 class AliCFEffGrid;
38
39 class AliHFEspectrum : public TNamed{
40   public:
41     enum CFContainer_t{
42       kDataContainer  = 0,
43       kBackgroundData = 1,
44       kMCContainerMC = 2,
45       kMCContainerESD = 3,
46       kMCContainerCharmMC = 4,
47       kMCWeightedContainerNonHFEESD =5,
48       kMCWeightedContainerConversionESD = 6,
49       kDataContainerV0 = 7
50     };
51
52     enum{
53       kElecBgSources = 6,
54       kBgLevels = 3,
55       kBgPtBins = 44,
56       kCentrality = 12
57         };
58
59    enum Chargetype_t{
60      kNegCharge = -1,
61      kPosCharge = 1,
62      kAllCharge = 0
63    };
64    
65     AliHFEspectrum(const char* name);
66     ~AliHFEspectrum();
67     
68
69     Bool_t Init(const AliHFEcontainer *datahfecontainer, const AliHFEcontainer *mchfecontainer, const AliHFEcontainer *v0hfecontainer=0x0, const AliHFEcontainer *bghfecontainer=0x0);
70     Bool_t Correct(Bool_t subtractcontamination=kTRUE);
71     Bool_t CorrectBeauty(Bool_t subtractcontamination=kTRUE);
72    
73     AliCFDataGrid *SubtractBackground(Bool_t setBackground = kFALSE);
74     
75     AliCFDataGrid *CorrectV0Efficiency(AliCFDataGrid* const bgsubpectrum = 0x0);
76     AliCFDataGrid *CorrectParametrizedEfficiency(AliCFDataGrid* const bgsubpectrum = 0x0);
77    
78     TList *Unfold(AliCFDataGrid* const bgsubpectrum = 0x0);
79     void UnfoldBG(AliCFDataGrid* const bgsubpectrum);
80     AliCFDataGrid *CorrectForEfficiency(AliCFDataGrid* const bgsubpectrum = 0x0);
81    
82     TGraphErrors *Normalize(THnSparse * const spectrum,Int_t i = 0) const;
83     TGraphErrors *Normalize(AliCFDataGrid * const spectrum,Int_t i = 0) const;
84     TGraphErrors *NormalizeTH1N(TH1 *input,Int_t normalization) const;
85     void CorrectFromTheWidth(TH1D *h1) const;
86     void CorrectStatErr(AliCFDataGrid *backgroundGrid) const;
87     
88     void SetCorrelation(THnSparseF * const correlation) {fCorrelation = correlation; };
89     void SetContainer(AliCFContainer *cont, AliHFEspectrum::CFContainer_t type);
90     void SetEfficiencyFunction(TF1 *efficiencyFunction) { fEfficiencyFunction = efficiencyFunction; };
91     void SetPbPbAnalysis(Bool_t isPbPb = kFALSE) { fBeamType=(Char_t) isPbPb; };
92     void SetEtaSyst(Bool_t etaSyst = kTRUE) { fEtaSyst = etaSyst; };
93
94     void SetParameterizedEff(AliCFContainer *container, AliCFContainer *containermb, AliCFContainer *containeresd, AliCFContainer *containeresdmb, Int_t *dimensions);
95     
96     void SetNumberOfEvents(Int_t nEvents,Int_t i = 0) { fNEvents[i] = nEvents; };
97     void SetNumberOfMCEvents(Int_t nEvents) { fNMCEvents = nEvents; };
98     void SetNumberOfMC2Events(Int_t nEvents,Int_t i = 0) { fNMCbgEvents[i] = nEvents; };
99     void SetMCEffStep(Int_t step) { fStepMC = step; };
100     void SetMCTruthStep(Int_t step) { fStepTrue = step; };
101     void SetStepToCorrect(Int_t step) { fStepData = step; };
102     void SetStepBeforeCutsV0(Int_t step) { fStepBeforeCutsV0 = step; };
103     void SetStepAfterCutsV0(Int_t step) { fStepAfterCutsV0 = step; };
104     void SetNbDimensions(Int_t nbDimensions) { fNbDimensions = nbDimensions; };
105     void SetChargeChoosen(Chargetype_t chargechoosen) {fChargeChoosen = chargechoosen; };
106     void SetEtaRange(Double_t etamin, Double_t etamax) { fEtaRange[0] = etamin; fEtaRange[1] = etamax; fEtaSelected = kTRUE; }
107     void SetUnSetCorrelatedErrors(Bool_t unsetcorrelatederrors) {fUnSetCorrelatedErrors = unsetcorrelatederrors;};
108     void SetSmoothing(Bool_t setSmoothing) {fSetSmoothing = setSmoothing;};
109     void SetTestOneBinCentrality(Double_t centralitymin, Double_t centralitymax) { fTestCentralityLow = centralitymin; fTestCentralityHigh = centralitymax;}
110     void SetFillMoreCorrelationMatrix(Bool_t fillMoreCorrelationMatrix) { fFillMoreCorrelationMatrix = fillMoreCorrelationMatrix;}
111
112     void SetNCentralityBinAtTheEnd(Int_t nCentralityBinAtTheEnd) {fNCentralityBinAtTheEnd = nCentralityBinAtTheEnd; };
113     void SetLowHighBoundaryCentralityBinAtTheEnd(Int_t low, Int_t high, Int_t i) { fLowBoundaryCentralityBinAtTheEnd[i] = low; fHighBoundaryCentralityBinAtTheEnd[i] = high;};
114
115     void SetBeautyAnalysis() { fInclusiveSpectrum = kFALSE; };
116     void CallInputFileForBeauty2ndMethod();
117     void SetInputFileForBeauty2ndMethod(const char *filenameb = "BSpectrum2ndmethod.root"){fkBeauty2ndMethodfilename = filenameb; };
118     void SetBeautyAnalysis2ndMethod(Bool_t beauty2ndmethod) { fBeauty2ndMethod = beauty2ndmethod; }
119     void SetIPEffCombinedSamples(Bool_t ipEffCombinedSamples) { fIPEffCombinedSamples = ipEffCombinedSamples; }
120     void SetHadronEffbyIPcut(THnSparseF* hsHadronEffbyIPcut) { fHadronEffbyIPcut = hsHadronEffbyIPcut;};
121     void SetNonHFEsyst(Bool_t syst){ fNonHFEsyst = syst; };
122
123     void SetStepGuessedUnfolding(Int_t stepGuessedUnfolding) { fStepGuessedUnfolding = stepGuessedUnfolding; };
124     void SetNumberOfIteration(Int_t numberOfIteration) { fNumberOfIterations = numberOfIteration; };
125     void SetUnfoldingRandomIterations(Int_t niter) { fNRandomIter = niter; }
126     
127     void SetDumpToFile(Bool_t dumpToFile) { fDumpToFile=dumpToFile; }; 
128   
129     void SetDebugLevel(Int_t debugLevel, Bool_t writeToFile = kFALSE) { fDebugLevel = debugLevel; fWriteToFile = writeToFile; };
130     void SetUnfoldBG() { fUnfoldBG = kTRUE; };
131
132
133     AliCFDataGrid* GetRawBspectra2ndMethod();
134     AliCFDataGrid* GetCharmBackground();
135     AliCFDataGrid* GetConversionBackground();
136     AliCFDataGrid* GetNonHFEBackground();
137     THnSparse* GetCharmWeights();
138     THnSparse* GetBeautyIPEff(Bool_t isMCpt);
139     THnSparse* GetPIDxIPEff(Int_t source);
140     void CalculateNonHFEsyst(Int_t centrality = 0);
141
142     void EnableIPanaHadronBgSubtract() { fIPanaHadronBgSubtract = kTRUE; };
143     void EnableIPanaCharmBgSubtract() { fIPanaCharmBgSubtract = kTRUE; };
144     void EnableIPanaConversionBgSubtract() { fIPanaConversionBgSubtract = kTRUE; };
145     void EnableIPanaNonHFEBgSubtract() { fIPanaNonHFEBgSubtract = kTRUE; };
146     void EnableIPParameterizedEff() { fIPParameterizedEff = kTRUE; };
147
148   protected:
149        
150     AliCFContainer *GetContainer(AliHFEspectrum::CFContainer_t contt);
151     AliCFContainer *GetSlicedContainer(AliCFContainer *cont, Int_t ndim, Int_t *dimensions,Int_t source=-1,Chargetype_t charge=kAllCharge,Int_t centralitylow=-1, Int_t centralityhigh=-1);
152     THnSparseF *GetSlicedCorrelation(THnSparseF *correlationmatrix,Int_t nDim, Int_t *dimensions,Int_t centralitylow=-1, Int_t centralityhigh=-1) const;
153     TObject* GetSpectrum(const AliCFContainer * const c, Int_t step);
154     TObject* GetEfficiency(const AliCFContainer * const c, Int_t step, Int_t step0);
155  
156     void AddTemporaryObject(TObject *cont);
157     void ClearObject(TObject *o);
158     
159     TGraphErrors *NormalizeTH1(TH1 *input,Int_t i = 0) const;
160
161
162   private:
163     AliHFEspectrum(const AliHFEspectrum &);
164     AliHFEspectrum &operator=(const AliHFEspectrum &);
165  
166     TObjArray *fCFContainers;     // List of Correction Framework Containers
167     TList *fTemporaryObjects;     // Emulate garbage collection
168     THnSparseF *fCorrelation;     // Correlation Matrices
169     AliCFDataGrid *fBackground;   // Background Grid
170     TF1 *fEfficiencyFunction;     // Efficiency Function
171     TF1 *fEfficiencyTOFPIDD[kCentrality];       // TOF PID efficiency parameterized
172     TF1 *fEfficiencyesdTOFPIDD[kCentrality];    // TOF PID efficiency parameterized
173     TF1 *fEfficiencyIPCharmD[kCentrality];      // IP efficiency parameterized for charm
174     TF1 *fEfficiencyIPBeautyD[kCentrality];     // IP efficiency parameterized for beauty 
175     TF1 *fEfficiencyIPBeautyesdD[kCentrality];  // IP efficiency parameterized for beauty for esd
176     TF1 *fEfficiencyIPConversionD[kCentrality]; // IP efficiency parameterized for conversion
177     TF1 *fEfficiencyIPNonhfeD[kCentrality];     // IP efficiency parameterized for nonhfe 
178
179     THnSparseF *fWeightCharm;     // Weight for charm bg
180
181     AliCFContainer *fConvSourceContainer[kElecBgSources][kBgLevels][kCentrality]; //container for conversion electrons, divided into different photon sources
182     AliCFContainer *fNonHFESourceContainer[kElecBgSources][kBgLevels][kCentrality]; //container for non-HF electrons, divided into different sources
183
184     Bool_t fInclusiveSpectrum;     // Inclusive Spectrum
185     Bool_t fDumpToFile;           // Write Result in a file
186
187     Bool_t fEtaSelected;              // Switch for eta selection
188     Bool_t fUnSetCorrelatedErrors;    // Unset correlated errors
189     Bool_t fSetSmoothing;             // Set smoothing
190
191     Bool_t fIPanaHadronBgSubtract;     // Hadron background subtraction
192     Bool_t fIPanaCharmBgSubtract;      // Charm background subtraction 
193     Bool_t fIPanaConversionBgSubtract; // Conversion background subtraction
194     Bool_t fIPanaNonHFEBgSubtract;     // nonHFE except for conversion background subtraction
195     Bool_t fIPParameterizedEff;        // switch to use parameterized efficiency for ip analysis
196     Bool_t fNonHFEsyst;            // choose NonHFE background level (upper, lower, central)
197     Bool_t fBeauty2ndMethod;      // 2nd method to get beauty spectrum
198     Bool_t fIPEffCombinedSamples; // flag to combine two different samples
199
200     Int_t fNbDimensions;          // Number of dimensions for the correction
201     Int_t fNEvents[20];           // Number of Events
202     Int_t fNMCEvents;             // Number of MC Events
203     Int_t fNMCbgEvents[20];       // Number of BG MC Events
204     Int_t fStepMC;                // MC step (for unfolding)
205     Int_t fStepTrue;              // MC step of the final spectrum
206     Int_t fStepData;              // Data Step (various applications)
207     Int_t fStepBeforeCutsV0;      // Before cuts V0
208     Int_t fStepAfterCutsV0;       // After cuts V0
209     Int_t fStepGuessedUnfolding;  // Step for first guessed unfolding
210     Int_t fNumberOfIterations;    // Number of iterations
211     Int_t fNRandomIter;           // Number of random iterations
212     Chargetype_t fChargeChoosen;         // Select positive or negative electrons
213
214     Double_t fEtaRange[2];        // Eta range 
215     Double_t fEtaRangeNorm[2];    // Eta range used in the normalization
216
217     Int_t fNCentralityBinAtTheEnd;// Number of centrality class at the end
218     Int_t fLowBoundaryCentralityBinAtTheEnd[20];  // Boundary of the bins
219     Int_t fHighBoundaryCentralityBinAtTheEnd[20];  // Boundary of the bins
220     Int_t fTestCentralityLow;                      // To test one bin in centrality only
221     Int_t fTestCentralityHigh;                     // To test one bin in centrality only
222     Bool_t fFillMoreCorrelationMatrix;             // For low stats to have reasonable errors
223
224     THnSparseF *fHadronEffbyIPcut;// container for hadron efficiency by IP cut
225     TH1D *fEfficiencyCharmSigD[kCentrality]; // charm IP cut eff from signal enhanced MC
226     TH1D *fEfficiencyBeautySigD[kCentrality]; // beauty IP cut eff from signal enhanced MC
227     TH1D *fEfficiencyBeautySigesdD[kCentrality]; // beauty IP cut eff from signal enhanced MC for esd
228     TH1D *fConversionEff[kCentrality];     // conversion IP cut eff
229     TH1D *fNonHFEEff[kCentrality];         // nonhfe IP cut eff
230     TH1D *fCharmEff[kCentrality];          // charm IP cut eff
231     TH1D *fBeautyEff[kCentrality];         // beauty IP cut eff
232     TH1D *fConversionEffbgc;      // conversion IP cut eff
233     TH1D *fNonHFEEffbgc;          // nonhfe IP cut eff
234     TH1D *fBSpectrum2ndMethod;             // beauty spectrum for 2nd method
235     const char *fkBeauty2ndMethodfilename;      // name of file, which contains beauty spectrum for 2ndmethod
236     Char_t fBeamType;             // beamtype; default -1; pp =0; PbPb=1
237     Bool_t fEtaSyst;              // pp 2.76 TeV (= kTRUE) or 7 TeV (= kFALSE)
238
239
240     Int_t fDebugLevel;            // Debug Level
241     Bool_t fWriteToFile;           // Write plots to eps files
242     Bool_t fUnfoldBG;             // flag to unfold backgroud
243
244     ClassDef(AliHFEspectrum, 1) 
245 };
246 #endif
247