hjet mass ana update + bug fix
[u/mrichter/AliRoot.git] / PWGJE / AliFragmentationFunctionCorrections.h
CommitLineData
39e2b057 1// *****************************************************************************
2// * Task for corrections to output from AliAnalysisTaskFragmentationFunctions *
3// ****************************************************************************
4
5#ifndef ALIFRAGMENTATIONFUNCTIONCORRECTIONS_H
6#define ALIFRAGMENTATIONFUNCTIONCORRECTIONS_H
7
8/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
9 * See cxx source for full Copyright notice */
10
11/* $Id$ */
12
13#include "TObject.h"
14
15class ThnSparse;
16
17class AliFragmentationFunctionCorrections : public TObject {
18
19 public:
20
21 //----------------------------------------
22 class AliFragFuncCorrHistos : public TObject
23 {
24
25 public:
26
27 AliFragFuncCorrHistos();
28 AliFragFuncCorrHistos(const AliFragFuncCorrHistos& copy);
29 AliFragFuncCorrHistos& operator=(const AliFragFuncCorrHistos &o);
30 virtual ~AliFragFuncCorrHistos();
31 AliFragFuncCorrHistos(const char* label,Int_t arraySize);
32 void AddCorrHistos(Int_t slice,TH1F* histPt=0,TH1F* histZ=0,TH1F* histXi=0);
33 void ReplaceCorrHistos(Int_t slice,TH1F* histPt=0,TH1F* histZ=0,TH1F* histXi=0);
34
35 TH1F* GetTrackPt(const Int_t slice);
36 TH1F* GetZ(const Int_t slice);
37 TH1F* GetXi(const Int_t slice);
38
39 TString GetLabel() { return fCorrLabel; }
40
41 private:
42
43 Int_t fArraySize;
44
45 TH1F** fh1CorrFFTrackPt; //! corrected FF histos
46 TH1F** fh1CorrFFZ; //! corrected FF histos
47 TH1F** fh1CorrFFXi; //! corrected FF histos
48
49 TString fCorrLabel; //! correction label
50
51 ClassDef(AliFragFuncCorrHistos, 1);
52 };
53
54 AliFragmentationFunctionCorrections();
55 AliFragmentationFunctionCorrections(const AliFragmentationFunctionCorrections &copy);
56 AliFragmentationFunctionCorrections& operator=(const AliFragmentationFunctionCorrections &o);
57 virtual ~AliFragmentationFunctionCorrections();
58
59 virtual void SetDebugLevel(Int_t debug){ fDebug = debug; }
60
61 void DeleteHistoArray(TH1F** hist) const;
62 void DeleteTHnSparseArray(THnSparse** hist) const;
63 TH1F** BookHistoArray();
64 THnSparse** BookTHnSparseArray();
65 void AddCorrectionLevel(const char* label = "");
66 void AddCorrectionLevelBgr(const char* label = "");
67 void AddCorrectionLevelSinglePt(const char* label = "");
68
69 void SetJetPtSlices(Float_t* bins, const Int_t nJetPtSlices);
70
71 void SetHistoBins(const Int_t jetPtSlice, const Int_t sizeBins, Double_t* bins,Int_t type);
72 void SetHistoBins(const Int_t jetPtSlice, const Int_t nBinsLimits, Double_t* binsLimits, Double_t* binsWidth,Int_t type);
80acde99 73 TArrayD* GetHistoBins(const Int_t& jetPtSlice, const Int_t& type);
ce55b926 74
39e2b057 75 void SetHistoBinsSinglePt(const Int_t sizeBins, Double_t* bins);
76 void SetHistoBinsSinglePt(const Int_t nBinsLimits, Double_t* binsLimits, Double_t* binsWidth);
77
78 // set histo bins for inclusive pt spectra
79
80 void NormalizeTH1(TH1* hist, const Float_t nJets);
81 void NormalizeFF();
82 void NormalizeBgr();
83 void ReadRawFF(TString strfile, TString strID, TString strFFID = "RecCuts");
84 void ReadRawFF(TString strfile, TString strdir, TString strlist, TString strFFID);
85 void ReadRawBgr(TString strfile, TString strID, TString strBgrID = "Perp", TString strFFID = "RecCuts");
86 void ReadRawBgr(TString strfile, TString strdir, TString strlist, TString strBgrID, TString strFFID);
87 void ReadRawBgrEmbedding(TString strfile, TString strID, TString strFFID);
88 void ReadRawBgrEmbedding(TString strfile, TString strdir, TString strlist, TString strFFID);
89
90 void WriteOutput(TString strfile, TString strdir = "", Bool_t updateOutfile = kTRUE);
91
92 THnSparse* TH1toSparse(const TH1F* hist, TString strName, TString strTit, const Bool_t fillConst = kFALSE);
93
ce55b926 94 TH1F* Unfold(THnSparse* hnHist, const THnSparse* hnResponse, const THnSparse* hnEff, const Int_t nIter,
95 const Bool_t useCorrelatedErrors = kTRUE, const THnSparse* hnPrior = 0x0);
39e2b057 96
97 void UnfoldHistos(const Int_t nIter, const Bool_t useCorrelatedErrors, const Int_t type);
98
99 void UnfoldPt(const Int_t nIter=5, const Bool_t useCorrelatedErrors=kTRUE);
100 void UnfoldZ(const Int_t nIter=5, const Bool_t useCorrelatedErrors=kTRUE);
101 void UnfoldXi(const Int_t nIter=5, const Bool_t useCorrelatedErrors=kTRUE);
102
103 TH1F* ApplyResponse(const TH1F* hist, THnSparse* hnResponse);
104
105 void ReadEfficiency(TString strfile, TString strdir = "", TString strlist = "");
106 void ReadBgrEfficiency(TString strfile, TString strdir = "", TString strlist = "");
107
108 void EffCorr();
109 void EffCorrBgr();
110
ce55b926 111 void SubtractBgr(Double_t sysErr = 0);
39e2b057 112
113 void WriteSingleTrackEff(TString strInfile, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE, TString strOutDir = "", TString strPostfix = "");
114 void WriteSingleTrackEff(TString strInfile, TString strdir, TString strlist, TString strOutfile, Bool_t updateOutfile = kTRUE, TString strOutDir = "",
115 TString strPostfix = "");
116
117 void WriteSingleTrackSecCorr(TString strInfile, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE, TString strOutDir = "");
118 void WriteSingleTrackSecCorr(TString strInfile, TString strdir, TString strlist, TString strOutfile, Bool_t updateOutfile = kTRUE, TString strOutDir = "");
119
120 void WriteSingleResponse(TString strInfile, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE, TString strOutDir = "");
121 void WriteSingleResponse(TString strInfile, TString strdir, TString strlist, TString strOutfile, Bool_t updateOutfile = kTRUE, TString strOutDir = "");
122
123 void WriteJetTrackEff(TString strInfile, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE);
124 void WriteJetTrackEff(TString strInfile, TString strdir, TString strlist, TString strOutfile, Bool_t updateOutfile = kTRUE);
125
ce55b926 126 void WriteJetSecCorr(TString strInfile, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE, TString strOutDir = "");
37f35567 127 void WriteBgrJetSecCorr(TString strInfile, TString strBgrID, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE,
128 TString strOutDir = "", Double_t scaleFacBgrRec=1);
ce55b926 129
130 void WriteJetSecCorr(TString strInfile, TString strdir, TString strlist, TString strOutfile, Bool_t updateOutfile = kTRUE,
37f35567 131 TString strOutDir = "",Bool_t writeBgr=kFALSE,TString strBgrID="",Double_t scaleFacBgrRec=1);
39e2b057 132
ce55b926 133 void WriteJetResponse(TString strInfile, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE, TString strOutDir = "");
134 void WriteJetResponse(TString strInfile, TString strdir, TString strlist,TString strOutfile, Bool_t updateOutfile, TString strOutDir = "");
39e2b057 135
136 void ReadResponse(TString strfile, TString strdir="", TString strlist="");
137 void ReadPriors(TString strfile,const Int_t type);
138
139 void ProjectSingleResponseMatrix(TString strOutfile, Bool_t updateOutfile, TString strOutDir = "");
140 void ProjectJetResponseMatrices(TString strOutfile);
141
142 void RebinHisto(const Int_t jetPtSlice, const Int_t nBinsLimits, Double_t* binsLimits, Double_t* binsWidth, const Int_t type);
143
633ed180 144 void WriteJetSpecResponse(TString strInfile, TString strdir, TString strlist /*, TString strOutfile*/ );
39e2b057 145
146 void ReadSingleTrackEfficiency(TString strfile, TString strdir="", TString strlist="", TString strname="hSingleTrackEffPt");
147 void ReadSingleTrackResponse(TString strfile, TString strdir="", TString strlist="", TString strname="fhnResponseSinglePt");
148 void ReadSingleTrackSecCorr(TString strfile, TString strdir="", TString strlist="", TString strname="hSingleTrackSecCorrPt");
149 void ReadSingleTrackCorrection(TString strfile, TString strdir, TString strlist, TString strname, const Int_t type);
150
151 void ReadRawPtSpec(TString strInfile, TString strID);
152 void ReadRawPtSpec(TString strfile, TString strdir, TString strlist);
153 void ReadRawPtSpecQATask(TString strfile, TString strdir, TString strlist); // spectra from Martas QA task
154 void EffCorrSinglePt();
155 void UnfoldSinglePt(const Int_t nIter, const Bool_t useCorrelatedErrors);
156 void SecCorrSinglePt();
ce55b926 157 void dNdz2dNdxi();
158
159 void WriteBinShiftCorr(TString strInfile, TString strIDGen, TString strIDRec,
160 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim = kTRUE,
37f35567 161 TString strOutDir = "", Double_t scaleFacBgrRec=1);
ce55b926 162
163 void WriteBgrBinShiftCorr(TString strInfile, TString strBgrID, TString strIDGen, TString strIDRec,
164 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim = kTRUE,
37f35567 165 TString strOutDir = "", Double_t scaleFacBgrRec=1);
ce55b926 166
167 void WriteBinShiftCorr(TString strInfile, TString strdirGen, TString strlistGen,
168 TString strdirRec, TString strlistRec,
169 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim = kTRUE,
37f35567 170 TString strOutDir = "",Bool_t writeBgr = kFALSE, TString strBgrID = "",Double_t scaleFacBgrRec=1);
ce55b926 171
172 void ReadBgrBinShiftCorr(TString strfile, TString strBgrID, TString strdir="", TString strlist="");
173 void ReadBinShiftCorr(TString strfile, TString strdir="", TString strlist="", Bool_t readBgr = kFALSE, TString strBgrID="");
174
175 void ReadFoldingCorr(TString strfile, TString strdir="", TString strlist="");
176
177 void BbBCorr();
178 void BbBCorrBgr();
179
180 void FoldingCorr();
181
182 void ReadBgrJetSecCorr(TString strfile, TString strBgrID, TString strdir="", TString strlist="", Bool_t useScaledStrangeness=kTRUE);
183 void ReadJetSecCorr(TString strfile, TString strdir="", TString strlist="", Bool_t useScaledStrangeness = kTRUE,
184 Bool_t readBgr=kFALSE, TString strBgrID="");
185
186 void JetSecCorr();
187 void JetSecCorrBgr();
188
189
190 void WriteBinShiftCorrSinglePt(TString strInfile, TString strIDGen, TString strIDRec,
191 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, TString strOutDir);
192
193 void WriteBinShiftCorrSinglePt(TString strInfile, TString strdirGen, TString strlistGen,
194 TString strdirRec, TString strlistRec,
195 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, TString strOutDir = "");
196
197 void ReadBinShiftCorrSinglePt(TString strfile, TString strdir = "", TString strlist = "", Bool_t useRecPrim = kTRUE);
198
199 void BbBCorrSinglePt();
39e2b057 200
201
202 enum {kFlagPt=0,kFlagZ,kFlagXi,kFlagSinglePt};
203 enum {kFlagEfficiency=0,kFlagResponse,kFlagSecondaries};
204
205
206 private:
207
208 static const Int_t fgMaxNCorrectionLevels = 10; //! max number of corrections
209
210 Int_t fDebug; //! Debug level
211 Int_t fNJetPtSlices; //! n slices in jet pt
212 TArrayF* fJetPtSlices; //! array to hold slices in jet pt
213
214 TArrayF* fNJets; //! nJets per jet pt slice - non-int e.g. for xsec/nTrials scaled spectra
215 TArrayF* fNJetsBgr; //! nJets bgr per jet pt slice - non-int e.g. for xsec/nTrials scaled spectra
216
217 Int_t fNHistoBinsSinglePt; //! nBins inclusive pt spec histos - leave undefinded to use original binning
218 TArrayD* fHistoBinsSinglePt; //! inclusive pt spec histo bins
219
220 Int_t* fNHistoBinsPt; //! nBins FF histos in each jet pt slice - leave undefinded for any slice to use original binning
221 Int_t* fNHistoBinsZ; //! nBins FF histos in each jet pt slice - leave undefinded for any slice to use original binning
222 Int_t* fNHistoBinsXi; //! nBins FF histos in each jet pt slice - leave undefinded for any slice to use original binning
223
224 TArrayD** fHistoBinsPt; //! FF histo bins
225 TArrayD** fHistoBinsZ; //! FF histo bins
226 TArrayD** fHistoBinsXi; //! FF histo bins
227
228 Int_t fNCorrectionLevels; //! corrections applied: efficiency, secondaries, resolution unfolding, bgr subtraction
229 AliFragFuncCorrHistos** fCorrFF; //! array of fragmentation functions, dimensions: jet pt bins, correction steps
230
231 Int_t fNCorrectionLevelsBgr; //! corrections applied: efficiency, secondaries, resolution unfolding, bgr subtraction
232 AliFragFuncCorrHistos** fCorrBgr; //! array of bgr fragmentation functions, dimensions: jet pt bins, correction steps
233
234 Int_t fNCorrectionLevelsSinglePt; //! corrections applied: efficiency, secondaries, resolution unfolding, bgr subtraction
235 AliFragFuncCorrHistos** fCorrSinglePt; //! array to keep single track pt spectra, 1D in jet pt bins dimension
236
237
39e2b057 238 // eff correction
239 TH1F* fh1EffSinglePt; //! efficiency all tracks
240
241 TH1F** fh1EffPt; //! reconstruction efficiency track pt
242 TH1F** fh1EffZ; //! reconstruction efficiency z
243 TH1F** fh1EffXi; //! reconstruction efficiency xi
244
245 TH1F** fh1EffBgrPt; //! reconstruction efficiency bgr track pt
246 TH1F** fh1EffBgrZ; //! reconstruction efficiency bgr z
247 TH1F** fh1EffBgrXi; //! reconstruction efficiency bgr xi
248
ce55b926 249 // bin-by-bin correction
250 TH1F* fh1BbBCorrSinglePt; //! BbB corr track pt
251
252 TH1F** fh1BbBPt; //! bin-by-bin correction track pt
253 TH1F** fh1BbBZ; //! bin-by-bin correction z
254 TH1F** fh1BbBXi; //! bin-by-bin correction xi
255
256 TH1F** fh1BbBBgrPt; //! bin-by-bin correction UE track pt
257 TH1F** fh1BbBBgrZ; //! bin-by-bin correction UE z
258 TH1F** fh1BbBBgrXi; //! bin-by-bin correction UE xi
259
260 TH1F** fh1FoldingCorrPt; //! corr factor rec/folded
261 TH1F** fh1FoldingCorrZ; //! corr factor rec/folded
262 TH1F** fh1FoldingCorrXi; //! corr factor rec/folded
263
264
265 // secondaries correction
266 TH1F** fh1SecCorrPt; //! secondaries correction track pt
267 TH1F** fh1SecCorrZ; //! secondaries correction z
268 TH1F** fh1SecCorrXi; //! secondaries correction xi
269
270 TH1F** fh1SecCorrBgrPt; //! secondaries correction track pt
271 TH1F** fh1SecCorrBgrZ; //! secondaries correction z
272 TH1F** fh1SecCorrBgrXi; //! reconstruction efficiency xi
39e2b057 273
274 // unfolding
275
276 TH1F** fh1FFTrackPtBackFolded; //! FF: track pt backfolded (unfolded + smeared with response matrix)
277 TH1F** fh1FFZBackFolded; //! FF: track z, backfolded (unfolded + smeared with response matrix)
278 TH1F** fh1FFXiBackFolded; //! FF: track xi,backfolded (unfolded + smeared with response matrix)
279
280 TH1F** fh1FFRatioTrackPtFolded; //! ratio FF: track pt unfolded / original
281 TH1F** fh1FFRatioZFolded; //! ratio FF: track z unfolded / original
282 TH1F** fh1FFRatioXiFolded; //! ratio FF: track xi unfolded / original
283
284 TH1F** fh1FFRatioTrackPtBackFolded; //! ratio FF: track pt backfolded / original
285 TH1F** fh1FFRatioZBackFolded; //! ratio FF: track z backfolded / original
286 TH1F** fh1FFRatioXiBackFolded; //! ratio FF: track xi backfolded / original
287
288 TH1F* fh1SingleTrackPtBackFolded; //! inclusive track pt backfolded (unfolded + smeared with response matrix)
289 TH1F* fh1RatioSingleTrackPtFolded; //! ratio inclusive track pt unfolded / original
290 TH1F* fh1RatioSingleTrackPtBackFolded; //! ratio inblusive track pt backfolded / original
291
292 THnSparse* fhnResponseSinglePt; //! response matrix pt gen vs rec all tracks
293 THnSparse** fhnResponsePt; //! response matrix pt gen vs rec
294 THnSparse** fhnResponseZ; //! response matrix z gen vs rec
295 THnSparse** fhnResponseXi; //! response matrix xi gen vs rec
296
297 TH1F** fh1FFTrackPtPrior; //! FF: track pt prior
298 TH1F** fh1FFZPrior; //! FF: track z prior
299 TH1F** fh1FFXiPrior; //! FF: track xi prior
300
ce55b926 301
39e2b057 302 // secondaries
303 TH1F* fh1SecCorrSinglePt; //! secondaries correction all tracks
39e2b057 304
305
306 ClassDef(AliFragmentationFunctionCorrections, 1);
307};
308
309#endif