coverity 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);
ce55b926 73 TArrayD* GetHistoBins(const Int_t jetPtSlice, const Int_t type);
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 = "");
127 void WriteBgrJetSecCorr(TString strInfile, TString strBgrID, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE, TString strOutDir = "");
128
129 void WriteJetSecCorr(TString strInfile, TString strdir, TString strlist, TString strOutfile, Bool_t updateOutfile = kTRUE,
130 TString strOutDir = "",Bool_t writeBgr=kFALSE,TString strBgrID="");
39e2b057 131
ce55b926 132 void WriteJetResponse(TString strInfile, TString strID, TString strOutfile,Bool_t updateOutfile = kTRUE, TString strOutDir = "");
133 void WriteJetResponse(TString strInfile, TString strdir, TString strlist,TString strOutfile, Bool_t updateOutfile, TString strOutDir = "");
39e2b057 134
135 void ReadResponse(TString strfile, TString strdir="", TString strlist="");
136 void ReadPriors(TString strfile,const Int_t type);
137
138 void ProjectSingleResponseMatrix(TString strOutfile, Bool_t updateOutfile, TString strOutDir = "");
139 void ProjectJetResponseMatrices(TString strOutfile);
140
141 void RebinHisto(const Int_t jetPtSlice, const Int_t nBinsLimits, Double_t* binsLimits, Double_t* binsWidth, const Int_t type);
142
633ed180 143 void WriteJetSpecResponse(TString strInfile, TString strdir, TString strlist /*, TString strOutfile*/ );
39e2b057 144
145 void ReadSingleTrackEfficiency(TString strfile, TString strdir="", TString strlist="", TString strname="hSingleTrackEffPt");
146 void ReadSingleTrackResponse(TString strfile, TString strdir="", TString strlist="", TString strname="fhnResponseSinglePt");
147 void ReadSingleTrackSecCorr(TString strfile, TString strdir="", TString strlist="", TString strname="hSingleTrackSecCorrPt");
148 void ReadSingleTrackCorrection(TString strfile, TString strdir, TString strlist, TString strname, const Int_t type);
149
150 void ReadRawPtSpec(TString strInfile, TString strID);
151 void ReadRawPtSpec(TString strfile, TString strdir, TString strlist);
152 void ReadRawPtSpecQATask(TString strfile, TString strdir, TString strlist); // spectra from Martas QA task
153 void EffCorrSinglePt();
154 void UnfoldSinglePt(const Int_t nIter, const Bool_t useCorrelatedErrors);
155 void SecCorrSinglePt();
ce55b926 156 void dNdz2dNdxi();
157
158 void WriteBinShiftCorr(TString strInfile, TString strIDGen, TString strIDRec,
159 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim = kTRUE,
160 TString strOutDir = "");
161
162 void WriteBgrBinShiftCorr(TString strInfile, TString strBgrID, TString strIDGen, TString strIDRec,
163 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim = kTRUE,
164 TString strOutDir = "");
165
166 void WriteBinShiftCorr(TString strInfile, TString strdirGen, TString strlistGen,
167 TString strdirRec, TString strlistRec,
168 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim = kTRUE,
169 TString strOutDir = "",Bool_t writeBgr = kFALSE, TString strBgrID = "");
170
171 void ReadBgrBinShiftCorr(TString strfile, TString strBgrID, TString strdir="", TString strlist="");
172 void ReadBinShiftCorr(TString strfile, TString strdir="", TString strlist="", Bool_t readBgr = kFALSE, TString strBgrID="");
173
174 void ReadFoldingCorr(TString strfile, TString strdir="", TString strlist="");
175
176 void BbBCorr();
177 void BbBCorrBgr();
178
179 void FoldingCorr();
180
181 void ReadBgrJetSecCorr(TString strfile, TString strBgrID, TString strdir="", TString strlist="", Bool_t useScaledStrangeness=kTRUE);
182 void ReadJetSecCorr(TString strfile, TString strdir="", TString strlist="", Bool_t useScaledStrangeness = kTRUE,
183 Bool_t readBgr=kFALSE, TString strBgrID="");
184
185 void JetSecCorr();
186 void JetSecCorrBgr();
187
188
189 void WriteBinShiftCorrSinglePt(TString strInfile, TString strIDGen, TString strIDRec,
190 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, TString strOutDir);
191
192 void WriteBinShiftCorrSinglePt(TString strInfile, TString strdirGen, TString strlistGen,
193 TString strdirRec, TString strlistRec,
194 TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, TString strOutDir = "");
195
196 void ReadBinShiftCorrSinglePt(TString strfile, TString strdir = "", TString strlist = "", Bool_t useRecPrim = kTRUE);
197
198 void BbBCorrSinglePt();
39e2b057 199
200
201 enum {kFlagPt=0,kFlagZ,kFlagXi,kFlagSinglePt};
202 enum {kFlagEfficiency=0,kFlagResponse,kFlagSecondaries};
203
204
205 private:
206
207 static const Int_t fgMaxNCorrectionLevels = 10; //! max number of corrections
208
209 Int_t fDebug; //! Debug level
210 Int_t fNJetPtSlices; //! n slices in jet pt
211 TArrayF* fJetPtSlices; //! array to hold slices in jet pt
212
213 TArrayF* fNJets; //! nJets per jet pt slice - non-int e.g. for xsec/nTrials scaled spectra
214 TArrayF* fNJetsBgr; //! nJets bgr per jet pt slice - non-int e.g. for xsec/nTrials scaled spectra
215
216 Int_t fNHistoBinsSinglePt; //! nBins inclusive pt spec histos - leave undefinded to use original binning
217 TArrayD* fHistoBinsSinglePt; //! inclusive pt spec histo bins
218
219 Int_t* fNHistoBinsPt; //! nBins FF histos in each jet pt slice - leave undefinded for any slice to use original binning
220 Int_t* fNHistoBinsZ; //! nBins FF histos in each jet pt slice - leave undefinded for any slice to use original binning
221 Int_t* fNHistoBinsXi; //! nBins FF histos in each jet pt slice - leave undefinded for any slice to use original binning
222
223 TArrayD** fHistoBinsPt; //! FF histo bins
224 TArrayD** fHistoBinsZ; //! FF histo bins
225 TArrayD** fHistoBinsXi; //! FF histo bins
226
227 Int_t fNCorrectionLevels; //! corrections applied: efficiency, secondaries, resolution unfolding, bgr subtraction
228 AliFragFuncCorrHistos** fCorrFF; //! array of fragmentation functions, dimensions: jet pt bins, correction steps
229
230 Int_t fNCorrectionLevelsBgr; //! corrections applied: efficiency, secondaries, resolution unfolding, bgr subtraction
231 AliFragFuncCorrHistos** fCorrBgr; //! array of bgr fragmentation functions, dimensions: jet pt bins, correction steps
232
233 Int_t fNCorrectionLevelsSinglePt; //! corrections applied: efficiency, secondaries, resolution unfolding, bgr subtraction
234 AliFragFuncCorrHistos** fCorrSinglePt; //! array to keep single track pt spectra, 1D in jet pt bins dimension
235
236
39e2b057 237 // eff correction
238 TH1F* fh1EffSinglePt; //! efficiency all tracks
239
240 TH1F** fh1EffPt; //! reconstruction efficiency track pt
241 TH1F** fh1EffZ; //! reconstruction efficiency z
242 TH1F** fh1EffXi; //! reconstruction efficiency xi
243
244 TH1F** fh1EffBgrPt; //! reconstruction efficiency bgr track pt
245 TH1F** fh1EffBgrZ; //! reconstruction efficiency bgr z
246 TH1F** fh1EffBgrXi; //! reconstruction efficiency bgr xi
247
ce55b926 248 // bin-by-bin correction
249 TH1F* fh1BbBCorrSinglePt; //! BbB corr track pt
250
251 TH1F** fh1BbBPt; //! bin-by-bin correction track pt
252 TH1F** fh1BbBZ; //! bin-by-bin correction z
253 TH1F** fh1BbBXi; //! bin-by-bin correction xi
254
255 TH1F** fh1BbBBgrPt; //! bin-by-bin correction UE track pt
256 TH1F** fh1BbBBgrZ; //! bin-by-bin correction UE z
257 TH1F** fh1BbBBgrXi; //! bin-by-bin correction UE xi
258
259 TH1F** fh1FoldingCorrPt; //! corr factor rec/folded
260 TH1F** fh1FoldingCorrZ; //! corr factor rec/folded
261 TH1F** fh1FoldingCorrXi; //! corr factor rec/folded
262
263
264 // secondaries correction
265 TH1F** fh1SecCorrPt; //! secondaries correction track pt
266 TH1F** fh1SecCorrZ; //! secondaries correction z
267 TH1F** fh1SecCorrXi; //! secondaries correction xi
268
269 TH1F** fh1SecCorrBgrPt; //! secondaries correction track pt
270 TH1F** fh1SecCorrBgrZ; //! secondaries correction z
271 TH1F** fh1SecCorrBgrXi; //! reconstruction efficiency xi
39e2b057 272
273 // unfolding
274
275 TH1F** fh1FFTrackPtBackFolded; //! FF: track pt backfolded (unfolded + smeared with response matrix)
276 TH1F** fh1FFZBackFolded; //! FF: track z, backfolded (unfolded + smeared with response matrix)
277 TH1F** fh1FFXiBackFolded; //! FF: track xi,backfolded (unfolded + smeared with response matrix)
278
279 TH1F** fh1FFRatioTrackPtFolded; //! ratio FF: track pt unfolded / original
280 TH1F** fh1FFRatioZFolded; //! ratio FF: track z unfolded / original
281 TH1F** fh1FFRatioXiFolded; //! ratio FF: track xi unfolded / original
282
283 TH1F** fh1FFRatioTrackPtBackFolded; //! ratio FF: track pt backfolded / original
284 TH1F** fh1FFRatioZBackFolded; //! ratio FF: track z backfolded / original
285 TH1F** fh1FFRatioXiBackFolded; //! ratio FF: track xi backfolded / original
286
287 TH1F* fh1SingleTrackPtBackFolded; //! inclusive track pt backfolded (unfolded + smeared with response matrix)
288 TH1F* fh1RatioSingleTrackPtFolded; //! ratio inclusive track pt unfolded / original
289 TH1F* fh1RatioSingleTrackPtBackFolded; //! ratio inblusive track pt backfolded / original
290
291 THnSparse* fhnResponseSinglePt; //! response matrix pt gen vs rec all tracks
292 THnSparse** fhnResponsePt; //! response matrix pt gen vs rec
293 THnSparse** fhnResponseZ; //! response matrix z gen vs rec
294 THnSparse** fhnResponseXi; //! response matrix xi gen vs rec
295
296 TH1F** fh1FFTrackPtPrior; //! FF: track pt prior
297 TH1F** fh1FFZPrior; //! FF: track z prior
298 TH1F** fh1FFXiPrior; //! FF: track xi prior
299
ce55b926 300
39e2b057 301 // secondaries
302 TH1F* fh1SecCorrSinglePt; //! secondaries correction all tracks
39e2b057 303
304
305 ClassDef(AliFragmentationFunctionCorrections, 1);
306};
307
308#endif