]>
Commit | Line | Data |
---|---|---|
39e2b057 | 1 | // ************************************************************************* |
2 | // * * | |
3 | // * corrections to Fragmentation Functions * | |
4 | // * * | |
5 | // ************************************************************************* | |
6 | ||
7 | ||
8 | /************************************************************************** | |
9 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
10 | * * | |
11 | * Author: The ALICE Off-line Project. * | |
12 | * Contributors are mentioned in the code where appropriate. * | |
13 | * * | |
14 | * Permission to use, copy, modify and distribute this software and its * | |
15 | * documentation strictly for non-commercial purposes is hereby granted * | |
16 | * without fee, provided that the above copyright notice appears in all * | |
17 | * copies and that both the copyright notice and this permission notice * | |
18 | * appear in the supporting documentation. The authors make no claims * | |
19 | * about the suitability of this software for any purpose. It is * | |
20 | * provided "as is" without express or implied warranty. * | |
21 | **************************************************************************/ | |
22 | ||
23 | /* $Id: */ | |
24 | ||
25 | #include "TMath.h" | |
26 | #include "TH2F.h" | |
27 | #include "THnSparse.h" | |
28 | #include "TFile.h" | |
29 | #include "TDirectory.h" | |
30 | #include "AliCFUnfolding.h" | |
31 | #include "AliFragmentationFunctionCorrections.h" | |
ce55b926 | 32 | #include <iostream> // OB TEST!!! |
33 | #include <fstream> | |
39e2b057 | 34 | |
35 | /////////////////////////////////////////////////////////////////////////////// | |
36 | // // | |
37 | // correction class for ouput of AliAnalysisTaskFragmentationFunction // | |
38 | // // | |
39 | // corrections for: reconstruction efficiency, momentum resolution, // | |
40 | // secondaries, UE / HI background, fluctuations // | |
41 | // back-correction on jet energy on dN/dxi // | |
42 | // // | |
43 | // read MC ouput and write out efficiency histos, response matrices etc. // | |
44 | // read measured distributions and apply efficiency, response matrices etc. // | |
45 | // // | |
46 | // contact: o.busch@gsi.de // | |
47 | // // | |
48 | /////////////////////////////////////////////////////////////////////////////// | |
49 | ||
50 | ||
51 | ClassImp(AliFragmentationFunctionCorrections) | |
52 | ||
53 | //________________________________________________________________________ | |
54 | AliFragmentationFunctionCorrections::AliFragmentationFunctionCorrections() | |
55 | : TObject() | |
56 | ,fDebug(0) | |
57 | ,fNJetPtSlices(0) | |
58 | ,fJetPtSlices(0) | |
59 | ,fNJets(0) | |
60 | ,fNJetsBgr(0) | |
61 | ,fNHistoBinsSinglePt(0) | |
62 | ,fHistoBinsSinglePt(0) | |
63 | ,fNHistoBinsPt(0) | |
64 | ,fNHistoBinsZ(0) | |
65 | ,fNHistoBinsXi(0) | |
66 | ,fHistoBinsPt(0) | |
67 | ,fHistoBinsZ(0) | |
68 | ,fHistoBinsXi(0) | |
69 | ,fNCorrectionLevels(0) | |
70 | ,fCorrFF(0) | |
71 | ,fNCorrectionLevelsBgr(0) | |
72 | ,fCorrBgr(0) | |
73 | ,fNCorrectionLevelsSinglePt(0) | |
74 | ,fCorrSinglePt(0) | |
75 | ,fh1FFXiShift(0) | |
76 | ,fh1EffSinglePt(0) | |
77 | ,fh1EffPt(0) | |
78 | ,fh1EffZ(0) | |
79 | ,fh1EffXi(0) | |
80 | ,fh1EffBgrPt(0) | |
81 | ,fh1EffBgrZ(0) | |
82 | ,fh1EffBgrXi(0) | |
ce55b926 | 83 | ,fh1BbBCorrSinglePt(0) |
84 | ,fh1BbBPt(0) | |
85 | ,fh1BbBZ(0) | |
86 | ,fh1BbBXi(0) | |
87 | ,fh1BbBBgrPt(0) | |
88 | ,fh1BbBBgrZ(0) | |
89 | ,fh1BbBBgrXi(0) | |
90 | ,fh1FoldingCorrPt(0) | |
91 | ,fh1FoldingCorrZ(0) | |
92 | ,fh1FoldingCorrXi(0) | |
93 | ,fh1SecCorrPt(0) | |
94 | ,fh1SecCorrZ(0) | |
95 | ,fh1SecCorrXi(0) | |
96 | ,fh1SecCorrBgrPt(0) | |
97 | ,fh1SecCorrBgrZ(0) | |
98 | ,fh1SecCorrBgrXi(0) | |
39e2b057 | 99 | ,fh1FFTrackPtBackFolded(0) |
100 | ,fh1FFZBackFolded(0) | |
101 | ,fh1FFXiBackFolded(0) | |
102 | ,fh1FFRatioTrackPtFolded(0) | |
103 | ,fh1FFRatioZFolded(0) | |
104 | ,fh1FFRatioXiFolded(0) | |
105 | ,fh1FFRatioTrackPtBackFolded(0) | |
106 | ,fh1FFRatioZBackFolded(0) | |
107 | ,fh1FFRatioXiBackFolded(0) | |
108 | ,fh1SingleTrackPtBackFolded(0) | |
109 | ,fh1RatioSingleTrackPtFolded(0) | |
110 | ,fh1RatioSingleTrackPtBackFolded(0) | |
111 | ,fhnResponseSinglePt(0) | |
112 | ,fhnResponsePt(0) | |
113 | ,fhnResponseZ(0) | |
114 | ,fhnResponseXi(0) | |
115 | ,fh1FFTrackPtPrior(0) | |
116 | ,fh1FFZPrior(0) | |
117 | ,fh1FFXiPrior(0) | |
118 | ,fh1SecCorrSinglePt(0) | |
119 | { | |
120 | // default constructor | |
121 | } | |
122 | ||
123 | //________________________________________________________________________________________________________________________ | |
124 | AliFragmentationFunctionCorrections::AliFragmentationFunctionCorrections(const AliFragmentationFunctionCorrections ©) | |
125 | : TObject() | |
126 | ,fDebug(copy.fDebug) | |
127 | ,fNJetPtSlices(copy.fNJetPtSlices) | |
128 | ,fJetPtSlices(copy.fJetPtSlices) | |
129 | ,fNJets(copy.fNJets) | |
130 | ,fNJetsBgr(copy.fNJetsBgr) | |
1aa4f09f | 131 | ,fNHistoBinsSinglePt(copy.fNHistoBinsSinglePt) |
132 | ,fHistoBinsSinglePt(copy.fHistoBinsSinglePt) | |
39e2b057 | 133 | ,fNHistoBinsPt(copy.fNHistoBinsPt) |
134 | ,fNHistoBinsZ(copy.fNHistoBinsZ) | |
135 | ,fNHistoBinsXi(copy.fNHistoBinsXi) | |
136 | ,fHistoBinsPt(copy.fHistoBinsPt) | |
137 | ,fHistoBinsZ(copy.fHistoBinsZ) | |
138 | ,fHistoBinsXi(copy.fHistoBinsXi) | |
139 | ,fNCorrectionLevels(copy.fNCorrectionLevels) | |
140 | ,fCorrFF(copy.fCorrFF) | |
141 | ,fNCorrectionLevelsBgr(copy.fNCorrectionLevelsBgr) | |
142 | ,fCorrBgr(copy.fCorrBgr) | |
143 | ,fNCorrectionLevelsSinglePt(copy.fNCorrectionLevelsSinglePt) | |
144 | ,fCorrSinglePt(copy.fCorrSinglePt) | |
145 | ,fh1FFXiShift(copy.fh1FFXiShift) | |
1aa4f09f | 146 | ,fh1EffSinglePt(copy.fh1EffSinglePt) |
39e2b057 | 147 | ,fh1EffPt(copy.fh1EffPt) |
148 | ,fh1EffZ(copy.fh1EffZ) | |
149 | ,fh1EffXi(copy.fh1EffXi) | |
150 | ,fh1EffBgrPt(copy.fh1EffBgrPt) | |
151 | ,fh1EffBgrZ(copy.fh1EffBgrZ) | |
152 | ,fh1EffBgrXi(copy.fh1EffBgrXi) | |
ce55b926 | 153 | ,fh1BbBCorrSinglePt(copy.fh1BbBCorrSinglePt) |
154 | ,fh1BbBPt(copy.fh1BbBPt) | |
155 | ,fh1BbBZ(copy.fh1BbBZ) | |
156 | ,fh1BbBXi(copy.fh1BbBXi) | |
157 | ,fh1BbBBgrPt(copy.fh1BbBBgrPt) | |
158 | ,fh1BbBBgrZ(copy.fh1BbBBgrZ) | |
159 | ,fh1BbBBgrXi(copy.fh1BbBBgrXi) | |
160 | ,fh1FoldingCorrPt(copy.fh1FoldingCorrPt) | |
161 | ,fh1FoldingCorrZ(copy.fh1FoldingCorrZ) | |
162 | ,fh1FoldingCorrXi(copy.fh1FoldingCorrXi) | |
163 | ,fh1SecCorrPt(copy.fh1SecCorrPt) | |
164 | ,fh1SecCorrZ(copy.fh1SecCorrZ) | |
165 | ,fh1SecCorrXi(copy.fh1SecCorrXi) | |
166 | ,fh1SecCorrBgrPt(copy.fh1SecCorrBgrPt) | |
167 | ,fh1SecCorrBgrZ(copy.fh1SecCorrBgrZ) | |
168 | ,fh1SecCorrBgrXi(copy.fh1SecCorrBgrXi) | |
39e2b057 | 169 | ,fh1FFTrackPtBackFolded(copy.fh1FFTrackPtBackFolded) |
170 | ,fh1FFZBackFolded(copy.fh1FFZBackFolded) | |
171 | ,fh1FFXiBackFolded(copy.fh1FFXiBackFolded) | |
172 | ,fh1FFRatioTrackPtFolded(copy.fh1FFRatioTrackPtFolded) | |
173 | ,fh1FFRatioZFolded(copy.fh1FFRatioZFolded) | |
174 | ,fh1FFRatioXiFolded(copy.fh1FFRatioXiFolded) | |
175 | ,fh1FFRatioTrackPtBackFolded(copy.fh1FFRatioTrackPtBackFolded) | |
176 | ,fh1FFRatioZBackFolded(copy.fh1FFRatioZBackFolded) | |
177 | ,fh1FFRatioXiBackFolded(copy.fh1FFRatioXiBackFolded) | |
178 | ,fh1SingleTrackPtBackFolded(copy.fh1SingleTrackPtBackFolded) | |
179 | ,fh1RatioSingleTrackPtFolded(copy.fh1RatioSingleTrackPtFolded) | |
180 | ,fh1RatioSingleTrackPtBackFolded(copy.fh1RatioSingleTrackPtBackFolded) | |
181 | ,fhnResponseSinglePt(copy.fhnResponseSinglePt) | |
182 | ,fhnResponsePt(copy.fhnResponsePt) | |
183 | ,fhnResponseZ(copy.fhnResponseZ) | |
184 | ,fhnResponseXi(copy.fhnResponseXi) | |
185 | ,fh1FFTrackPtPrior(copy.fh1FFTrackPtPrior) | |
186 | ,fh1FFZPrior(copy.fh1FFZPrior) | |
187 | ,fh1FFXiPrior(copy.fh1FFXiPrior) | |
188 | ,fh1SecCorrSinglePt(copy.fh1SecCorrSinglePt) | |
189 | { | |
190 | // copy constructor | |
191 | ||
192 | } | |
193 | ||
194 | // ______________________________________________________________________________________________________________________________ | |
195 | AliFragmentationFunctionCorrections& AliFragmentationFunctionCorrections::operator=(const AliFragmentationFunctionCorrections& o) | |
196 | { | |
197 | // assignment | |
198 | ||
199 | if(this!=&o){ | |
200 | TObject::operator=(o); | |
201 | fDebug = o.fDebug; | |
202 | fNJetPtSlices = o.fNJetPtSlices; | |
203 | fJetPtSlices = o.fJetPtSlices; | |
204 | fNJets = o.fNJets; | |
205 | fNJetsBgr = o.fNJetsBgr; | |
206 | fNHistoBinsSinglePt = o.fNHistoBinsSinglePt; | |
207 | fHistoBinsSinglePt = o.fHistoBinsSinglePt; | |
208 | fNHistoBinsPt = o.fNHistoBinsPt; | |
209 | fNHistoBinsZ = o.fNHistoBinsZ; | |
210 | fNHistoBinsXi = o.fNHistoBinsXi; | |
211 | fHistoBinsPt = o.fHistoBinsPt; | |
212 | fHistoBinsZ = o.fHistoBinsZ; | |
213 | fHistoBinsXi = o.fHistoBinsXi; | |
214 | fNCorrectionLevels = o.fNCorrectionLevels; | |
215 | fCorrFF = o.fCorrFF; | |
216 | fNCorrectionLevelsBgr = o.fNCorrectionLevelsBgr; | |
217 | fCorrBgr = o.fCorrBgr; | |
218 | fNCorrectionLevelsSinglePt = o.fNCorrectionLevelsSinglePt; | |
219 | fCorrSinglePt = o.fCorrSinglePt; | |
220 | fh1FFXiShift = o.fh1FFXiShift; | |
221 | fh1EffSinglePt = o.fh1EffSinglePt; | |
222 | fh1EffPt = o.fh1EffPt; | |
223 | fh1EffZ = o.fh1EffZ; | |
224 | fh1EffXi = o.fh1EffXi; | |
225 | fh1EffBgrPt = o.fh1EffBgrPt; | |
226 | fh1EffBgrZ = o.fh1EffBgrZ; | |
227 | fh1EffBgrXi = o.fh1EffBgrXi; | |
ce55b926 | 228 | fh1BbBCorrSinglePt = o.fh1BbBCorrSinglePt; |
229 | fh1BbBPt = o.fh1BbBPt; | |
230 | fh1BbBZ = o.fh1BbBZ; | |
231 | fh1BbBXi = o.fh1BbBXi; | |
232 | fh1BbBBgrPt = o.fh1BbBBgrPt; | |
233 | fh1BbBBgrZ = o.fh1BbBBgrZ; | |
234 | fh1BbBBgrXi = o.fh1BbBBgrXi; | |
235 | fh1FoldingCorrPt = o.fh1FoldingCorrPt; | |
236 | fh1FoldingCorrZ = o.fh1FoldingCorrZ; | |
237 | fh1FoldingCorrXi = o.fh1FoldingCorrXi; | |
238 | fh1SecCorrPt = o.fh1SecCorrPt; | |
239 | fh1SecCorrZ = o.fh1SecCorrZ; | |
240 | fh1SecCorrXi = o.fh1SecCorrXi; | |
241 | fh1SecCorrBgrPt = o.fh1SecCorrBgrPt; | |
242 | fh1SecCorrBgrZ = o.fh1SecCorrBgrZ; | |
243 | fh1SecCorrBgrXi = o.fh1SecCorrBgrXi; | |
39e2b057 | 244 | fh1FFTrackPtBackFolded = o.fh1FFTrackPtBackFolded; |
245 | fh1FFZBackFolded = o.fh1FFZBackFolded; | |
246 | fh1FFXiBackFolded = o.fh1FFXiBackFolded; | |
247 | fh1FFRatioTrackPtFolded = o.fh1FFRatioTrackPtFolded; | |
248 | fh1FFRatioZFolded = o.fh1FFRatioZFolded; | |
249 | fh1FFRatioXiFolded = o.fh1FFRatioXiFolded; | |
250 | fh1FFRatioTrackPtBackFolded = o.fh1FFRatioTrackPtBackFolded; | |
251 | fh1FFRatioZBackFolded = o.fh1FFRatioZBackFolded; | |
252 | fh1FFRatioXiBackFolded = o.fh1FFRatioXiBackFolded; | |
253 | fh1SingleTrackPtBackFolded = o.fh1SingleTrackPtBackFolded; | |
254 | fh1RatioSingleTrackPtFolded = o.fh1RatioSingleTrackPtFolded; | |
255 | fh1RatioSingleTrackPtBackFolded = o.fh1RatioSingleTrackPtBackFolded; | |
256 | fhnResponseSinglePt = o.fhnResponseSinglePt; | |
257 | fhnResponsePt = o.fhnResponsePt; | |
258 | fhnResponseZ = o.fhnResponseZ; | |
259 | fhnResponseXi = o.fhnResponseXi; | |
260 | fh1FFTrackPtPrior = o.fh1FFTrackPtPrior; | |
261 | fh1FFZPrior = o.fh1FFZPrior; | |
262 | fh1FFXiPrior = o.fh1FFXiPrior; | |
263 | fh1SecCorrSinglePt = o.fh1SecCorrSinglePt; | |
264 | } | |
265 | ||
266 | return *this; | |
267 | } | |
268 | ||
269 | //_________________________________________________________________________ | |
270 | AliFragmentationFunctionCorrections::~AliFragmentationFunctionCorrections() | |
271 | { | |
272 | // destructor | |
273 | ||
274 | if(fJetPtSlices) delete fJetPtSlices; | |
275 | if(fNJets) delete fNJets; | |
276 | if(fNJetsBgr) delete fNJetsBgr; | |
277 | ||
278 | DeleteHistoArray(fh1FFXiShift); | |
279 | ||
280 | DeleteHistoArray(fh1EffPt); | |
281 | DeleteHistoArray(fh1EffXi); | |
282 | DeleteHistoArray(fh1EffZ ); | |
283 | ||
284 | DeleteHistoArray(fh1EffBgrPt); | |
285 | DeleteHistoArray(fh1EffBgrXi); | |
286 | DeleteHistoArray(fh1EffBgrZ); | |
287 | ||
ce55b926 | 288 | // BbB |
289 | DeleteHistoArray(fh1BbBPt); | |
290 | DeleteHistoArray(fh1BbBXi); | |
291 | DeleteHistoArray(fh1BbBZ); | |
292 | ||
293 | DeleteHistoArray(fh1BbBBgrPt); | |
294 | DeleteHistoArray(fh1BbBBgrXi); | |
295 | DeleteHistoArray(fh1BbBBgrZ); | |
296 | ||
297 | DeleteHistoArray(fh1FoldingCorrPt); | |
298 | DeleteHistoArray(fh1FoldingCorrXi); | |
299 | DeleteHistoArray(fh1FoldingCorrZ); | |
300 | ||
301 | // sec corr | |
302 | DeleteHistoArray(fh1SecCorrPt); | |
303 | DeleteHistoArray(fh1SecCorrXi); | |
304 | DeleteHistoArray(fh1SecCorrZ); | |
305 | ||
306 | DeleteHistoArray(fh1SecCorrBgrPt); | |
307 | DeleteHistoArray(fh1SecCorrBgrXi); | |
308 | DeleteHistoArray(fh1SecCorrBgrZ); | |
309 | ||
39e2b057 | 310 | // unfolding |
311 | ||
312 | DeleteHistoArray(fh1FFTrackPtBackFolded); | |
313 | DeleteHistoArray(fh1FFZBackFolded); | |
314 | DeleteHistoArray(fh1FFXiBackFolded); | |
315 | ||
316 | DeleteHistoArray(fh1FFRatioTrackPtFolded); | |
317 | DeleteHistoArray(fh1FFRatioZFolded); | |
318 | DeleteHistoArray(fh1FFRatioXiFolded); | |
319 | ||
320 | DeleteHistoArray(fh1FFRatioTrackPtBackFolded); | |
321 | DeleteHistoArray(fh1FFRatioZBackFolded); | |
322 | DeleteHistoArray(fh1FFRatioXiBackFolded); | |
323 | ||
324 | DeleteTHnSparseArray(fhnResponsePt); | |
325 | DeleteTHnSparseArray(fhnResponseZ); | |
326 | DeleteTHnSparseArray(fhnResponseXi); | |
327 | ||
328 | DeleteHistoArray(fh1FFTrackPtPrior); | |
329 | DeleteHistoArray(fh1FFZPrior); | |
330 | DeleteHistoArray(fh1FFXiPrior); | |
331 | ||
39e2b057 | 332 | // clean up corrected FF |
333 | ||
334 | for(Int_t c=0; c<fNCorrectionLevels; c++) delete fCorrFF[c]; | |
335 | delete[] fCorrFF; | |
336 | ||
337 | // clean up bgr | |
338 | ||
339 | for(Int_t c=0; c<fNCorrectionLevelsBgr; c++) delete fCorrBgr[c]; | |
340 | delete[] fCorrBgr; | |
341 | ||
342 | // clean up inclusive pt | |
343 | for(Int_t c=0; c<fNCorrectionLevelsSinglePt; c++) delete fCorrSinglePt[c]; | |
344 | delete[] fCorrSinglePt; | |
345 | ||
346 | delete[] fNHistoBinsPt; | |
347 | delete[] fNHistoBinsZ; | |
348 | delete[] fNHistoBinsXi; | |
349 | ||
350 | // clean up histo bins | |
351 | ||
352 | if(fHistoBinsSinglePt) delete fHistoBinsSinglePt; | |
353 | ||
354 | for(Int_t i=0; i<fNJetPtSlices; i++) delete fHistoBinsPt[i]; | |
355 | for(Int_t i=0; i<fNJetPtSlices; i++) delete fHistoBinsZ[i]; | |
356 | for(Int_t i=0; i<fNJetPtSlices; i++) delete fHistoBinsXi[i]; | |
357 | ||
358 | delete[] fHistoBinsPt; | |
359 | delete[] fHistoBinsZ; | |
360 | delete[] fHistoBinsXi; | |
361 | } | |
362 | ||
363 | //_________________________________________________________________________________ | |
364 | AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::AliFragFuncCorrHistos() | |
365 | : TObject() | |
366 | ,fArraySize(0) | |
367 | ,fh1CorrFFTrackPt(0) | |
368 | ,fh1CorrFFZ(0) | |
369 | ,fh1CorrFFXi(0) | |
370 | ,fCorrLabel(0) | |
371 | { | |
372 | // default constructor | |
373 | ||
374 | } | |
375 | ||
376 | //__________________________________________________________________________________________________________________ | |
6daac008 | 377 | AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::AliFragFuncCorrHistos(const AliFragmentationFunctionCorrections::AliFragFuncCorrHistos& copy) |
39e2b057 | 378 | : TObject() |
379 | ,fArraySize(copy.fArraySize) | |
6daac008 | 380 | ,fh1CorrFFTrackPt(0) |
381 | ,fh1CorrFFZ(0) | |
382 | ,fh1CorrFFXi(0) | |
39e2b057 | 383 | ,fCorrLabel(copy.fCorrLabel) |
384 | { | |
385 | // copy constructor | |
6daac008 | 386 | |
387 | fh1CorrFFTrackPt = new TH1F*[copy.fArraySize]; | |
388 | fh1CorrFFZ = new TH1F*[copy.fArraySize]; | |
389 | fh1CorrFFXi = new TH1F*[copy.fArraySize]; | |
390 | ||
1aa4f09f | 391 | for(Int_t i=0; i<copy.fArraySize; i++){ |
6daac008 | 392 | fh1CorrFFTrackPt[i] = new TH1F(*(copy.fh1CorrFFTrackPt[i])); |
393 | fh1CorrFFZ[i] = new TH1F(*(copy.fh1CorrFFZ[i])); | |
394 | fh1CorrFFXi[i] = new TH1F(*(copy.fh1CorrFFXi[i])); | |
1aa4f09f | 395 | } |
39e2b057 | 396 | } |
397 | ||
39e2b057 | 398 | //_______________________________________________________________________________________________________________________________________________________________ |
399 | AliFragmentationFunctionCorrections::AliFragFuncCorrHistos& AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::operator=(const AliFragmentationFunctionCorrections::AliFragFuncCorrHistos& o) | |
400 | { | |
401 | // assignment | |
402 | ||
403 | if(this!=&o){ | |
404 | TObject::operator=(o); | |
6daac008 | 405 | Int_t fArraySize_new = o.fArraySize; |
39e2b057 | 406 | fCorrLabel = o.fCorrLabel; |
1aa4f09f | 407 | |
6daac008 | 408 | TH1F** fh1CorrFFTrackPt_new = new TH1F*[fArraySize_new]; |
409 | TH1F** fh1CorrFFZ_new = new TH1F*[fArraySize_new]; | |
410 | TH1F** fh1CorrFFXi_new = new TH1F*[fArraySize_new]; | |
411 | ||
412 | for(Int_t i=0; i<fArraySize_new; i++){ | |
413 | fh1CorrFFTrackPt_new[i] = new TH1F(*(o.fh1CorrFFTrackPt[i])); | |
414 | fh1CorrFFZ_new[i] = new TH1F(*(o.fh1CorrFFZ[i])); | |
415 | fh1CorrFFXi_new[i] = new TH1F(*(o.fh1CorrFFXi[i])); | |
1aa4f09f | 416 | } |
39e2b057 | 417 | |
6daac008 | 418 | // --- |
419 | ||
420 | if(fArraySize){ | |
421 | for(int i=0; i<fArraySize; i++) delete fh1CorrFFTrackPt[i]; | |
422 | for(int i=0; i<fArraySize; i++) delete fh1CorrFFZ[i]; | |
423 | for(int i=0; i<fArraySize; i++) delete fh1CorrFFXi[i]; | |
424 | } | |
425 | ||
426 | if(fh1CorrFFTrackPt) delete[] fh1CorrFFTrackPt; | |
427 | if(fh1CorrFFZ) delete[] fh1CorrFFZ; | |
428 | if(fh1CorrFFXi) delete[] fh1CorrFFXi; | |
429 | ||
430 | // --- | |
431 | ||
432 | fArraySize = fArraySize_new; | |
433 | ||
434 | fh1CorrFFTrackPt = fh1CorrFFTrackPt_new; | |
435 | fh1CorrFFZ = fh1CorrFFZ_new; | |
436 | fh1CorrFFXi = fh1CorrFFXi_new; | |
437 | ||
438 | for(Int_t i=0; i<fArraySize; i++){ | |
439 | fh1CorrFFTrackPt[i] = fh1CorrFFTrackPt_new[i]; | |
440 | fh1CorrFFZ[i] = fh1CorrFFZ_new[i]; | |
441 | fh1CorrFFXi[i] = fh1CorrFFXi_new[i]; | |
442 | } | |
443 | } | |
444 | ||
39e2b057 | 445 | return *this; |
446 | } | |
447 | ||
448 | //__________________________________________________________________________________ | |
449 | AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::~AliFragFuncCorrHistos() | |
450 | { | |
451 | // destructor | |
452 | ||
453 | if(fArraySize){ | |
454 | for(int i=0; i<fArraySize; i++) delete fh1CorrFFTrackPt[i]; | |
455 | for(int i=0; i<fArraySize; i++) delete fh1CorrFFZ[i]; | |
456 | for(int i=0; i<fArraySize; i++) delete fh1CorrFFXi[i]; | |
457 | } | |
458 | ||
459 | if(fh1CorrFFTrackPt) delete[] fh1CorrFFTrackPt; | |
460 | if(fh1CorrFFZ) delete[] fh1CorrFFZ; | |
461 | if(fh1CorrFFXi) delete[] fh1CorrFFXi; | |
462 | ||
463 | } | |
464 | ||
465 | //___________________________________________________________________________________________________________________ | |
466 | AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::AliFragFuncCorrHistos(const char* label, Int_t arraySize) | |
467 | : TObject() | |
468 | ,fArraySize(0) | |
469 | ,fh1CorrFFTrackPt(0) | |
470 | ,fh1CorrFFZ(0) | |
471 | ,fh1CorrFFXi(0) | |
472 | ,fCorrLabel(label) | |
473 | { | |
474 | // constructor | |
475 | ||
476 | fArraySize = arraySize; | |
477 | fh1CorrFFTrackPt = new TH1F*[arraySize]; | |
478 | fh1CorrFFZ = new TH1F*[arraySize]; | |
479 | fh1CorrFFXi = new TH1F*[arraySize]; | |
480 | ||
481 | for(int i=0; i<arraySize; i++) fh1CorrFFTrackPt[i] = new TH1F; | |
482 | for(int i=0; i<arraySize; i++) fh1CorrFFZ[i] = new TH1F; | |
483 | for(int i=0; i<arraySize; i++) fh1CorrFFXi[i] = new TH1F; | |
484 | } | |
485 | ||
486 | //_______________________________________________________________________________________________________________________________ | |
487 | void AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::AddCorrHistos(Int_t slice,TH1F* histPt,TH1F* histZ,TH1F* histXi) | |
488 | { | |
489 | // place histo in array, add corrLabel to histo name | |
490 | ||
491 | if(slice>=fArraySize){ | |
492 | Printf("%s:%d -- slice > array size", (char*)__FILE__,__LINE__); | |
493 | return; | |
494 | } | |
495 | ||
496 | if(histPt){ | |
497 | TString name = histPt->GetName(); | |
498 | if(fCorrLabel.Length()>0) name += "_"+fCorrLabel; | |
499 | histPt->SetName(name); | |
500 | ||
501 | if(!(histPt->GetSumw2())) histPt->Sumw2(); | |
502 | ||
503 | new(fh1CorrFFTrackPt[slice]) TH1F(*histPt); | |
504 | } | |
505 | ||
506 | if(histZ){ | |
507 | TString name = histZ->GetName(); | |
508 | if(fCorrLabel.Length()>0) name += "_"+fCorrLabel; | |
509 | histZ->SetName(name); | |
510 | ||
511 | if(!(histZ->GetSumw2())) histZ->Sumw2(); | |
512 | ||
513 | new(fh1CorrFFZ[slice]) TH1F(*histZ); | |
514 | } | |
515 | ||
516 | if(histXi){ | |
517 | TString name = histXi->GetName(); | |
518 | if(fCorrLabel.Length()>0) name += "_"+fCorrLabel; | |
519 | histXi->SetName(name); | |
520 | ||
521 | if(!(histXi->GetSumw2())) histXi->Sumw2(); | |
522 | ||
523 | new(fh1CorrFFXi[slice]) TH1F(*histXi); | |
524 | } | |
525 | } | |
526 | ||
527 | //___________________________________________________________________________________________________________________________________ | |
528 | void AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::ReplaceCorrHistos(Int_t slice,TH1F* histPt,TH1F* histZ,TH1F* histXi) | |
529 | { | |
530 | // replace histo in array | |
531 | ||
532 | if(slice>=fArraySize){ | |
533 | Printf("%s:%d -- slice > array size", (char*)__FILE__,__LINE__); | |
534 | return; | |
535 | } | |
536 | ||
537 | if(histPt){ | |
538 | if(!(histPt->GetSumw2())) histPt->Sumw2(); | |
539 | ||
540 | TString name = histPt->GetName(); | |
541 | histPt->SetName(name); | |
542 | ||
543 | delete fh1CorrFFTrackPt[slice]; | |
544 | fh1CorrFFTrackPt[slice] = new TH1F; | |
545 | new(fh1CorrFFTrackPt[slice]) TH1F(*histPt); | |
546 | } | |
547 | ||
548 | if(histZ){ | |
549 | if(!(histZ->GetSumw2())) histZ->Sumw2(); | |
550 | ||
551 | TString name = histZ->GetName(); | |
552 | histZ->SetName(name); | |
553 | ||
554 | delete fh1CorrFFZ[slice]; | |
555 | fh1CorrFFZ[slice] = new TH1F; | |
556 | new(fh1CorrFFZ[slice]) TH1F(*histZ); | |
557 | } | |
558 | ||
559 | if(histXi){ | |
560 | if(!(histXi->GetSumw2())) histXi->Sumw2(); | |
561 | ||
562 | TString name = histXi->GetName(); | |
563 | histXi->SetName(name); | |
564 | ||
565 | delete fh1CorrFFXi[slice]; | |
566 | fh1CorrFFXi[slice] = new TH1F; | |
567 | new(fh1CorrFFXi[slice]) TH1F(*histXi); | |
568 | } | |
569 | } | |
570 | ||
571 | // ___________________________________________________________________________________________ | |
572 | TH1F* AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::GetTrackPt(const Int_t slice) | |
573 | { | |
574 | // return pt histo | |
575 | ||
576 | if(slice>=fArraySize){ | |
577 | Printf("%s:%d -- slice > array size", (char*)__FILE__,__LINE__); | |
578 | return 0; | |
579 | } | |
580 | ||
581 | return fh1CorrFFTrackPt[slice]; | |
582 | ||
583 | } | |
584 | ||
585 | // ______________________________________________________________________________________ | |
586 | TH1F* AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::GetZ(const Int_t slice) | |
587 | { | |
588 | // return z histo | |
589 | ||
590 | if(slice>=fArraySize){ | |
591 | Printf("%s:%d -- slice > array size", (char*)__FILE__,__LINE__); | |
592 | return 0; | |
593 | } | |
594 | ||
595 | return fh1CorrFFZ[slice]; | |
596 | } | |
597 | ||
598 | // ________________________________________________________________________________________ | |
599 | TH1F* AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::GetXi(const Int_t slice) | |
600 | { | |
601 | // return xi histo | |
602 | ||
603 | if(slice>=fArraySize){ | |
604 | Printf("%s:%d -- slice > array size", (char*)__FILE__,__LINE__); | |
605 | return 0; | |
606 | } | |
607 | ||
608 | return fh1CorrFFXi[slice]; | |
609 | } | |
610 | ||
611 | // __________________________________________________________________________ | |
612 | void AliFragmentationFunctionCorrections::DeleteHistoArray(TH1F** hist) const | |
613 | { | |
614 | // delete array of TH1 | |
615 | ||
616 | if(hist){ | |
617 | for(Int_t i=0; i<fNJetPtSlices; i++) delete hist[i]; | |
618 | delete[] hist; | |
619 | } | |
620 | } | |
621 | ||
622 | // ____________________________________________________________________________________ | |
623 | void AliFragmentationFunctionCorrections::DeleteTHnSparseArray(THnSparse** hist) const | |
624 | { | |
625 | // delete array of THnSparse | |
626 | ||
627 | if(hist){ | |
628 | for(Int_t i=0; i<fNJetPtSlices; i++) delete hist[i]; | |
629 | delete[] hist; | |
630 | } | |
631 | } | |
632 | ||
633 | // _________________________________________________________ | |
634 | TH1F** AliFragmentationFunctionCorrections::BookHistoArray() | |
635 | { | |
636 | // book array of TH1 | |
637 | ||
638 | if(!fNJetPtSlices){ | |
639 | Printf("%s:%d -- jetPtSlices not defined", (char*)__FILE__,__LINE__); | |
640 | return 0; | |
641 | } | |
642 | ||
643 | TH1F** hist = new TH1F*[fNJetPtSlices]; | |
644 | for(Int_t i=0; i<fNJetPtSlices; i++) hist[i] = new TH1F(); | |
645 | ||
646 | return hist; | |
647 | } | |
648 | ||
649 | //__________________________________________________________________ | |
650 | THnSparse** AliFragmentationFunctionCorrections::BookTHnSparseArray() | |
651 | { | |
652 | // book array of THnSparse | |
653 | ||
654 | if(!fNJetPtSlices){ | |
655 | Printf("%s:%d -- jetPtSlices not defined", (char*)__FILE__,__LINE__); | |
656 | return 0; | |
657 | } | |
658 | ||
659 | THnSparse** hist = new THnSparse*[fNJetPtSlices]; | |
660 | for(Int_t i=0; i<fNJetPtSlices; i++) hist[i] = new THnSparseF(); | |
661 | ||
662 | return hist; | |
663 | } | |
664 | ||
665 | //_____________________________________________________________________________ | |
666 | void AliFragmentationFunctionCorrections::AddCorrectionLevel(const char* label) | |
667 | { | |
668 | // increase corr level | |
669 | ||
670 | if(!fNJetPtSlices){ | |
671 | Printf("%s:%d -- jetPtSlices not defined", (char*)__FILE__,__LINE__); | |
672 | return; | |
673 | } | |
674 | ||
675 | if(fNCorrectionLevels >= fgMaxNCorrectionLevels){ | |
676 | Printf("%s:%d -- max correction level exceeded", (char*)__FILE__,__LINE__); | |
677 | return; | |
678 | } | |
679 | ||
680 | fCorrFF[fNCorrectionLevels] = new AliFragFuncCorrHistos(label,fNJetPtSlices); | |
681 | fNCorrectionLevels++; | |
682 | } | |
683 | ||
684 | ||
685 | //________________________________________________________________________________ | |
686 | void AliFragmentationFunctionCorrections::AddCorrectionLevelBgr(const char* label) | |
687 | { | |
688 | // increase corr level for bgr FF | |
689 | ||
690 | if(!fNJetPtSlices){ | |
691 | if(fDebug>0) Printf("%s:%d -- jetPtSlices not defined", (char*)__FILE__,__LINE__); | |
692 | return; | |
693 | } | |
694 | ||
695 | if(fNCorrectionLevelsBgr >= fgMaxNCorrectionLevels){ | |
696 | Printf("%s:%d -- max correction level exceeded", (char*)__FILE__,__LINE__); | |
697 | return; | |
698 | } | |
699 | ||
700 | fCorrBgr[fNCorrectionLevelsBgr] = new AliFragFuncCorrHistos(label,fNJetPtSlices); | |
701 | fNCorrectionLevelsBgr++; | |
702 | } | |
703 | ||
704 | //_____________________________________________________________________________________ | |
705 | void AliFragmentationFunctionCorrections::AddCorrectionLevelSinglePt(const char* label) | |
706 | { | |
707 | // increase corr level single pt spec | |
708 | ||
709 | Int_t nJetPtSlicesSingle = 1; // pro forma | |
710 | ||
711 | if(fNCorrectionLevelsSinglePt >= fgMaxNCorrectionLevels){ | |
712 | Printf("%s:%d -- max correction level exceeded", (char*)__FILE__,__LINE__); | |
713 | return; | |
714 | } | |
715 | ||
716 | fCorrSinglePt[fNCorrectionLevelsSinglePt] = new AliFragFuncCorrHistos(label,nJetPtSlicesSingle); | |
717 | fNCorrectionLevelsSinglePt++; | |
718 | } | |
719 | ||
720 | //_____________________________________________________________________________________________ | |
721 | void AliFragmentationFunctionCorrections::SetJetPtSlices(Float_t* bins, const Int_t nJetPtSlices) | |
722 | { | |
723 | // set jet pt slices | |
724 | // once slices are known, can book all other histos | |
725 | ||
726 | fNJetPtSlices = nJetPtSlices; | |
727 | ||
728 | const Int_t size = nJetPtSlices+1; | |
729 | fJetPtSlices = new TArrayF(size,bins); | |
730 | ||
731 | // nJets array | |
732 | ||
733 | fNJets = new TArrayF(size); | |
734 | fNJets->Reset(0); | |
735 | ||
736 | fNJetsBgr = new TArrayF(size); | |
737 | fNJetsBgr->Reset(0); | |
738 | ||
739 | // histos | |
740 | ||
741 | fNCorrectionLevels = 0; | |
742 | fCorrFF = new AliFragFuncCorrHistos*[fgMaxNCorrectionLevels]; | |
743 | AddCorrectionLevel(); // first 'correction' level = raw FF | |
744 | ||
745 | fNCorrectionLevelsBgr = 0; | |
746 | fCorrBgr = new AliFragFuncCorrHistos*[fgMaxNCorrectionLevels]; | |
747 | AddCorrectionLevelBgr(); // first 'correction' level = raw bgr dist | |
748 | ||
749 | fh1FFXiShift = BookHistoArray(); | |
750 | ||
751 | // eff histos | |
752 | ||
753 | fh1EffPt = BookHistoArray(); | |
754 | fh1EffXi = BookHistoArray(); | |
755 | fh1EffZ = BookHistoArray(); | |
756 | ||
757 | fh1EffBgrPt = BookHistoArray(); | |
758 | fh1EffBgrXi = BookHistoArray(); | |
759 | fh1EffBgrZ = BookHistoArray(); | |
760 | ||
761 | ||
ce55b926 | 762 | // BbB |
763 | ||
764 | fh1BbBPt = BookHistoArray(); | |
765 | fh1BbBXi = BookHistoArray(); | |
766 | fh1BbBZ = BookHistoArray(); | |
767 | ||
768 | fh1BbBBgrPt = BookHistoArray(); | |
769 | fh1BbBBgrXi = BookHistoArray(); | |
770 | fh1BbBBgrZ = BookHistoArray(); | |
771 | ||
772 | fh1FoldingCorrPt = BookHistoArray(); | |
773 | fh1FoldingCorrXi = BookHistoArray(); | |
774 | fh1FoldingCorrZ = BookHistoArray(); | |
775 | ||
776 | // SecCorr | |
777 | ||
778 | fh1SecCorrPt = BookHistoArray(); | |
779 | fh1SecCorrXi = BookHistoArray(); | |
780 | fh1SecCorrZ = BookHistoArray(); | |
781 | ||
782 | fh1SecCorrBgrPt = BookHistoArray(); | |
783 | fh1SecCorrBgrXi = BookHistoArray(); | |
784 | fh1SecCorrBgrZ = BookHistoArray(); | |
785 | ||
39e2b057 | 786 | // unfolding |
787 | ||
788 | fh1FFTrackPtBackFolded = BookHistoArray(); | |
789 | fh1FFXiBackFolded = BookHistoArray(); | |
790 | fh1FFZBackFolded = BookHistoArray(); | |
791 | ||
792 | fh1FFRatioTrackPtFolded = BookHistoArray(); | |
793 | fh1FFRatioXiFolded = BookHistoArray(); | |
794 | fh1FFRatioZFolded = BookHistoArray(); | |
795 | ||
796 | fh1FFRatioTrackPtBackFolded = BookHistoArray(); | |
797 | fh1FFRatioXiBackFolded = BookHistoArray(); | |
798 | fh1FFRatioZBackFolded = BookHistoArray(); | |
799 | ||
800 | // | |
801 | ||
802 | fhnResponsePt = BookTHnSparseArray(); | |
803 | fhnResponseZ = BookTHnSparseArray(); | |
804 | fhnResponseXi = BookTHnSparseArray(); | |
805 | ||
806 | fh1FFTrackPtPrior = BookHistoArray(); | |
807 | fh1FFZPrior = BookHistoArray(); | |
808 | fh1FFXiPrior = BookHistoArray(); | |
809 | ||
39e2b057 | 810 | // histos bins |
811 | ||
812 | fNHistoBinsPt = new Int_t[fNJetPtSlices]; | |
813 | fNHistoBinsXi = new Int_t[fNJetPtSlices]; | |
814 | fNHistoBinsZ = new Int_t[fNJetPtSlices]; | |
815 | ||
816 | for(Int_t i=0; i<fNJetPtSlices; i++) fNHistoBinsPt[i] = 0; | |
817 | for(Int_t i=0; i<fNJetPtSlices; i++) fNHistoBinsXi[i] = 0; | |
818 | for(Int_t i=0; i<fNJetPtSlices; i++) fNHistoBinsZ[i] = 0; | |
819 | ||
820 | fHistoBinsPt = new TArrayD*[fNJetPtSlices]; | |
821 | fHistoBinsXi = new TArrayD*[fNJetPtSlices]; | |
822 | fHistoBinsZ = new TArrayD*[fNJetPtSlices]; | |
823 | ||
824 | for(Int_t i=0; i<fNJetPtSlices; i++) fHistoBinsPt[i] = new TArrayD(0); | |
825 | for(Int_t i=0; i<fNJetPtSlices; i++) fHistoBinsXi[i] = new TArrayD(0); | |
826 | for(Int_t i=0; i<fNJetPtSlices; i++) fHistoBinsZ[i] = new TArrayD(0); | |
827 | } | |
828 | ||
829 | //_____________________________________________________________________________________________________________________________________ | |
830 | void AliFragmentationFunctionCorrections::SetHistoBins(const Int_t jetPtSlice, const Int_t sizeBins, Double_t* bins, const Int_t type) | |
831 | { | |
832 | // set histo bins for jet pt slice | |
833 | // if binning undefined for any slice, original binning will be used | |
834 | ||
835 | if(!fNJetPtSlices){ | |
836 | Printf("%s:%d -- jetPtSlices not defined", (char*)__FILE__,__LINE__); | |
837 | return; | |
838 | } | |
839 | ||
840 | if(jetPtSlice>=fNJetPtSlices){ | |
841 | Printf("%s:%d -- jetPtSlice %d exceeds max",(char*)__FILE__,__LINE__,jetPtSlice); | |
842 | return; | |
843 | } | |
844 | ||
845 | if(type == kFlagPt){ | |
846 | fNHistoBinsPt[jetPtSlice] = sizeBins-1; | |
847 | fHistoBinsPt[jetPtSlice]->Set(sizeBins,bins); | |
848 | } | |
849 | else if(type==kFlagZ){ | |
850 | fNHistoBinsZ[jetPtSlice] = sizeBins-1; | |
851 | fHistoBinsZ[jetPtSlice]->Set(sizeBins,bins); | |
852 | } | |
853 | ||
854 | else if(type==kFlagXi){ | |
855 | fNHistoBinsXi[jetPtSlice] = sizeBins-1; | |
856 | fHistoBinsXi[jetPtSlice]->Set(sizeBins,bins); | |
857 | } | |
858 | } | |
859 | ||
860 | //__________________________________________________________________________________________________________________________________________________________________ | |
861 | void AliFragmentationFunctionCorrections::SetHistoBins(const Int_t jetPtSlice, const Int_t nBinsLimits, Double_t* binsLimits, Double_t* binsWidth, const Int_t type) | |
862 | { | |
863 | // set histo bins for jet pt slice | |
864 | // function takes array of limits and widths (e.g. 1 GeV bins up to 10 GeV, 2 GeV width up to 20 GeV, ...) | |
865 | // array size of binsLimits: nBinsLimits | |
866 | // array size of binsWidth: nBinsLimits-1 | |
867 | // binsLimits have to be in increasing order | |
868 | // if binning undefined for any slice, original binning will be used | |
869 | ||
870 | if(!fNJetPtSlices){ | |
871 | Printf("%s:%d -- jetPtSlices not defined", (char*)__FILE__,__LINE__); | |
872 | return; | |
873 | } | |
874 | ||
875 | if(jetPtSlice>=fNJetPtSlices){ | |
876 | Printf("%s:%d -- jetPtSlice %d exceeds max",(char*)__FILE__,__LINE__,jetPtSlice); | |
877 | return; | |
878 | } | |
879 | ||
880 | ||
881 | Double_t binLimitMin = binsLimits[0]; | |
882 | Double_t binLimitMax = binsLimits[nBinsLimits-1]; | |
883 | ||
884 | Double_t binLimit = binLimitMin; // start value | |
885 | ||
886 | Int_t sizeUpperLim = 10000; //static_cast<Int_t>(binLimitMax/binsWidth[0])+1; | |
887 | TArrayD binsArray(sizeUpperLim); | |
888 | Int_t nBins = 0; | |
889 | binsArray.SetAt(binLimitMin,nBins++); | |
890 | ||
ce55b926 | 891 | while(binLimit<0.999999*binLimitMax && nBins<sizeUpperLim){ // 0.999 numerical safety factor |
39e2b057 | 892 | |
893 | Int_t currentSlice = -1; | |
894 | for(Int_t i=0; i<nBinsLimits; i++){ | |
ce55b926 | 895 | if(binLimit >= 0.999999*binsLimits[i]) currentSlice = i; |
39e2b057 | 896 | } |
897 | ||
898 | Double_t currentBinWidth = binsWidth[currentSlice]; | |
899 | binLimit += currentBinWidth; | |
900 | ||
ce55b926 | 901 | // if(type == kFlagZ) std::cout<<" SetHistoBins: nBins "<<nBins<<" binLimit "<<binLimit<<" binLimitMax "<<binLimitMax |
902 | // <<" currentSlice "<<currentSlice<<std::endl; | |
903 | ||
39e2b057 | 904 | binsArray.SetAt(binLimit,nBins++); |
905 | } | |
906 | ||
907 | Double_t* bins = binsArray.GetArray(); | |
908 | ||
909 | SetHistoBins(jetPtSlice,nBins,bins,type); | |
910 | } | |
911 | ||
ce55b926 | 912 | //_____________________________________________________________________________________________________________________________________ |
913 | TArrayD* AliFragmentationFunctionCorrections::GetHistoBins(const Int_t jetPtSlice, const Int_t type) | |
914 | { | |
915 | // set histo bins for jet pt slice | |
916 | // if binning undefined for any slice, original binning will be used | |
917 | ||
918 | if(!fNJetPtSlices){ | |
919 | Printf("%s:%d -- jetPtSlices not defined", (char*)__FILE__,__LINE__); | |
920 | return 0; | |
921 | } | |
922 | ||
923 | if(jetPtSlice>=fNJetPtSlices){ | |
924 | Printf("%s:%d -- jetPtSlice %d exceeds max",(char*)__FILE__,__LINE__,jetPtSlice); | |
925 | return 0; | |
926 | } | |
927 | ||
928 | if(type == kFlagPt){ | |
929 | return fHistoBinsPt[jetPtSlice]; | |
930 | } | |
931 | else if(type==kFlagZ){ | |
932 | return fHistoBinsZ[jetPtSlice]; | |
933 | } | |
934 | ||
935 | else if(type==kFlagXi){ | |
936 | return fHistoBinsXi[jetPtSlice]; | |
937 | } | |
938 | else{ | |
939 | Printf("%s%d unknown type",(char*)__FILE__,__LINE__); | |
940 | return 0; | |
941 | } | |
942 | } | |
943 | ||
39e2b057 | 944 | //__________________________________________________________________________________________________ |
945 | void AliFragmentationFunctionCorrections::SetHistoBinsSinglePt(const Int_t sizeBins, Double_t* bins) | |
946 | { | |
947 | // set histo bins for inclusive pt spectra | |
948 | // if binning undefined, original binning will be used | |
949 | ||
950 | fNHistoBinsSinglePt = sizeBins-1; | |
951 | ||
952 | fHistoBinsSinglePt = new TArrayD(sizeBins); | |
953 | fHistoBinsSinglePt->Set(sizeBins,bins); | |
954 | } | |
955 | ||
956 | //__________________________________________________________________________________________________________________________________________________________________ | |
957 | void AliFragmentationFunctionCorrections::SetHistoBinsSinglePt(const Int_t nBinsLimits, Double_t* binsLimits, Double_t* binsWidth) | |
958 | { | |
959 | // set histo bins for inclusive pt spectra | |
960 | // function takes array of limits and widths (e.g. 1 GeV bins up to 10 GeV, 2 GeV width up to 20 GeV, ...) | |
961 | // array size of binsLimits: nBinsLimits | |
962 | // array size of binsWidth: nBinsLimits-1 | |
963 | // binsLimits have to be in increasing order | |
964 | // if binning undefined for any slice, original binning will be used | |
965 | ||
966 | ||
967 | Double_t binLimitMin = binsLimits[0]; | |
968 | Double_t binLimitMax = binsLimits[nBinsLimits-1]; | |
969 | ||
970 | Double_t binLimit = binLimitMin; // start value | |
971 | ||
972 | Int_t sizeUpperLim = 10000; //static_cast<Int_t>(binLimitMax/binsWidth[0])+1; | |
973 | TArrayD binsArray(sizeUpperLim); | |
974 | Int_t nBins = 0; | |
975 | binsArray.SetAt(binLimitMin,nBins++); | |
976 | ||
977 | while(binLimit<binLimitMax && nBins<sizeUpperLim){ | |
978 | ||
979 | Int_t currentSlice = -1; | |
980 | for(Int_t i=0; i<nBinsLimits; i++){ | |
981 | if(binLimit >= 0.999*binsLimits[i]) currentSlice = i; // 0.999 numerical saftey factor | |
982 | } | |
983 | ||
984 | Double_t currentBinWidth = binsWidth[currentSlice]; | |
985 | binLimit += currentBinWidth; | |
986 | ||
987 | binsArray.SetAt(binLimit,nBins++); | |
988 | } | |
989 | ||
990 | Double_t* bins = binsArray.GetArray(); | |
991 | ||
992 | SetHistoBinsSinglePt(nBins,bins); | |
993 | } | |
994 | ||
995 | //____________________________________________________________________________________ | |
996 | void AliFragmentationFunctionCorrections::NormalizeTH1(TH1* hist, const Float_t nJets) | |
997 | { | |
998 | // FF normalization: divide by bin width and normalize to entries/jets | |
999 | // should also work for TH2, but to be tested !!! | |
1000 | ||
1001 | if(nJets == 0){ // nothing to do | |
1002 | if(fDebug>0) Printf("%s:%d -- normalize: nJets = 0, do nothing", (char*)__FILE__,__LINE__); | |
1003 | return; | |
1004 | } | |
1005 | ||
1006 | Int_t nBins = hist->GetNbinsX()*hist->GetNbinsY()*hist->GetNbinsZ(); | |
1007 | ||
1008 | for(Int_t bin=0; bin<=nBins; bin++){ // include under-/overflow (?) | |
1009 | ||
1010 | Double_t binWidth = hist->GetBinWidth(bin); | |
1011 | Double_t binCont = hist->GetBinContent(bin); | |
1012 | Double_t binErr = hist->GetBinError(bin); | |
1013 | ||
1014 | binCont /= binWidth; | |
1015 | binErr /= binWidth; | |
1016 | ||
1017 | hist->SetBinContent(bin,binCont); | |
1018 | hist->SetBinError(bin,binErr); | |
1019 | } | |
1020 | ||
1021 | hist->Scale(1/nJets); | |
1022 | } | |
1023 | ||
1024 | //_____________________________________________________ | |
1025 | void AliFragmentationFunctionCorrections::NormalizeFF() | |
1026 | { | |
1027 | // normalize FF | |
1028 | ||
1029 | if(fNCorrectionLevels>1){ | |
1030 | Printf("%s:%d -- FF normalization should be done BEFORE any correction !!!", (char*)__FILE__,__LINE__); | |
1031 | } | |
1032 | ||
1033 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1034 | ||
1035 | if(fDebug>0) Printf(" normalizeFF: i %d, nJets %f",i,fNJets->At(i)); | |
1036 | ||
1037 | NormalizeTH1(fCorrFF[0]->GetTrackPt(i),fNJets->At(i)); // always normalize corr level 0 = raw FF | |
1038 | NormalizeTH1(fCorrFF[0]->GetZ(i),fNJets->At(i)); | |
1039 | NormalizeTH1(fCorrFF[0]->GetXi(i),fNJets->At(i)); | |
1040 | } | |
1041 | } | |
1042 | ||
1043 | //______________________________________________________ | |
1044 | void AliFragmentationFunctionCorrections::NormalizeBgr() | |
1045 | { | |
1046 | // normalize bgr/UE FF | |
1047 | ||
1048 | if(fNCorrectionLevelsBgr>1){ | |
1049 | Printf("%s:%d -- FF normalization should be done BEFORE any correction !!!", (char*)__FILE__,__LINE__); | |
1050 | } | |
1051 | ||
1052 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1053 | NormalizeTH1(fCorrBgr[0]->GetTrackPt(i), fNJetsBgr->At(i)); // always normalize corr level 0 = raw FF | |
1054 | NormalizeTH1(fCorrBgr[0]->GetZ(i), fNJetsBgr->At(i)); | |
1055 | NormalizeTH1(fCorrBgr[0]->GetXi(i),fNJetsBgr->At(i)); | |
1056 | } | |
1057 | ||
1058 | } | |
1059 | ||
1060 | //__________________________________________________________________________________________________ | |
1061 | void AliFragmentationFunctionCorrections::ReadRawFF(TString strfile, TString strID, TString strFFID) | |
1062 | { | |
1063 | // read raw FF - standard dir/list name | |
1064 | ||
b541fbca | 1065 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 1066 | TString strlist = "fracfunc_" + strID; |
1067 | ||
1068 | ReadRawFF(strfile,strdir,strlist,strFFID); | |
1069 | } | |
1070 | ||
1071 | //____________________________________________________________________________________________________________________ | |
1072 | void AliFragmentationFunctionCorrections::ReadRawFF(TString strfile, TString strdir, TString strlist, TString strFFID) | |
1073 | { | |
1074 | // get raw FF from input file, project in jet pt slice | |
1075 | // normalization done separately | |
1076 | ||
1077 | TFile f(strfile,"READ"); | |
1078 | ||
1079 | if(!f.IsOpen()){ | |
1080 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
1081 | return; | |
1082 | } | |
1083 | ||
ce55b926 | 1084 | if(fDebug>0) Printf("%s:%d -- read FF from file %s, dir %s ",(char*)__FILE__,__LINE__,strfile.Data(), strdir.Data()); |
39e2b057 | 1085 | |
1086 | gDirectory->cd(strdir); | |
1087 | ||
1088 | TList* list = 0; | |
1089 | ||
ce55b926 | 1090 | if(strlist && strlist.Length()){ |
1091 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
1092 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
1093 | return; | |
1094 | } | |
39e2b057 | 1095 | } |
1096 | ||
1097 | TString hnameJetPt(Form("fh1FFJetPt%s",strFFID.Data())); | |
1098 | TString hnameTrackPt(Form("fh2FFTrackPt%s",strFFID.Data())); | |
1099 | TString hnameZ(Form("fh2FFZ%s",strFFID.Data())); | |
1100 | TString hnameXi(Form("fh2FFXi%s",strFFID.Data())); | |
1101 | ||
ce55b926 | 1102 | TH1F* fh1FFJetPt = 0; |
1103 | TH2F* fh2FFTrackPt = 0; | |
1104 | TH2F* fh2FFZ = 0; | |
1105 | TH2F* fh2FFXi = 0; | |
1106 | ||
1107 | if(list){ | |
1108 | fh1FFJetPt = (TH1F*) list->FindObject(hnameJetPt); | |
1109 | fh2FFTrackPt = (TH2F*) list->FindObject(hnameTrackPt); | |
1110 | fh2FFZ = (TH2F*) list->FindObject(hnameZ); | |
1111 | fh2FFXi = (TH2F*) list->FindObject(hnameXi); | |
1112 | } | |
1113 | else{ | |
1114 | fh1FFJetPt = (TH1F*) gDirectory->Get(hnameJetPt); | |
1115 | fh2FFTrackPt = (TH2F*) gDirectory->Get(hnameTrackPt); | |
1116 | fh2FFZ = (TH2F*) gDirectory->Get(hnameZ); | |
1117 | fh2FFXi = (TH2F*) gDirectory->Get(hnameXi); | |
1118 | } | |
1119 | ||
39e2b057 | 1120 | |
1121 | if(!fh1FFJetPt) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameJetPt.Data()); return; } | |
1122 | if(!fh2FFTrackPt){ Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameTrackPt.Data()); return; } | |
1123 | if(!fh2FFZ) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameZ.Data()); return; } | |
1124 | if(!fh2FFXi) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameXi.Data()); return; } | |
1125 | ||
1126 | fh1FFJetPt->SetDirectory(0); | |
1127 | fh2FFTrackPt->SetDirectory(0); | |
1128 | fh2FFZ->SetDirectory(0); | |
1129 | fh2FFXi->SetDirectory(0); | |
1130 | ||
1131 | f.Close(); | |
1132 | ||
1133 | ||
1134 | // nJets per bin | |
1135 | ||
1136 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1137 | ||
1138 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
1139 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
1140 | ||
1141 | Int_t binLo = static_cast<Int_t>(fh1FFJetPt->FindBin(jetPtLoLim)); | |
1142 | Int_t binUp = static_cast<Int_t>(fh1FFJetPt->FindBin(jetPtUpLim)) - 1; | |
1143 | ||
1144 | Float_t nJetsBin = fh1FFJetPt->Integral(binLo,binUp); | |
1145 | ||
1146 | fNJets->SetAt(nJetsBin,i); | |
1147 | ||
1148 | if(fDebug>0) Printf("jet pt %d to %d: nJets %f",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),fNJets->At(i)); | |
1149 | } | |
1150 | ||
1151 | // projections: FF | |
1152 | ||
1153 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1154 | ||
1155 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
1156 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
1157 | ||
1158 | Int_t binLo = static_cast<Int_t>(fh2FFTrackPt->GetXaxis()->FindBin(jetPtLoLim)); | |
1159 | Int_t binUp = static_cast<Int_t>(fh2FFTrackPt->GetXaxis()->FindBin(jetPtUpLim))-1; | |
1160 | ||
1161 | if(binUp > fh2FFTrackPt->GetNbinsX()){ | |
1162 | Printf("%s:%d -- jet pt range %0.3f exceeds histo limits",(char*)__FILE__,__LINE__,jetPtUpLim); | |
1163 | return; | |
1164 | } | |
1165 | ||
1166 | TString strNameFFPt(Form("fh1FFTrackPt%s_%02d_%02d",strFFID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1167 | TString strNameFFZ(Form("fh1FFZ%s_%02d_%02d",strFFID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1168 | TString strNameFFXi(Form("fh1FFXi%s_%02d_%02d",strFFID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1169 | ||
1170 | // appendix 'unbinned' to avoid histos with same name after rebinning | |
1171 | TH1F* projPt = (TH1F*) fh2FFTrackPt->ProjectionY(strNameFFPt+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
1172 | TH1F* projZ = (TH1F*) fh2FFZ->ProjectionY(strNameFFZ+"_unBinned",binLo,binUp,"o"); | |
1173 | TH1F* projXi = (TH1F*) fh2FFXi->ProjectionY(strNameFFXi+"_unBinned",binLo,binUp,"o"); | |
1174 | ||
1175 | if(fNHistoBinsPt[i]) projPt = (TH1F*) projPt->Rebin(fNHistoBinsPt[i],strNameFFPt,fHistoBinsPt[i]->GetArray()); | |
1176 | if(fNHistoBinsZ[i]) projZ = (TH1F*) projZ->Rebin(fNHistoBinsZ[i],strNameFFZ,fHistoBinsZ[i]->GetArray()); | |
1177 | if(fNHistoBinsXi[i]) projXi = (TH1F*) projXi->Rebin(fNHistoBinsXi[i],strNameFFXi,fHistoBinsXi[i]->GetArray()); | |
1178 | ||
1179 | projPt->SetNameTitle(strNameFFPt,""); | |
1180 | projZ->SetNameTitle(strNameFFZ,""); | |
1181 | projXi->SetNameTitle(strNameFFXi,""); | |
1182 | ||
1183 | // raw FF = corr level 0 | |
1184 | fCorrFF[0]->AddCorrHistos(i,projPt,projZ,projXi); | |
ce55b926 | 1185 | } |
1186 | ||
1187 | ||
1188 | delete fh1FFJetPt; | |
1189 | delete fh2FFTrackPt; | |
1190 | delete fh2FFZ; | |
1191 | delete fh2FFXi; | |
39e2b057 | 1192 | } |
1193 | ||
1194 | //_____________________________________________________________________________________________________________________ | |
1195 | void AliFragmentationFunctionCorrections::ReadRawBgr(TString strfile, TString strID, TString strBgrID, TString strFFID) | |
1196 | { | |
1197 | // read raw FF - standard dir/list name | |
1198 | ||
b541fbca | 1199 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 1200 | TString strlist = "fracfunc_" + strID; |
1201 | ||
1202 | ReadRawBgr(strfile,strdir,strlist,strBgrID,strFFID); | |
1203 | } | |
1204 | ||
1205 | //_______________________________________________________________________________________________________________________________________ | |
1206 | void AliFragmentationFunctionCorrections::ReadRawBgr(TString strfile, TString strdir, TString strlist, TString strBgrID, TString strFFID) | |
1207 | { | |
1208 | // get raw FF from input file, project in jet pt slice | |
1209 | // use jet dN/dpt corresponding to strFFID, bgr FF to strBgrID+strFFID | |
1210 | // e.g. "fh1FFJetPtRecCuts", "fh2FFXiBgrPerpRecCuts" | |
1211 | // normalization done separately | |
1212 | ||
1213 | TString strID = strBgrID + strFFID; | |
1214 | ||
1215 | TFile f(strfile,"READ"); | |
1216 | ||
1217 | if(!f.IsOpen()){ | |
1218 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
1219 | return; | |
1220 | } | |
1221 | ||
ce55b926 | 1222 | if(fDebug>0) Printf("%s:%d -- read Bgr %s from file %s, dir %s ",(char*)__FILE__,__LINE__,strBgrID.Data(),strfile.Data(),strdir.Data()); |
39e2b057 | 1223 | |
1224 | gDirectory->cd(strdir); | |
1225 | ||
1226 | TList* list = 0; | |
1227 | ||
ce55b926 | 1228 | if(strlist && strlist.Length()){ |
1229 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
1230 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
1231 | return; | |
1232 | } | |
39e2b057 | 1233 | } |
1234 | ||
1235 | TString hnameNJets = "fh1nRecJetsCuts"; | |
1236 | TString hnameJetPt(Form("fh1FFJetPt%s",strFFID.Data())); // not: strID.Data() !!! would not be proper normalization | |
1237 | TString hnameBgrTrackPt(Form("fh2FFTrackPt%s",strID.Data())); | |
1238 | TString hnameBgrZ(Form("fh2FFZ%s",strID.Data())); | |
1239 | TString hnameBgrXi(Form("fh2FFXi%s",strID.Data())); | |
1240 | ||
ce55b926 | 1241 | TH1F* fh1NJets; |
1242 | TH1F* fh1FFJetPtBgr; | |
1243 | TH2F* fh2FFTrackPtBgr; | |
1244 | TH2F* fh2FFZBgr; | |
1245 | TH2F* fh2FFXiBgr; | |
1246 | ||
1247 | if(list){ | |
1248 | fh1NJets = (TH1F*) list->FindObject(hnameNJets); // needed for normalization of bgr out of 2 jets | |
1249 | fh1FFJetPtBgr = (TH1F*) list->FindObject(hnameJetPt); | |
1250 | fh2FFTrackPtBgr = (TH2F*) list->FindObject(hnameBgrTrackPt); | |
1251 | fh2FFZBgr = (TH2F*) list->FindObject(hnameBgrZ); | |
1252 | fh2FFXiBgr = (TH2F*) list->FindObject(hnameBgrXi); | |
1253 | } | |
1254 | else{ | |
1255 | fh1NJets = (TH1F*) gDirectory->Get(hnameNJets); // needed for normalization of bgr out of 2 jets | |
1256 | fh1FFJetPtBgr = (TH1F*) gDirectory->Get(hnameJetPt); | |
1257 | fh2FFTrackPtBgr = (TH2F*) gDirectory->Get(hnameBgrTrackPt); | |
1258 | fh2FFZBgr = (TH2F*) gDirectory->Get(hnameBgrZ); | |
1259 | fh2FFXiBgr = (TH2F*) gDirectory->Get(hnameBgrXi); | |
1260 | } | |
1261 | ||
39e2b057 | 1262 | |
1263 | if(!fh1FFJetPtBgr) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameJetPt.Data()); return; } | |
ce55b926 | 1264 | if(!fh1NJets) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameNJets.Data()); } |
39e2b057 | 1265 | if(!fh2FFTrackPtBgr){ Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameBgrTrackPt.Data()); return; } |
1266 | if(!fh2FFZBgr) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameBgrZ.Data()); return; } | |
1267 | if(!fh2FFXiBgr) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameBgrXi.Data()); return; } | |
1268 | ||
1269 | fh1FFJetPtBgr->SetDirectory(0); | |
39e2b057 | 1270 | fh2FFTrackPtBgr->SetDirectory(0); |
1271 | fh2FFZBgr->SetDirectory(0); | |
1272 | fh2FFXiBgr->SetDirectory(0); | |
ce55b926 | 1273 | if(fh1NJets) fh1NJets->SetDirectory(0); |
39e2b057 | 1274 | |
1275 | f.Close(); | |
1276 | ||
1277 | // nJets per bin | |
1278 | ||
1279 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1280 | ||
1281 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
1282 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
1283 | ||
1284 | Int_t binLo = static_cast<Int_t>(fh1FFJetPtBgr->FindBin(jetPtLoLim)); | |
1285 | Int_t binUp = static_cast<Int_t>(fh1FFJetPtBgr->FindBin(jetPtUpLim)) - 1; | |
1286 | ||
1287 | Float_t nJetsBin = fh1FFJetPtBgr->Integral(binLo,binUp); | |
1288 | Double_t scaleF = 1; | |
1289 | ||
1290 | //if(strBgrID.Contains("Out2Jets")){ // scale by ratio 2 jets events / all events | |
1291 | // scaleF = fh1NJets->Integral(fh1NJets->FindBin(2),fh1NJets->GetNbinsX()) | |
1292 | // / fh1NJets->Integral(fh1NJets->FindBin(1),fh1NJets->GetNbinsX());} | |
1293 | ||
1294 | ||
ce55b926 | 1295 | if(strBgrID.Contains("OutAllJets") ){ // scale by ratio >3 jets events / all events |
1296 | ||
1297 | if(fh1NJets){ | |
1298 | scaleF = fh1NJets->Integral(fh1NJets->FindBin(4),fh1NJets->GetNbinsX()) | |
1299 | / fh1NJets->Integral(fh1NJets->FindBin(1),fh1NJets->GetNbinsX()); | |
1300 | } | |
1301 | else{ | |
1302 | Printf("%s:%d -- use bgr OutAllJets, but histo fhn1NJets not found",(char*)__FILE__,__LINE__); | |
1303 | } | |
39e2b057 | 1304 | } |
ce55b926 | 1305 | |
1306 | ||
39e2b057 | 1307 | fNJetsBgr->SetAt(nJetsBin*scaleF,i); |
1308 | ||
1309 | if(fDebug>0) Printf("bgr jet pt %d to %d: nJets %f, scaleF %.2f", | |
1310 | static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),nJetsBin,scaleF); | |
1311 | ||
1312 | } | |
1313 | ||
1314 | // projections: FF | |
1315 | ||
1316 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1317 | ||
1318 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
1319 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
1320 | ||
1321 | Int_t binLo = static_cast<Int_t>(fh2FFTrackPtBgr->GetXaxis()->FindBin(jetPtLoLim)); | |
1322 | Int_t binUp = static_cast<Int_t>(fh2FFTrackPtBgr->GetXaxis()->FindBin(jetPtUpLim))-1; | |
1323 | ||
1324 | if(binUp > fh2FFTrackPtBgr->GetNbinsX()){ | |
1325 | Printf("%s:%d -- jet pt range %0.3f exceeds histo limits",(char*)__FILE__,__LINE__,jetPtUpLim); | |
1326 | return; | |
1327 | } | |
1328 | ||
1329 | TString strNameBgrPt(Form("fh1BgrTrackPt%s_%02d_%02d",strID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1330 | TString strNameBgrZ(Form("fh1BgrZ%s_%02d_%02d",strID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1331 | TString strNameBgrXi(Form("fh1BgrXi%s_%02d_%02d",strID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1332 | ||
1333 | // appendix 'unbinned' to avoid histos with same name after rebinning | |
1334 | TH1F* projPt = (TH1F*) fh2FFTrackPtBgr->ProjectionY(strNameBgrPt+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
1335 | TH1F* projZ = (TH1F*) fh2FFZBgr->ProjectionY(strNameBgrZ+"_unBinned",binLo,binUp,"o"); | |
1336 | TH1F* projXi = (TH1F*) fh2FFXiBgr->ProjectionY(strNameBgrXi+"_unBinned",binLo,binUp,"o"); | |
1337 | ||
1338 | if(fNHistoBinsPt[i]) projPt = (TH1F*) projPt->Rebin(fNHistoBinsPt[i],strNameBgrPt,fHistoBinsPt[i]->GetArray()); | |
1339 | if(fNHistoBinsZ[i]) projZ = (TH1F*) projZ->Rebin(fNHistoBinsZ[i],strNameBgrZ,fHistoBinsZ[i]->GetArray()); | |
1340 | if(fNHistoBinsXi[i]) projXi = (TH1F*) projXi->Rebin(fNHistoBinsXi[i],strNameBgrXi,fHistoBinsXi[i]->GetArray()); | |
1341 | ||
1342 | projPt->SetNameTitle(strNameBgrPt,""); | |
1343 | projZ->SetNameTitle(strNameBgrZ,""); | |
1344 | projXi->SetNameTitle(strNameBgrXi,""); | |
1345 | ||
1346 | // raw bgr = corr level 0 | |
1347 | fCorrBgr[0]->AddCorrHistos(i,projPt,projZ,projXi); | |
ce55b926 | 1348 | } |
1349 | ||
1350 | delete fh1FFJetPtBgr; | |
1351 | if(fh1NJets) delete fh1NJets; | |
1352 | delete fh2FFTrackPtBgr; | |
1353 | delete fh2FFZBgr; | |
1354 | delete fh2FFXiBgr; | |
39e2b057 | 1355 | } |
1356 | ||
1357 | //_____________________________________________________________________________________________________________________ | |
1358 | void AliFragmentationFunctionCorrections::ReadRawBgrEmbedding(TString strfile, TString strID, TString strFFID) | |
1359 | { | |
1360 | // read raw FF - standard dir/list name | |
1361 | ||
b541fbca | 1362 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 1363 | TString strlist = "fracfunc_" + strID; |
1364 | ||
1365 | ReadRawBgrEmbedding(strfile,strdir,strlist,strFFID); | |
1366 | } | |
1367 | ||
1368 | //_______________________________________________________________________________________________________________________________________ | |
1369 | void AliFragmentationFunctionCorrections::ReadRawBgrEmbedding(TString strfile, TString strdir, TString strlist, TString strFFID) | |
1370 | { | |
1371 | // get raw FF from input file, project in jet pt slice | |
1372 | // for embedding, the bgr FF are taken from histos "fh1FFJetPtRecCuts", "fh2FFXiRecCuts" | |
1373 | // normalization done separately | |
1374 | ||
1375 | TString strBgrID = "BckgEmbed"; | |
1376 | TString strID = strBgrID + strFFID; | |
1377 | ||
1378 | TFile f(strfile,"READ"); | |
1379 | ||
1380 | if(!f.IsOpen()){ | |
1381 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
1382 | return; | |
1383 | } | |
1384 | ||
1385 | if(fDebug>0) Printf("%s:%d -- read Bgr %s from file %s ",(char*)__FILE__,__LINE__,strFFID.Data(),strfile.Data()); | |
1386 | ||
1387 | gDirectory->cd(strdir); | |
1388 | ||
1389 | TList* list = 0; | |
1390 | ||
1391 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
1392 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
1393 | return; | |
1394 | } | |
1395 | ||
1396 | TString hnameNJets = "fh1nRecJetsCuts"; | |
1397 | TString hnameJetPt(Form("fh1FFJetPt%s",strFFID.Data())); | |
1398 | TString hnameBgrTrackPt(Form("fh2FFTrackPt%s",strFFID.Data())); | |
1399 | TString hnameBgrZ(Form("fh2FFZ%s",strFFID.Data())); | |
1400 | TString hnameBgrXi(Form("fh2FFXi%s",strFFID.Data())); | |
1401 | ||
1402 | TH1F* fh1NJets = (TH1F*) list->FindObject(hnameNJets); // needed for normalization of bgr out of 2 jets | |
1403 | TH1F* fh1FFJetPtBgr = (TH1F*) list->FindObject(hnameJetPt); | |
1404 | TH2F* fh2FFTrackPtBgr = (TH2F*) list->FindObject(hnameBgrTrackPt); | |
1405 | TH2F* fh2FFZBgr = (TH2F*) list->FindObject(hnameBgrZ); | |
1406 | TH2F* fh2FFXiBgr = (TH2F*) list->FindObject(hnameBgrXi); | |
1407 | ||
1408 | if(!fh1FFJetPtBgr) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameJetPt.Data()); return; } | |
1409 | if(!fh1NJets) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameNJets.Data()); return; } | |
1410 | if(!fh2FFTrackPtBgr){ Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameBgrTrackPt.Data()); return; } | |
1411 | if(!fh2FFZBgr) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameBgrZ.Data()); return; } | |
1412 | if(!fh2FFXiBgr) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameBgrXi.Data()); return; } | |
1413 | ||
1414 | fh1FFJetPtBgr->SetDirectory(0); | |
1415 | fh1NJets->SetDirectory(0); | |
1416 | fh2FFTrackPtBgr->SetDirectory(0); | |
1417 | fh2FFZBgr->SetDirectory(0); | |
1418 | fh2FFXiBgr->SetDirectory(0); | |
1419 | ||
1420 | f.Close(); | |
1421 | ||
1422 | // nJets per bin | |
1423 | ||
1424 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1425 | ||
1426 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
1427 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
1428 | ||
1429 | Int_t binLo = static_cast<Int_t>(fh1FFJetPtBgr->FindBin(jetPtLoLim)); | |
1430 | Int_t binUp = static_cast<Int_t>(fh1FFJetPtBgr->FindBin(jetPtUpLim)) - 1; | |
1431 | ||
1432 | Float_t nJetsBin = fh1FFJetPtBgr->Integral(binLo,binUp); | |
1433 | Double_t scaleF = 1; | |
1434 | ||
1435 | fNJetsBgr->SetAt(nJetsBin*scaleF,i); | |
1436 | ||
1437 | if(fDebug>0) Printf("bgr jet pt %d to %d: nJets %f, scaleF %.2f", | |
1438 | static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),nJetsBin,scaleF); | |
1439 | ||
1440 | } | |
1441 | ||
1442 | // projections: FF | |
1443 | ||
1444 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1445 | ||
1446 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
1447 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
1448 | ||
1449 | Int_t binLo = static_cast<Int_t>(fh2FFTrackPtBgr->GetXaxis()->FindBin(jetPtLoLim)); | |
1450 | Int_t binUp = static_cast<Int_t>(fh2FFTrackPtBgr->GetXaxis()->FindBin(jetPtUpLim))-1; | |
1451 | ||
1452 | if(binUp > fh2FFTrackPtBgr->GetNbinsX()){ | |
1453 | Printf("%s:%d -- jet pt range %0.3f exceeds histo limits",(char*)__FILE__,__LINE__,jetPtUpLim); | |
1454 | return; | |
1455 | } | |
1456 | ||
1457 | TString strNameBgrPt(Form("fh1BgrTrackPt%s_%02d_%02d",strID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1458 | TString strNameBgrZ(Form("fh1BgrZ%s_%02d_%02d",strID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1459 | TString strNameBgrXi(Form("fh1BgrXi%s_%02d_%02d",strID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
1460 | ||
1461 | // appendix 'unbinned' to avoid histos with same name after rebinning | |
1462 | TH1F* projPt = (TH1F*) fh2FFTrackPtBgr->ProjectionY(strNameBgrPt+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
1463 | TH1F* projZ = (TH1F*) fh2FFZBgr->ProjectionY(strNameBgrZ+"_unBinned",binLo,binUp,"o"); | |
1464 | TH1F* projXi = (TH1F*) fh2FFXiBgr->ProjectionY(strNameBgrXi+"_unBinned",binLo,binUp,"o"); | |
1465 | ||
1466 | if(fNHistoBinsPt[i]) projPt = (TH1F*) projPt->Rebin(fNHistoBinsPt[i],strNameBgrPt,fHistoBinsPt[i]->GetArray()); | |
1467 | if(fNHistoBinsZ[i]) projZ = (TH1F*) projZ->Rebin(fNHistoBinsZ[i],strNameBgrZ,fHistoBinsZ[i]->GetArray()); | |
1468 | if(fNHistoBinsXi[i]) projXi = (TH1F*) projXi->Rebin(fNHistoBinsXi[i],strNameBgrXi,fHistoBinsXi[i]->GetArray()); | |
1469 | ||
1470 | projPt->SetNameTitle(strNameBgrPt,""); | |
1471 | projZ->SetNameTitle(strNameBgrZ,""); | |
1472 | projXi->SetNameTitle(strNameBgrXi,""); | |
1473 | ||
1474 | // raw bgr = corr level 0 | |
1475 | fCorrBgr[0]->AddCorrHistos(i,projPt,projZ,projXi); | |
ce55b926 | 1476 | } |
1477 | ||
1478 | delete fh1FFJetPtBgr; | |
1479 | delete fh1NJets; | |
1480 | delete fh2FFTrackPtBgr; | |
1481 | delete fh2FFZBgr; | |
1482 | delete fh2FFXiBgr; | |
39e2b057 | 1483 | } |
1484 | ||
1485 | ||
1486 | //__________________________________________________________________________________________________________ | |
1487 | void AliFragmentationFunctionCorrections::WriteOutput(TString strfile, TString strdir, Bool_t updateOutfile) | |
1488 | { | |
1489 | // write histos to file | |
1490 | // skip histos with 0 entries | |
1491 | ||
1492 | TString outfileOption = "RECREATE"; | |
1493 | if(updateOutfile) outfileOption = "UPDATE"; | |
1494 | ||
1495 | TFile f(strfile,outfileOption); | |
1496 | ||
1497 | if(!f.IsOpen()){ | |
1498 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
1499 | return; | |
1500 | } | |
1501 | ||
1502 | if(fDebug>0) Printf("%s:%d -- write FF to file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
1503 | ||
1504 | if(strdir && strdir.Length()){ | |
1505 | TDirectory* dir = f.mkdir(strdir); | |
1506 | dir->cd(); | |
1507 | } | |
1508 | ||
1509 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1510 | ||
1511 | for(Int_t c=0; c<fNCorrectionLevels; c++) if(fCorrFF[c]->GetTrackPt(i)->GetEntries()) fCorrFF[c]->GetTrackPt(i)->Write(); | |
1512 | for(Int_t c=0; c<fNCorrectionLevels; c++) if(fCorrFF[c]->GetZ(i)->GetEntries()) fCorrFF[c]->GetZ(i)->Write(); | |
1513 | for(Int_t c=0; c<fNCorrectionLevels; c++) if(fCorrFF[c]->GetXi(i)->GetEntries()) fCorrFF[c]->GetXi(i)->Write(); | |
1514 | ||
1515 | if(fh1FFXiShift[i]->GetEntries()) fh1FFXiShift[i]->Write(); | |
1516 | ||
1517 | for(Int_t c=0; c<fNCorrectionLevelsBgr; c++) if(fCorrBgr[c]->GetTrackPt(i)->GetEntries()) fCorrBgr[c]->GetTrackPt(i)->Write(); | |
1518 | for(Int_t c=0; c<fNCorrectionLevelsBgr; c++) if(fCorrBgr[c]->GetZ(i)->GetEntries()) fCorrBgr[c]->GetZ(i)->Write(); | |
1519 | for(Int_t c=0; c<fNCorrectionLevelsBgr; c++) if(fCorrBgr[c]->GetXi(i)->GetEntries()) fCorrBgr[c]->GetXi(i)->Write(); | |
1520 | ||
1521 | ||
1522 | if(fh1FFTrackPtBackFolded[i] && fh1FFTrackPtBackFolded[i]->GetEntries()) fh1FFTrackPtBackFolded[i]->Write(); | |
1523 | if(fh1FFZBackFolded[i] && fh1FFZBackFolded[i]->GetEntries()) fh1FFZBackFolded[i]->Write(); | |
1524 | if(fh1FFXiBackFolded[i] && fh1FFXiBackFolded[i]->GetEntries()) fh1FFXiBackFolded[i]->Write(); | |
1525 | ||
1526 | ||
1527 | if(fh1FFRatioTrackPtFolded[i] && fh1FFRatioTrackPtFolded[i]->GetEntries()) fh1FFRatioTrackPtFolded[i]->Write(); | |
1528 | if(fh1FFRatioZFolded[i] && fh1FFRatioZFolded[i]->GetEntries()) fh1FFRatioZFolded[i]->Write(); | |
1529 | if(fh1FFRatioXiFolded[i] && fh1FFRatioXiFolded[i]->GetEntries()) fh1FFRatioXiFolded[i]->Write(); | |
1530 | ||
1531 | if(fh1FFRatioTrackPtBackFolded[i] && fh1FFRatioTrackPtBackFolded[i]->GetEntries()) fh1FFRatioTrackPtBackFolded[i]->Write(); | |
1532 | if(fh1FFRatioZBackFolded[i] && fh1FFRatioZBackFolded[i]->GetEntries()) fh1FFRatioZBackFolded[i]->Write(); | |
1533 | if(fh1FFRatioXiBackFolded[i] &&fh1FFRatioXiBackFolded[i]->GetEntries()) fh1FFRatioXiBackFolded[i]->Write(); | |
1534 | ||
ce55b926 | 1535 | if(fh1FoldingCorrPt[i] && fh1FoldingCorrPt[i]->GetEntries()) fh1FoldingCorrPt[i]->Write(); // TEST!!! |
1536 | if(fh1FoldingCorrZ[i] && fh1FoldingCorrZ[i]->GetEntries()) fh1FoldingCorrZ[i]->Write(); // TEST!!! | |
1537 | if(fh1FoldingCorrXi[i] && fh1FoldingCorrXi[i]->GetEntries()) fh1FoldingCorrXi[i]->Write(); // TEST!!! | |
39e2b057 | 1538 | } |
1539 | ||
1540 | // inclusive track pt | |
1541 | ||
1542 | for(Int_t c=0; c<fNCorrectionLevelsSinglePt; c++) if(fCorrSinglePt[c]->GetTrackPt(0)->GetEntries()) fCorrSinglePt[c]->GetTrackPt(0)->Write(); | |
1543 | if(fh1SingleTrackPtBackFolded) fh1SingleTrackPtBackFolded->Write(); | |
1544 | if(fh1RatioSingleTrackPtFolded) fh1RatioSingleTrackPtFolded->Write(); | |
1545 | if(fh1RatioSingleTrackPtBackFolded) fh1RatioSingleTrackPtBackFolded->Write(); | |
1546 | ||
ce55b926 | 1547 | |
1548 | ||
1549 | ||
39e2b057 | 1550 | f.Close(); |
1551 | } | |
1552 | ||
1553 | //____________________________________________________________________________________________________________________________________ | |
1554 | THnSparse* AliFragmentationFunctionCorrections::TH1toSparse(const TH1F* hist, TString strName, TString strTit, const Bool_t fillConst) | |
1555 | { | |
1556 | // copy 1-dimensional histo to THnSparse | |
1557 | // if fillConst TRUE, create THnSparse with same binning as hist but all entries = 1 | |
1558 | // histos with variable bin size are supported | |
1559 | ||
1560 | // note: function returns pointer to 'new' THnSparse on heap, object needs to be deleted by user | |
1561 | ||
1562 | THnSparseF* fhnHist; | |
1563 | ||
1564 | Int_t nBins = hist->GetXaxis()->GetNbins(); | |
1565 | Int_t nBinsVec[1] = { nBins }; | |
1566 | ||
1567 | const Double_t* binsVec = hist->GetXaxis()->GetXbins()->GetArray(); | |
1568 | ||
1569 | if(binsVec){ // binsVec only neq NULL if histo was rebinned before | |
1570 | ||
1571 | fhnHist = new THnSparseF(strName,strTit,1,nBinsVec/*,binMinVec,binMaxVec*/); | |
1572 | fhnHist->SetBinEdges(0,binsVec); | |
1573 | } | |
1574 | else{ // uniform bin size | |
1575 | ||
1576 | Double_t xMin = hist->GetXaxis()->GetXmin(); | |
1577 | Double_t xMax = hist->GetXaxis()->GetXmax(); | |
1578 | ||
1579 | Double_t binMinVec[1] = { xMin }; | |
1580 | Double_t binMaxVec[1] = { xMax }; | |
1581 | ||
1582 | fhnHist = new THnSparseF(strName,strTit,1,nBinsVec,binMinVec,binMaxVec); | |
1583 | } | |
1584 | ||
1585 | ||
1586 | for(Int_t bin=1; bin<=nBins; bin++){ | |
1587 | ||
1588 | Double_t binCenter = fhnHist->GetAxis(0)->GetBinCenter(bin); | |
1589 | ||
1590 | Double_t binCoord[] = {binCenter}; | |
1591 | fhnHist->Fill(binCoord,1); // initially need to create the bin | |
1592 | ||
1593 | Long64_t binIndex = fhnHist->GetBin(binCoord); | |
1594 | ||
1595 | Double_t cont = hist->GetBinContent(bin); | |
1596 | Double_t err = hist->GetBinError(bin); | |
1597 | ||
1598 | if(fillConst){ | |
1599 | cont = 1; | |
1600 | err = 0; | |
1601 | } | |
1602 | ||
1603 | fhnHist->SetBinContent(binIndex,cont); | |
1604 | fhnHist->SetBinError(binIndex,err); | |
1605 | } | |
1606 | ||
1607 | return fhnHist; | |
1608 | } | |
1609 | ||
1610 | //______________________________________________________________________________________________________________________________________________ | |
ce55b926 | 1611 | TH1F* AliFragmentationFunctionCorrections::Unfold(THnSparse* hnHist, const THnSparse* hnResponse, const THnSparse* hnEff, const Int_t nIter, |
1612 | const Bool_t useCorrelatedErrors, const THnSparse* hnPrior) | |
39e2b057 | 1613 | { |
1614 | // unfold input histo | |
1615 | ||
1616 | AliCFUnfolding unfolding("unfolding","",1,hnResponse,hnEff,hnHist,hnPrior); // arg3: nVar; hnEff required, hnPrior not (defaults to 0x0) | |
1617 | unfolding.SetMaxNumberOfIterations(nIter); | |
1618 | // unfolding.SetMaxChi2PerDOF(1.e-07); // OBSOLETE !!! | |
1619 | // if(useSmoothing) unfolding.UseSmoothing(); | |
1620 | ||
1621 | if(useCorrelatedErrors) unfolding.SetUseCorrelatedErrors(); | |
1622 | unfolding.Unfold(); | |
1623 | ||
1624 | THnSparse* unfolded = unfolding.GetUnfolded(); | |
1625 | ||
1626 | TString hnameUnf = hnHist->GetName(); | |
1627 | hnameUnf.Append("_unf"); | |
1628 | unfolded->SetNameTitle(hnameUnf,hnHist->GetTitle()); | |
ce55b926 | 1629 | |
1630 | TH1F* h1Unfolded = (TH1F*) unfolded->Projection(0); | |
1631 | h1Unfolded->SetNameTitle(hnHist->GetName(),hnHist->GetTitle()); | |
1632 | ||
1633 | return h1Unfolded; | |
39e2b057 | 1634 | } |
1635 | ||
1636 | //___________________________________________________________________________________________________________________________ | |
1637 | void AliFragmentationFunctionCorrections::UnfoldHistos(const Int_t nIter, const Bool_t useCorrelatedErrors, const Int_t type) | |
1638 | { | |
1639 | // loop over jet pt slices and unfold dN/dpt spectra | |
1640 | ||
1641 | TString labelCorr = fCorrFF[fNCorrectionLevels-1]->GetLabel(); | |
1642 | if(!labelCorr.Contains("unfold")) AddCorrectionLevel("unfold"); | |
1643 | ||
1644 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1645 | ||
1646 | TH1F* hist = 0; | |
1aa4f09f | 1647 | if(type == kFlagPt) hist = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i); // level -2: before unfolding, level -1: unfolded |
1648 | else if(type == kFlagZ) hist = fCorrFF[fNCorrectionLevels-2]->GetZ(i); // level -2: before unfolding, level -1: unfolded | |
1649 | else if(type == kFlagXi) hist = fCorrFF[fNCorrectionLevels-2]->GetXi(i); // level -2: before unfolding, level -1: unfolded | |
6daac008 | 1650 | else{ |
1651 | Printf("%s%d unknown type",(char*)__FILE__,__LINE__); | |
1652 | return; | |
1653 | } | |
b6c0e285 | 1654 | |
1655 | if(!hist){ | |
1656 | Printf("%s%d no histo found ",(char*)__FILE__,__LINE__); | |
1657 | return; | |
1658 | } | |
1659 | ||
39e2b057 | 1660 | |
1661 | THnSparse* hnResponse = 0; | |
6daac008 | 1662 | if(type == kFlagPt) hnResponse = fhnResponsePt[i]; |
1aa4f09f | 1663 | else if(type == kFlagZ) hnResponse = fhnResponseZ[i]; |
1664 | else if(type == kFlagXi) hnResponse = fhnResponseXi[i]; | |
39e2b057 | 1665 | |
1666 | TH1F* hPrior = 0; | |
1667 | if(type == kFlagPt && fh1FFTrackPtPrior[i] && ((TString(fh1FFTrackPtPrior[i]->GetName())).Length() > 0) ) hPrior = fh1FFTrackPtPrior[i]; | |
a5592cfa | 1668 | else if(type == kFlagZ && fh1FFZPrior[i] && ((TString(fh1FFZPrior[i]->GetName())).Length() > 0) ) hPrior = fh1FFZPrior[i]; |
1669 | else if(type == kFlagXi && fh1FFXiPrior[i] && ((TString(fh1FFXiPrior[i]->GetName())).Length() > 0) ) hPrior = fh1FFXiPrior[i]; | |
1aa4f09f | 1670 | |
39e2b057 | 1671 | |
191e5919 | 1672 | TString histNameTHn; |
b6c0e285 | 1673 | histNameTHn = hist->GetName(); |
1674 | histNameTHn.ReplaceAll("TH1","THn"); | |
1675 | ||
39e2b057 | 1676 | |
1677 | TString priorNameTHn; | |
1678 | if(hPrior){ | |
1679 | priorNameTHn = hPrior->GetName(); | |
1680 | priorNameTHn.ReplaceAll("TH1","THn"); | |
1681 | } | |
1682 | ||
191e5919 | 1683 | TString histNameBackFolded; |
b6c0e285 | 1684 | histNameBackFolded = hist->GetName(); |
39e2b057 | 1685 | histNameBackFolded.Append("_backfold"); |
b6c0e285 | 1686 | |
191e5919 | 1687 | TString histNameRatioFolded; |
b6c0e285 | 1688 | histNameRatioFolded = hist->GetName(); |
1689 | histNameRatioFolded.ReplaceAll("fh1FF","hRatioFF"); | |
1690 | ||
39e2b057 | 1691 | histNameRatioFolded.Append("_unfold"); |
1692 | ||
191e5919 | 1693 | TString histNameRatioBackFolded; |
b6c0e285 | 1694 | histNameRatioBackFolded = hist->GetName(); |
1695 | histNameRatioBackFolded.ReplaceAll("fh1FF","hRatioFF"); | |
39e2b057 | 1696 | histNameRatioBackFolded.Append("_backfold"); |
1697 | ||
1698 | THnSparse* hnHist = TH1toSparse(hist,histNameTHn,hist->GetTitle()); | |
1699 | THnSparse* hnFlatEfficiency = TH1toSparse(hist,"fhnEfficiency","eff",kTRUE); // could optionally also use real eff | |
1700 | THnSparse* hnPrior = 0; | |
1701 | if(hPrior) hnPrior = TH1toSparse(hPrior,priorNameTHn,hPrior->GetTitle()); | |
b6c0e285 | 1702 | |
ce55b926 | 1703 | //THnSparse* hnUnfolded |
1704 | // = Unfold(hnHist,hnResponse,hnFlatEfficiency,nIter,useCorrelatedErrors,hnPrior); | |
1705 | ||
1706 | //TH1F* hUnfolded = (TH1F*) hnUnfolded->Projection(0); | |
1707 | //hUnfolded->SetNameTitle(hist->GetName(),hist->GetTitle()); | |
1708 | ||
1709 | TH1F* hUnfolded | |
39e2b057 | 1710 | = Unfold(hnHist,hnResponse,hnFlatEfficiency,nIter,useCorrelatedErrors,hnPrior); |
1711 | ||
ce55b926 | 1712 | //TH1F* hUnfolded = (TH1F*) hnUnfolded->Projection(0); |
1713 | //hUnfolded->SetNameTitle(hist->GetName(),hist->GetTitle()); | |
1714 | ||
1715 | // errors | |
1716 | for(Int_t bin=1; bin<=hist->GetNbinsX(); bin++){ | |
1717 | ||
1718 | Double_t contOrg = hist->GetBinContent(bin); | |
1719 | Double_t errOrg = hist->GetBinError(bin); | |
1720 | ||
1721 | Double_t contUnf = hUnfolded->GetBinContent(bin); | |
1722 | //Double_t errUnf = hUnfolded->GetBinError(bin); | |
1723 | ||
1724 | Double_t relErrOrg = 0; | |
1725 | if(contOrg) relErrOrg = errOrg/contOrg; | |
1726 | ||
1727 | // std::cout<<" cont original "<<contOrg<<" err original "<<errOrg<<std::endl; | |
1728 | // std::cout<<" cont unf "<<contUnf<<" errUnf"<<errUnf<<std::endl; | |
1729 | // std::cout<<" err/cont original "<<relErrOrg<<std::endl; | |
1730 | // if(contUnf) std::cout<<" err/conf unf "<<errUnf/contUnf<<std::endl; | |
1731 | ||
1732 | hUnfolded->SetBinError(bin,relErrOrg*contUnf); | |
1733 | ||
1734 | // if(hUnfolded->GetBinContent(bin)){ | |
1735 | // std::cout<<" modified err unfolded "<<hUnfolded->GetBinError(bin)/hUnfolded->GetBinContent(bin)<<std::endl; | |
1736 | // } | |
1737 | } | |
39e2b057 | 1738 | |
ce55b926 | 1739 | |
39e2b057 | 1740 | if(type == kFlagPt) fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hUnfolded,0,0); |
1741 | if(type == kFlagZ) fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,0,hUnfolded,0); | |
1742 | if(type == kFlagXi) fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,0,0,hUnfolded); | |
1743 | ||
1744 | // backfolding: apply response matrix to unfolded spectrum | |
6daac008 | 1745 | TH1F* hBackFolded = ApplyResponse(hUnfolded,hnResponse); |
b6c0e285 | 1746 | hBackFolded->SetNameTitle(histNameBackFolded,hist->GetTitle()); |
39e2b057 | 1747 | |
1748 | if(type == kFlagPt) fh1FFTrackPtBackFolded[i] = hBackFolded; | |
1749 | if(type == kFlagZ) fh1FFZBackFolded[i] = hBackFolded; | |
1750 | if(type == kFlagXi) fh1FFXiBackFolded[i] = hBackFolded; | |
1751 | ||
1752 | // ratio unfolded to original histo | |
1753 | TH1F* hRatioUnfolded = (TH1F*) hUnfolded->Clone(histNameRatioFolded); | |
1754 | hRatioUnfolded->Reset(); | |
b6c0e285 | 1755 | hRatioUnfolded->Divide(hUnfolded,hist,1,1,"B"); |
39e2b057 | 1756 | |
1757 | if(type == kFlagPt) fh1FFRatioTrackPtFolded[i] = hRatioUnfolded; | |
1758 | if(type == kFlagZ) fh1FFRatioZFolded[i] = hRatioUnfolded; | |
1759 | if(type == kFlagXi) fh1FFRatioXiFolded[i] = hRatioUnfolded; | |
1760 | ||
1761 | ||
1762 | // ratio backfolded to original histo | |
1763 | TH1F* hRatioBackFolded = (TH1F*) hBackFolded->Clone(histNameRatioBackFolded); | |
1764 | hRatioBackFolded->Reset(); | |
1765 | hRatioBackFolded->Divide(hBackFolded,hist,1,1,"B"); | |
1766 | ||
1767 | if(type == kFlagPt) fh1FFRatioTrackPtBackFolded[i] = hRatioBackFolded; | |
1768 | if(type == kFlagZ) fh1FFRatioZBackFolded[i] = hRatioBackFolded; | |
1769 | if(type == kFlagXi) fh1FFRatioXiBackFolded[i] = hRatioBackFolded; | |
1770 | ||
1771 | delete hnHist; | |
1772 | delete hnFlatEfficiency; | |
39e2b057 | 1773 | } |
1774 | } | |
1775 | ||
1776 | //_____________________________________________________________________________________________________ | |
1777 | void AliFragmentationFunctionCorrections::UnfoldPt(const Int_t nIter, const Bool_t useCorrelatedErrors) | |
1778 | { | |
1779 | ||
1780 | Int_t type = kFlagPt; | |
1781 | UnfoldHistos(nIter, useCorrelatedErrors, type); | |
1782 | } | |
1783 | ||
1784 | //_____________________________________________________________________________________________________ | |
1785 | void AliFragmentationFunctionCorrections::UnfoldZ(const Int_t nIter, const Bool_t useCorrelatedErrors) | |
1786 | { | |
1787 | ||
1788 | Int_t type = kFlagZ; | |
1789 | UnfoldHistos(nIter, useCorrelatedErrors, type); | |
1790 | } | |
1791 | ||
1792 | //_____________________________________________________________________________________________________ | |
1793 | void AliFragmentationFunctionCorrections::UnfoldXi(const Int_t nIter, const Bool_t useCorrelatedErrors) | |
1794 | { | |
1795 | ||
1796 | Int_t type = kFlagXi; | |
1797 | UnfoldHistos(nIter, useCorrelatedErrors, type); | |
1798 | } | |
1799 | ||
ce55b926 | 1800 | |
39e2b057 | 1801 | //______________________________________________________________________________________________ |
1802 | TH1F* AliFragmentationFunctionCorrections::ApplyResponse(const TH1F* hist, THnSparse* hnResponse) | |
1803 | { | |
1804 | // apply (multiply) response matrix to hist | |
1805 | ||
1806 | TH1F* hOut = new TH1F(*hist); | |
1807 | hOut->Reset(); | |
1808 | ||
1809 | const Int_t axisM = 0; | |
1810 | const Int_t axisT = 1; | |
1811 | ||
1812 | Int_t nBinsM = hnResponse->GetAxis(axisM)->GetNbins(); | |
1813 | Int_t nBinsT = hnResponse->GetAxis(axisT)->GetNbins(); | |
1814 | ||
1815 | // response matrix normalization | |
1816 | // do it in this function and not when reading response, since for 'proper' normalization errors are difficult to assign | |
1817 | // so for unfolding proper we leave it to CORRFW ... | |
1818 | ||
ce55b926 | 1819 | Double_t normFacResponse[nBinsT+1]; |
39e2b057 | 1820 | |
1821 | for(Int_t iT=1; iT<=nBinsT; iT++){ | |
1822 | ||
1823 | Double_t sumResp = 0; | |
1824 | ||
1825 | for(Int_t iM=1; iM<=nBinsM; iM++){ | |
1826 | ||
1827 | Double_t coordM = hnResponse->GetAxis(axisM)->GetBinCenter(iM); | |
1828 | Double_t coordT = hnResponse->GetAxis(axisT)->GetBinCenter(iT); | |
1829 | ||
1830 | Double_t binCoord[] = {coordM,coordT}; | |
1831 | ||
1832 | Long64_t binIndex = hnResponse->GetBin(binCoord); | |
1833 | ||
1834 | Double_t resp = hnResponse->GetBinContent(binIndex); | |
1835 | ||
1836 | sumResp += resp; | |
1837 | } | |
1838 | ||
1839 | normFacResponse[iT] = 0; | |
1840 | if(sumResp) normFacResponse[iT] = 1/sumResp; | |
1841 | } | |
1842 | ||
1843 | ||
1844 | ||
1845 | for(Int_t iM=1; iM<=nBinsM; iM++){ | |
1846 | ||
1847 | Double_t contM = 0; | |
1848 | ||
1849 | for(Int_t iT=1; iT<=nBinsT; iT++){ | |
1850 | ||
1851 | Double_t contT = hist->GetBinContent(iT); | |
1852 | ||
1853 | Double_t coordM = hnResponse->GetAxis(axisM)->GetBinCenter(iM); | |
1854 | Double_t coordT = hnResponse->GetAxis(axisT)->GetBinCenter(iT); | |
1855 | ||
1856 | Double_t binCoord[] = {coordM,coordT}; | |
1857 | ||
1858 | Long64_t binIndex = hnResponse->GetBin(binCoord); | |
1859 | ||
1860 | Double_t resp = hnResponse->GetBinContent(binIndex); | |
1861 | ||
1862 | contM += resp*normFacResponse[iT]*contT; | |
1863 | } | |
1864 | ||
1865 | hOut->SetBinContent(iM,contM); | |
1866 | } | |
1867 | ||
1868 | return hOut; | |
1869 | } | |
1870 | ||
1871 | //_______________________________________________________________________________________________________ | |
1872 | void AliFragmentationFunctionCorrections::ReadEfficiency(TString strfile, TString strdir, TString strlist) | |
1873 | { | |
1874 | // read reconstruction efficiency from file | |
1875 | // argument strlist optional - read from directory strdir if not specified | |
1876 | ||
1877 | // temporary histos to hold histos from file | |
1878 | TH1F* hEffPt[fNJetPtSlices]; | |
1879 | TH1F* hEffZ[fNJetPtSlices]; | |
1880 | TH1F* hEffXi[fNJetPtSlices]; | |
1881 | ||
1882 | for(Int_t i=0; i<fNJetPtSlices; i++) hEffPt[i] = 0; | |
1883 | for(Int_t i=0; i<fNJetPtSlices; i++) hEffZ[i] = 0; | |
1884 | for(Int_t i=0; i<fNJetPtSlices; i++) hEffXi[i] = 0; | |
1885 | ||
1886 | TFile f(strfile,"READ"); | |
1887 | ||
1888 | if(!f.IsOpen()){ | |
1889 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
1890 | return; | |
1891 | } | |
1892 | ||
1893 | if(fDebug>0) Printf("%s:%d -- read efficiencies from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
1894 | ||
1895 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
1896 | ||
1897 | TList* list = 0; | |
1898 | ||
1899 | if(strlist && strlist.Length()){ | |
1900 | ||
1901 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
1902 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
1903 | return; | |
1904 | } | |
1905 | } | |
1906 | ||
1907 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1908 | ||
1909 | Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i)); | |
1910 | Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1)); | |
1911 | ||
1912 | TString strNameEffPt(Form("hEffPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
1913 | TString strNameEffZ(Form("hEffZ_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
1914 | TString strNameEffXi(Form("hEffXi_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
1915 | ||
1916 | ||
1917 | if(list){ | |
1918 | hEffPt[i] = (TH1F*) list->FindObject(strNameEffPt); | |
1919 | hEffZ[i] = (TH1F*) list->FindObject(strNameEffZ); | |
1920 | hEffXi[i] = (TH1F*) list->FindObject(strNameEffXi); | |
1921 | } | |
1922 | else{ | |
1923 | hEffPt[i] = (TH1F*) gDirectory->Get(strNameEffPt); | |
1924 | hEffZ[i] = (TH1F*) gDirectory->Get(strNameEffZ); | |
1925 | hEffXi[i] = (TH1F*) gDirectory->Get(strNameEffXi); | |
1926 | } | |
1927 | ||
1928 | if(!hEffPt[i]){ | |
1929 | Printf("%s:%d -- error retrieving efficiency %s", (char*)__FILE__,__LINE__,strNameEffPt.Data()); | |
1930 | } | |
1931 | ||
1932 | if(!hEffZ[i]){ | |
1933 | Printf("%s:%d -- error retrieving efficiency %s", (char*)__FILE__,__LINE__,strNameEffZ.Data()); | |
1934 | } | |
1935 | ||
1936 | if(!hEffXi[i]){ | |
1937 | Printf("%s:%d -- error retrieving efficiency %s", (char*)__FILE__,__LINE__,strNameEffXi.Data()); | |
1938 | } | |
1939 | ||
1940 | ||
1941 | if(fNHistoBinsPt[i]) hEffPt[i] = (TH1F*) hEffPt[i]->Rebin(fNHistoBinsPt[i],strNameEffPt+"_rebin",fHistoBinsPt[i]->GetArray()); | |
1942 | if(fNHistoBinsZ[i]) hEffZ[i] = (TH1F*) hEffZ[i]->Rebin(fNHistoBinsZ[i],strNameEffZ+"_rebin",fHistoBinsZ[i]->GetArray()); | |
1943 | if(fNHistoBinsXi[i]) hEffXi[i] = (TH1F*) hEffXi[i]->Rebin(fNHistoBinsXi[i],strNameEffXi+"_rebin",fHistoBinsXi[i]->GetArray()); | |
1944 | ||
1945 | if(hEffPt[i]) hEffPt[i]->SetDirectory(0); | |
1946 | if(hEffZ[i]) hEffZ[i]->SetDirectory(0); | |
1947 | if(hEffXi[i]) hEffXi[i]->SetDirectory(0); | |
1948 | ||
1949 | } // jet slices loop | |
1950 | ||
1951 | f.Close(); | |
1952 | ||
1953 | for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos | |
1954 | if(hEffPt[i]) new(fh1EffPt[i]) TH1F(*hEffPt[i]); | |
1955 | if(hEffZ[i]) new(fh1EffZ[i]) TH1F(*hEffZ[i]); | |
1956 | if(hEffXi[i]) new(fh1EffXi[i]) TH1F(*hEffXi[i]); | |
1957 | } | |
1958 | } | |
1959 | ||
1960 | //___________________________________________________________________________________________________________ | |
1961 | void AliFragmentationFunctionCorrections::ReadBgrEfficiency(TString strfile, TString strdir, TString strlist) | |
1962 | { | |
1963 | // read bgr eff from file | |
1964 | // argument strlist optional - read from directory strdir if not specified | |
1965 | ||
1966 | TH1F* hEffPtBgr[fNJetPtSlices]; | |
1967 | TH1F* hEffZBgr [fNJetPtSlices]; | |
1968 | TH1F* hEffXiBgr[fNJetPtSlices]; | |
1969 | ||
1970 | for(Int_t i=0; i<fNJetPtSlices; i++) hEffPtBgr[i] = 0; | |
1971 | for(Int_t i=0; i<fNJetPtSlices; i++) hEffZBgr[i] = 0; | |
1972 | for(Int_t i=0; i<fNJetPtSlices; i++) hEffXiBgr[i] = 0; | |
1973 | ||
1974 | ||
1975 | TFile f(strfile,"READ"); | |
1976 | ||
1977 | if(!f.IsOpen()){ | |
1978 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
1979 | return; | |
1980 | } | |
1981 | ||
1982 | if(fDebug>0) Printf("%s:%d -- read bgr efficiencies from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
1983 | ||
1984 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
1985 | ||
1986 | TList* list = 0; | |
1987 | ||
1988 | if(strlist && strlist.Length()){ | |
1989 | ||
1990 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
1991 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
1992 | return; | |
1993 | } | |
1994 | } | |
1995 | ||
1996 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
1997 | ||
1998 | Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i)); | |
1999 | Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1)); | |
2000 | ||
2001 | TString strNameEffPtBgr(Form("hEffPtBgr%02dto%02d",jetPtLoLim,jetPtUpLim)); | |
2002 | TString strNameEffZBgr(Form("hEffZBgr%02dto%02d",jetPtLoLim,jetPtUpLim)); | |
2003 | TString strNameEffXiBgr(Form("hEffXiBgr%02dto%02d",jetPtLoLim,jetPtUpLim)); | |
2004 | ||
2005 | ||
2006 | if(list){ | |
2007 | hEffPtBgr[i] = (TH1F*) list->FindObject(strNameEffPtBgr); | |
2008 | hEffZBgr[i] = (TH1F*) list->FindObject(strNameEffZBgr); | |
2009 | hEffXiBgr[i] = (TH1F*) list->FindObject(strNameEffXiBgr); | |
2010 | } | |
2011 | else{ | |
2012 | hEffPtBgr[i] = (TH1F*) gDirectory->Get(strNameEffPtBgr); | |
2013 | hEffZBgr[i] = (TH1F*) gDirectory->Get(strNameEffZBgr); | |
2014 | hEffXiBgr[i] = (TH1F*) gDirectory->Get(strNameEffXiBgr); | |
2015 | } | |
2016 | ||
2017 | if(!hEffPtBgr[i]){ | |
2018 | Printf("%s:%d -- error retrieving efficiency %s", (char*)__FILE__,__LINE__,strNameEffPtBgr.Data()); | |
2019 | } | |
2020 | ||
2021 | if(!hEffZBgr[i]){ | |
2022 | Printf("%s:%d -- error retrieving efficiency %s", (char*)__FILE__,__LINE__,strNameEffZBgr.Data()); | |
2023 | } | |
2024 | ||
2025 | if(!hEffXiBgr[i]){ | |
2026 | Printf("%s:%d -- error retrieving efficiency %s", (char*)__FILE__,__LINE__,strNameEffXiBgr.Data()); | |
2027 | } | |
2028 | ||
2029 | ||
2030 | if(fNHistoBinsPt[i]) hEffPtBgr[i] = (TH1F*) hEffPtBgr[i]->Rebin(fNHistoBinsPt[i],strNameEffPtBgr+"_rebin",fHistoBinsPt[i]->GetArray()); | |
2031 | if(fNHistoBinsZ[i]) hEffZBgr[i] = (TH1F*) hEffZBgr[i]->Rebin(fNHistoBinsZ[i],strNameEffZBgr+"_rebin",fHistoBinsZ[i]->GetArray()); | |
2032 | if(fNHistoBinsXi[i]) hEffXiBgr[i] = (TH1F*) hEffXiBgr[i]->Rebin(fNHistoBinsXi[i],strNameEffXiBgr+"_rebin",fHistoBinsXi[i]->GetArray()); | |
2033 | ||
2034 | if(hEffPtBgr[i]) hEffPtBgr[i]->SetDirectory(0); | |
2035 | if(hEffZBgr[i]) hEffZBgr[i]->SetDirectory(0); | |
2036 | if(hEffXiBgr[i]) hEffXiBgr[i]->SetDirectory(0); | |
2037 | ||
2038 | } // jet slices loop | |
2039 | ||
2040 | f.Close(); | |
2041 | ||
2042 | for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos | |
2043 | if(hEffPtBgr[i]) new(fh1EffBgrPt[i]) TH1F(*hEffPtBgr[i]); | |
2044 | if(hEffZBgr[i]) new(fh1EffBgrZ[i]) TH1F(*hEffZBgr[i]); | |
2045 | if(hEffXiBgr[i]) new(fh1EffBgrXi[i]) TH1F(*hEffXiBgr[i]); | |
2046 | } | |
2047 | } | |
2048 | ||
2049 | // ________________________________________________ | |
2050 | void AliFragmentationFunctionCorrections::EffCorr() | |
2051 | { | |
2052 | // apply efficiency correction | |
2053 | ||
2054 | AddCorrectionLevel("eff"); | |
2055 | ||
2056 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
2057 | ||
2058 | TH1F* histPt = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i); | |
2059 | TH1F* histZ = fCorrFF[fNCorrectionLevels-2]->GetZ(i); | |
2060 | TH1F* histXi = fCorrFF[fNCorrectionLevels-2]->GetXi(i); | |
2061 | ||
2062 | TString histNamePt = histPt->GetName(); | |
2063 | TString histNameZ = histZ->GetName(); | |
2064 | TString histNameXi = histXi->GetName(); | |
2065 | ||
2066 | ||
2067 | TH1F* hFFTrackPtEffCorr = (TH1F*) histPt->Clone(histNamePt); | |
2068 | hFFTrackPtEffCorr->Divide(histPt,fh1EffPt[i],1,1,""); | |
2069 | ||
2070 | TH1F* hFFZEffCorr = (TH1F*) histZ->Clone(histNameZ); | |
2071 | hFFZEffCorr->Divide(histZ,fh1EffZ[i],1,1,""); | |
2072 | ||
2073 | TH1F* hFFXiEffCorr = (TH1F*) histXi->Clone(histNameXi); | |
2074 | hFFXiEffCorr->Divide(histXi,fh1EffXi[i],1,1,""); | |
2075 | ||
2076 | fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hFFTrackPtEffCorr,hFFZEffCorr,hFFXiEffCorr); | |
2077 | } | |
2078 | } | |
2079 | ||
2080 | //___________________________________________________ | |
2081 | void AliFragmentationFunctionCorrections::EffCorrBgr() | |
2082 | { | |
2083 | // apply efficiency correction to bgr distributions | |
2084 | ||
2085 | AddCorrectionLevelBgr("eff"); | |
2086 | ||
2087 | Printf("%s:%d -- apply efficiency correction, corrLevel %d",(char*)__FILE__,__LINE__,fNCorrectionLevels-1); | |
2088 | ||
2089 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
2090 | ||
2091 | TH1F* histPt = fCorrBgr[fNCorrectionLevelsBgr-2]->GetTrackPt(i); | |
2092 | TH1F* histZ = fCorrBgr[fNCorrectionLevelsBgr-2]->GetZ(i); | |
2093 | TH1F* histXi = fCorrBgr[fNCorrectionLevelsBgr-2]->GetXi(i); | |
2094 | ||
2095 | TString histNamePt = histPt->GetName(); | |
2096 | TString histNameZ = histZ->GetName(); | |
2097 | TString histNameXi = histXi->GetName(); | |
2098 | ||
2099 | ||
2100 | TH1F* hFFTrackPtEffCorr = (TH1F*) histPt->Clone(histNamePt); | |
2101 | hFFTrackPtEffCorr->Divide(histPt,fh1EffPt[i],1,1,""); | |
2102 | ||
2103 | TH1F* hFFZEffCorr = (TH1F*) histZ->Clone(histNameZ); | |
2104 | hFFZEffCorr->Divide(histZ,fh1EffZ[i],1,1,""); | |
2105 | ||
2106 | TH1F* hFFXiEffCorr = (TH1F*) histXi->Clone(histNameXi); | |
2107 | hFFXiEffCorr->Divide(histXi,fh1EffXi[i],1,1,""); | |
2108 | ||
2109 | fCorrBgr[fNCorrectionLevelsBgr-1]->AddCorrHistos(i,hFFTrackPtEffCorr,hFFZEffCorr,hFFXiEffCorr); | |
2110 | } | |
2111 | } | |
2112 | ||
2113 | //______________________________________________________________________ | |
2114 | void AliFragmentationFunctionCorrections::XiShift(const Int_t corrLevel) | |
2115 | { | |
2116 | // re-evaluate jet energy after FF corrections from dN/dpt distribution | |
2117 | // apply correction (shift) to dN/dxi distribution: xi = ln (pt/E) -> xi' = ln (pt/E') = ln (pt/E x E/E') = xi + ln E/E' | |
2118 | // argument corrlevel: which level of correction to be corrected/shifted to | |
2119 | ||
2120 | if(corrLevel>=fNCorrectionLevels){ | |
2121 | Printf(" calc xi shift: corrLevel exceeded - do nothing"); | |
2122 | return; | |
2123 | } | |
2124 | ||
2125 | Double_t* jetPtUncorr = new Double_t[fNJetPtSlices]; | |
2126 | Double_t* jetPtCorr = new Double_t[fNJetPtSlices]; | |
2127 | Double_t* deltaXi = new Double_t[fNJetPtSlices]; | |
2128 | ||
2129 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
2130 | ||
2131 | TH1F* histPtRaw = fCorrFF[0]->GetTrackPt(i); | |
2132 | TH1F* histPt = fCorrFF[corrLevel]->GetTrackPt(i); | |
2133 | ||
2134 | Double_t ptUncorr = 0; | |
2135 | Double_t ptCorr = 0; | |
2136 | ||
2137 | for(Int_t bin = 1; bin<=histPtRaw->GetNbinsX(); bin++){ | |
2138 | ||
2139 | Double_t cont = histPtRaw->GetBinContent(bin); | |
2140 | Double_t width = histPtRaw->GetBinWidth(bin); | |
2141 | Double_t meanPt = histPtRaw->GetBinCenter(bin); | |
2142 | ||
2143 | ptUncorr += meanPt*cont*width; | |
2144 | } | |
2145 | ||
2146 | for(Int_t bin = 1; bin<=histPt->GetNbinsX(); bin++){ | |
2147 | ||
2148 | Double_t cont = histPt->GetBinContent(bin); | |
2149 | Double_t width = histPt->GetBinWidth(bin); | |
2150 | Double_t meanPt = histPt->GetBinCenter(bin); | |
2151 | ||
2152 | ptCorr += meanPt*cont*width; | |
2153 | } | |
2154 | ||
2155 | jetPtUncorr[i] = ptUncorr; | |
2156 | jetPtCorr[i] = ptCorr; | |
2157 | } | |
2158 | ||
ce55b926 | 2159 | // --- |
2160 | ||
2161 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
2162 | ||
2163 | std::cout<<" jet pt bin "<<i<<" from "<<fJetPtSlices->At(i)<<" to "<<fJetPtSlices->At(i+1) | |
2164 | <<" jetPtUncorr "<<jetPtUncorr[i]<<" corrLevel "<<corrLevel<<" jet pt corr "<<jetPtCorr[i]<<" ratio " | |
2165 | <<jetPtCorr[i]/jetPtUncorr[i]<<std::endl; | |
2166 | } | |
2167 | ||
2168 | return; // for TEST!!! | |
2169 | ||
39e2b057 | 2170 | // calc dXi from dN/dpt distribution : |
2171 | // sum over track pt for raw and corrected FF is equivalent to raw/corrected jet pt | |
2172 | ||
2173 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
2174 | ||
2175 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
2176 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
2177 | ||
2178 | Double_t meanJetPt = 0.5*(jetPtUpLim+jetPtLoLim); | |
2179 | ||
2180 | Double_t ptUncorr = jetPtUncorr[i]; | |
2181 | Double_t ptCorr = jetPtCorr[i]; | |
2182 | ||
2183 | Double_t dXi = TMath::Log(ptCorr/ptUncorr); | |
2184 | ||
2185 | Printf(" calc xi shift: jet pt slice %d, mean jet pt %f, ptUncorr %f, ptCorr %f, ratio corr/uncorr %f, dXi %f " | |
2186 | ,i,meanJetPt,ptUncorr,ptCorr,ptCorr/ptUncorr,dXi); | |
2187 | ||
2188 | deltaXi[i] = dXi; | |
2189 | } | |
2190 | ||
2191 | // book & fill new dN/dxi histos | |
2192 | ||
2193 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
2194 | ||
2195 | TH1F* histXi = fCorrFF[corrLevel]->GetXi(i); | |
2196 | ||
2197 | Double_t dXi = deltaXi[i]; | |
2198 | ||
2199 | Int_t nBins = histXi->GetNbinsX(); | |
2200 | const Double_t* binsVec = histXi->GetXaxis()->GetXbins()->GetArray(); | |
2201 | Float_t binsVecNew[nBins+1]; | |
2202 | ||
2203 | TString strName = histXi->GetName(); | |
2204 | strName.Append("_shift"); | |
2205 | TString strTit = histXi->GetTitle(); | |
2206 | ||
2207 | TH1F* hXiCorr; | |
2208 | ||
2209 | // create shifted histo ... | |
2210 | ||
2211 | if(binsVec){ // binsVec only neq NULL if histo was rebinned before | |
2212 | ||
2213 | for(Int_t bin=0; bin<nBins+1; bin++) binsVecNew[bin] = binsVec[bin] + dXi; | |
2214 | hXiCorr = new TH1F(strName,strTit,nBins,binsVecNew); | |
2215 | } | |
2216 | else{ // uniform bin size | |
2217 | ||
2218 | Double_t xMin = histXi->GetXaxis()->GetXmin(); | |
2219 | Double_t xMax = histXi->GetXaxis()->GetXmax(); | |
2220 | ||
2221 | xMin += dXi; | |
2222 | xMax += dXi; | |
2223 | ||
2224 | hXiCorr = new TH1F(strName,strTit,nBins,xMin,xMax); | |
2225 | } | |
2226 | ||
2227 | // ... and fill | |
2228 | ||
2229 | for(Int_t bin=1; bin<nBins+1; bin++){ | |
2230 | Double_t cont = histXi->GetBinContent(bin); | |
2231 | Double_t err = histXi->GetBinError(bin); | |
2232 | ||
2233 | hXiCorr->SetBinContent(bin,cont); | |
2234 | hXiCorr->SetBinError(bin,err); | |
2235 | } | |
2236 | ||
2237 | new(fh1FFXiShift[i]) TH1F(*hXiCorr); | |
2238 | delete hXiCorr; | |
2239 | } | |
2240 | ||
2241 | delete[] jetPtUncorr; | |
2242 | delete[] jetPtCorr; | |
2243 | delete[] deltaXi; | |
2244 | } | |
2245 | ||
2246 | //_____________________________________________________ | |
ce55b926 | 2247 | void AliFragmentationFunctionCorrections::SubtractBgr(Double_t sysErr) |
39e2b057 | 2248 | { |
2249 | // subtract bgr distribution from FF | |
2250 | // the current corr level is used for both | |
2251 | ||
2252 | AddCorrectionLevel("bgrSub"); | |
2253 | ||
ce55b926 | 2254 | fstream ascii_out_pt; |
2255 | fstream ascii_out_z; | |
2256 | fstream ascii_out_xi; | |
2257 | ||
2258 | if(sysErr) ascii_out_pt.open("sysErrUE_pt.txt",std::ios::out); | |
2259 | if(sysErr) ascii_out_z.open("sysErrUE_z.txt",std::ios::out); | |
2260 | if(sysErr) ascii_out_xi.open("sysErrUE_xi.txt",std::ios::out); | |
2261 | ||
2262 | for(Int_t i=0; i<fNJetPtSlices; i++){ // jet slices | |
39e2b057 | 2263 | |
2264 | TH1F* histPt = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i); | |
2265 | TH1F* histZ = fCorrFF[fNCorrectionLevels-2]->GetZ(i); | |
2266 | TH1F* histXi = fCorrFF[fNCorrectionLevels-2]->GetXi(i); | |
2267 | ||
2268 | TH1F* histPtBgr = fCorrBgr[fNCorrectionLevelsBgr-1]->GetTrackPt(i); | |
2269 | TH1F* histZBgr = fCorrBgr[fNCorrectionLevelsBgr-1]->GetZ(i); | |
2270 | TH1F* histXiBgr = fCorrBgr[fNCorrectionLevelsBgr-1]->GetXi(i); | |
2271 | ||
2272 | TString histNamePt = histPt->GetName(); | |
2273 | TString histNameZ = histZ->GetName(); | |
2274 | TString histNameXi = histXi->GetName(); | |
2275 | ||
2276 | ||
2277 | TH1F* hFFTrackPtBgrSub = (TH1F*) histPt->Clone(histNamePt); | |
2278 | hFFTrackPtBgrSub->Add(histPtBgr,-1); | |
2279 | ||
2280 | TH1F* hFFZBgrSub = (TH1F*) histZ->Clone(histNameZ); | |
2281 | hFFZBgrSub->Add(histZBgr,-1); | |
2282 | ||
2283 | TH1F* hFFXiBgrSub = (TH1F*) histXi->Clone(histNameXi); | |
2284 | hFFXiBgrSub->Add(histXiBgr,-1); | |
2285 | ||
2286 | fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hFFTrackPtBgrSub,hFFZBgrSub,hFFXiBgrSub); | |
ce55b926 | 2287 | |
2288 | if(sysErr){ | |
2289 | ||
2290 | for(Int_t bin=1; bin<=histPt->GetNbinsX(); bin++){ | |
2291 | ||
2292 | //Double_t sigPlBgr = histPt->GetBinContent(bin); | |
2293 | Double_t sig = hFFTrackPtBgrSub->GetBinContent(bin); | |
2294 | Double_t bgr = histPtBgr->GetBinContent(bin); | |
2295 | ||
2296 | Double_t relErr = 0; | |
2297 | if(sig>0) relErr = sysErr*bgr/sig; | |
2298 | ||
2299 | // std::cout<<" pt bin "<<bin<<" mean "<<histPt->GetBinCenter(bin) | |
2300 | // <<" sigPlBgr "<<sigPlBgr<<" sig "<<sig<<" bgr "<<bgr<<" relErr "<<relErr<<std::endl; | |
2301 | ||
2302 | ascii_out_pt<<i<<" "<<bin<<" "<<relErr<<std::endl; | |
2303 | } | |
2304 | ||
2305 | ||
2306 | for(Int_t bin=1; bin<=histZ->GetNbinsX(); bin++){ | |
2307 | ||
2308 | //Double_t sigPlBgr = histZ->GetBinContent(bin); | |
2309 | Double_t sig = hFFZBgrSub->GetBinContent(bin); | |
2310 | Double_t bgr = histZBgr->GetBinContent(bin); | |
2311 | ||
2312 | Double_t relErr = 0; | |
2313 | if(sig>0) relErr = sysErr*bgr/sig; | |
2314 | ||
2315 | std::cout<<" z bin "<<bin<<" mean "<<histZ->GetBinCenter(bin) | |
2316 | <<" sigPlBgr "<<histZ->GetBinContent(bin)<<" sig "<<sig<<" bgr "<<bgr<<" relErr "<<relErr<<std::endl; | |
2317 | ||
2318 | ascii_out_z<<i<<" "<<bin<<" "<<relErr<<std::endl; | |
2319 | } | |
2320 | ||
2321 | ||
2322 | for(Int_t bin=1; bin<=histXi->GetNbinsX(); bin++){ | |
2323 | ||
2324 | //Double_t sigPlBgr = histXi->GetBinContent(bin); | |
2325 | Double_t sig = hFFXiBgrSub->GetBinContent(bin); | |
2326 | Double_t bgr = histXiBgr->GetBinContent(bin); | |
2327 | ||
2328 | Double_t relErr = 0; | |
2329 | if(sig>0) relErr = sysErr*bgr/sig; | |
2330 | ||
2331 | std::cout<<" xi bin "<<bin<<" mean "<<histXi->GetBinCenter(bin) | |
2332 | <<" sigPlBgr "<<histXi->GetBinContent(bin)<<" sig "<<sig<<" bgr "<<bgr<<" relErr "<<relErr<<std::endl; | |
2333 | ||
2334 | ascii_out_xi<<i<<" "<<bin<<" "<<relErr<<std::endl; | |
2335 | } | |
2336 | } | |
39e2b057 | 2337 | } |
ce55b926 | 2338 | |
2339 | if(sysErr) ascii_out_pt.close(); | |
2340 | if(sysErr) ascii_out_xi.close(); | |
2341 | ||
2342 | ||
39e2b057 | 2343 | } |
2344 | ||
2345 | //________________________________________________________________________________________________________________ | |
2346 | void AliFragmentationFunctionCorrections::WriteSingleTrackEff(TString strInfile, TString strID, TString strOutfile, | |
2347 | Bool_t updateOutfile, TString strOutDir,TString strPostfix) | |
2348 | { | |
2349 | // read task ouput from MC and write single track eff - standard dir/list | |
2350 | ||
b541fbca | 2351 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 2352 | TString strlist = "fracfunc_" + strID; |
2353 | ||
2354 | WriteSingleTrackEff(strInfile,strdir,strlist,strOutfile,updateOutfile,strOutDir,strPostfix); | |
2355 | } | |
2356 | ||
2357 | //___________________________________________________________________________________________________________________________________ | |
2358 | void AliFragmentationFunctionCorrections::WriteSingleTrackEff(TString strInfile, TString strdir, TString strlist, | |
2359 | TString strOutfile, Bool_t updateOutfile, TString strOutDir,TString strPostfix) | |
2360 | { | |
2361 | // read task output from MC and write single track eff as function of pt, eta, phi | |
2362 | // argument strlist optional - read from directory strdir if not specified | |
2363 | // write eff to file stroutfile - by default only 'update' file (don't overwrite) | |
2364 | ||
2365 | ||
2366 | TH1D* hdNdptTracksMCPrimGen; | |
2367 | TH2D* hdNdetadphiTracksMCPrimGen; | |
2368 | ||
2369 | TH1D* hdNdptTracksMCPrimRec; | |
2370 | TH2D* hdNdetadphiTracksMCPrimRec; | |
2371 | ||
2372 | ||
2373 | TFile f(strInfile,"READ"); | |
2374 | ||
2375 | if(!f.IsOpen()){ | |
2376 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
2377 | return; | |
2378 | } | |
2379 | ||
2380 | if(fDebug>0) Printf("%s:%d -- writeSingleTrackEff: open task ouput file %s ",(char*)__FILE__,__LINE__,strInfile.Data()); | |
2381 | ||
2382 | if(strdir && strdir.Length()){ | |
2383 | if(fDebug>0) Printf("%s:%d -- writeSingleTrackEff: change dir to %s",(char*)__FILE__,__LINE__,strdir.Data()); | |
2384 | gDirectory->cd(strdir); | |
2385 | } | |
2386 | ||
2387 | TList* list = 0; | |
2388 | ||
2389 | if(strlist && strlist.Length()){ | |
2390 | ||
2391 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
2392 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
2393 | return; | |
2394 | } | |
2395 | } | |
2396 | ||
2397 | ||
2398 | TString hnamePtRecEffGen = "fh1TrackQAPtRecEffGen"; | |
2399 | if(strPostfix.Length()) hnamePtRecEffGen.Form("fh1TrackQAPtRecEffGen_%s",strPostfix.Data()); | |
2400 | ||
2401 | TString hnamePtRecEffRec = "fh1TrackQAPtRecEffRec"; | |
2402 | if(strPostfix.Length()) hnamePtRecEffRec.Form("fh1TrackQAPtRecEffRec_%s",strPostfix.Data()); | |
2403 | ||
2404 | TString hnameEtaPhiRecEffGen = "fh2TrackQAEtaPhiRecEffGen"; | |
2405 | if(strPostfix.Length()) hnameEtaPhiRecEffGen.Form("fh2TrackQAEtaPhiRecEffGen_%s",strPostfix.Data()); | |
2406 | ||
2407 | TString hnameEtaPhiRecEffRec = "fh2TrackQAEtaPhiRecEffRec"; | |
2408 | if(strPostfix.Length()) hnameEtaPhiRecEffRec.Form("fh2TrackQAEtaPhiRecEffRec_%s",strPostfix.Data()); | |
2409 | ||
2410 | ||
2411 | if(list){ | |
2412 | hdNdptTracksMCPrimGen = (TH1D*) list->FindObject(hnamePtRecEffGen); | |
2413 | hdNdetadphiTracksMCPrimGen = (TH2D*) list->FindObject(hnameEtaPhiRecEffGen); | |
2414 | ||
2415 | hdNdptTracksMCPrimRec = (TH1D*) list->FindObject(hnamePtRecEffRec); | |
2416 | hdNdetadphiTracksMCPrimRec = (TH2D*) list->FindObject(hnameEtaPhiRecEffRec); | |
2417 | } | |
2418 | else{ | |
2419 | hdNdptTracksMCPrimGen = (TH1D*) gDirectory->Get(hnamePtRecEffGen); | |
2420 | hdNdetadphiTracksMCPrimGen = (TH2D*) gDirectory->Get(hnameEtaPhiRecEffGen); | |
2421 | ||
2422 | hdNdptTracksMCPrimRec = (TH1D*) gDirectory->Get(hnamePtRecEffRec); | |
2423 | hdNdetadphiTracksMCPrimRec = (TH2D*) gDirectory->Get(hnameEtaPhiRecEffRec); | |
2424 | } | |
2425 | ||
2426 | hdNdptTracksMCPrimGen->SetDirectory(0); | |
2427 | hdNdetadphiTracksMCPrimGen->SetDirectory(0); | |
2428 | hdNdptTracksMCPrimRec->SetDirectory(0); | |
2429 | hdNdetadphiTracksMCPrimRec->SetDirectory(0); | |
2430 | ||
2431 | f.Close(); | |
2432 | ||
2433 | // projections: dN/deta, dN/dphi | |
2434 | ||
2435 | TH1D* hdNdetaTracksMCPrimGen = (TH1D*) hdNdetadphiTracksMCPrimGen->ProjectionX("hdNdetaTracksMcPrimGen"); | |
2436 | TH1D* hdNdphiTracksMCPrimGen = (TH1D*) hdNdetadphiTracksMCPrimGen->ProjectionY("hdNdphiTracksMcPrimGen"); | |
2437 | ||
2438 | TH1D* hdNdetaTracksMCPrimRec = (TH1D*) hdNdetadphiTracksMCPrimRec->ProjectionX("hdNdetaTracksMcPrimRec"); | |
2439 | TH1D* hdNdphiTracksMCPrimRec = (TH1D*) hdNdetadphiTracksMCPrimRec->ProjectionY("hdNdphiTracksMcPrimRec"); | |
2440 | ||
2441 | // rebin | |
2442 | ||
2443 | TString strNamePtGen = "hTrackPtGenPrim"; | |
2444 | TString strNamePtRec = "hTrackPtRecPrim"; | |
2445 | ||
2446 | if(fNHistoBinsSinglePt) hdNdptTracksMCPrimGen = (TH1D*) hdNdptTracksMCPrimGen->Rebin(fNHistoBinsSinglePt,strNamePtGen,fHistoBinsSinglePt->GetArray()); | |
2447 | if(fNHistoBinsSinglePt) hdNdptTracksMCPrimRec = (TH1D*) hdNdptTracksMCPrimRec->Rebin(fNHistoBinsSinglePt,strNamePtRec,fHistoBinsSinglePt->GetArray()); | |
2448 | ||
2449 | // efficiency: divide | |
2450 | ||
2451 | TString hNameTrackEffPt = "hSingleTrackEffPt"; | |
2452 | if(strPostfix.Length()) hNameTrackEffPt.Form("hSingleTrackEffPt_%s",strPostfix.Data()); | |
2453 | ||
2454 | TString hNameTrackEffEta = "hSingleTrackEffEta"; | |
2455 | if(strPostfix.Length()) hNameTrackEffEta.Form("hSingleTrackEffEta_%s",strPostfix.Data()); | |
2456 | ||
2457 | TString hNameTrackEffPhi = "hSingleTrackEffPhi"; | |
2458 | if(strPostfix.Length()) hNameTrackEffPhi.Form("hSingleTrackEffPhi_%s",strPostfix.Data()); | |
2459 | ||
2460 | ||
2461 | TH1F* hSingleTrackEffPt = (TH1F*) hdNdptTracksMCPrimRec->Clone(hNameTrackEffPt); | |
2462 | hSingleTrackEffPt->Divide(hdNdptTracksMCPrimRec,hdNdptTracksMCPrimGen,1,1,"B"); // binominal errors | |
2463 | ||
2464 | TH1F* hSingleTrackEffEta = (TH1F*) hdNdetaTracksMCPrimRec->Clone(hNameTrackEffEta); | |
2465 | hSingleTrackEffEta->Divide(hdNdetaTracksMCPrimRec,hdNdetaTracksMCPrimGen,1,1,"B"); // binominal errors | |
2466 | ||
2467 | TH1F* hSingleTrackEffPhi = (TH1F*) hdNdphiTracksMCPrimRec->Clone(hNameTrackEffPhi); | |
2468 | hSingleTrackEffPhi->Divide(hdNdphiTracksMCPrimRec,hdNdphiTracksMCPrimGen,1,1,"B"); // binominal errors | |
2469 | ||
2470 | ||
2471 | TString outfileOption = "RECREATE"; | |
2472 | if(updateOutfile) outfileOption = "UPDATE"; | |
2473 | ||
2474 | TFile out(strOutfile,outfileOption); | |
2475 | ||
2476 | if(!out.IsOpen()){ | |
2477 | Printf("%s:%d -- error opening efficiency output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
2478 | return; | |
2479 | } | |
2480 | ||
2481 | if(fDebug>0) Printf("%s:%d -- write efficiency to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
2482 | ||
2483 | if(strOutDir && strOutDir.Length()){ | |
2484 | ||
2485 | TDirectory* dir; | |
2486 | if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd(); | |
2487 | else{ | |
2488 | dir = out.mkdir(strOutDir); | |
2489 | dir->cd(); | |
2490 | } | |
2491 | } | |
2492 | ||
2493 | hSingleTrackEffPt->Write(); | |
2494 | hSingleTrackEffEta->Write(); | |
2495 | hSingleTrackEffPhi->Write(); | |
2496 | ||
2497 | out.Close(); | |
ce55b926 | 2498 | |
2499 | delete hdNdptTracksMCPrimGen; | |
2500 | delete hdNdetadphiTracksMCPrimGen; | |
2501 | delete hdNdptTracksMCPrimRec; | |
2502 | delete hdNdetadphiTracksMCPrimRec; | |
39e2b057 | 2503 | } |
2504 | ||
2505 | //________________________________________________________________________________________________________________ | |
2506 | void AliFragmentationFunctionCorrections::WriteSingleTrackSecCorr(TString strInfile, TString strID, TString strOutfile, | |
2507 | Bool_t updateOutfile, TString strOutDir) | |
2508 | { | |
2509 | // read task ouput from MC and write single track eff - standard dir/list | |
2510 | ||
b541fbca | 2511 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 2512 | TString strlist = "fracfunc_" + strID; |
2513 | ||
2514 | WriteSingleTrackSecCorr(strInfile,strdir,strlist,strOutfile,updateOutfile,strOutDir); | |
2515 | } | |
2516 | ||
2517 | //___________________________________________________________________________________________________________________________________ | |
2518 | void AliFragmentationFunctionCorrections::WriteSingleTrackSecCorr(TString strInfile, TString strdir, TString strlist, | |
2519 | TString strOutfile, Bool_t updateOutfile, TString strOutDir) | |
2520 | { | |
2521 | // read task output from MC and write single track secondaries contamination correction as function of pt, eta, phi | |
2522 | // argument strlist optional - read from directory strdir if not specified | |
2523 | // write corr factor to file stroutfile - by default only 'update' file (don't overwrite) | |
2524 | ||
2525 | TH1D* hdNdptTracksMCPrimRec; | |
2526 | TH2D* hdNdetadphiTracksMCPrimRec; | |
2527 | ||
ce55b926 | 2528 | TH1D* hdNdptTracksMCSecRecNS; |
2529 | TH2D* hdNdetadphiTracksMCSecRecNS; | |
2530 | ||
2531 | TH1D* hdNdptTracksMCSecRecSsc; | |
2532 | TH2D* hdNdetadphiTracksMCSecRecSsc; | |
39e2b057 | 2533 | |
2534 | TFile f(strInfile,"READ"); | |
2535 | ||
2536 | if(!f.IsOpen()){ | |
2537 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
2538 | return; | |
2539 | } | |
2540 | ||
2541 | if(fDebug>0) Printf("%s:%d -- writeSingleTrackEff: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data()); | |
2542 | ||
2543 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
2544 | ||
2545 | TList* list = 0; | |
2546 | ||
2547 | if(strlist && strlist.Length()){ | |
2548 | ||
2549 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
2550 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
2551 | return; | |
2552 | } | |
2553 | } | |
2554 | ||
2555 | ||
2556 | if(list){ | |
ce55b926 | 2557 | hdNdptTracksMCPrimRec = (TH1D*) list->FindObject("fh1TrackQAPtRecEffGen"); |
2558 | hdNdetadphiTracksMCPrimRec = (TH2D*) list->FindObject("fh2TrackQAEtaPhiRecEffGen"); | |
39e2b057 | 2559 | |
ce55b926 | 2560 | hdNdptTracksMCSecRecNS = (TH1D*) list->FindObject("fh1TrackQAPtSecRecNS"); |
2561 | hdNdetadphiTracksMCSecRecNS = (TH2D*) list->FindObject("fh2TrackQAEtaPhiSecRecNS"); | |
2562 | ||
2563 | hdNdptTracksMCSecRecSsc = (TH1D*) list->FindObject("fh1TrackQAPtSecRecSsc"); | |
2564 | hdNdetadphiTracksMCSecRecSsc = (TH2D*) list->FindObject("fh2TrackQAEtaPhiSecRecSsc"); | |
2565 | ||
39e2b057 | 2566 | } |
2567 | else{ | |
ce55b926 | 2568 | hdNdptTracksMCPrimRec = (TH1D*) gDirectory->Get("fh1TrackQAPtRecEffGen"); |
2569 | hdNdetadphiTracksMCPrimRec = (TH2D*) gDirectory->Get("fh2TrackQAEtaPhiRecEffGen"); | |
39e2b057 | 2570 | |
ce55b926 | 2571 | hdNdptTracksMCSecRecNS = (TH1D*) gDirectory->Get("fh1TrackQAPtSecRecNS"); |
2572 | hdNdetadphiTracksMCSecRecNS = (TH2D*) gDirectory->Get("fh2TrackQAEtaPhiSecRecNS"); | |
2573 | ||
2574 | hdNdptTracksMCSecRecSsc = (TH1D*) gDirectory->Get("fh1TrackQAPtSecRecSsc"); | |
2575 | hdNdetadphiTracksMCSecRecSsc = (TH2D*) gDirectory->Get("fh2TrackQAEtaPhiSecRecSsc"); | |
39e2b057 | 2576 | } |
2577 | ||
2578 | hdNdptTracksMCPrimRec->SetDirectory(0); | |
2579 | hdNdetadphiTracksMCPrimRec->SetDirectory(0); | |
ce55b926 | 2580 | |
2581 | hdNdptTracksMCSecRecNS->SetDirectory(0); | |
2582 | hdNdetadphiTracksMCSecRecNS->SetDirectory(0); | |
2583 | ||
2584 | hdNdptTracksMCSecRecSsc->SetDirectory(0); | |
2585 | hdNdetadphiTracksMCSecRecSsc->SetDirectory(0); | |
39e2b057 | 2586 | |
2587 | f.Close(); | |
2588 | ||
2589 | // projections: dN/deta, dN/dphi | |
2590 | ||
ce55b926 | 2591 | TH1D* hdNdetaTracksMCPrimRec = (TH1D*) hdNdetadphiTracksMCPrimRec->ProjectionX("hdNdetaTracksMcPrimRec"); |
2592 | TH1D* hdNdphiTracksMCPrimRec = (TH1D*) hdNdetadphiTracksMCPrimRec->ProjectionY("hdNdphiTracksMcPrimRec"); | |
39e2b057 | 2593 | |
ce55b926 | 2594 | TH1D* hdNdetaTracksMCSecRecNS = (TH1D*) hdNdetadphiTracksMCSecRecNS->ProjectionX("hdNdetaTracksMcSecRecNS"); |
2595 | TH1D* hdNdphiTracksMCSecRecNS = (TH1D*) hdNdetadphiTracksMCSecRecNS->ProjectionY("hdNdphiTracksMcSecRecNS"); | |
39e2b057 | 2596 | |
ce55b926 | 2597 | TH1D* hdNdetaTracksMCSecRecSsc = (TH1D*) hdNdetadphiTracksMCSecRecSsc->ProjectionX("hdNdetaTracksMcSecRecSsc"); |
2598 | TH1D* hdNdphiTracksMCSecRecSsc = (TH1D*) hdNdetadphiTracksMCSecRecSsc->ProjectionY("hdNdphiTracksMcSecRecSsc"); | |
39e2b057 | 2599 | |
2600 | // rebin | |
2601 | ||
2602 | TString strNamePtPrim = "hTrackPtPrim"; | |
2603 | TString strNamePtSec = "hTrackPtSec"; | |
2604 | ||
ce55b926 | 2605 | if(fNHistoBinsSinglePt) hdNdptTracksMCPrimRec = (TH1D*) hdNdptTracksMCPrimRec->Rebin(fNHistoBinsSinglePt,strNamePtPrim,fHistoBinsSinglePt->GetArray()); |
2606 | if(fNHistoBinsSinglePt) hdNdptTracksMCSecRecNS = (TH1D*) hdNdptTracksMCSecRecNS->Rebin(fNHistoBinsSinglePt,strNamePtSec,fHistoBinsSinglePt->GetArray()); | |
2607 | if(fNHistoBinsSinglePt) hdNdptTracksMCSecRecSsc = (TH1D*) hdNdptTracksMCSecRecSsc->Rebin(fNHistoBinsSinglePt,strNamePtSec,fHistoBinsSinglePt->GetArray()); | |
39e2b057 | 2608 | |
2609 | ||
2610 | // secondary correction factor: divide prim/(prim+sec) | |
2611 | ||
ce55b926 | 2612 | TH1F* hSingleTrackSecCorrPt = (TH1F*) hdNdptTracksMCPrimRec->Clone("hSingleTrackSecCorrPt"); |
2613 | TH1F* hSumPrimSecPt = (TH1F*) hdNdptTracksMCPrimRec->Clone("hSumPrimSecPt"); | |
2614 | hSumPrimSecPt->Add(hdNdptTracksMCSecRecNS); | |
2615 | hSumPrimSecPt->Add(hdNdptTracksMCSecRecSsc); | |
39e2b057 | 2616 | hSingleTrackSecCorrPt->Divide(hdNdptTracksMCPrimRec,hSumPrimSecPt,1,1,"B"); // binominal errors |
2617 | ||
ce55b926 | 2618 | |
2619 | TH1F* hSingleTrackSecCorrEta = (TH1F*) hdNdetaTracksMCPrimRec->Clone("hSingleTrackSecCorrEta"); | |
2620 | TH1F* hSumPrimSecEta = (TH1F*) hdNdetaTracksMCPrimRec->Clone("hSumPrimSecEta"); | |
2621 | hSumPrimSecEta->Add(hdNdetaTracksMCSecRecNS); | |
2622 | hSumPrimSecEta->Add(hdNdetaTracksMCSecRecSsc); | |
39e2b057 | 2623 | hSingleTrackSecCorrEta->Divide(hdNdetaTracksMCPrimRec,hSumPrimSecEta,1,1,"B"); // binominal errors |
2624 | ||
ce55b926 | 2625 | TH1F* hSingleTrackSecCorrPhi = (TH1F*) hdNdphiTracksMCPrimRec->Clone("hSingleTrackSecCorrPhi"); |
2626 | TH1F* hSumPrimSecPhi = (TH1F*) hdNdphiTracksMCPrimRec->Clone("hSumPrimSecPhi"); | |
2627 | hSumPrimSecPhi->Add(hdNdphiTracksMCSecRecNS); | |
2628 | hSumPrimSecPhi->Add(hdNdphiTracksMCSecRecSsc); | |
39e2b057 | 2629 | hSingleTrackSecCorrPhi->Divide(hdNdphiTracksMCPrimRec,hSumPrimSecPhi,1,1,"B"); // binominal errors |
ce55b926 | 2630 | |
2631 | // | |
39e2b057 | 2632 | |
2633 | TString outfileOption = "RECREATE"; | |
2634 | if(updateOutfile) outfileOption = "UPDATE"; | |
2635 | ||
2636 | TFile out(strOutfile,outfileOption); | |
2637 | ||
2638 | if(!out.IsOpen()){ | |
2639 | Printf("%s:%d -- error opening secCorr output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
2640 | return; | |
2641 | } | |
2642 | ||
2643 | if(fDebug>0) Printf("%s:%d -- write secCorr to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
2644 | ||
2645 | if(strOutDir && strOutDir.Length()){ | |
2646 | ||
2647 | TDirectory* dir; | |
2648 | if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd(); | |
2649 | else{ | |
2650 | dir = out.mkdir(strOutDir); | |
2651 | dir->cd(); | |
2652 | } | |
2653 | } | |
2654 | ||
ce55b926 | 2655 | hdNdptTracksMCSecRecNS->Write(); |
2656 | hdNdetaTracksMCSecRecNS->Write(); | |
2657 | hdNdphiTracksMCSecRecNS->Write(); | |
2658 | ||
2659 | hdNdptTracksMCSecRecSsc->Write(); | |
2660 | hdNdetaTracksMCSecRecSsc->Write(); | |
2661 | hdNdphiTracksMCSecRecSsc->Write(); | |
39e2b057 | 2662 | |
2663 | hSingleTrackSecCorrPt->Write(); | |
2664 | hSingleTrackSecCorrEta->Write(); | |
2665 | hSingleTrackSecCorrPhi->Write(); | |
2666 | ||
2667 | out.Close(); | |
ce55b926 | 2668 | |
2669 | delete hdNdptTracksMCPrimRec; | |
2670 | delete hdNdetadphiTracksMCPrimRec; | |
2671 | delete hdNdptTracksMCSecRecNS; | |
2672 | delete hdNdetadphiTracksMCSecRecNS; | |
2673 | delete hdNdptTracksMCSecRecSsc; | |
2674 | delete hdNdetadphiTracksMCSecRecSsc; | |
39e2b057 | 2675 | } |
2676 | ||
2677 | //________________________________________________________________________________________________________________ | |
2678 | void AliFragmentationFunctionCorrections::WriteSingleResponse(TString strInfile, TString strID, TString strOutfile, | |
2679 | Bool_t updateOutfile, TString strOutDir) | |
2680 | { | |
2681 | // read task ouput from MC and write single track eff - standard dir/list | |
2682 | ||
b541fbca | 2683 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 2684 | TString strlist = "fracfunc_" + strID; |
2685 | ||
2686 | WriteSingleResponse(strInfile,strdir,strlist,strOutfile,updateOutfile,strOutDir); | |
2687 | } | |
2688 | ||
2689 | ||
2690 | //_____________________________________________________________________________________________________________________________________ | |
2691 | void AliFragmentationFunctionCorrections::WriteSingleResponse(TString strInfile, TString strdir, TString strlist, | |
2692 | TString strOutfile, Bool_t updateOutfile, TString strOutDir) | |
2693 | { | |
2694 | // read 2d THnSparse response matrices in pt from file | |
2695 | // project TH2 | |
2696 | // write to strOutfile | |
2697 | ||
2698 | THnSparse* hnResponseSinglePt; | |
2699 | TH2F* h2ResponseSinglePt; | |
2700 | ||
2701 | TFile f(strInfile,"READ"); | |
2702 | ||
2703 | if(!f.IsOpen()){ | |
2704 | Printf("%s:%d -- error opening file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
2705 | return; | |
2706 | } | |
2707 | ||
2708 | if(fDebug>0) Printf("%s:%d -- read response matrices from file %s ",(char*)__FILE__,__LINE__,strInfile.Data()); | |
2709 | ||
2710 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
2711 | ||
2712 | TList* list = 0; | |
2713 | ||
2714 | if(strlist && strlist.Length()){ | |
2715 | ||
2716 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
2717 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
2718 | return; | |
2719 | } | |
2720 | } | |
2721 | ||
2722 | if(list) hnResponseSinglePt = (THnSparse*) list->FindObject("fhnResponseSinglePt"); | |
2723 | else hnResponseSinglePt = (THnSparse*) gDirectory->Get("fhnResponseSinglePt"); | |
2724 | ||
2725 | ||
2726 | if(!hnResponseSinglePt){ | |
2727 | Printf("%s:%d -- error retrieving response matrix fhnResponseSinglePt",(char*)__FILE__,__LINE__); | |
2728 | return; | |
2729 | } | |
2730 | ||
2731 | f.Close(); | |
2732 | ||
2733 | ||
2734 | // project 2d histo | |
2735 | h2ResponseSinglePt = (TH2F*) hnResponseSinglePt->Projection(1,0);// note convention: yDim,xDim | |
2736 | h2ResponseSinglePt->SetNameTitle("h2ResponseSinglePt",""); | |
2737 | ||
2738 | ||
2739 | // write | |
2740 | ||
2741 | TString outfileOption = "RECREATE"; | |
2742 | if(updateOutfile) outfileOption = "UPDATE"; | |
2743 | ||
2744 | TFile out(strOutfile,outfileOption); | |
2745 | ||
2746 | if(!out.IsOpen()){ | |
2747 | Printf("%s:%d -- error opening response matrix output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
2748 | return; | |
2749 | } | |
2750 | ||
2751 | if(fDebug>0) Printf("%s:%d -- write response matrices to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
2752 | ||
2753 | if(strOutDir && strOutDir.Length()){ | |
2754 | ||
2755 | TDirectory* dir; | |
2756 | if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd(); | |
2757 | else{ | |
2758 | dir = out.mkdir(strOutDir); | |
2759 | dir->cd(); | |
2760 | } | |
2761 | } | |
2762 | ||
2763 | hnResponseSinglePt->Write(); | |
2764 | h2ResponseSinglePt->Write(); | |
2765 | ||
2766 | out.Close(); | |
2767 | } | |
2768 | ||
2769 | //________________________________________________________________________________________________________________ | |
2770 | void AliFragmentationFunctionCorrections::WriteJetTrackEff(TString strInfile, TString strID, TString strOutfile, | |
2771 | Bool_t updateOutfile) | |
2772 | { | |
2773 | // read task ouput from MC and write single track eff - standard dir/list | |
2774 | ||
b541fbca | 2775 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 2776 | TString strlist = "fracfunc_" + strID; |
2777 | ||
2778 | WriteJetTrackEff(strInfile,strdir,strlist,strOutfile,updateOutfile); | |
2779 | } | |
2780 | ||
2781 | //___________________________________________________________________________________________________________________________________ | |
2782 | void AliFragmentationFunctionCorrections::WriteJetTrackEff(TString strInfile, TString strdir, TString strlist, | |
2783 | TString strOutfile, Bool_t updateOutfile) | |
2784 | { | |
2785 | // read task output from MC and write track eff in jet pt slices as function of pt, z, xi | |
2786 | // argument strlist optional - read from directory strdir if not specified | |
2787 | // write eff to file strOutfile - by default only 'update' file (don't overwrite) | |
2788 | ||
2789 | TH1F* hEffPt[fNJetPtSlices]; | |
2790 | TH1F* hEffXi[fNJetPtSlices]; | |
2791 | TH1F* hEffZ[fNJetPtSlices]; | |
2792 | ||
2793 | TH1F* hdNdptTracksMCPrimGen[fNJetPtSlices]; | |
2794 | TH1F* hdNdxiMCPrimGen[fNJetPtSlices]; | |
2795 | TH1F* hdNdzMCPrimGen[fNJetPtSlices]; | |
2796 | ||
2797 | TH1F* hdNdptTracksMCPrimRec[fNJetPtSlices]; | |
2798 | TH1F* hdNdxiMCPrimRec[fNJetPtSlices]; | |
2799 | TH1F* hdNdzMCPrimRec[fNJetPtSlices]; | |
2800 | ||
2801 | ||
2802 | TH1F* fh1FFJetPtRecEffGen; | |
2803 | ||
2804 | TH2F* fh2FFTrackPtRecEffGen; | |
2805 | TH2F* fh2FFZRecEffGen; | |
2806 | TH2F* fh2FFXiRecEffGen; | |
2807 | ||
2808 | TH2F* fh2FFTrackPtRecEffRec; | |
2809 | TH2F* fh2FFZRecEffRec; | |
2810 | TH2F* fh2FFXiRecEffRec; | |
2811 | ||
2812 | ||
2813 | TFile f(strInfile,"READ"); | |
2814 | ||
2815 | if(!f.IsOpen()){ | |
2816 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
2817 | return; | |
2818 | } | |
2819 | ||
2820 | if(fDebug>0) Printf("%s:%d -- writeJetTrackEff: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data()); | |
2821 | ||
2822 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
2823 | ||
2824 | TList* list = 0; | |
2825 | ||
2826 | if(strlist && strlist.Length()){ | |
2827 | ||
2828 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
2829 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
2830 | return; | |
2831 | } | |
2832 | } | |
2833 | ||
2834 | if(list){ | |
2835 | fh1FFJetPtRecEffGen = (TH1F*) list->FindObject("fh1FFJetPtRecEffGen"); | |
2836 | ||
2837 | fh2FFTrackPtRecEffGen = (TH2F*) list->FindObject("fh2FFTrackPtRecEffGen"); | |
2838 | fh2FFZRecEffGen = (TH2F*) list->FindObject("fh2FFZRecEffGen"); | |
2839 | fh2FFXiRecEffGen = (TH2F*) list->FindObject("fh2FFXiRecEffGen"); | |
2840 | ||
2841 | fh2FFTrackPtRecEffRec = (TH2F*) list->FindObject("fh2FFTrackPtRecEffRec"); | |
2842 | fh2FFZRecEffRec = (TH2F*) list->FindObject("fh2FFZRecEffRec"); | |
2843 | fh2FFXiRecEffRec = (TH2F*) list->FindObject("fh2FFXiRecEffRec"); | |
2844 | } | |
2845 | else{ | |
ce55b926 | 2846 | fh1FFJetPtRecEffGen = (TH1F*) gDirectory->Get("fh1FFJetPtRecEffGen"); |
39e2b057 | 2847 | |
ce55b926 | 2848 | fh2FFTrackPtRecEffGen = (TH2F*) gDirectory->Get("fh2FFTrackPtRecEffGen"); |
2849 | fh2FFZRecEffGen = (TH2F*) gDirectory->Get("fh2FFZRecEffGen"); | |
2850 | fh2FFXiRecEffGen = (TH2F*) gDirectory->Get("fh2FFXiRecEffGen"); | |
39e2b057 | 2851 | |
ce55b926 | 2852 | fh2FFTrackPtRecEffRec = (TH2F*) gDirectory->Get("fh2FFTrackPtRecEffRec"); |
2853 | fh2FFZRecEffRec = (TH2F*) gDirectory->Get("fh2FFZRecEffRec"); | |
2854 | fh2FFXiRecEffRec = (TH2F*) gDirectory->Get("fh2FFXiRecEffRec"); | |
39e2b057 | 2855 | } |
2856 | ||
2857 | fh1FFJetPtRecEffGen->SetDirectory(0); | |
2858 | ||
2859 | fh2FFTrackPtRecEffGen->SetDirectory(0); | |
2860 | fh2FFZRecEffGen->SetDirectory(0); | |
2861 | fh2FFXiRecEffGen->SetDirectory(0); | |
2862 | ||
2863 | fh2FFTrackPtRecEffRec->SetDirectory(0); | |
2864 | fh2FFZRecEffRec->SetDirectory(0); | |
2865 | fh2FFXiRecEffRec->SetDirectory(0); | |
2866 | ||
2867 | f.Close(); | |
2868 | ||
2869 | ||
2870 | // projections: FF for generated and reconstructed primaries | |
2871 | ||
2872 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
2873 | ||
2874 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
2875 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
2876 | ||
2877 | Int_t binLo = static_cast<Int_t>(fh2FFTrackPtRecEffGen->GetXaxis()->FindBin(jetPtLoLim)); | |
2878 | Int_t binUp = static_cast<Int_t>(fh2FFTrackPtRecEffGen->GetXaxis()->FindBin(jetPtUpLim))-1; | |
2879 | ||
2880 | if(binUp > fh2FFTrackPtRecEffGen->GetNbinsX()){ | |
2881 | Printf("%s:%d -- jet pt range %0.3f exceeds histo limits",(char*)__FILE__,__LINE__,jetPtUpLim); | |
2882 | return; | |
2883 | } | |
2884 | ||
2885 | TString strNameFFPtGen(Form("fh1FFTrackPtGenPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
2886 | TString strNameFFZGen(Form("fh1FFZGenPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
2887 | TString strNameFFXiGen(Form("fh1FFXiGenPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
2888 | ||
2889 | TString strNameFFPtRec(Form("fh1FFTrackPtRecPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
2890 | TString strNameFFZRec(Form("fh1FFZRecPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
2891 | TString strNameFFXiRec(Form("fh1FFXiRecPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
2892 | ||
2893 | // project | |
2894 | // appendix 'unbinned' to avoid histos with same name after rebinning | |
2895 | ||
2896 | hdNdptTracksMCPrimGen[i] = (TH1F*) fh2FFTrackPtRecEffGen->ProjectionY(strNameFFPtGen+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
2897 | hdNdzMCPrimGen[i] = (TH1F*) fh2FFZRecEffGen->ProjectionY(strNameFFZGen+"_unBinned",binLo,binUp,"o"); | |
2898 | hdNdxiMCPrimGen[i] = (TH1F*) fh2FFXiRecEffGen->ProjectionY(strNameFFXiGen+"_unBinned",binLo,binUp,"o"); | |
2899 | ||
2900 | hdNdptTracksMCPrimRec[i] = (TH1F*) fh2FFTrackPtRecEffRec->ProjectionY(strNameFFPtRec+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
2901 | hdNdzMCPrimRec[i] = (TH1F*) fh2FFZRecEffRec->ProjectionY(strNameFFZRec+"_unBinned",binLo,binUp,"o"); | |
2902 | hdNdxiMCPrimRec[i] = (TH1F*) fh2FFXiRecEffRec->ProjectionY(strNameFFXiRec+"_unBinned",binLo,binUp,"o"); | |
2903 | ||
2904 | // rebin | |
2905 | ||
2906 | if(fNHistoBinsPt[i]) hdNdptTracksMCPrimGen[i] = (TH1F*) hdNdptTracksMCPrimGen[i]->Rebin(fNHistoBinsPt[i],strNameFFPtGen,fHistoBinsPt[i]->GetArray()); | |
2907 | if(fNHistoBinsZ[i]) hdNdzMCPrimGen[i] = (TH1F*) hdNdzMCPrimGen[i]->Rebin(fNHistoBinsZ[i],strNameFFZGen,fHistoBinsZ[i]->GetArray()); | |
2908 | if(fNHistoBinsXi[i]) hdNdxiMCPrimGen[i] = (TH1F*) hdNdxiMCPrimGen[i]->Rebin(fNHistoBinsXi[i],strNameFFXiGen,fHistoBinsXi[i]->GetArray()); | |
2909 | ||
2910 | if(fNHistoBinsPt[i]) hdNdptTracksMCPrimRec[i] = (TH1F*) hdNdptTracksMCPrimRec[i]->Rebin(fNHistoBinsPt[i],strNameFFPtRec,fHistoBinsPt[i]->GetArray()); | |
2911 | if(fNHistoBinsZ[i]) hdNdzMCPrimRec[i] = (TH1F*) hdNdzMCPrimRec[i]->Rebin(fNHistoBinsZ[i],strNameFFZRec,fHistoBinsZ[i]->GetArray()); | |
2912 | if(fNHistoBinsXi[i]) hdNdxiMCPrimRec[i] = (TH1F*) hdNdxiMCPrimRec[i]->Rebin(fNHistoBinsXi[i],strNameFFXiRec,fHistoBinsXi[i]->GetArray()); | |
2913 | ||
2914 | hdNdptTracksMCPrimGen[i]->SetNameTitle(strNameFFPtGen,""); | |
2915 | hdNdzMCPrimGen[i]->SetNameTitle(strNameFFZGen,""); | |
2916 | hdNdxiMCPrimGen[i]->SetNameTitle(strNameFFXiGen,""); | |
2917 | ||
2918 | hdNdptTracksMCPrimRec[i]->SetNameTitle(strNameFFPtRec,""); | |
2919 | hdNdzMCPrimRec[i]->SetNameTitle(strNameFFZRec,""); | |
2920 | hdNdxiMCPrimRec[i]->SetNameTitle(strNameFFXiRec,""); | |
2921 | ||
2922 | // normalize | |
2923 | ||
2924 | Double_t nJetsBin = fh1FFJetPtRecEffGen->Integral(binLo,binUp); | |
2925 | ||
2926 | NormalizeTH1(hdNdptTracksMCPrimGen[i],nJetsBin); | |
2927 | NormalizeTH1(hdNdzMCPrimGen[i],nJetsBin); | |
2928 | NormalizeTH1(hdNdxiMCPrimGen[i],nJetsBin); | |
2929 | ||
2930 | NormalizeTH1(hdNdptTracksMCPrimRec[i],nJetsBin); | |
2931 | NormalizeTH1(hdNdzMCPrimRec[i],nJetsBin); | |
2932 | NormalizeTH1(hdNdxiMCPrimRec[i],nJetsBin); | |
2933 | ||
2934 | // divide rec/gen : efficiency | |
2935 | ||
2936 | TString strNameEffPt(Form("hEffPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
2937 | TString strNameEffZ(Form("hEffZ_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
2938 | TString strNameEffXi(Form("hEffXi_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
2939 | ||
2940 | hEffPt[i] = (TH1F*) hdNdptTracksMCPrimRec[i]->Clone(strNameEffPt); | |
2941 | hEffPt[i]->Divide(hdNdptTracksMCPrimRec[i],hdNdptTracksMCPrimGen[i],1,1,"B"); // binominal errors | |
2942 | ||
2943 | hEffXi[i] = (TH1F*) hdNdxiMCPrimRec[i]->Clone(strNameEffXi); | |
2944 | hEffXi[i]->Divide(hdNdxiMCPrimRec[i],hdNdxiMCPrimGen[i],1,1,"B"); // binominal errors | |
2945 | ||
2946 | hEffZ[i] = (TH1F*) hdNdzMCPrimRec[i]->Clone(strNameEffZ); | |
2947 | hEffZ[i]->Divide(hdNdzMCPrimRec[i],hdNdzMCPrimGen[i],1,1,"B"); // binominal errors | |
2948 | } | |
2949 | ||
2950 | // write | |
2951 | ||
2952 | TString outfileOption = "RECREATE"; | |
2953 | if(updateOutfile) outfileOption = "UPDATE"; | |
2954 | ||
2955 | TFile out(strOutfile,outfileOption); | |
2956 | ||
2957 | if(!out.IsOpen()){ | |
2958 | Printf("%s:%d -- error opening efficiency output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
2959 | return; | |
2960 | } | |
2961 | ||
2962 | if(fDebug>0) Printf("%s:%d -- write efficiency to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
2963 | ||
2964 | // if(strdir && strdir.Length()){ | |
2965 | // TDirectory* dir = out.mkdir(strdir); | |
2966 | // dir->cd(); | |
2967 | // } | |
2968 | ||
2969 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
2970 | ||
2971 | hdNdptTracksMCPrimGen[i]->Write(); | |
2972 | hdNdxiMCPrimGen[i]->Write(); | |
2973 | hdNdzMCPrimGen[i]->Write(); | |
2974 | ||
2975 | hdNdptTracksMCPrimRec[i]->Write(); | |
2976 | hdNdxiMCPrimRec[i]->Write(); | |
2977 | hdNdzMCPrimRec[i]->Write(); | |
2978 | ||
2979 | hEffPt[i]->Write(); | |
2980 | hEffXi[i]->Write(); | |
2981 | hEffZ[i]->Write(); | |
2982 | } | |
2983 | ||
2984 | out.Close(); | |
2985 | ||
ce55b926 | 2986 | |
2987 | delete fh1FFJetPtRecEffGen; | |
2988 | ||
2989 | delete fh2FFTrackPtRecEffGen; | |
2990 | delete fh2FFZRecEffGen; | |
2991 | delete fh2FFXiRecEffGen; | |
2992 | ||
2993 | delete fh2FFTrackPtRecEffRec; | |
2994 | delete fh2FFZRecEffRec; | |
2995 | delete fh2FFXiRecEffRec; | |
39e2b057 | 2996 | } |
2997 | ||
2998 | //________________________________________________________________________________________________________________ | |
2999 | void AliFragmentationFunctionCorrections::WriteJetSecCorr(TString strInfile, TString strID, TString strOutfile, | |
ce55b926 | 3000 | Bool_t updateOutfile, TString strOutDir) |
39e2b057 | 3001 | { |
3002 | // read task ouput from MC and write secondary correction - standard dir/list | |
3003 | ||
b541fbca | 3004 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 3005 | TString strlist = "fracfunc_" + strID; |
3006 | ||
ce55b926 | 3007 | WriteJetSecCorr(strInfile,strdir,strlist,strOutfile,updateOutfile, strOutDir,kFALSE,""); |
39e2b057 | 3008 | } |
3009 | ||
ce55b926 | 3010 | //________________________________________________________________________________________________________________ |
3011 | void AliFragmentationFunctionCorrections::WriteBgrJetSecCorr(TString strInfile, TString strBgrID, TString strID, TString strOutfile, | |
3012 | Bool_t updateOutfile, TString strOutDir) | |
3013 | { | |
3014 | // read task ouput from MC and write secondary correction - standard dir/list | |
3015 | ||
3016 | TString strdir = "PWGJE_FragmentationFunction_" + strID; | |
3017 | TString strlist = "fracfunc_" + strID; | |
3018 | ||
3019 | WriteJetSecCorr(strInfile,strdir,strlist,strOutfile,updateOutfile, strOutDir,kTRUE,strBgrID); | |
3020 | } | |
3021 | ||
3022 | ||
39e2b057 | 3023 | //___________________________________________________________________________________________________________________________________ |
3024 | void AliFragmentationFunctionCorrections::WriteJetSecCorr(TString strInfile, TString strdir, TString strlist, | |
ce55b926 | 3025 | TString strOutfile, Bool_t updateOutfile, TString strOutDir, |
3026 | Bool_t writeBgr, TString strBgrID) | |
39e2b057 | 3027 | { |
3028 | // read task output from MC and write secondary correction in jet pt slices as function of pt, z, xi | |
3029 | // argument strlist optional - read from directory strdir if not specified | |
3030 | // write eff to file strOutfile - by default only 'update' file (don't overwrite) | |
3031 | ||
3032 | TH1F* hSecCorrPt[fNJetPtSlices]; | |
3033 | TH1F* hSecCorrXi[fNJetPtSlices]; | |
3034 | TH1F* hSecCorrZ[fNJetPtSlices]; | |
3035 | ||
ce55b926 | 3036 | // corr factors using naive Pythia strangeness - for sys uncertainties |
3037 | TH1F* hSecCorrPt_nonSc[fNJetPtSlices]; | |
3038 | TH1F* hSecCorrXi_nonSc[fNJetPtSlices]; | |
3039 | TH1F* hSecCorrZ_nonSc[fNJetPtSlices]; | |
3040 | ||
39e2b057 | 3041 | TH1F* hdNdptTracksMCPrimRec[fNJetPtSlices]; |
3042 | TH1F* hdNdxiMCPrimRec[fNJetPtSlices]; | |
3043 | TH1F* hdNdzMCPrimRec[fNJetPtSlices]; | |
3044 | ||
ce55b926 | 3045 | TH1F* hdNdptTracksMCSecRecNS[fNJetPtSlices]; |
3046 | TH1F* hdNdxiMCSecRecNS[fNJetPtSlices]; | |
3047 | TH1F* hdNdzMCSecRecNS[fNJetPtSlices]; | |
39e2b057 | 3048 | |
ce55b926 | 3049 | TH1F* hdNdptTracksMCSecRecS[fNJetPtSlices]; |
3050 | TH1F* hdNdxiMCSecRecS[fNJetPtSlices]; | |
3051 | TH1F* hdNdzMCSecRecS[fNJetPtSlices]; | |
3052 | ||
3053 | TH1F* hdNdptTracksMCSecRecSsc[fNJetPtSlices]; | |
3054 | TH1F* hdNdxiMCSecRecSsc[fNJetPtSlices]; | |
3055 | TH1F* hdNdzMCSecRecSsc[fNJetPtSlices]; | |
3056 | ||
3057 | // --- | |
3058 | ||
3059 | TH1F* fh1FFJetPtRecEffRec; | |
39e2b057 | 3060 | |
3061 | TH2F* fh2FFTrackPtRecEffRec; | |
3062 | TH2F* fh2FFZRecEffRec; | |
3063 | TH2F* fh2FFXiRecEffRec; | |
3064 | ||
ce55b926 | 3065 | TH2F* fh2FFTrackPtSecRecNS; |
3066 | TH2F* fh2FFZSecRecNS; | |
3067 | TH2F* fh2FFXiSecRecNS; | |
3068 | ||
3069 | TH2F* fh2FFTrackPtSecRecS; | |
3070 | TH2F* fh2FFZSecRecS; | |
3071 | TH2F* fh2FFXiSecRecS; | |
3072 | ||
3073 | TH2F* fh2FFTrackPtSecRecSsc; | |
3074 | TH2F* fh2FFZSecRecSsc; | |
3075 | TH2F* fh2FFXiSecRecSsc; | |
3076 | ||
3077 | // --- | |
39e2b057 | 3078 | |
3079 | TFile f(strInfile,"READ"); | |
3080 | ||
3081 | if(!f.IsOpen()){ | |
3082 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
3083 | return; | |
3084 | } | |
3085 | ||
ce55b926 | 3086 | if(fDebug>0) Printf("%s:%d -- writeJetTrackSecCorr: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data()); |
39e2b057 | 3087 | |
3088 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
3089 | ||
3090 | TList* list = 0; | |
3091 | ||
3092 | if(strlist && strlist.Length()){ | |
3093 | ||
3094 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
3095 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
3096 | return; | |
3097 | } | |
3098 | } | |
3099 | ||
3100 | if(list){ | |
ce55b926 | 3101 | fh1FFJetPtRecEffRec = (TH1F*) list->FindObject("fh1FFJetPtRecEffRec"); |
39e2b057 | 3102 | |
ce55b926 | 3103 | if(writeBgr){ |
3104 | fh2FFTrackPtRecEffRec = (TH2F*) list->FindObject(Form("fh2FFTrackPt%sRecEffRec",strBgrID.Data())); | |
3105 | fh2FFZRecEffRec = (TH2F*) list->FindObject(Form("fh2FFZ%sRecEffRec",strBgrID.Data())); | |
3106 | fh2FFXiRecEffRec = (TH2F*) list->FindObject(Form("fh2FFXi%sRecEffRec",strBgrID.Data())); | |
3107 | ||
3108 | fh2FFTrackPtSecRecNS = (TH2F*) list->FindObject(Form("fh2FFTrackPt%sSecRecNS",strBgrID.Data())); | |
3109 | fh2FFZSecRecNS = (TH2F*) list->FindObject(Form("fh2FFZ%sSecRecNS",strBgrID.Data())); | |
3110 | fh2FFXiSecRecNS = (TH2F*) list->FindObject(Form("fh2FFXi%sSecRecNS",strBgrID.Data())); | |
3111 | ||
3112 | fh2FFTrackPtSecRecS = (TH2F*) list->FindObject(Form("fh2FFTrackPt%sSecRecS",strBgrID.Data())); | |
3113 | fh2FFZSecRecS = (TH2F*) list->FindObject(Form("fh2FFZ%sSecRecS",strBgrID.Data())); | |
3114 | fh2FFXiSecRecS = (TH2F*) list->FindObject(Form("fh2FFXi%sSecRecS",strBgrID.Data())); | |
3115 | ||
3116 | fh2FFTrackPtSecRecSsc = (TH2F*) list->FindObject(Form("fh2FFTrackPt%sSecRecSsc",strBgrID.Data())); | |
3117 | fh2FFZSecRecSsc = (TH2F*) list->FindObject(Form("fh2FFZ%sSecRecSsc",strBgrID.Data())); | |
3118 | fh2FFXiSecRecSsc = (TH2F*) list->FindObject(Form("fh2FFXi%sSecRecSsc",strBgrID.Data())); | |
3119 | } | |
3120 | else{ | |
3121 | fh2FFTrackPtRecEffRec = (TH2F*) list->FindObject("fh2FFTrackPtRecEffRec"); | |
3122 | fh2FFZRecEffRec = (TH2F*) list->FindObject("fh2FFZRecEffRec"); | |
3123 | fh2FFXiRecEffRec = (TH2F*) list->FindObject("fh2FFXiRecEffRec"); | |
3124 | ||
3125 | fh2FFTrackPtSecRecNS = (TH2F*) list->FindObject("fh2FFTrackPtSecRecNS"); | |
3126 | fh2FFZSecRecNS = (TH2F*) list->FindObject("fh2FFZSecRecNS"); | |
3127 | fh2FFXiSecRecNS = (TH2F*) list->FindObject("fh2FFXiSecRecNS"); | |
3128 | ||
3129 | fh2FFTrackPtSecRecS = (TH2F*) list->FindObject("fh2FFTrackPtSecRecS"); | |
3130 | fh2FFZSecRecS = (TH2F*) list->FindObject("fh2FFZSecRecS"); | |
3131 | fh2FFXiSecRecS = (TH2F*) list->FindObject("fh2FFXiSecRecS"); | |
3132 | ||
3133 | fh2FFTrackPtSecRecSsc = (TH2F*) list->FindObject("fh2FFTrackPtSecRecSsc"); | |
3134 | fh2FFZSecRecSsc = (TH2F*) list->FindObject("fh2FFZSecRecSsc"); | |
3135 | fh2FFXiSecRecSsc = (TH2F*) list->FindObject("fh2FFXiSecRecSsc"); | |
3136 | } | |
39e2b057 | 3137 | } |
3138 | else{ | |
ce55b926 | 3139 | fh1FFJetPtRecEffRec = (TH1F*) gDirectory->Get("fh1FFJetPtRecEffRec"); |
3140 | ||
3141 | if(writeBgr){ | |
3142 | fh2FFTrackPtRecEffRec = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sRecEffRec",strBgrID.Data())); | |
3143 | fh2FFZRecEffRec = (TH2F*) gDirectory->Get(Form("fh2FFZ%sRecEffRec",strBgrID.Data())); | |
3144 | fh2FFXiRecEffRec = (TH2F*) gDirectory->Get(Form("fh2FFXi%sRecEffRec",strBgrID.Data())); | |
3145 | ||
3146 | fh2FFTrackPtSecRecNS = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sSecRecNS",strBgrID.Data())); | |
3147 | fh2FFZSecRecNS = (TH2F*) gDirectory->Get(Form("fh2FFZ%sSecRecNS",strBgrID.Data())); | |
3148 | fh2FFXiSecRecNS = (TH2F*) gDirectory->Get(Form("fh2FFXi%sSecRecNS",strBgrID.Data())); | |
39e2b057 | 3149 | |
ce55b926 | 3150 | fh2FFTrackPtSecRecS = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sSecRecS",strBgrID.Data())); |
3151 | fh2FFZSecRecS = (TH2F*) gDirectory->Get(Form("fh2FFZ%sSecRecS",strBgrID.Data())); | |
3152 | fh2FFXiSecRecS = (TH2F*) gDirectory->Get(Form("fh2FFXi%sSecRecS",strBgrID.Data())); | |
3153 | ||
3154 | fh2FFTrackPtSecRecSsc = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sSecRecSsc",strBgrID.Data())); | |
3155 | fh2FFZSecRecSsc = (TH2F*) gDirectory->Get(Form("fh2FFZ%sSecRecSsc",strBgrID.Data())); | |
3156 | fh2FFXiSecRecSsc = (TH2F*) gDirectory->Get(Form("fh2FFXi%sSecRecSsc",strBgrID.Data())); | |
3157 | } | |
3158 | else{ | |
3159 | fh2FFTrackPtRecEffRec = (TH2F*) gDirectory->Get("fh2FFTrackPtRecEffRec"); | |
3160 | fh2FFZRecEffRec = (TH2F*) gDirectory->Get("fh2FFZRecEffRec"); | |
3161 | fh2FFXiRecEffRec = (TH2F*) gDirectory->Get("fh2FFXiRecEffRec"); | |
39e2b057 | 3162 | |
ce55b926 | 3163 | fh2FFTrackPtSecRecNS = (TH2F*) gDirectory->Get("fh2FFTrackPtSecRecNS"); |
3164 | fh2FFZSecRecNS = (TH2F*) gDirectory->Get("fh2FFZSecRecNS"); | |
3165 | fh2FFXiSecRecNS = (TH2F*) gDirectory->Get("fh2FFXiSecRecNS"); | |
3166 | ||
3167 | fh2FFTrackPtSecRecS = (TH2F*) gDirectory->Get("fh2FFTrackPtSecRecS"); | |
3168 | fh2FFZSecRecS = (TH2F*) gDirectory->Get("fh2FFZSecRecS"); | |
3169 | fh2FFXiSecRecS = (TH2F*) gDirectory->Get("fh2FFXiSecRecS"); | |
3170 | ||
3171 | fh2FFTrackPtSecRecSsc = (TH2F*) gDirectory->Get("fh2FFTrackPtSecRecSsc"); | |
3172 | fh2FFZSecRecSsc = (TH2F*) gDirectory->Get("fh2FFZSecRecSsc"); | |
3173 | fh2FFXiSecRecSsc = (TH2F*) gDirectory->Get("fh2FFXiSecRecSsc"); | |
3174 | } | |
39e2b057 | 3175 | } |
3176 | ||
ce55b926 | 3177 | fh1FFJetPtRecEffRec->SetDirectory(0); |
3178 | ||
39e2b057 | 3179 | fh2FFTrackPtRecEffRec->SetDirectory(0); |
3180 | fh2FFZRecEffRec->SetDirectory(0); | |
3181 | fh2FFXiRecEffRec->SetDirectory(0); | |
3182 | ||
ce55b926 | 3183 | fh2FFTrackPtSecRecNS->SetDirectory(0); |
3184 | fh2FFZSecRecNS->SetDirectory(0); | |
3185 | fh2FFXiSecRecNS->SetDirectory(0); | |
3186 | ||
3187 | fh2FFTrackPtSecRecS->SetDirectory(0); | |
3188 | fh2FFZSecRecS->SetDirectory(0); | |
3189 | fh2FFXiSecRecS->SetDirectory(0); | |
39e2b057 | 3190 | |
ce55b926 | 3191 | fh2FFTrackPtSecRecSsc->SetDirectory(0); |
3192 | fh2FFZSecRecSsc->SetDirectory(0); | |
3193 | fh2FFXiSecRecSsc->SetDirectory(0); | |
3194 | ||
39e2b057 | 3195 | f.Close(); |
3196 | ||
3197 | ||
3198 | // projections: FF for generated and reconstructed primaries | |
3199 | ||
3200 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
3201 | ||
3202 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
3203 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
3204 | ||
3205 | Int_t binLo = static_cast<Int_t>(fh2FFTrackPtRecEffRec->GetXaxis()->FindBin(jetPtLoLim)); | |
3206 | Int_t binUp = static_cast<Int_t>(fh2FFTrackPtRecEffRec->GetXaxis()->FindBin(jetPtUpLim))-1; | |
3207 | ||
3208 | if(binUp > fh2FFTrackPtRecEffRec->GetNbinsX()){ | |
3209 | Printf("%s:%d -- jet pt range %0.3f exceeds histo limits",(char*)__FILE__,__LINE__,jetPtUpLim); | |
3210 | return; | |
3211 | } | |
3212 | ||
3213 | TString strNameFFPtPrimRec(Form("fh1FFTrackPtRecPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3214 | TString strNameFFZPrimRec(Form("fh1FFZRecPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3215 | TString strNameFFXiPrimRec(Form("fh1FFXiRecPrim_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3216 | ||
ce55b926 | 3217 | TString strNameFFPtSecRecNS(Form("fh1FFTrackPtRecSecNS_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); |
3218 | TString strNameFFZSecRecNS(Form("fh1FFZRecSecNS_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3219 | TString strNameFFXiSecRecNS(Form("fh1FFXiRecSecNS_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3220 | ||
3221 | TString strNameFFPtSecRecS(Form("fh1FFTrackPtRecSecS_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3222 | TString strNameFFZSecRecS(Form("fh1FFZRecSecS_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3223 | TString strNameFFXiSecRecS(Form("fh1FFXiRecSecS_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3224 | ||
3225 | TString strNameFFPtSecRecSsc(Form("fh1FFTrackPtRecSecSsc_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3226 | TString strNameFFZSecRecSsc(Form("fh1FFZRecSecSsc_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3227 | TString strNameFFXiSecRecSsc(Form("fh1FFXiRecSecSsc_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3228 | ||
3229 | if(writeBgr){ | |
3230 | strNameFFPtPrimRec.Form("fh1BgrTrackPt%sRecPrim_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3231 | strNameFFZPrimRec.Form("fh1BgrZ%sRecPrim_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3232 | strNameFFXiPrimRec.Form("fh1BgrXi%sRecPrim_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3233 | ||
3234 | strNameFFPtSecRecNS.Form("fh1BgrTrackPt%sRecSecNS_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3235 | strNameFFZSecRecNS.Form("fh1BgrZ%sRecSecNS_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3236 | strNameFFXiSecRecNS.Form("fh1BgrXi%sRecSecNS_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3237 | ||
3238 | strNameFFPtSecRecS.Form("fh1BgrTrackPt%sRecSecS_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3239 | strNameFFZSecRecS.Form("fh1BgrZ%sRecSecS_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3240 | strNameFFXiSecRecS.Form("fh1BgrXi%sRecSecS_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3241 | ||
3242 | strNameFFPtSecRecSsc.Form("fh1BgrTrackPt%sRecSecSsc_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3243 | strNameFFZSecRecSsc.Form("fh1BgrZ%sRecSecSsc_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3244 | strNameFFXiSecRecSsc.Form("fh1BgrXi%sRecSecSsc_%02d_%02d",strBgrID.Data(),static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)); | |
3245 | } | |
39e2b057 | 3246 | |
3247 | // project | |
3248 | // appendix 'unbinned' to avoid histos with same name after rebinning | |
3249 | ||
3250 | hdNdptTracksMCPrimRec[i] = (TH1F*) fh2FFTrackPtRecEffRec->ProjectionY(strNameFFPtPrimRec+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
3251 | hdNdzMCPrimRec[i] = (TH1F*) fh2FFZRecEffRec->ProjectionY(strNameFFZPrimRec+"_unBinned",binLo,binUp,"o"); | |
3252 | hdNdxiMCPrimRec[i] = (TH1F*) fh2FFXiRecEffRec->ProjectionY(strNameFFXiPrimRec+"_unBinned",binLo,binUp,"o"); | |
3253 | ||
ce55b926 | 3254 | hdNdptTracksMCSecRecNS[i] = (TH1F*) fh2FFTrackPtSecRecNS->ProjectionY(strNameFFPtSecRecNS+"_unBinned",binLo,binUp,"o"); // option "o": original axis range |
3255 | hdNdzMCSecRecNS[i] = (TH1F*) fh2FFZSecRecNS->ProjectionY(strNameFFZSecRecNS+"_unBinned",binLo,binUp,"o"); | |
3256 | hdNdxiMCSecRecNS[i] = (TH1F*) fh2FFXiSecRecNS->ProjectionY(strNameFFXiSecRecNS+"_unBinned",binLo,binUp,"o"); | |
39e2b057 | 3257 | |
ce55b926 | 3258 | hdNdptTracksMCSecRecS[i] = (TH1F*) fh2FFTrackPtSecRecS->ProjectionY(strNameFFPtSecRecS+"_unBinned",binLo,binUp,"o"); // option "o": original axis range |
3259 | hdNdzMCSecRecS[i] = (TH1F*) fh2FFZSecRecS->ProjectionY(strNameFFZSecRecS+"_unBinned",binLo,binUp,"o"); | |
3260 | hdNdxiMCSecRecS[i] = (TH1F*) fh2FFXiSecRecS->ProjectionY(strNameFFXiSecRecS+"_unBinned",binLo,binUp,"o"); | |
3261 | ||
3262 | hdNdptTracksMCSecRecSsc[i] = (TH1F*) fh2FFTrackPtSecRecSsc->ProjectionY(strNameFFPtSecRecSsc+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
3263 | hdNdzMCSecRecSsc[i] = (TH1F*) fh2FFZSecRecSsc->ProjectionY(strNameFFZSecRecSsc+"_unBinned",binLo,binUp,"o"); | |
3264 | hdNdxiMCSecRecSsc[i] = (TH1F*) fh2FFXiSecRecSsc->ProjectionY(strNameFFXiSecRecSsc+"_unBinned",binLo,binUp,"o"); | |
3265 | ||
39e2b057 | 3266 | |
ce55b926 | 3267 | // rebin |
39e2b057 | 3268 | if(fNHistoBinsPt[i]) hdNdptTracksMCPrimRec[i] = (TH1F*) hdNdptTracksMCPrimRec[i]->Rebin(fNHistoBinsPt[i],strNameFFPtPrimRec,fHistoBinsPt[i]->GetArray()); |
3269 | if(fNHistoBinsZ[i]) hdNdzMCPrimRec[i] = (TH1F*) hdNdzMCPrimRec[i]->Rebin(fNHistoBinsZ[i],strNameFFZPrimRec,fHistoBinsZ[i]->GetArray()); | |
3270 | if(fNHistoBinsXi[i]) hdNdxiMCPrimRec[i] = (TH1F*) hdNdxiMCPrimRec[i]->Rebin(fNHistoBinsXi[i],strNameFFXiPrimRec,fHistoBinsXi[i]->GetArray()); | |
3271 | ||
ce55b926 | 3272 | if(fNHistoBinsPt[i]) hdNdptTracksMCSecRecNS[i] = (TH1F*) hdNdptTracksMCSecRecNS[i]->Rebin(fNHistoBinsPt[i],strNameFFPtSecRecNS,fHistoBinsPt[i]->GetArray()); |
3273 | if(fNHistoBinsZ[i]) hdNdzMCSecRecNS[i] = (TH1F*) hdNdzMCSecRecNS[i]->Rebin(fNHistoBinsZ[i],strNameFFZSecRecNS,fHistoBinsZ[i]->GetArray()); | |
3274 | if(fNHistoBinsXi[i]) hdNdxiMCSecRecNS[i] = (TH1F*) hdNdxiMCSecRecNS[i]->Rebin(fNHistoBinsXi[i],strNameFFXiSecRecNS,fHistoBinsXi[i]->GetArray()); | |
3275 | ||
3276 | if(fNHistoBinsPt[i]) hdNdptTracksMCSecRecS[i] = (TH1F*) hdNdptTracksMCSecRecS[i]->Rebin(fNHistoBinsPt[i],strNameFFPtSecRecS,fHistoBinsPt[i]->GetArray()); | |
3277 | if(fNHistoBinsZ[i]) hdNdzMCSecRecS[i] = (TH1F*) hdNdzMCSecRecS[i]->Rebin(fNHistoBinsZ[i],strNameFFZSecRecS,fHistoBinsZ[i]->GetArray()); | |
3278 | if(fNHistoBinsXi[i]) hdNdxiMCSecRecS[i] = (TH1F*) hdNdxiMCSecRecS[i]->Rebin(fNHistoBinsXi[i],strNameFFXiSecRecS,fHistoBinsXi[i]->GetArray()); | |
3279 | ||
3280 | if(fNHistoBinsPt[i]) hdNdptTracksMCSecRecSsc[i] = (TH1F*) hdNdptTracksMCSecRecSsc[i]->Rebin(fNHistoBinsPt[i],strNameFFPtSecRecSsc,fHistoBinsPt[i]->GetArray()); | |
3281 | if(fNHistoBinsZ[i]) hdNdzMCSecRecSsc[i] = (TH1F*) hdNdzMCSecRecSsc[i]->Rebin(fNHistoBinsZ[i],strNameFFZSecRecSsc,fHistoBinsZ[i]->GetArray()); | |
3282 | if(fNHistoBinsXi[i]) hdNdxiMCSecRecSsc[i] = (TH1F*) hdNdxiMCSecRecSsc[i]->Rebin(fNHistoBinsXi[i],strNameFFXiSecRecSsc,fHistoBinsXi[i]->GetArray()); | |
3283 | ||
39e2b057 | 3284 | |
3285 | hdNdptTracksMCPrimRec[i]->SetNameTitle(strNameFFPtPrimRec,""); | |
3286 | hdNdzMCPrimRec[i]->SetNameTitle(strNameFFZPrimRec,""); | |
3287 | hdNdxiMCPrimRec[i]->SetNameTitle(strNameFFXiPrimRec,""); | |
3288 | ||
ce55b926 | 3289 | hdNdptTracksMCSecRecNS[i]->SetNameTitle(strNameFFPtSecRecNS,""); |
3290 | hdNdzMCSecRecNS[i]->SetNameTitle(strNameFFZSecRecNS,""); | |
3291 | hdNdxiMCSecRecNS[i]->SetNameTitle(strNameFFXiSecRecNS,""); | |
39e2b057 | 3292 | |
ce55b926 | 3293 | hdNdptTracksMCSecRecS[i]->SetNameTitle(strNameFFPtSecRecS,""); |
3294 | hdNdzMCSecRecS[i]->SetNameTitle(strNameFFZSecRecS,""); | |
3295 | hdNdxiMCSecRecS[i]->SetNameTitle(strNameFFXiSecRecS,""); | |
3296 | ||
3297 | hdNdptTracksMCSecRecSsc[i]->SetNameTitle(strNameFFPtSecRecSsc,""); | |
3298 | hdNdzMCSecRecSsc[i]->SetNameTitle(strNameFFZSecRecSsc,""); | |
3299 | hdNdxiMCSecRecSsc[i]->SetNameTitle(strNameFFXiSecRecSsc,""); | |
39e2b057 | 3300 | |
ce55b926 | 3301 | // normalize |
3302 | Double_t nJetsBin = fh1FFJetPtRecEffRec->Integral(binLo,binUp); | |
39e2b057 | 3303 | |
3304 | NormalizeTH1(hdNdptTracksMCPrimRec[i],nJetsBin); | |
3305 | NormalizeTH1(hdNdzMCPrimRec[i],nJetsBin); | |
3306 | NormalizeTH1(hdNdxiMCPrimRec[i],nJetsBin); | |
3307 | ||
ce55b926 | 3308 | NormalizeTH1(hdNdptTracksMCSecRecNS[i],nJetsBin); |
3309 | NormalizeTH1(hdNdzMCSecRecNS[i],nJetsBin); | |
3310 | NormalizeTH1(hdNdxiMCSecRecNS[i],nJetsBin); | |
3311 | ||
3312 | NormalizeTH1(hdNdptTracksMCSecRecS[i],nJetsBin); | |
3313 | NormalizeTH1(hdNdzMCSecRecS[i],nJetsBin); | |
3314 | NormalizeTH1(hdNdxiMCSecRecS[i],nJetsBin); | |
3315 | ||
3316 | NormalizeTH1(hdNdptTracksMCSecRecSsc[i],nJetsBin); | |
3317 | NormalizeTH1(hdNdzMCSecRecSsc[i],nJetsBin); | |
3318 | NormalizeTH1(hdNdxiMCSecRecSsc[i],nJetsBin); | |
39e2b057 | 3319 | |
ce55b926 | 3320 | |
3321 | // divide prim / (prim+sec) : corr factor | |
39e2b057 | 3322 | TString strNameSecCorrPt(Form("hSecCorrPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); |
3323 | TString strNameSecCorrZ(Form("hSecCorrZ_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3324 | TString strNameSecCorrXi(Form("hSecCorrXi_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
ce55b926 | 3325 | |
3326 | if(writeBgr){ | |
3327 | strNameSecCorrPt.Form("hSecCorrBgrPt_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
3328 | strNameSecCorrZ.Form("hSecCorrBgrZ_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
3329 | strNameSecCorrXi.Form("hSecCorrBgrXi_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
3330 | } | |
3331 | ||
3332 | hSecCorrPt[i] = (TH1F*) hdNdptTracksMCPrimRec[i]->Clone(strNameSecCorrPt); | |
3333 | TH1F* hSumPrimSecPt = (TH1F*) hdNdptTracksMCPrimRec[i]->Clone("hSumPrimSecPt"); | |
3334 | hSumPrimSecPt->Add(hdNdptTracksMCSecRecNS[i]); | |
3335 | hSumPrimSecPt->Add(hdNdptTracksMCSecRecSsc[i]); | |
39e2b057 | 3336 | hSecCorrPt[i]->Divide(hdNdptTracksMCPrimRec[i],hSumPrimSecPt,1,1,"B"); // binominal errors |
3337 | ||
ce55b926 | 3338 | hSecCorrXi[i] = (TH1F*) hdNdxiMCPrimRec[i]->Clone(strNameSecCorrXi); |
3339 | TH1F* hSumPrimSecXi = (TH1F*) hdNdxiMCPrimRec[i]->Clone("hSumPrimSecXi"); | |
3340 | hSumPrimSecXi->Add(hdNdxiMCSecRecNS[i]); | |
3341 | hSumPrimSecXi->Add(hdNdxiMCSecRecSsc[i]); | |
39e2b057 | 3342 | hSecCorrXi[i]->Divide(hdNdxiMCPrimRec[i],hSumPrimSecXi,1,1,"B"); // binominal errors |
3343 | ||
ce55b926 | 3344 | hSecCorrZ[i] = (TH1F*) hdNdzMCPrimRec[i]->Clone(strNameSecCorrZ); |
3345 | TH1F* hSumPrimSecZ = (TH1F*) hdNdzMCPrimRec[i]->Clone("hSumPrimSecZ"); | |
3346 | hSumPrimSecZ->Add(hdNdzMCSecRecNS[i]); | |
3347 | hSumPrimSecZ->Add(hdNdzMCSecRecSsc[i]); | |
39e2b057 | 3348 | hSecCorrZ[i]->Divide(hdNdzMCPrimRec[i],hSumPrimSecZ,1,1,"B"); // binominal errors |
ce55b926 | 3349 | |
3350 | // the same using unscaled strangeness | |
3351 | TString strNameSecCorrPt_nonSc(Form("hSecCorrPt_nonSc_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3352 | TString strNameSecCorrZ_nonSc(Form("hSecCorrZ_nonSc_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3353 | TString strNameSecCorrXi_nonSc(Form("hSecCorrXi_nonSc_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3354 | ||
3355 | if(writeBgr){ | |
3356 | strNameSecCorrPt_nonSc.Form("hSecCorrBgrPt_nonSc_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
3357 | strNameSecCorrZ_nonSc.Form("hSecCorrBgrZ_nonSc_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
3358 | strNameSecCorrXi_nonSc.Form("hSecCorrBgrXi_nonSc_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
3359 | } | |
3360 | ||
3361 | hSecCorrPt_nonSc[i] = (TH1F*) hdNdptTracksMCPrimRec[i]->Clone(strNameSecCorrPt_nonSc); | |
3362 | TH1F* hSumPrimSecPt_nonSc = (TH1F*) hdNdptTracksMCPrimRec[i]->Clone("hSumPrimSecPt_nonSc"); | |
3363 | hSumPrimSecPt_nonSc->Add(hdNdptTracksMCSecRecNS[i]); | |
3364 | hSumPrimSecPt_nonSc->Add(hdNdptTracksMCSecRecS[i]); // non-scaled secondaries from strangeness | |
3365 | hSecCorrPt_nonSc[i]->Divide(hdNdptTracksMCPrimRec[i],hSumPrimSecPt_nonSc,1,1,"B"); // binominal errors | |
3366 | ||
3367 | hSecCorrZ_nonSc[i] = (TH1F*) hdNdzMCPrimRec[i]->Clone(strNameSecCorrZ_nonSc); | |
3368 | TH1F* hSumPrimSecZ_nonSc = (TH1F*) hdNdzMCPrimRec[i]->Clone("hSumPrimSecZ_nonSc"); | |
3369 | hSumPrimSecZ_nonSc->Add(hdNdzMCSecRecNS[i]); | |
3370 | hSumPrimSecZ_nonSc->Add(hdNdzMCSecRecS[i]); // non-scaled secondaries from strangeness | |
3371 | hSecCorrZ_nonSc[i]->Divide(hdNdzMCPrimRec[i],hSumPrimSecZ_nonSc,1,1,"B"); // binominal errors | |
3372 | ||
3373 | hSecCorrXi_nonSc[i] = (TH1F*) hdNdxiMCPrimRec[i]->Clone(strNameSecCorrXi_nonSc); | |
3374 | TH1F* hSumPrimSecXi_nonSc = (TH1F*) hdNdxiMCPrimRec[i]->Clone("hSumPrimSecXi_nonSc"); | |
3375 | hSumPrimSecXi_nonSc->Add(hdNdxiMCSecRecNS[i]); | |
3376 | hSumPrimSecXi_nonSc->Add(hdNdxiMCSecRecS[i]); // non-scaled secondaries from strangeness | |
3377 | hSecCorrXi_nonSc[i]->Divide(hdNdxiMCPrimRec[i],hSumPrimSecXi_nonSc,1,1,"B"); // binominal errors | |
39e2b057 | 3378 | } |
3379 | ||
3380 | // write | |
3381 | ||
3382 | TString outfileOption = "RECREATE"; | |
3383 | if(updateOutfile) outfileOption = "UPDATE"; | |
3384 | ||
3385 | TFile out(strOutfile,outfileOption); | |
3386 | ||
3387 | if(!out.IsOpen()){ | |
ce55b926 | 3388 | Printf("%s:%d -- error opening sec corr output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); |
39e2b057 | 3389 | return; |
3390 | } | |
3391 | ||
ce55b926 | 3392 | if(fDebug>0) Printf("%s:%d -- write jet sec corr to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data()); |
39e2b057 | 3393 | |
ce55b926 | 3394 | if(strOutDir && strOutDir.Length()){ |
3395 | ||
3396 | TDirectory* dir; | |
3397 | if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd(); | |
3398 | else{ | |
3399 | dir = out.mkdir(strOutDir); | |
3400 | dir->cd(); | |
3401 | } | |
3402 | } | |
3403 | ||
39e2b057 | 3404 | |
ce55b926 | 3405 | for(Int_t i=0; i<fNJetPtSlices; i++){ |
39e2b057 | 3406 | |
3407 | hSecCorrPt[i]->Write(); | |
3408 | hSecCorrXi[i]->Write(); | |
3409 | hSecCorrZ[i]->Write(); | |
ce55b926 | 3410 | |
3411 | hSecCorrPt_nonSc[i]->Write(); | |
3412 | hSecCorrXi_nonSc[i]->Write(); | |
3413 | hSecCorrZ_nonSc[i]->Write(); | |
3414 | } | |
3415 | ||
3416 | TString strSpectraDir = "spectraSecCorr"; | |
3417 | if(writeBgr) strSpectraDir = "spectraBgrSecCorr"; | |
3418 | ||
3419 | TDirectory *dOut = gDirectory->mkdir(strSpectraDir); | |
3420 | dOut->cd(); | |
3421 | ||
3422 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
3423 | ||
3424 | hdNdptTracksMCPrimRec[i]->Write(); | |
3425 | hdNdzMCPrimRec[i]->Write(); | |
3426 | hdNdxiMCPrimRec[i]->Write(); | |
3427 | ||
3428 | hdNdptTracksMCSecRecNS[i]->Write(); | |
3429 | hdNdzMCSecRecNS[i]->Write(); | |
3430 | hdNdxiMCSecRecNS[i]->Write(); | |
3431 | ||
3432 | hdNdptTracksMCSecRecS[i]->Write(); | |
3433 | hdNdzMCSecRecS[i]->Write(); | |
3434 | hdNdxiMCSecRecS[i]->Write(); | |
3435 | ||
3436 | hdNdptTracksMCSecRecSsc[i]->Write(); | |
3437 | hdNdzMCSecRecSsc[i]->Write(); | |
3438 | hdNdxiMCSecRecSsc[i]->Write(); | |
39e2b057 | 3439 | } |
3440 | ||
3441 | out.Close(); | |
ce55b926 | 3442 | |
3443 | delete fh1FFJetPtRecEffRec; | |
3444 | ||
3445 | delete fh2FFTrackPtRecEffRec; | |
3446 | delete fh2FFZRecEffRec; | |
3447 | delete fh2FFXiRecEffRec; | |
3448 | ||
3449 | delete fh2FFTrackPtSecRecNS; | |
3450 | delete fh2FFZSecRecNS; | |
3451 | delete fh2FFXiSecRecNS; | |
3452 | ||
3453 | delete fh2FFTrackPtSecRecS; | |
3454 | delete fh2FFZSecRecS; | |
3455 | delete fh2FFXiSecRecS; | |
3456 | ||
3457 | delete fh2FFTrackPtSecRecSsc; | |
3458 | delete fh2FFZSecRecSsc; | |
3459 | delete fh2FFXiSecRecSsc; | |
39e2b057 | 3460 | } |
3461 | ||
3462 | //________________________________________________________________________________________________________________ | |
3463 | void AliFragmentationFunctionCorrections::WriteJetResponse(TString strInfile, TString strID, TString strOutfile, | |
ce55b926 | 3464 | Bool_t updateOutfile, TString strOutDir ) |
39e2b057 | 3465 | { |
3466 | // read task ouput from MC and write single track eff - standard dir/list | |
3467 | ||
b541fbca | 3468 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 3469 | TString strlist = "fracfunc_" + strID; |
3470 | ||
ce55b926 | 3471 | WriteJetResponse(strInfile,strdir,strlist,strOutfile,updateOutfile, strOutDir); |
39e2b057 | 3472 | } |
3473 | ||
3474 | //_____________________________________________________________________________________________________________________________________ | |
3475 | void AliFragmentationFunctionCorrections::WriteJetResponse(TString strInfile, TString strdir, TString strlist, | |
ce55b926 | 3476 | TString strOutfile, Bool_t updateOutfile, TString strOutDir) |
39e2b057 | 3477 | { |
3478 | // read 3d THnSparse response matrices in pt,z,xi vs jet pt from file | |
3479 | // project THnSparse + TH2 in jet pt slices | |
3480 | // write to strOutfile | |
3481 | ||
3482 | THnSparse* hn3ResponseJetPt; | |
3483 | THnSparse* hn3ResponseJetZ; | |
3484 | THnSparse* hn3ResponseJetXi; | |
3485 | ||
3486 | // 2D response matrices | |
3487 | ||
3488 | THnSparse* hnResponsePt[fNJetPtSlices]; | |
3489 | THnSparse* hnResponseZ[fNJetPtSlices]; | |
3490 | THnSparse* hnResponseXi[fNJetPtSlices]; | |
3491 | ||
3492 | TH2F* h2ResponsePt[fNJetPtSlices]; | |
3493 | TH2F* h2ResponseZ[fNJetPtSlices]; | |
3494 | TH2F* h2ResponseXi[fNJetPtSlices]; | |
3495 | ||
3496 | // 1D projections on gen pt / rec pt axes | |
3497 | ||
3498 | TH1F* h1FFPtRec[fNJetPtSlices]; | |
3499 | TH1F* h1FFZRec[fNJetPtSlices]; | |
3500 | TH1F* h1FFXiRec[fNJetPtSlices]; | |
3501 | ||
3502 | TH1F* h1FFPtGen[fNJetPtSlices]; | |
3503 | TH1F* h1FFZGen[fNJetPtSlices]; | |
3504 | TH1F* h1FFXiGen[fNJetPtSlices]; | |
3505 | ||
3506 | TH1F* h1RatioPt[fNJetPtSlices]; | |
3507 | TH1F* h1RatioZ[fNJetPtSlices]; | |
3508 | TH1F* h1RatioXi[fNJetPtSlices]; | |
3509 | ||
3510 | ||
3511 | ||
3512 | TFile f(strInfile,"READ"); | |
3513 | ||
3514 | if(!f.IsOpen()){ | |
3515 | Printf("%s:%d -- error opening file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
3516 | return; | |
3517 | } | |
3518 | ||
3519 | if(fDebug>0) Printf("%s:%d -- read response matrices from file %s ",(char*)__FILE__,__LINE__,strInfile.Data()); | |
3520 | ||
3521 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
3522 | ||
3523 | TList* list = 0; | |
3524 | ||
3525 | if(strlist && strlist.Length()){ | |
3526 | ||
3527 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
3528 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
3529 | return; | |
3530 | } | |
3531 | } | |
3532 | ||
3533 | if(list){ | |
3534 | hn3ResponseJetPt = (THnSparse*) list->FindObject("fhnResponseJetTrackPt"); | |
3535 | hn3ResponseJetZ = (THnSparse*) list->FindObject("fhnResponseJetZ"); | |
3536 | hn3ResponseJetXi = (THnSparse*) list->FindObject("fhnResponseJetXi"); | |
3537 | } | |
3538 | else{ | |
3539 | hn3ResponseJetPt = (THnSparse*) gDirectory->Get("fhnResponseJetTrackPt"); | |
3540 | hn3ResponseJetZ = (THnSparse*) gDirectory->Get("fhnResponseJetZ"); | |
3541 | hn3ResponseJetXi = (THnSparse*) gDirectory->Get("fhnResponseJetXi"); | |
3542 | } | |
3543 | ||
3544 | ||
3545 | if(!hn3ResponseJetPt){ | |
3546 | Printf("%s:%d -- error retrieving response matrix fhnResponseJetTrackPt",(char*)__FILE__,__LINE__); | |
3547 | return; | |
3548 | } | |
3549 | ||
3550 | if(!hn3ResponseJetZ){ | |
3551 | Printf("%s:%d -- error retrieving response matrix fhnResponseJetZ",(char*)__FILE__,__LINE__); | |
3552 | return; | |
3553 | } | |
3554 | ||
3555 | if(!hn3ResponseJetXi){ | |
3556 | Printf("%s:%d -- error retrieving response matrix fhnResponseJetXi",(char*)__FILE__,__LINE__); | |
3557 | return; | |
3558 | } | |
3559 | ||
3560 | f.Close(); | |
3561 | ||
3562 | // axes | |
3563 | ||
3564 | Int_t axisJetPtTHn3 = -1; | |
3565 | Int_t axisGenPtTHn3 = -1; | |
3566 | Int_t axisRecPtTHn3 = -1; | |
3567 | ||
3568 | for(Int_t i=0; i<hn3ResponseJetPt->GetNdimensions(); i++){ | |
3569 | ||
3570 | TString title = hn3ResponseJetPt->GetAxis(i)->GetTitle(); | |
3571 | ||
3572 | if(title.Contains("jet p_{T}")) axisJetPtTHn3 = i; | |
3573 | if(title.Contains("gen p_{T}")) axisGenPtTHn3 = i; | |
3574 | if(title.Contains("rec p_{T}")) axisRecPtTHn3 = i; | |
3575 | } | |
3576 | ||
3577 | if(axisJetPtTHn3 == -1){ | |
3578 | Printf("%s:%d -- error axisJetPtTHn3",(char*)__FILE__,__LINE__); | |
3579 | return; | |
3580 | } | |
3581 | ||
3582 | if(axisGenPtTHn3 == -1){ | |
3583 | Printf("%s:%d -- error axisGenPtTHn3",(char*)__FILE__,__LINE__); | |
3584 | return; | |
3585 | } | |
3586 | ||
3587 | if(axisRecPtTHn3 == -1){ | |
3588 | Printf("%s:%d -- error axisRecPtTHn3",(char*)__FILE__,__LINE__); | |
3589 | return; | |
3590 | } | |
3591 | ||
3592 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
3593 | ||
3594 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
3595 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
3596 | ||
3597 | Int_t binLo = static_cast<Int_t>(hn3ResponseJetPt->GetAxis(axisJetPtTHn3)->FindBin(jetPtLoLim)); | |
3598 | Int_t binUp = static_cast<Int_t>(hn3ResponseJetPt->GetAxis(axisJetPtTHn3)->FindBin(jetPtUpLim))-1; | |
3599 | ||
3600 | if(binUp > hn3ResponseJetPt->GetAxis(axisJetPtTHn3)->GetNbins()){ | |
3601 | Printf("%s:%d -- jet pt range %0.3f exceeds histo limits",(char*)__FILE__,__LINE__,jetPtUpLim); | |
3602 | return; | |
3603 | } | |
3604 | ||
3605 | TString strNameRespPt(Form("hnResponsePt_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3606 | TString strNameRespZ(Form("hnResponseZ_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3607 | TString strNameRespXi(Form("hnResponseXi_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3608 | ||
3609 | TString strNameTH2RespPt(Form("h2ResponsePt_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3610 | TString strNameTH2RespZ(Form("h2ResponseZ_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3611 | TString strNameTH2RespXi(Form("h2ResponseXi_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
3612 | ||
3613 | TString strNameRecPt(Form("h1FFTrackPtRecPrim_recPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3614 | TString strNameRecZ(Form("h1FFZRecPrim_recPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3615 | TString strNameRecXi(Form("h1FFXiRecPrim_recPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3616 | ||
3617 | TString strNameGenPt(Form("h1FFTrackPtRecPrim_genPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3618 | TString strNameGenZ(Form("h1FFZRecPrim_genPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3619 | TString strNameGenXi(Form("h1FFXiRecPrim_genPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3620 | ||
3621 | TString strNameRatioPt(Form("h1RatioTrackPtRecPrim_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3622 | TString strNameRatioZ(Form("h1RatioZRecPrim_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3623 | TString strNameRatioXi(Form("h1RatioXiRecPrim_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
3624 | ||
3625 | ||
3626 | // 2D projections in jet pt range | |
3627 | ||
3628 | hn3ResponseJetPt->GetAxis(axisJetPtTHn3)->SetRange(binLo,binUp); | |
3629 | hn3ResponseJetZ->GetAxis(axisJetPtTHn3)->SetRange(binLo,binUp); | |
3630 | hn3ResponseJetXi->GetAxis(axisJetPtTHn3)->SetRange(binLo,binUp); | |
3631 | ||
3632 | Int_t axesProj[2] = {axisRecPtTHn3,axisGenPtTHn3}; | |
3633 | ||
3634 | hnResponsePt[i] = hn3ResponseJetPt->Projection(2,axesProj); | |
3635 | hnResponseZ[i] = hn3ResponseJetZ->Projection(2,axesProj); | |
3636 | hnResponseXi[i] = hn3ResponseJetXi->Projection(2,axesProj); | |
3637 | ||
3638 | hnResponsePt[i]->SetNameTitle(strNameRespPt,""); | |
3639 | hnResponseZ[i]->SetNameTitle(strNameRespZ,""); | |
3640 | hnResponseXi[i]->SetNameTitle(strNameRespXi,""); | |
3641 | ||
3642 | h2ResponsePt[i] = (TH2F*) hnResponsePt[i]->Projection(1,0);// note convention: yDim,xDim | |
3643 | h2ResponseZ[i] = (TH2F*) hnResponseZ[i]->Projection(1,0); // note convention: yDim,xDim | |
3644 | h2ResponseXi[i] = (TH2F*) hnResponseXi[i]->Projection(1,0);// note convention: yDim,xDim | |
3645 | ||
3646 | h2ResponsePt[i]->SetNameTitle(strNameTH2RespPt,""); | |
3647 | h2ResponseZ[i]->SetNameTitle(strNameTH2RespZ,""); | |
3648 | h2ResponseXi[i]->SetNameTitle(strNameTH2RespXi,""); | |
3649 | ||
3650 | ||
3651 | // 1D projections | |
3652 | ||
3653 | Int_t axisGenPtTHn2 = -1; | |
3654 | Int_t axisRecPtTHn2 = -1; | |
3655 | ||
3656 | for(Int_t d=0; d<hnResponsePt[i]->GetNdimensions(); d++){ | |
3657 | ||
3658 | TString title = hnResponsePt[i]->GetAxis(d)->GetTitle(); | |
3659 | ||
3660 | if(title.Contains("gen p_{T}")) axisGenPtTHn2 = d; | |
3661 | if(title.Contains("rec p_{T}")) axisRecPtTHn2 = d; | |
3662 | } | |
3663 | ||
3664 | ||
3665 | if(axisGenPtTHn2 == -1){ | |
3666 | Printf("%s:%d -- error axisGenPtTHn2",(char*)__FILE__,__LINE__); | |
3667 | return; | |
3668 | } | |
3669 | ||
3670 | if(axisRecPtTHn2 == -1){ | |
3671 | Printf("%s:%d -- error axisRecPtTHn2",(char*)__FILE__,__LINE__); | |
3672 | return; | |
3673 | } | |
3674 | ||
3675 | ||
3676 | h1FFPtRec[i] = (TH1F*) hnResponsePt[i]->Projection(axisRecPtTHn2);// note convention: yDim,xDim | |
3677 | h1FFZRec[i] = (TH1F*) hnResponseZ[i]->Projection(axisRecPtTHn2);// note convention: yDim,xDim | |
3678 | h1FFXiRec[i] = (TH1F*) hnResponseXi[i]->Projection(axisRecPtTHn2);// note convention: yDim,xDim | |
3679 | ||
3680 | h1FFPtRec[i]->SetNameTitle(strNameRecPt,""); | |
3681 | h1FFZRec[i]->SetNameTitle(strNameRecZ,""); | |
3682 | h1FFXiRec[i]->SetNameTitle(strNameRecXi,""); | |
3683 | ||
3684 | h1FFPtGen[i] = (TH1F*) hnResponsePt[i]->Projection(axisGenPtTHn2);// note convention: yDim,xDim | |
3685 | h1FFZGen[i] = (TH1F*) hnResponseZ[i]->Projection(axisGenPtTHn2);// note convention: yDim,xDim | |
3686 | h1FFXiGen[i] = (TH1F*) hnResponseXi[i]->Projection(axisGenPtTHn2);// note convention: yDim,xDim | |
3687 | ||
3688 | h1FFPtGen[i]->SetNameTitle(strNameGenPt,""); | |
3689 | h1FFZGen[i]->SetNameTitle(strNameGenZ,""); | |
3690 | h1FFXiGen[i]->SetNameTitle(strNameGenXi,""); | |
3691 | ||
3692 | // normalize 1D projections | |
3693 | ||
3694 | if(fNHistoBinsPt[i]) h1FFPtRec[i] = (TH1F*) h1FFPtRec[i]->Rebin(fNHistoBinsPt[i],"",fHistoBinsPt[i]->GetArray()); | |
3695 | if(fNHistoBinsZ[i]) h1FFZRec[i] = (TH1F*) h1FFZRec[i]->Rebin(fNHistoBinsZ[i],"",fHistoBinsZ[i]->GetArray()); | |
3696 | if(fNHistoBinsXi[i]) h1FFXiRec[i] = (TH1F*) h1FFXiRec[i]->Rebin(fNHistoBinsXi[i],"",fHistoBinsXi[i]->GetArray()); | |
3697 | ||
3698 | if(fNHistoBinsPt[i]) h1FFPtGen[i] = (TH1F*) h1FFPtGen[i]->Rebin(fNHistoBinsPt[i],"",fHistoBinsPt[i]->GetArray()); | |
3699 | if(fNHistoBinsZ[i]) h1FFZGen[i] = (TH1F*) h1FFZGen[i]->Rebin(fNHistoBinsZ[i],"",fHistoBinsZ[i]->GetArray()); | |
3700 | if(fNHistoBinsXi[i]) h1FFXiGen[i] = (TH1F*) h1FFXiGen[i]->Rebin(fNHistoBinsXi[i],"",fHistoBinsXi[i]->GetArray()); | |
3701 | ||
3702 | NormalizeTH1(h1FFPtRec[i],fNJets->At(i)); | |
3703 | NormalizeTH1(h1FFZRec[i],fNJets->At(i)); | |
3704 | NormalizeTH1(h1FFXiRec[i],fNJets->At(i)); | |
3705 | ||
3706 | NormalizeTH1(h1FFPtGen[i],fNJets->At(i)); | |
3707 | NormalizeTH1(h1FFZGen[i],fNJets->At(i)); | |
3708 | NormalizeTH1(h1FFXiGen[i],fNJets->At(i)); | |
3709 | ||
3710 | // ratios 1D projections | |
3711 | ||
3712 | h1RatioPt[i] = (TH1F*) h1FFPtRec[i]->Clone(strNameRatioPt); | |
3713 | h1RatioPt[i]->Reset(); | |
3714 | h1RatioPt[i]->Divide(h1FFPtRec[i],h1FFPtGen[i],1,1,"B"); | |
3715 | ||
3716 | h1RatioZ[i] = (TH1F*) h1FFZRec[i]->Clone(strNameRatioZ); | |
3717 | h1RatioZ[i]->Reset(); | |
3718 | h1RatioZ[i]->Divide(h1FFZRec[i],h1FFZGen[i],1,1,"B"); | |
3719 | ||
3720 | h1RatioXi[i] = (TH1F*) h1FFXiRec[i]->Clone(strNameRatioXi); | |
3721 | h1RatioXi[i]->Reset(); | |
3722 | h1RatioXi[i]->Divide(h1FFXiRec[i],h1FFXiGen[i],1,1,"B"); | |
3723 | } | |
ce55b926 | 3724 | |
39e2b057 | 3725 | |
3726 | // write | |
3727 | ||
3728 | TString outfileOption = "RECREATE"; | |
3729 | if(updateOutfile) outfileOption = "UPDATE"; | |
3730 | ||
3731 | TFile out(strOutfile,outfileOption); | |
3732 | ||
3733 | if(!out.IsOpen()){ | |
3734 | Printf("%s:%d -- error opening response matrix output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
3735 | return; | |
3736 | } | |
3737 | ||
3738 | if(fDebug>0) Printf("%s:%d -- write response matrices to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
3739 | ||
ce55b926 | 3740 | if(strOutDir && strOutDir.Length()){ |
3741 | ||
3742 | TDirectory* dir; | |
3743 | if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd(); | |
3744 | else{ | |
3745 | dir = out.mkdir(strOutDir); | |
3746 | dir->cd(); | |
3747 | } | |
3748 | } | |
3749 | ||
3750 | ||
3751 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
39e2b057 | 3752 | |
3753 | hnResponsePt[i]->Write(); | |
3754 | hnResponseXi[i]->Write(); | |
3755 | hnResponseZ[i]->Write(); | |
3756 | ||
3757 | h2ResponsePt[i]->Write(); | |
3758 | h2ResponseXi[i]->Write(); | |
3759 | h2ResponseZ[i]->Write(); | |
3760 | ||
3761 | h1FFPtRec[i]->Write(); | |
3762 | h1FFZRec[i]->Write(); | |
3763 | h1FFXiRec[i]->Write(); | |
3764 | ||
3765 | h1FFPtGen[i]->Write(); | |
3766 | h1FFZGen[i]->Write(); | |
3767 | h1FFXiGen[i]->Write(); | |
3768 | ||
3769 | h1RatioPt[i]->Write(); | |
3770 | h1RatioZ[i]->Write(); | |
3771 | h1RatioXi[i]->Write(); | |
3772 | ||
3773 | } | |
3774 | ||
3775 | out.Close(); | |
3776 | } | |
3777 | ||
3778 | //______________________________________________________________________________________________________ | |
3779 | void AliFragmentationFunctionCorrections::ReadResponse(TString strfile, TString strdir, TString strlist) | |
3780 | { | |
3781 | // read response matrices from file | |
3782 | // argument strlist optional - read from directory strdir if not specified | |
3783 | // note: THnSparse are not rebinned | |
3784 | ||
3785 | THnSparse* hRespPt[fNJetPtSlices]; | |
3786 | THnSparse* hRespZ[fNJetPtSlices]; | |
3787 | THnSparse* hRespXi[fNJetPtSlices]; | |
3788 | ||
3789 | for(Int_t i=0; i<fNJetPtSlices; i++) hRespPt[i] = 0; | |
3790 | for(Int_t i=0; i<fNJetPtSlices; i++) hRespZ[i] = 0; | |
3791 | for(Int_t i=0; i<fNJetPtSlices; i++) hRespXi[i] = 0; | |
3792 | ||
3793 | TFile f(strfile,"READ"); | |
3794 | ||
3795 | if(!f.IsOpen()){ | |
3796 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
3797 | return; | |
3798 | } | |
3799 | ||
3800 | if(fDebug>0) Printf("%s:%d -- read response matrices from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
3801 | ||
3802 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
3803 | ||
3804 | TList* list = 0; | |
3805 | ||
3806 | if(strlist && strlist.Length()){ | |
3807 | ||
3808 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
3809 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
3810 | return; | |
3811 | } | |
3812 | } | |
3813 | ||
3814 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
3815 | ||
3816 | Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i)); | |
3817 | Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1)); | |
3818 | ||
3819 | TString strNameRespPt(Form("hnResponsePt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
3820 | TString strNameRespZ(Form("hnResponseZ_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
3821 | TString strNameRespXi(Form("hnResponseXi_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
3822 | ||
3823 | if(list){ | |
3824 | hRespPt[i] = (THnSparse*) list->FindObject(strNameRespPt); | |
3825 | hRespZ[i] = (THnSparse*) list->FindObject(strNameRespZ); | |
3826 | hRespXi[i] = (THnSparse*) list->FindObject(strNameRespXi); | |
3827 | } | |
3828 | else{ | |
3829 | hRespPt[i] = (THnSparse*) gDirectory->Get(strNameRespPt); | |
3830 | hRespZ[i] = (THnSparse*) gDirectory->Get(strNameRespZ); | |
3831 | hRespXi[i] = (THnSparse*) gDirectory->Get(strNameRespXi); | |
3832 | } | |
3833 | ||
3834 | if(!hRespPt[i]){ | |
3835 | Printf("%s:%d -- error retrieving response %s", (char*)__FILE__,__LINE__,strNameRespPt.Data()); | |
3836 | } | |
3837 | ||
3838 | if(!hRespZ[i]){ | |
3839 | Printf("%s:%d -- error retrieving response %s", (char*)__FILE__,__LINE__,strNameRespZ.Data()); | |
3840 | } | |
3841 | ||
3842 | if(!hRespXi[i]){ | |
3843 | Printf("%s:%d -- error retrieving response %s", (char*)__FILE__,__LINE__,strNameRespXi.Data()); | |
3844 | } | |
3845 | ||
3846 | // if(0){ // can't rebin THnSparse ... | |
3847 | // if(fNHistoBinsPt[i]) hRespPt[i]->SetBinEdges(0,fHistoBinsPt[i]->GetArray()); | |
3848 | // if(fNHistoBinsPt[i]) hRespPt[i]->SetBinEdges(1,fHistoBinsPt[i]->GetArray()); | |
3849 | ||
3850 | // if(fNHistoBinsZ[i]) hRespZ[i]->SetBinEdges(0,fHistoBinsZ[i]->GetArray()); | |
3851 | // if(fNHistoBinsZ[i]) hRespZ[i]->SetBinEdges(1,fHistoBinsZ[i]->GetArray()); | |
3852 | ||
3853 | // if(fNHistoBinsXi[i]) hRespXi[i]->SetBinEdges(0,fHistoBinsXi[i]->GetArray()); | |
3854 | // if(fNHistoBinsXi[i]) hRespXi[i]->SetBinEdges(1,fHistoBinsXi[i]->GetArray()); | |
3855 | // } | |
3856 | ||
3857 | ||
3858 | } // jet slices loop | |
3859 | ||
3860 | f.Close(); // THnSparse pointers still valid even if file closed | |
3861 | ||
3862 | // for(Int_t i=0; i<fNJetPtSlices; i++){ // no copy c'tor ... | |
3863 | // if(hRespPt[i]) new(fhnResponsePt[i]) THnSparseF(*hRespPt[i]); | |
3864 | // if(hRespZ[i]) new(fhnResponseZ[i]) THnSparseF(*hRespZ[i]); | |
3865 | // if(hRespXi[i]) new(fhnResponseXi[i]) THnSparseF(*hRespXi[i]); | |
3866 | // } | |
3867 | ||
3868 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
3869 | fhnResponsePt[i] = hRespPt[i]; | |
3870 | fhnResponseZ[i] = hRespZ[i]; | |
3871 | fhnResponseXi[i] = hRespXi[i]; | |
3872 | } | |
3873 | } | |
3874 | ||
3875 | //______________________________________________________________________________________________________________________ | |
3876 | void AliFragmentationFunctionCorrections::ReadPriors(TString strfile,const Int_t type) | |
3877 | { | |
3878 | // read priors from file: rec primaries, gen pt dist | |
3879 | ||
3880 | if(fDebug>0) Printf("%s:%d -- read priors from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
3881 | ||
3882 | // temporary histos to store pointers from file | |
3883 | TH1F* hist[fNJetPtSlices]; | |
3884 | ||
3885 | for(Int_t i=0; i<fNJetPtSlices; i++) hist[i] = 0; | |
3886 | ||
3887 | TFile f(strfile,"READ"); | |
3888 | ||
3889 | if(!f.IsOpen()){ | |
3890 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
3891 | return; | |
3892 | } | |
3893 | ||
3894 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
3895 | ||
3896 | Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i)); | |
3897 | Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1)); | |
3898 | ||
3899 | TString strName; | |
3900 | ||
3901 | if(type == kFlagPt) strName.Form("h1FFTrackPtRecPrim_genPt_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
3902 | if(type == kFlagZ) strName.Form("h1FFZRecPrim_genPt_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
3903 | if(type == kFlagXi) strName.Form("h1FFXiRecPrim_genPt_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
3904 | ||
3905 | hist[i] = (TH1F*) gDirectory->Get(strName); | |
3906 | ||
3907 | if(!hist[i]){ | |
3908 | Printf("%s:%d -- error retrieving prior %s", (char*)__FILE__,__LINE__,strName.Data()); | |
3909 | } | |
3910 | ||
3911 | ||
3912 | //if(fNHistoBinsPt[i]) hist[i] = (TH1F*) hist[i]->Rebin(fNHistoBinsPt[i],hist[i]->GetName()+"_rebin",fHistoBinsPt[i]->GetArray()); | |
3913 | ||
3914 | if(hist[i]) hist[i]->SetDirectory(0); | |
3915 | ||
3916 | } // jet slices loop | |
3917 | ||
3918 | f.Close(); | |
3919 | ||
3920 | ||
3921 | for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos | |
3922 | if(hist[i] && type == kFlagPt) new(fh1FFTrackPtPrior[i]) TH1F(*hist[i]); | |
3923 | if(hist[i] && type == kFlagZ) new(fh1FFZPrior[i]) TH1F(*hist[i]); | |
3924 | if(hist[i] && type == kFlagXi) new(fh1FFXiPrior[i]) TH1F(*hist[i]); | |
3925 | } | |
3926 | } | |
3927 | ||
ce55b926 | 3928 | |
39e2b057 | 3929 | //_____________________________________________________ |
3930 | // void AliFragmentationFunctionCorrections::RatioRecGen() | |
3931 | // { | |
3932 | // // create ratio reconstructed over generated FF | |
3933 | // // use current highest corrLevel | |
3934 | ||
3935 | // Printf("%s:%d -- build ratio rec.gen, corrLevel %d",(char*)__FILE__,__LINE__,fNCorrectionLevels-1); | |
3936 | ||
3937 | // for(Int_t i=0; i<fNJetPtSlices; i++){ | |
3938 | ||
3939 | // TH1F* histPtRec = fCorrFF[fNCorrectionLevels-1]->GetTrackPt(i); // levels -1: latest corr level | |
3940 | // TH1F* histZRec = fCorrFF[fNCorrectionLevels-1]->GetZ(i); // levels -1: latest corr level | |
3941 | // TH1F* histXiRec = fCorrFF[fNCorrectionLevels-1]->GetXi(i); // levels -1: latest corr level | |
3942 | ||
3943 | // TH1F* histPtGen = fh1FFTrackPtGenPrim[i]; | |
3944 | // TH1F* histZGen = fh1FFZGenPrim[i]; | |
3945 | // TH1F* histXiGen = fh1FFXiGenPrim[i]; | |
3946 | ||
3947 | // TString histNamePt = histPtRec->GetName(); | |
3948 | // TString histNameZ = histZRec->GetName(); | |
3949 | // TString histNameXi = histXiRec->GetName(); | |
3950 | ||
3951 | // histNamePt.ReplaceAll("fh1FF","fh1FFRatioRecGen"); | |
3952 | // histNameZ.ReplaceAll("fh1FF","fh1FFRatioRecGen"); | |
3953 | // histNameXi.ReplaceAll("fh1FF","fh1FFRatioRecGen"); | |
3954 | ||
3955 | // // ratio | |
3956 | // TH1F* hRatioRecGenPt = (TH1F*) histPtRec->Clone(histNamePt); | |
3957 | // hRatioRecGenPt->Reset(); | |
3958 | // hRatioRecGenPt->Divide(histPtRec,histPtGen,1,1,"B"); | |
3959 | ||
3960 | // TH1F* hRatioRecGenZ = (TH1F*) histZRec->Clone(histNameZ); | |
3961 | // hRatioRecGenZ->Reset(); | |
3962 | // hRatioRecGenZ->Divide(histZRec,histZGen,1,1,"B"); | |
3963 | ||
3964 | // TH1F* hRatioRecGenXi = (TH1F*) histXiRec->Clone(histNameXi); | |
3965 | // hRatioRecGenXi->Reset(); | |
3966 | // hRatioRecGenXi->Divide(histXiRec,histXiGen,1,1,"B"); | |
3967 | ||
3968 | // new(fh1FFRatioRecGenPt[i]) TH1F(*hRatioRecGenPt); | |
3969 | // new(fh1FFRatioRecGenZ[i]) TH1F(*hRatioRecGenZ); | |
3970 | // new(fh1FFRatioRecGenXi[i]) TH1F(*hRatioRecGenXi); | |
3971 | // } | |
3972 | // } | |
3973 | ||
3974 | // //___________________________________________________________ | |
3975 | // void AliFragmentationFunctionCorrections::RatioRecPrimaries() | |
3976 | // { | |
3977 | // // create ratio reconstructed tracks over reconstructed primaries | |
3978 | // // use raw FF (corrLevel 0) | |
3979 | ||
3980 | // Printf("%s:%d -- build ratio rec tracks /rec primaries",(char*)__FILE__,__LINE__); | |
3981 | ||
3982 | // for(Int_t i=0; i<fNJetPtSlices; i++){ | |
3983 | ||
3984 | // const Int_t corrLevel = 0; | |
3985 | ||
3986 | // TH1F* histPtRec = fCorrFF[corrLevel]->GetTrackPt(i); // levels -1: latest corr level | |
3987 | // TH1F* histZRec = fCorrFF[corrLevel]->GetZ(i); // levels -1: latest corr level | |
3988 | // TH1F* histXiRec = fCorrFF[corrLevel]->GetXi(i); // levels -1: latest corr level | |
3989 | ||
3990 | // TH1F* histPtRecPrim = fh1FFTrackPtRecPrim[i]; | |
3991 | // TH1F* histZRecPrim = fh1FFZRecPrim[i]; | |
3992 | // TH1F* histXiRecPrim = fh1FFXiRecPrim[i]; | |
3993 | ||
3994 | // TString histNamePt = histPtRec->GetName(); | |
3995 | // TString histNameZ = histZRec->GetName(); | |
3996 | // TString histNameXi = histXiRec->GetName(); | |
3997 | ||
3998 | // histNamePt.ReplaceAll("fh1FF","fh1FFRatioRecPrim"); | |
3999 | // histNameZ.ReplaceAll("fh1FF","fh1FFRatioRecPrim"); | |
4000 | // histNameXi.ReplaceAll("fh1FF","fh1FFRatioRecPrim"); | |
4001 | ||
4002 | // // ratio | |
4003 | // TH1F* hRatioRecPrimPt = (TH1F*) histPtRec->Clone(histNamePt); | |
4004 | // hRatioRecPrimPt->Reset(); | |
4005 | // hRatioRecPrimPt->Divide(histPtRec,histPtRecPrim,1,1,"B"); | |
4006 | ||
4007 | // TH1F* hRatioRecPrimZ = (TH1F*) histZRec->Clone(histNameZ); | |
4008 | // hRatioRecPrimZ->Reset(); | |
4009 | // hRatioRecPrimZ->Divide(histZRec,histZRecPrim,1,1,"B"); | |
4010 | ||
4011 | // TH1F* hRatioRecPrimXi = (TH1F*) histXiRec->Clone(histNameXi); | |
4012 | // hRatioRecPrimXi->Reset(); | |
4013 | // hRatioRecPrimXi->Divide(histXiRec,histXiRecPrim,1,1,"B"); | |
4014 | ||
4015 | ||
4016 | // new(fh1FFRatioRecPrimPt[i]) TH1F(*hRatioRecPrimPt); | |
4017 | // new(fh1FFRatioRecPrimZ[i]) TH1F(*hRatioRecPrimZ); | |
4018 | // new(fh1FFRatioRecPrimXi[i]) TH1F(*hRatioRecPrimXi); | |
4019 | // } | |
4020 | // } | |
4021 | ||
4022 | // __________________________________________________________________________________ | |
4023 | void AliFragmentationFunctionCorrections::ProjectJetResponseMatrices(TString strOutfile) | |
4024 | { | |
4025 | ||
4026 | // project response matrices on both axes: | |
4027 | // FF for rec primaries, in terms of generated and reconstructed momentum | |
4028 | // write FF and ratios to outFile | |
4029 | ||
4030 | Printf("%s:%d -- project response matrices, write to %s",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
4031 | ||
4032 | TH1F* hFFPtRec[fNJetPtSlices]; | |
4033 | TH1F* hFFZRec[fNJetPtSlices]; | |
4034 | TH1F* hFFXiRec[fNJetPtSlices]; | |
4035 | ||
4036 | TH1F* hFFPtGen[fNJetPtSlices]; | |
4037 | TH1F* hFFZGen[fNJetPtSlices]; | |
4038 | TH1F* hFFXiGen[fNJetPtSlices]; | |
4039 | ||
4040 | TH1F* hRatioPt[fNJetPtSlices]; | |
4041 | TH1F* hRatioZ[fNJetPtSlices]; | |
4042 | TH1F* hRatioXi[fNJetPtSlices]; | |
4043 | ||
4044 | ||
4045 | Int_t axisGenPt = 1; | |
4046 | Int_t axisRecPt = 0; | |
4047 | ||
4048 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
4049 | ||
4050 | Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i)); | |
4051 | Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1)); | |
4052 | ||
4053 | TString strNameRecPt(Form("h1FFTrackPtRecPrim_recPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4054 | TString strNameRecZ(Form("h1FFZRecPrim_recPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4055 | TString strNameRecXi(Form("h1FFXiRecPrim_recPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4056 | ||
4057 | TString strNameGenPt(Form("h1FFTrackPtRecPrim_genPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4058 | TString strNameGenZ(Form("h1FFZRecPrim_genPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4059 | TString strNameGenXi(Form("h1FFXiRecPrim_genPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4060 | ||
4061 | TString strNameRatioPt(Form("h1RatioTrackPtRecPrim_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4062 | TString strNameRatioZ(Form("h1RatioZRecPrim_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4063 | TString strNameRatioXi(Form("h1RatioXiRecPrim_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
4064 | ||
4065 | ||
4066 | hFFPtRec[i] = (TH1F*) fhnResponsePt[i]->Projection(axisRecPt);// note convention: yDim,xDim | |
4067 | hFFZRec[i] = (TH1F*) fhnResponseZ[i]->Projection(axisRecPt);// note convention: yDim,xDim | |
4068 | hFFXiRec[i] = (TH1F*) fhnResponseXi[i]->Projection(axisRecPt);// note convention: yDim,xDim | |
4069 | ||
4070 | hFFPtRec[i]->SetNameTitle(strNameRecPt,""); | |
4071 | hFFZRec[i]->SetNameTitle(strNameRecZ,""); | |
4072 | hFFXiRec[i]->SetNameTitle(strNameRecXi,""); | |
4073 | ||
4074 | ||
4075 | hFFPtGen[i] = (TH1F*) fhnResponsePt[i]->Projection(axisGenPt);// note convention: yDim,xDim | |
4076 | hFFZGen[i] = (TH1F*) fhnResponseZ[i]->Projection(axisGenPt);// note convention: yDim,xDim | |
4077 | hFFXiGen[i] = (TH1F*) fhnResponseXi[i]->Projection(axisGenPt);// note convention: yDim,xDim | |
4078 | ||
4079 | hFFPtGen[i]->SetNameTitle(strNameGenPt,""); | |
4080 | hFFZGen[i]->SetNameTitle(strNameGenZ,""); | |
4081 | hFFXiGen[i]->SetNameTitle(strNameGenXi,""); | |
4082 | ||
4083 | ||
4084 | if(fNHistoBinsPt[i]) hFFPtRec[i] = (TH1F*) hFFPtRec[i]->Rebin(fNHistoBinsPt[i],"",fHistoBinsPt[i]->GetArray()); | |
4085 | if(fNHistoBinsZ[i]) hFFZRec[i] = (TH1F*) hFFZRec[i]->Rebin(fNHistoBinsZ[i],"",fHistoBinsZ[i]->GetArray()); | |
4086 | if(fNHistoBinsXi[i]) hFFXiRec[i] = (TH1F*) hFFXiRec[i]->Rebin(fNHistoBinsXi[i],"",fHistoBinsXi[i]->GetArray()); | |
4087 | ||
4088 | if(fNHistoBinsPt[i]) hFFPtGen[i] = (TH1F*) hFFPtGen[i]->Rebin(fNHistoBinsPt[i],"",fHistoBinsPt[i]->GetArray()); | |
4089 | if(fNHistoBinsZ[i]) hFFZGen[i] = (TH1F*) hFFZGen[i]->Rebin(fNHistoBinsZ[i],"",fHistoBinsZ[i]->GetArray()); | |
4090 | if(fNHistoBinsXi[i]) hFFXiGen[i] = (TH1F*) hFFXiGen[i]->Rebin(fNHistoBinsXi[i],"",fHistoBinsXi[i]->GetArray()); | |
4091 | ||
4092 | NormalizeTH1(hFFPtGen[i],fNJets->At(i)); | |
4093 | NormalizeTH1(hFFZGen[i],fNJets->At(i)); | |
4094 | NormalizeTH1(hFFXiGen[i],fNJets->At(i)); | |
4095 | ||
4096 | NormalizeTH1(hFFPtRec[i],fNJets->At(i)); | |
4097 | NormalizeTH1(hFFZRec[i],fNJets->At(i)); | |
4098 | NormalizeTH1(hFFXiRec[i],fNJets->At(i)); | |
4099 | ||
4100 | ||
4101 | hRatioPt[i] = (TH1F*) hFFPtRec[i]->Clone(strNameRatioPt); | |
4102 | hRatioPt[i]->Reset(); | |
4103 | hRatioPt[i]->Divide(hFFPtRec[i],hFFPtGen[i],1,1,"B"); | |
4104 | ||
4105 | hRatioZ[i] = (TH1F*) hFFZRec[i]->Clone(strNameRatioZ); | |
4106 | hRatioZ[i]->Reset(); | |
4107 | hRatioZ[i]->Divide(hFFZRec[i],hFFZGen[i],1,1,"B"); | |
4108 | ||
4109 | hRatioXi[i] = (TH1F*) hFFXiRec[i]->Clone(strNameRatioXi); | |
4110 | hRatioXi[i]->Reset(); | |
4111 | hRatioXi[i]->Divide(hFFXiRec[i],hFFXiGen[i],1,1,"B"); | |
4112 | } | |
4113 | ||
4114 | ||
4115 | ||
4116 | // write | |
4117 | ||
4118 | TFile out(strOutfile,"RECREATE"); | |
4119 | ||
4120 | if(!out.IsOpen()){ | |
4121 | Printf("%s:%d -- error opening response matrix output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
4122 | return; | |
4123 | } | |
4124 | ||
4125 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
4126 | ||
4127 | hFFPtRec[i]->Write(); | |
4128 | hFFZRec[i]->Write(); | |
4129 | hFFXiRec[i]->Write(); | |
4130 | ||
4131 | hFFPtGen[i]->Write(); | |
4132 | hFFZGen[i]->Write(); | |
4133 | hFFXiGen[i]->Write(); | |
4134 | ||
4135 | hRatioPt[i]->Write(); | |
4136 | hRatioZ[i]->Write(); | |
4137 | hRatioXi[i]->Write(); | |
4138 | } | |
4139 | ||
4140 | out.Close(); | |
4141 | } | |
4142 | ||
4143 | // ____________________________________________________________________________________________________________________________ | |
ce55b926 | 4144 | void AliFragmentationFunctionCorrections::ProjectSingleResponseMatrix(TString strOutfile, Bool_t updateOutfile, TString strOutDir) |
39e2b057 | 4145 | { |
4146 | // project response matrix on both axes: | |
4147 | // pt spec for rec primaries, in terms of generated and reconstructed momentum | |
4148 | // write spec and ratios to outFile | |
4149 | ||
4150 | Printf("%s:%d -- project single pt response matrix, write to %s",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
4151 | ||
4152 | TH1F* hSpecPtRec; | |
4153 | TH1F* hSpecPtGen; | |
4154 | TH1F* hRatioPt; | |
4155 | ||
4156 | Int_t axisGenPt = 1; | |
4157 | Int_t axisRecPt = 0; | |
4158 | ||
4159 | TString strNameRecPt = "h1SpecTrackPtRecPrim_recPt"; | |
4160 | TString strNameGenPt = "h1SpecTrackPtRecPrim_genPt"; | |
4161 | TString strNameRatioPt = "h1RatioTrackPtRecPrim"; | |
4162 | ||
4163 | hSpecPtRec = (TH1F*) fhnResponseSinglePt->Projection(axisRecPt);// note convention: yDim,xDim | |
4164 | hSpecPtRec->SetNameTitle(strNameRecPt,""); | |
4165 | ||
4166 | hSpecPtGen = (TH1F*) fhnResponseSinglePt->Projection(axisGenPt);// note convention: yDim,xDim | |
4167 | hSpecPtGen->SetNameTitle(strNameGenPt,""); | |
4168 | ||
4169 | hRatioPt = (TH1F*) hSpecPtRec->Clone(strNameRatioPt); | |
4170 | hRatioPt->Reset(); | |
4171 | hRatioPt->Divide(hSpecPtRec,hSpecPtGen,1,1,"B"); | |
4172 | ||
4173 | TString outfileOption = "RECREATE"; | |
4174 | if(updateOutfile) outfileOption = "UPDATE"; | |
4175 | ||
4176 | TFile out(strOutfile,outfileOption); | |
4177 | ||
4178 | if(!out.IsOpen()){ | |
4179 | Printf("%s:%d -- error opening reponse matrix projections output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
4180 | return; | |
4181 | } | |
4182 | ||
4183 | ||
4184 | if(strOutDir && strOutDir.Length()){ | |
4185 | ||
4186 | TDirectory* dir; | |
4187 | if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd(); | |
4188 | else{ | |
4189 | dir = out.mkdir(strOutDir); | |
4190 | dir->cd(); | |
4191 | } | |
4192 | } | |
4193 | ||
4194 | hSpecPtRec->Write(); | |
4195 | hSpecPtGen->Write(); | |
4196 | hRatioPt->Write(); | |
4197 | ||
4198 | out.Close(); | |
4199 | } | |
4200 | ||
4201 | ||
4202 | //__________________________________________________________________________________________________________________________________________________________________ | |
4203 | void AliFragmentationFunctionCorrections::RebinHisto(const Int_t jetPtSlice, const Int_t nBinsLimits, Double_t* binsLimits, Double_t* binsWidth, const Int_t type) | |
4204 | { | |
4205 | // rebin histo, rescale bins according to new width | |
4206 | // only correct for input histos with equal bin size | |
4207 | ||
4208 | // args: jetPtSlice, type, use current corr level | |
4209 | ||
4210 | // function takes array of limits and widths (e.g. 1 GeV bins up to 10 GeV, 2 GeV width up to 20 GeV, ...) | |
4211 | // array size of binsLimits: nBinsLimits | |
4212 | // array size of binsWidth: nBinsLimits-1 | |
4213 | // binsLimits have to be in increasing order | |
4214 | // if binning undefined for any slice, original binning will be kept | |
4215 | ||
4216 | if(!fNJetPtSlices){ | |
4217 | Printf("%s:%d -- jetPtSlices not defined", (char*)__FILE__,__LINE__); | |
4218 | return; | |
4219 | } | |
4220 | ||
4221 | if(jetPtSlice>=fNJetPtSlices){ | |
4222 | Printf("%s:%d -- jetPtSlice %d exceeds max",(char*)__FILE__,__LINE__,jetPtSlice); | |
4223 | return; | |
4224 | } | |
4225 | ||
4226 | ||
4227 | Double_t binLimitMin = binsLimits[0]; | |
4228 | Double_t binLimitMax = binsLimits[nBinsLimits-1]; | |
4229 | ||
4230 | Double_t binLimit = binLimitMin; // start value | |
4231 | ||
4232 | Int_t sizeUpperLim = 1000; //static_cast<Int_t>(binLimitMax/binsWidth[0])+1; - only if first bin has smallest width, but not case for dN/dxi ... | |
4233 | TArrayD binsArray(sizeUpperLim); | |
4234 | Int_t nBins = 0; | |
4235 | binsArray.SetAt(binLimitMin,nBins++); | |
4236 | ||
4237 | while(binLimit<binLimitMax && nBins<sizeUpperLim){ | |
4238 | ||
4239 | Int_t currentSlice = -1; | |
4240 | for(Int_t i=0; i<nBinsLimits; i++){ | |
4241 | if(binLimit >= 0.999*binsLimits[i]) currentSlice = i; // 0.999 numerical saftey factor | |
4242 | } | |
4243 | ||
4244 | Double_t currentBinWidth = binsWidth[currentSlice]; | |
4245 | binLimit += currentBinWidth; | |
4246 | ||
4247 | binsArray.SetAt(binLimit,nBins++); | |
4248 | } | |
4249 | ||
4250 | ||
4251 | TH1F* hist = 0; | |
a5592cfa | 4252 | if(type == kFlagPt) hist = fCorrFF[fNCorrectionLevels-1]->GetTrackPt(jetPtSlice); |
1aa4f09f | 4253 | else if(type == kFlagZ) hist = fCorrFF[fNCorrectionLevels-1]->GetZ(jetPtSlice); |
4254 | else if(type == kFlagXi) hist = fCorrFF[fNCorrectionLevels-1]->GetXi(jetPtSlice); | |
4255 | else if(type == kFlagSinglePt) hist = fCorrSinglePt[fNCorrectionLevelsSinglePt-1]->GetTrackPt(0); | |
4256 | else{ | |
4257 | Printf("%s%d unknown type",(char*)__FILE__,__LINE__); | |
4258 | return; | |
4259 | } | |
39e2b057 | 4260 | |
4261 | Double_t binWidthNoRebin = hist->GetBinWidth(1); | |
4262 | ||
4263 | Double_t* bins = binsArray.GetArray(); | |
4264 | ||
4265 | hist = (TH1F*) hist->Rebin(nBins-1,"",bins); | |
4266 | ||
4267 | for(Int_t bin=0; bin <= hist->GetNbinsX(); bin++){ | |
4268 | ||
4269 | Double_t binWidthRebin = hist->GetBinWidth(bin); | |
4270 | Double_t scaleF = binWidthNoRebin / binWidthRebin; | |
4271 | ||
4272 | Double_t binCont = hist->GetBinContent(bin); | |
4273 | Double_t binErr = hist->GetBinError(bin); | |
4274 | ||
4275 | binCont *= scaleF; | |
4276 | binErr *= scaleF; | |
4277 | ||
4278 | hist->SetBinContent(bin,binCont); | |
4279 | hist->SetBinError(bin,binErr); | |
4280 | } | |
4281 | ||
4282 | ||
4283 | ||
4284 | TH1F* temp = new TH1F(*hist); | |
4285 | ||
4286 | if(type == kFlagPt) fCorrFF[fNCorrectionLevels-1]->ReplaceCorrHistos(jetPtSlice,temp,0,0); | |
4287 | if(type == kFlagZ) fCorrFF[fNCorrectionLevels-1]->ReplaceCorrHistos(jetPtSlice,0,temp,0); | |
4288 | if(type == kFlagXi) fCorrFF[fNCorrectionLevels-1]->ReplaceCorrHistos(jetPtSlice,0,0,temp); | |
4289 | if(type == kFlagSinglePt) fCorrSinglePt[fNCorrectionLevelsSinglePt-1]->ReplaceCorrHistos(0,temp,0,0); | |
4290 | ||
4291 | ||
4292 | delete temp; | |
4293 | } | |
4294 | //__________________________________________________________________________________________________________________________________________________________________ | |
633ed180 | 4295 | void AliFragmentationFunctionCorrections::WriteJetSpecResponse(TString strInfile, TString strdir, TString strlist/*, TString strOutfile*/) |
39e2b057 | 4296 | { |
4297 | ||
4298 | if(fDebug>0) Printf("%s:%d -- read jet spectrum response matrix from file %s ",(char*)__FILE__,__LINE__,strInfile.Data()); | |
4299 | ||
4300 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
4301 | ||
4302 | TList* list = 0; | |
4303 | ||
441afcb9 | 4304 | if(strlist && strlist.Length()){ |
39e2b057 | 4305 | if(!(list = (TList*) gDirectory->Get(strlist))){ |
4306 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
4307 | return; | |
4308 | } | |
4309 | } | |
441afcb9 | 4310 | if(list == 0)return; // catch strlist.Lenght() == 0; |
4311 | ||
a5592cfa | 4312 | THnSparse* hn6ResponseJetPt = (THnSparse*) list->FindObject("fhnCorrelation"); |
4313 | ||
39e2b057 | 4314 | Int_t axis6RecJetPt = 0; |
4315 | Int_t axis6GenJetPt = 3; | |
4316 | ||
4317 | hn6ResponseJetPt->GetAxis(axis6RecJetPt)->SetTitle("rec jet p_{T} (GeV/c)"); | |
4318 | hn6ResponseJetPt->GetAxis(axis6GenJetPt)->SetTitle("gen jet p_{T} (GeV/c)"); | |
4319 | ||
4320 | Int_t nBinsRecPt = hn6ResponseJetPt->GetAxis(axis6RecJetPt)->GetNbins(); | |
4321 | Double_t loLimRecPt = hn6ResponseJetPt->GetAxis(axis6RecJetPt)->GetBinLowEdge(1); | |
4322 | Double_t upLimRecPt = hn6ResponseJetPt->GetAxis(axis6RecJetPt)->GetBinUpEdge(nBinsRecPt); | |
4323 | ||
4324 | Int_t nBinsGenPt = hn6ResponseJetPt->GetAxis(axis6GenJetPt)->GetNbins(); | |
4325 | Double_t loLimGenPt = hn6ResponseJetPt->GetAxis(axis6GenJetPt)->GetBinLowEdge(1); | |
4326 | Double_t upLimGenPt = hn6ResponseJetPt->GetAxis(axis6GenJetPt)->GetBinUpEdge(nBinsGenPt); | |
4327 | ||
4328 | Int_t nBinsTrackPt = 200; | |
4329 | Int_t loLimTrackPt = 0; | |
4330 | Int_t upLimTrackPt = 200; | |
4331 | ||
4332 | ||
4333 | Int_t nBinsResponse[4] = {nBinsRecPt,nBinsTrackPt,nBinsGenPt,nBinsTrackPt}; | |
4334 | Double_t binMinResponse[4] = {loLimRecPt,loLimTrackPt,loLimGenPt,loLimTrackPt}; | |
4335 | Double_t binMaxResponse[4] = {upLimRecPt,upLimTrackPt,upLimGenPt,upLimTrackPt}; | |
4336 | ||
4337 | const char* labelsResponseSinglePt[4] = {"rec jet p_{T} (GeV/c)", "rec track p_{T} (GeV/c)", "gen jet p_{T} (GeV/c)", "gen track p_{T} (GeV/c)"}; | |
4338 | ||
4339 | THnSparseD* hn4ResponseTrackPtJetPt = new THnSparseD("hn4ResponseTrackPtJetPt","",4,nBinsResponse,binMinResponse,binMaxResponse); | |
4340 | ||
4341 | for(Int_t i=0; i<4; i++){ | |
4342 | hn4ResponseTrackPtJetPt->GetAxis(i)->SetTitle(labelsResponseSinglePt[i]); | |
4343 | } | |
4344 | ||
4345 | ||
4346 | // fill | |
4347 | ||
4348 | ||
4349 | } | |
4350 | ||
4351 | //_____________________________________________________________________________________________________________________________________ | |
4352 | void AliFragmentationFunctionCorrections::ReadSingleTrackEfficiency(TString strfile, TString strdir, TString strlist, TString strname) | |
4353 | { | |
4354 | ||
4355 | ReadSingleTrackCorrection(strfile,strdir,strlist,strname,kFlagEfficiency); | |
4356 | ||
4357 | } | |
4358 | ||
4359 | //_____________________________________________________________________________________________________________________________________ | |
4360 | void AliFragmentationFunctionCorrections::ReadSingleTrackResponse(TString strfile, TString strdir, TString strlist, TString strname) | |
4361 | { | |
4362 | ||
4363 | ReadSingleTrackCorrection(strfile,strdir,strlist,strname,kFlagResponse); | |
4364 | ||
4365 | } | |
4366 | ||
4367 | //_____________________________________________________________________________________________________________________________________ | |
4368 | void AliFragmentationFunctionCorrections::ReadSingleTrackSecCorr(TString strfile, TString strdir, TString strlist, TString strname) | |
4369 | { | |
4370 | ||
4371 | ReadSingleTrackCorrection(strfile,strdir,strlist,strname,kFlagSecondaries); | |
4372 | ||
4373 | } | |
4374 | ||
4375 | //______________________________________________________________________________________________________________________________________________________ | |
4376 | void AliFragmentationFunctionCorrections::ReadSingleTrackCorrection(TString strfile, TString strdir, TString strlist, TString strname, const Int_t type) | |
4377 | { | |
4378 | // read single track correction (pt) from file | |
4379 | // type: efficiency / response / secondaries correction | |
4380 | ||
4381 | if(!((type == kFlagEfficiency) || (type == kFlagResponse) || (type == kFlagSecondaries))){ | |
4382 | Printf("%s:%d -- no such correction ",(char*)__FILE__,__LINE__); | |
4383 | return; | |
4384 | } | |
4385 | ||
4386 | TFile f(strfile,"READ"); | |
4387 | ||
4388 | if(!f.IsOpen()){ | |
4389 | Printf("%s:%d -- error opening file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
4390 | return; | |
4391 | } | |
4392 | ||
4393 | if(fDebug>0 && type==kFlagEfficiency) Printf("%s:%d -- read single track corr from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
4394 | if(fDebug>0 && type==kFlagResponse) Printf("%s:%d -- read single track response from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
4395 | if(fDebug>0 && type==kFlagSecondaries) Printf("%s:%d -- read single track secondaries corr from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
4396 | ||
4397 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
4398 | ||
4399 | TList* list = 0; | |
4400 | ||
4401 | if(strlist && strlist.Length()){ | |
4402 | ||
4403 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
4404 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
4405 | return; | |
4406 | } | |
4407 | } | |
4408 | ||
4409 | TH1F* h1CorrHist = 0; // common TObject pointer not possible, need SetDirectory() later | |
4410 | THnSparse* hnCorrHist = 0; | |
4411 | ||
4412 | if(type == kFlagEfficiency || type == kFlagSecondaries){ | |
4413 | ||
4414 | if(list) h1CorrHist = (TH1F*) list->FindObject(strname); | |
4415 | else h1CorrHist = (TH1F*) gDirectory->Get(strname); | |
4416 | ||
4417 | if(!h1CorrHist){ | |
4418 | Printf("%s:%d -- error retrieving histo %s", (char*)__FILE__,__LINE__,strname.Data()); | |
4419 | return; | |
4420 | } | |
4421 | ||
4422 | } | |
4423 | else if(type == kFlagResponse){ | |
4424 | ||
4425 | if(list) hnCorrHist = (THnSparse*) list->FindObject(strname); | |
4426 | else hnCorrHist = (THnSparse*) gDirectory->Get(strname); | |
4427 | ||
4428 | if(!hnCorrHist){ | |
4429 | Printf("%s:%d -- error retrieving histo %s", (char*)__FILE__,__LINE__,strname.Data()); | |
4430 | return; | |
4431 | } | |
4432 | ||
4433 | } | |
4434 | ||
4435 | if(h1CorrHist) h1CorrHist->SetDirectory(0); | |
4436 | //if(hnCorrHist) hnCorrHist->SetDirectory(0); | |
4437 | ||
4438 | f.Close(); | |
4439 | ||
4440 | if(type == kFlagEfficiency) fh1EffSinglePt = h1CorrHist; | |
4441 | else if(type == kFlagResponse) fhnResponseSinglePt = hnCorrHist; | |
4442 | else if(type == kFlagSecondaries) fh1SecCorrSinglePt = h1CorrHist; | |
4443 | ||
4444 | } | |
4445 | ||
4446 | //________________________________________________________________________________________________________________ | |
4447 | void AliFragmentationFunctionCorrections::ReadRawPtSpec(TString strInfile, TString strID) | |
4448 | { | |
4449 | // read track pt spec from task ouput - standard dir/list | |
4450 | ||
b541fbca | 4451 | TString strdir = "PWGJE_FragmentationFunction_" + strID; |
39e2b057 | 4452 | TString strlist = "fracfunc_" + strID; |
4453 | ||
4454 | ReadRawPtSpec(strInfile,strdir,strlist); | |
4455 | } | |
4456 | ||
4457 | //_______________________________________________________________________________________________________ | |
4458 | void AliFragmentationFunctionCorrections::ReadRawPtSpec(TString strfile, TString strdir, TString strlist) | |
4459 | { | |
4460 | // get raw pt spectra from file | |
4461 | ||
39e2b057 | 4462 | // book histos |
4463 | fNCorrectionLevelsSinglePt = 0; | |
4464 | fCorrSinglePt = new AliFragFuncCorrHistos*[fgMaxNCorrectionLevels]; | |
4465 | AddCorrectionLevelSinglePt(); // first 'correction' level = raw spectrum | |
4466 | ||
4467 | // get raw pt spec from input file, normalize | |
4468 | ||
4469 | TFile f(strfile,"READ"); | |
4470 | ||
4471 | if(!f.IsOpen()){ | |
4472 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
4473 | return; | |
4474 | } | |
4475 | ||
4476 | if(fDebug>0) Printf("%s:%d -- read raw spectra from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
4477 | ||
4478 | gDirectory->cd(strdir); | |
4479 | ||
4480 | TList* list = 0; | |
4481 | ||
4482 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
4483 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
4484 | return; | |
4485 | } | |
4486 | ||
4487 | TString hnameTrackPt("fh1TrackQAPtRecCuts"); | |
4488 | TString hnameEvtSel("fh1EvtSelection"); | |
4489 | ||
4490 | TH1F* fh1TrackPt = (TH1F*) list->FindObject(hnameTrackPt); | |
4491 | TH1F* fh1EvtSel = (TH1F*) list->FindObject(hnameEvtSel); | |
4492 | ||
4493 | if(!fh1TrackPt){ Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameTrackPt.Data()); return; } | |
4494 | if(!fh1EvtSel) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameEvtSel.Data()); return; } | |
ce55b926 | 4495 | |
4496 | Float_t nEvents = fh1EvtSel->GetBinContent(fh1EvtSel->FindBin(0)); | |
39e2b057 | 4497 | |
39e2b057 | 4498 | fh1TrackPt->SetDirectory(0); |
4499 | ||
4500 | f.Close(); | |
39e2b057 | 4501 | |
ce55b926 | 4502 | // rebin + normalize |
4503 | if(fNHistoBinsSinglePt) fh1TrackPt = (TH1F*) fh1TrackPt->Rebin(fNHistoBinsSinglePt,"",fHistoBinsSinglePt->GetArray()); | |
4504 | ||
39e2b057 | 4505 | NormalizeTH1(fh1TrackPt,nEvents); |
4506 | ||
4507 | // raw FF = corr level 0 | |
4508 | fCorrSinglePt[0]->AddCorrHistos(0,fh1TrackPt); | |
4509 | } | |
4510 | ||
4511 | ||
4512 | //_______________________________________________________________________________________________________ | |
4513 | void AliFragmentationFunctionCorrections::ReadRawPtSpecQATask(TString strfile, TString strdir, TString strlist) | |
4514 | { | |
4515 | // get raw pt spectra from file | |
4516 | // for output from Martas QA task | |
4517 | ||
4518 | ||
4519 | // book histos | |
4520 | fNCorrectionLevelsSinglePt = 0; | |
4521 | fCorrSinglePt = new AliFragFuncCorrHistos*[fgMaxNCorrectionLevels]; | |
4522 | AddCorrectionLevelSinglePt(); // first 'correction' level = raw spectrum | |
4523 | ||
4524 | // get raw pt spec from input file, normalize | |
4525 | ||
4526 | TFile f(strfile,"READ"); | |
4527 | ||
4528 | if(!f.IsOpen()){ | |
4529 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
4530 | return; | |
4531 | } | |
4532 | ||
4533 | if(fDebug>0) Printf("%s:%d -- read raw pt spec from QA task output file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
4534 | ||
4535 | gDirectory->cd(strdir); | |
4536 | ||
4537 | TList* list = 0; | |
4538 | ||
4539 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
4540 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
4541 | return; | |
4542 | } | |
4543 | ||
4544 | TString hnameTrackPt("fPtSel"); | |
4545 | TString hnameEvtSel("fNEventAll"); | |
4546 | ||
4547 | TH1F* fh1TrackPt = (TH1F*) list->FindObject(hnameTrackPt); | |
4548 | TH1F* fh1EvtSel = (TH1F*) list->FindObject(hnameEvtSel); | |
4549 | ||
4550 | if(!fh1TrackPt){ Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameTrackPt.Data()); return; } | |
4551 | if(!fh1EvtSel) { Printf("%s:%d -- histo %s not found",(char*)__FILE__,__LINE__,hnameEvtSel.Data()); return; } | |
4552 | ||
4553 | ||
4554 | // evts after physics selection | |
4555 | Float_t nEvents = fh1EvtSel->GetEntries(); | |
4556 | ||
4557 | fh1TrackPt->SetDirectory(0); | |
4558 | ||
4559 | f.Close(); | |
4560 | ||
4561 | ||
4562 | NormalizeTH1(fh1TrackPt,nEvents); | |
4563 | ||
4564 | // raw FF = corr level 0 | |
4565 | fCorrSinglePt[0]->AddCorrHistos(0,fh1TrackPt); | |
4566 | } | |
4567 | ||
4568 | // ________________________________________________________ | |
4569 | void AliFragmentationFunctionCorrections::EffCorrSinglePt() | |
4570 | { | |
4571 | // apply efficiency correction to inclusive track pt spec | |
4572 | ||
4573 | AddCorrectionLevelSinglePt("eff"); | |
4574 | ||
4575 | TH1F* histPt = fCorrSinglePt[fNCorrectionLevelsSinglePt-2]->GetTrackPt(0); | |
4576 | ||
4577 | if(histPt->GetNbinsX() != fh1EffSinglePt->GetNbinsX()) Printf("%s:%d: inconsistency pt spec and eff corr bins - rebin effCorr ...", (char*)__FILE__,__LINE__); | |
4578 | ||
4579 | TString histNamePt = histPt->GetName(); | |
4580 | TH1F* hTrackPtEffCorr = (TH1F*) histPt->Clone(histNamePt); | |
4581 | hTrackPtEffCorr->Divide(histPt,fh1EffSinglePt,1,1,""); | |
4582 | ||
4583 | fCorrSinglePt[fNCorrectionLevelsSinglePt-1]->AddCorrHistos(0,hTrackPtEffCorr); | |
4584 | } | |
4585 | ||
4586 | //___________________________________________________________________________________________________________________________ | |
4587 | void AliFragmentationFunctionCorrections::UnfoldSinglePt(const Int_t nIter, const Bool_t useCorrelatedErrors) | |
4588 | { | |
4589 | // unfolde inclusive dN/dpt spectra | |
4590 | ||
4591 | AddCorrectionLevelSinglePt("unfold"); | |
4592 | ||
4593 | TH1F* hist = fCorrSinglePt[fNCorrectionLevelsSinglePt-2]->GetTrackPt(0); // level -2: before unfolding, level -1: unfolded | |
4594 | THnSparse* hnResponse = fhnResponseSinglePt; | |
4595 | ||
4596 | TString histNameTHn = hist->GetName(); | |
4597 | if(histNameTHn.Contains("TH1")) histNameTHn.ReplaceAll("TH1","THn"); | |
4598 | if(histNameTHn.Contains("fPt")) histNameTHn.ReplaceAll("fPt","fhnPt"); | |
4599 | ||
4600 | ||
4601 | TString histNameBackFolded = hist->GetName(); | |
4602 | histNameBackFolded.Append("_backfold"); | |
4603 | ||
4604 | TString histNameRatioFolded = hist->GetName(); | |
4605 | if(histNameRatioFolded.Contains("fh1")) histNameRatioFolded.ReplaceAll("fh1","hRatio"); | |
4606 | if(histNameRatioFolded.Contains("fPt")) histNameRatioFolded.ReplaceAll("fPt","hRatioPt"); | |
4607 | histNameRatioFolded.Append("_unfold"); | |
4608 | ||
4609 | TString histNameRatioBackFolded = hist->GetName(); | |
4610 | if(histNameRatioBackFolded.Contains("fh1")) histNameRatioBackFolded.ReplaceAll("fh1","hRatio"); | |
4611 | if(histNameRatioBackFolded.Contains("fPt")) histNameRatioBackFolded.ReplaceAll("fPt","hRatioPt"); | |
4612 | histNameRatioBackFolded.Append("_backfold"); | |
4613 | ||
4614 | THnSparse* hnHist = TH1toSparse(hist,histNameTHn,hist->GetTitle()); | |
4615 | THnSparse* hnFlatEfficiency = TH1toSparse(hist,"fhnEfficiency","eff",kTRUE); // could optionally also use real eff | |
4616 | ||
ce55b926 | 4617 | TH1F* hUnfolded |
39e2b057 | 4618 | = Unfold(hnHist,hnResponse,hnFlatEfficiency,nIter,useCorrelatedErrors); |
4619 | ||
ce55b926 | 4620 | //TH1F* hUnfolded = (TH1F*) hnUnfolded->Projection(0); |
4621 | //hUnfolded->SetNameTitle(hist->GetName(),hist->GetTitle()); | |
39e2b057 | 4622 | |
4623 | fCorrSinglePt[fNCorrectionLevelsSinglePt-1]->AddCorrHistos(0,hUnfolded); | |
4624 | ||
4625 | // backfolding: apply response matrix to unfolded spectrum | |
4626 | TH1F* hBackFolded = ApplyResponse(hUnfolded,hnResponse); | |
4627 | hBackFolded->SetNameTitle(histNameBackFolded,hist->GetTitle()); | |
4628 | ||
4629 | fh1SingleTrackPtBackFolded = hBackFolded; | |
4630 | ||
4631 | ||
4632 | // ratio unfolded to original histo | |
4633 | TH1F* hRatioUnfolded = (TH1F*) hUnfolded->Clone(histNameRatioFolded); | |
4634 | hRatioUnfolded->Reset(); | |
4635 | hRatioUnfolded->Divide(hUnfolded,hist,1,1,"B"); | |
4636 | ||
4637 | fh1RatioSingleTrackPtFolded = hRatioUnfolded; | |
4638 | ||
4639 | ||
4640 | // ratio backfolded to original histo | |
4641 | TH1F* hRatioBackFolded = (TH1F*) hBackFolded->Clone(histNameRatioBackFolded); | |
4642 | hRatioBackFolded->Reset(); | |
4643 | hRatioBackFolded->Divide(hBackFolded,hist,1,1,"B"); | |
4644 | ||
4645 | fh1RatioSingleTrackPtBackFolded = hRatioBackFolded; | |
4646 | ||
4647 | delete hnHist; | |
4648 | delete hnFlatEfficiency; | |
4649 | ||
4650 | } | |
4651 | ||
4652 | // ________________________________________________________ | |
4653 | void AliFragmentationFunctionCorrections::SecCorrSinglePt() | |
4654 | { | |
4655 | // apply efficiency correction to inclusive track pt spec | |
4656 | ||
4657 | AddCorrectionLevelSinglePt("secCorr"); | |
4658 | ||
4659 | TH1F* histPt = fCorrSinglePt[fNCorrectionLevelsSinglePt-2]->GetTrackPt(0); | |
4660 | ||
4661 | if(histPt->GetNbinsX() != fh1SecCorrSinglePt->GetNbinsX()) | |
4662 | Printf("%s:%d: inconsistency pt spec and secondaries corr bins - rebin effCorr ...", (char*)__FILE__,__LINE__); | |
4663 | ||
4664 | TString histNamePt = histPt->GetName(); | |
4665 | TH1F* hTrackPtSecCorr = (TH1F*) histPt->Clone(histNamePt); | |
4666 | ||
4667 | hTrackPtSecCorr->Multiply(histPt,fh1SecCorrSinglePt,1,1,""); | |
4668 | ||
4669 | fCorrSinglePt[fNCorrectionLevelsSinglePt-1]->AddCorrHistos(0,hTrackPtSecCorr); | |
4670 | } | |
ce55b926 | 4671 | |
4672 | //___________________________________________________________________________________________________________________________________ | |
4673 | void AliFragmentationFunctionCorrections::dNdz2dNdxi() | |
4674 | { | |
4675 | // transform dN/dz distribution into dN/dxi | |
4676 | // for current corr level, all jet pt slices | |
4677 | ||
4678 | ||
4679 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
4680 | ||
4681 | TH1F* histZ = fCorrFF[fNCorrectionLevels-1]->GetZ(i); | |
4682 | Int_t nBins = histZ->GetNbinsX(); | |
4683 | ||
4684 | Double_t* binLims = new Double_t[nBins+1]; | |
4685 | ||
4686 | for(Int_t bin = 0; bin<nBins; bin++){ | |
4687 | ||
4688 | Int_t binZ = nBins-bin; | |
4689 | ||
4690 | Double_t zLo = histZ->GetXaxis()->GetBinLowEdge(binZ); | |
4691 | Double_t zUp = histZ->GetXaxis()->GetBinUpEdge(binZ); | |
4692 | ||
4693 | Double_t xiLo = TMath::Log(1/zUp); | |
4694 | Double_t xiUp = TMath::Log(1/zLo); | |
4695 | ||
4696 | if(bin == 0) binLims[0] = xiLo; | |
4697 | binLims[bin+1] = xiUp; | |
4698 | } | |
4699 | ||
4700 | // for(Int_t bin = 0; bin<=nBins; bin++) std::cout<<" bin "<<bin<<" binLims "<<binLims[bin]<<std::endl; | |
4701 | ||
4702 | TString strTitle = histZ->GetTitle(); | |
4703 | TString strName = histZ->GetName(); | |
4704 | ||
4705 | strName.ReplaceAll("Z","XiNew"); | |
4706 | strTitle.ReplaceAll("Z","XiNew"); | |
4707 | ||
4708 | ||
4709 | TH1F* histXiNew = new TH1F("histXiNew","",nBins,binLims); | |
4710 | histXiNew->SetNameTitle(strName,strTitle); | |
4711 | ||
4712 | ||
4713 | for(Int_t binZ = 1; binZ<=nBins; binZ++){ | |
4714 | ||
4715 | Double_t meanZ = histZ->GetBinCenter(binZ); | |
4716 | Double_t cont = histZ->GetBinContent(binZ); | |
4717 | Double_t err = histZ->GetBinError(binZ); | |
4718 | ||
4719 | Double_t meanXi = TMath::Log(1/meanZ); | |
4720 | Int_t binXi = histXiNew->FindBin(meanXi); | |
4721 | ||
4722 | histXiNew->SetBinContent(binXi,cont); | |
4723 | histXiNew->SetBinError(binXi,err); | |
4724 | ||
4725 | //std::cout<<" binZ "<<binZ<<" meanZ "<<meanZ<<" binXi "<<binXi<<" meanXi "<<meanXi<<" cont "<<cont<<" err "<<err<<std::endl; | |
4726 | } | |
4727 | ||
4728 | fCorrFF[fNCorrectionLevels-1]->ReplaceCorrHistos(i,0,0,histXiNew); | |
4729 | ||
4730 | delete histXiNew; | |
4731 | delete[] binLims; | |
4732 | } | |
4733 | } | |
4734 | ||
4735 | //________________________________________________________________________________________________________________ | |
4736 | void AliFragmentationFunctionCorrections::WriteBinShiftCorr(TString strInfile, TString strIDGen, TString strIDRec, | |
4737 | TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, | |
4738 | TString strOutDir) | |
4739 | { | |
4740 | TString strdirGen = "PWGJE_FragmentationFunction_" + strIDGen; | |
4741 | TString strlistGen = "fracfunc_" + strIDGen; | |
4742 | ||
4743 | TString strdirRec = "PWGJE_FragmentationFunction_" + strIDRec; | |
4744 | TString strlistRec = "fracfunc_" + strIDRec; | |
4745 | ||
4746 | WriteBinShiftCorr(strInfile,strdirGen,strlistGen,strdirRec,strlistRec,strOutfile,updateOutfile,useRecPrim, strOutDir, kFALSE, ""); | |
4747 | } | |
4748 | ||
4749 | //________________________________________________________________________________________________________________ | |
4750 | void AliFragmentationFunctionCorrections::WriteBgrBinShiftCorr(TString strInfile, TString strBgrID, TString strIDGen, TString strIDRec, | |
4751 | TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, | |
4752 | TString strOutDir) | |
4753 | { | |
4754 | TString strdirGen = "PWGJE_FragmentationFunction_" + strIDGen; | |
4755 | TString strlistGen = "fracfunc_" + strIDGen; | |
4756 | ||
4757 | TString strdirRec = "PWGJE_FragmentationFunction_" + strIDRec; | |
4758 | TString strlistRec = "fracfunc_" + strIDRec; | |
4759 | ||
4760 | WriteBinShiftCorr(strInfile,strdirGen,strlistGen,strdirRec,strlistRec,strOutfile,updateOutfile,useRecPrim, strOutDir, kTRUE, strBgrID); | |
4761 | } | |
4762 | ||
4763 | //___________________________________________________________________________________________________________________________________ | |
4764 | void AliFragmentationFunctionCorrections::WriteBinShiftCorr(TString strInfile, TString strdirGen, TString strlistGen, | |
4765 | TString strdirRec, TString strlistRec, | |
4766 | TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, | |
4767 | TString strOutDir, Bool_t writeBgr, TString strBgrID) | |
4768 | { | |
4769 | ||
4770 | if((writeBgr && strBgrID.Length() == 0) || (!writeBgr && strBgrID.Length()>0) ){ | |
4771 | Printf("%s:%d -- inconsistent arguments to WriteBinShiftCorr FF/UE", (char*)__FILE__,__LINE__); | |
4772 | return; | |
4773 | } | |
4774 | ||
4775 | TH1F* hCorrPt[fNJetPtSlices]; | |
4776 | TH1F* hCorrXi[fNJetPtSlices]; | |
4777 | TH1F* hCorrZ[fNJetPtSlices]; | |
4778 | ||
4779 | TH1F* hdNdptTracksMCGen[fNJetPtSlices]; | |
4780 | TH1F* hdNdxiMCGen[fNJetPtSlices]; | |
4781 | TH1F* hdNdzMCGen[fNJetPtSlices]; | |
4782 | ||
4783 | TH1F* hdNdptTracksMCRec[fNJetPtSlices]; | |
4784 | TH1F* hdNdxiMCRec[fNJetPtSlices]; | |
4785 | TH1F* hdNdzMCRec[fNJetPtSlices]; | |
4786 | ||
4787 | TH1F* fh1FFJetPtMCGen = 0; | |
4788 | TH1F* fh1FFJetPtMCRec = 0; | |
4789 | ||
4790 | TH2F* fh2FFTrackPtMCGen = 0; | |
4791 | TH2F* fh2FFZMCGen = 0; | |
4792 | TH2F* fh2FFXiMCGen = 0; | |
4793 | ||
4794 | TH2F* fh2FFTrackPtMCRec = 0; | |
4795 | TH2F* fh2FFZMCRec = 0; | |
4796 | TH2F* fh2FFXiMCRec = 0; | |
4797 | ||
4798 | // gen level FF | |
4799 | ||
4800 | TFile f(strInfile,"READ"); | |
4801 | ||
4802 | if(!f.IsOpen()){ | |
4803 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
4804 | return; | |
4805 | } | |
4806 | ||
4807 | if(fDebug>0) Printf("%s:%d -- writeBinShiftCorr: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data()); | |
4808 | ||
4809 | if(strdirGen && strdirGen.Length()) gDirectory->cd(strdirGen); | |
4810 | ||
4811 | TList* listGen = 0; | |
4812 | ||
4813 | if(strlistGen && strlistGen.Length()){ | |
4814 | ||
4815 | if(!(listGen = (TList*) gDirectory->Get(strlistGen))){ | |
4816 | Printf("%s:%d -- error retrieving listGen %s from directory %s", (char*)__FILE__,__LINE__,strlistGen.Data(),strdirGen.Data()); | |
4817 | return; | |
4818 | } | |
4819 | } | |
4820 | ||
4821 | if(listGen){ | |
4822 | ||
4823 | fh1FFJetPtMCGen = (TH1F*) listGen->FindObject("fh1FFJetPtGen"); | |
4824 | ||
4825 | if(writeBgr){ | |
4826 | fh2FFTrackPtMCGen = (TH2F*) listGen->FindObject(Form("fh2FFTrackPt%sGen",strBgrID.Data())); | |
4827 | fh2FFZMCGen = (TH2F*) listGen->FindObject(Form("fh2FFZ%sGen",strBgrID.Data())); | |
4828 | fh2FFXiMCGen = (TH2F*) listGen->FindObject(Form("fh2FFXi%sGen",strBgrID.Data())); | |
4829 | } | |
4830 | else{ | |
4831 | fh2FFTrackPtMCGen = (TH2F*) listGen->FindObject("fh2FFTrackPtGen"); | |
4832 | fh2FFZMCGen = (TH2F*) listGen->FindObject("fh2FFZGen"); | |
4833 | fh2FFXiMCGen = (TH2F*) listGen->FindObject("fh2FFXiGen"); | |
4834 | } | |
4835 | } | |
4836 | else{ | |
4837 | fh1FFJetPtMCGen = (TH1F*) gDirectory->Get("fh1FFJetPtGen"); | |
4838 | if(writeBgr){ | |
4839 | fh2FFTrackPtMCGen = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sGen",strBgrID.Data())); | |
4840 | fh2FFZMCGen = (TH2F*) gDirectory->Get(Form("fh2FFZ%sGen",strBgrID.Data())); | |
4841 | fh2FFXiMCGen = (TH2F*) gDirectory->Get(Form("fh2FFXi%sGen",strBgrID.Data())); | |
4842 | } | |
4843 | else{ | |
4844 | fh2FFTrackPtMCGen = (TH2F*) gDirectory->Get("fh2FFTrackPtGen"); | |
4845 | fh2FFZMCGen = (TH2F*) gDirectory->Get("fh2FFZGen"); | |
4846 | fh2FFXiMCGen = (TH2F*) gDirectory->Get("fh2FFXiGen"); | |
4847 | } | |
4848 | } | |
4849 | ||
4850 | fh1FFJetPtMCGen->SetDirectory(0); | |
4851 | fh2FFTrackPtMCGen->SetDirectory(0); | |
4852 | fh2FFZMCGen->SetDirectory(0); | |
4853 | fh2FFXiMCGen->SetDirectory(0); | |
4854 | ||
4855 | f.Close(); | |
4856 | ||
4857 | // rec level FF | |
4858 | ||
4859 | TFile g(strInfile,"READ"); | |
4860 | ||
4861 | if(!g.IsOpen()){ | |
4862 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
4863 | return; | |
4864 | } | |
4865 | ||
4866 | if(fDebug>0) Printf("%s:%d -- writeBinShiftCorr: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data()); | |
4867 | ||
4868 | if(strdirRec && strdirRec.Length()) gDirectory->cd(strdirRec); | |
4869 | ||
4870 | TList* listRec = 0; | |
4871 | ||
4872 | if(strlistRec && strlistRec.Length()){ | |
4873 | ||
4874 | if(!(listRec = (TList*) gDirectory->Get(strlistRec))){ | |
4875 | Printf("%s:%d -- error retrieving listRec %s from directory %s", (char*)__FILE__,__LINE__,strlistRec.Data(),strdirRec.Data()); | |
4876 | return; | |
4877 | } | |
4878 | } | |
4879 | ||
4880 | if(useRecPrim){ | |
4881 | if(listRec){ | |
4882 | fh1FFJetPtMCRec = (TH1F*) listRec->FindObject("fh1FFJetPtRecEffRec"); | |
4883 | ||
4884 | if(writeBgr){ | |
4885 | fh2FFTrackPtMCRec = (TH2F*) listRec->FindObject(Form("fh2FFTrackPt%sRecEffRec",strBgrID.Data())); | |
4886 | fh2FFZMCRec = (TH2F*) listRec->FindObject(Form("fh2FFZ%sRecEffRec",strBgrID.Data())); | |
4887 | fh2FFXiMCRec = (TH2F*) listRec->FindObject(Form("fh2FFXi%sRecEffRec",strBgrID.Data())); | |
4888 | } | |
4889 | else{ | |
4890 | fh2FFTrackPtMCRec = (TH2F*) listRec->FindObject("fh2FFTrackPtRecEffRec"); | |
4891 | fh2FFZMCRec = (TH2F*) listRec->FindObject("fh2FFZRecEffRec"); | |
4892 | fh2FFXiMCRec = (TH2F*) listRec->FindObject("fh2FFXiRecEffRec"); | |
4893 | } | |
4894 | } | |
4895 | else{ | |
4896 | fh1FFJetPtMCRec = (TH1F*) gDirectory->Get("fh1FFJetPtRecEffRec"); | |
4897 | if(writeBgr){ | |
4898 | fh2FFTrackPtMCRec = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sRecEffRec",strBgrID.Data())); | |
4899 | fh2FFZMCRec = (TH2F*) gDirectory->Get(Form("fh2FFZ%sRecEffRec",strBgrID.Data())); | |
4900 | fh2FFXiMCRec = (TH2F*) gDirectory->Get(Form("fh2FFXi%sRecEffRec",strBgrID.Data())); | |
4901 | } | |
4902 | else{ | |
4903 | fh2FFTrackPtMCRec = (TH2F*) gDirectory->Get("fh2FFTrackPtRecEffRec"); | |
4904 | fh2FFZMCRec = (TH2F*) gDirectory->Get("fh2FFZRecEffRec"); | |
4905 | fh2FFXiMCRec = (TH2F*) gDirectory->Get("fh2FFXiRecEffRec"); | |
4906 | } | |
4907 | } | |
4908 | } | |
4909 | else{ | |
4910 | if(listRec){ | |
4911 | fh1FFJetPtMCRec = (TH1F*) listRec->FindObject("fh1FFJetPtRecCuts"); | |
4912 | if(writeBgr){ | |
4913 | fh2FFTrackPtMCRec = (TH2F*) listRec->FindObject(Form("fh2FFTrackPt%sRecCuts",strBgrID.Data())); | |
4914 | fh2FFZMCRec = (TH2F*) listRec->FindObject(Form("fh2FFZ%sRecCuts",strBgrID.Data())); | |
4915 | fh2FFXiMCRec = (TH2F*) listRec->FindObject(Form("fh2FFXi%sRecCuts",strBgrID.Data())); | |
4916 | } | |
4917 | else{ | |
4918 | fh2FFTrackPtMCRec = (TH2F*) listRec->FindObject("fh2FFTrackPtRecCuts"); | |
4919 | fh2FFZMCRec = (TH2F*) listRec->FindObject("fh2FFZRecCuts"); | |
4920 | fh2FFXiMCRec = (TH2F*) listRec->FindObject("fh2FFXiRecCuts"); | |
4921 | } | |
4922 | } | |
4923 | else{ | |
4924 | fh1FFJetPtMCRec = (TH1F*) gDirectory->Get("fh1FFJetPtRecCuts"); | |
4925 | if(writeBgr){ | |
4926 | fh2FFTrackPtMCRec = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sRecCuts",strBgrID.Data())); | |
4927 | fh2FFZMCRec = (TH2F*) gDirectory->Get(Form("fh2FFZ%sRecCuts",strBgrID.Data())); | |
4928 | fh2FFXiMCRec = (TH2F*) gDirectory->Get(Form("fh2FFXi%sRecCuts",strBgrID.Data())); | |
4929 | } | |
4930 | else{ | |
4931 | fh2FFTrackPtMCRec = (TH2F*) gDirectory->Get("fh2FFTrackPtRecCuts"); | |
4932 | fh2FFZMCRec = (TH2F*) gDirectory->Get("fh2FFZRecCuts"); | |
4933 | fh2FFXiMCRec = (TH2F*) gDirectory->Get("fh2FFXiRecCuts"); | |
4934 | } | |
4935 | } | |
4936 | } | |
4937 | ||
4938 | ||
4939 | fh1FFJetPtMCRec->SetDirectory(0); | |
4940 | fh2FFTrackPtMCRec->SetDirectory(0); | |
4941 | fh2FFZMCRec->SetDirectory(0); | |
4942 | fh2FFXiMCRec->SetDirectory(0); | |
4943 | ||
4944 | g.Close(); | |
4945 | ||
4946 | // projections: FF for generated and reconstructed | |
4947 | ||
4948 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
4949 | ||
4950 | Float_t jetPtLoLim = fJetPtSlices->At(i); | |
4951 | Float_t jetPtUpLim = fJetPtSlices->At(i+1); | |
4952 | ||
4953 | Int_t binLo = static_cast<Int_t>(fh2FFTrackPtMCGen->GetXaxis()->FindBin(jetPtLoLim)); | |
4954 | Int_t binUp = static_cast<Int_t>(fh2FFTrackPtMCGen->GetXaxis()->FindBin(jetPtUpLim))-1; | |
4955 | ||
4956 | if(binUp > fh2FFTrackPtMCGen->GetNbinsX()){ | |
4957 | Printf("%s:%d -- jet pt range %0.3f exceeds histo limits",(char*)__FILE__,__LINE__,jetPtUpLim); | |
4958 | return; | |
4959 | } | |
4960 | ||
4961 | TString strNameFFPtGen(Form("fh1FFTrackPtGenBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
4962 | TString strNameFFZGen(Form("fh1FFZGenBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
4963 | TString strNameFFXiGen(Form("fh1FFXiGenBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
4964 | ||
4965 | TString strNameFFPtRec(Form("fh1FFTrackPtRecBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
4966 | TString strNameFFZRec(Form("fh1FFZRecBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
4967 | TString strNameFFXiRec(Form("fh1FFXiRecBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim))); | |
4968 | ||
4969 | if(writeBgr){ | |
4970 | strNameFFPtGen.Form("fh1TrackPtGenBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data()); | |
4971 | strNameFFZGen.Form("fh1ZGenBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data()); | |
4972 | strNameFFXiGen.Form("fh1XiGenBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data()); | |
4973 | ||
4974 | strNameFFPtRec.Form("fh1TrackPtRecBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data()); | |
4975 | strNameFFZRec.Form("fh1ZRecBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data()); | |
4976 | strNameFFXiRec.Form("fh1XiRecBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data()); | |
4977 | } | |
4978 | ||
4979 | // project | |
4980 | // appendix 'unbinned' to avoid histos with same name after rebinning | |
4981 | ||
4982 | hdNdptTracksMCGen[i] = (TH1F*) fh2FFTrackPtMCGen->ProjectionY(strNameFFPtGen+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
4983 | hdNdzMCGen[i] = (TH1F*) fh2FFZMCGen->ProjectionY(strNameFFZGen+"_unBinned",binLo,binUp,"o"); | |
4984 | hdNdxiMCGen[i] = (TH1F*) fh2FFXiMCGen->ProjectionY(strNameFFXiGen+"_unBinned",binLo,binUp,"o"); | |
4985 | ||
4986 | hdNdptTracksMCRec[i] = (TH1F*) fh2FFTrackPtMCRec->ProjectionY(strNameFFPtRec+"_unBinned",binLo,binUp,"o"); // option "o": original axis range | |
4987 | hdNdzMCRec[i] = (TH1F*) fh2FFZMCRec->ProjectionY(strNameFFZRec+"_unBinned",binLo,binUp,"o"); | |
4988 | hdNdxiMCRec[i] = (TH1F*) fh2FFXiMCRec->ProjectionY(strNameFFXiRec+"_unBinned",binLo,binUp,"o"); | |
4989 | ||
4990 | ||
4991 | // rebin | |
4992 | ||
4993 | if(fNHistoBinsPt[i]) hdNdptTracksMCGen[i] = (TH1F*) hdNdptTracksMCGen[i]->Rebin(fNHistoBinsPt[i],strNameFFPtGen,fHistoBinsPt[i]->GetArray()); | |
4994 | if(fNHistoBinsZ[i]) hdNdzMCGen[i] = (TH1F*) hdNdzMCGen[i]->Rebin(fNHistoBinsZ[i],strNameFFZGen,fHistoBinsZ[i]->GetArray()); | |
4995 | if(fNHistoBinsXi[i]) hdNdxiMCGen[i] = (TH1F*) hdNdxiMCGen[i]->Rebin(fNHistoBinsXi[i],strNameFFXiGen,fHistoBinsXi[i]->GetArray()); | |
4996 | ||
4997 | if(fNHistoBinsPt[i]) hdNdptTracksMCRec[i] = (TH1F*) hdNdptTracksMCRec[i]->Rebin(fNHistoBinsPt[i],strNameFFPtRec,fHistoBinsPt[i]->GetArray()); | |
4998 | if(fNHistoBinsZ[i]) hdNdzMCRec[i] = (TH1F*) hdNdzMCRec[i]->Rebin(fNHistoBinsZ[i],strNameFFZRec,fHistoBinsZ[i]->GetArray()); | |
4999 | if(fNHistoBinsXi[i]) hdNdxiMCRec[i] = (TH1F*) hdNdxiMCRec[i]->Rebin(fNHistoBinsXi[i],strNameFFXiRec,fHistoBinsXi[i]->GetArray()); | |
5000 | ||
5001 | ||
5002 | hdNdptTracksMCGen[i]->SetNameTitle(strNameFFPtGen,""); | |
5003 | hdNdzMCGen[i]->SetNameTitle(strNameFFZGen,""); | |
5004 | hdNdxiMCGen[i]->SetNameTitle(strNameFFXiGen,""); | |
5005 | ||
5006 | hdNdptTracksMCRec[i]->SetNameTitle(strNameFFPtRec,""); | |
5007 | hdNdzMCRec[i]->SetNameTitle(strNameFFZRec,""); | |
5008 | hdNdxiMCRec[i]->SetNameTitle(strNameFFXiRec,""); | |
5009 | ||
5010 | // normalize | |
5011 | ||
5012 | Double_t nJetsBinGen = fh1FFJetPtMCGen->Integral(binLo,binUp); | |
5013 | Double_t nJetsBinRec = fh1FFJetPtMCRec->Integral(binLo,binUp); | |
5014 | ||
5015 | NormalizeTH1(hdNdptTracksMCGen[i],nJetsBinGen); | |
5016 | NormalizeTH1(hdNdzMCGen[i],nJetsBinGen); | |
5017 | NormalizeTH1(hdNdxiMCGen[i],nJetsBinGen); | |
5018 | ||
5019 | NormalizeTH1(hdNdptTracksMCRec[i],nJetsBinRec); | |
5020 | NormalizeTH1(hdNdzMCRec[i],nJetsBinRec); | |
5021 | NormalizeTH1(hdNdxiMCRec[i],nJetsBinRec); | |
5022 | ||
5023 | // divide gen/rec : corr factor | |
5024 | ||
5025 | TString strNameCorrPt(Form("hBbBCorrPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
5026 | TString strNameCorrZ(Form("hBbBCorrZ_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
5027 | TString strNameCorrXi(Form("hBbBCorrXi_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim))); | |
5028 | ||
5029 | if(writeBgr){ | |
5030 | strNameCorrPt.Form("hBbBCorrBgrPt_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
5031 | strNameCorrZ.Form("hBbBCorrBgrZ_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
5032 | strNameCorrXi.Form("hBbBCorrBgrXi_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
5033 | } | |
5034 | ||
5035 | hCorrPt[i] = (TH1F*) hdNdptTracksMCGen[i]->Clone(strNameCorrPt); | |
5036 | hCorrPt[i]->Divide(hdNdptTracksMCGen[i],hdNdptTracksMCRec[i],1,1,"B"); // binominal errors | |
5037 | ||
5038 | hCorrXi[i] = (TH1F*) hdNdxiMCGen[i]->Clone(strNameCorrXi); | |
5039 | hCorrXi[i]->Divide(hdNdxiMCGen[i],hdNdxiMCRec[i],1,1,"B"); // binominal errors | |
5040 | ||
5041 | hCorrZ[i] = (TH1F*) hdNdzMCGen[i]->Clone(strNameCorrZ); | |
5042 | hCorrZ[i]->Divide(hdNdzMCGen[i],hdNdzMCRec[i],1,1,"B"); // binominal errors | |
5043 | } | |
5044 | ||
5045 | // write | |
5046 | ||
5047 | TString outfileOption = "RECREATE"; | |
5048 | if(updateOutfile) outfileOption = "UPDATE"; | |
5049 | ||
5050 | TFile out(strOutfile,outfileOption); | |
5051 | ||
5052 | if(!out.IsOpen()){ | |
5053 | Printf("%s:%d -- error opening efficiency output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
5054 | return; | |
5055 | } | |
5056 | ||
5057 | if(fDebug>0) Printf("%s:%d -- write bin shift correction to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
5058 | ||
5059 | if(strOutDir && strOutDir.Length()){ | |
5060 | ||
5061 | TDirectory* dir; | |
5062 | if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd(); | |
5063 | else{ | |
5064 | dir = out.mkdir(strOutDir); | |
5065 | dir->cd(); | |
5066 | } | |
5067 | } | |
5068 | ||
5069 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5070 | ||
5071 | hdNdptTracksMCGen[i]->Write(); | |
5072 | hdNdxiMCGen[i]->Write(); | |
5073 | hdNdzMCGen[i]->Write(); | |
5074 | ||
5075 | hdNdptTracksMCRec[i]->Write(); | |
5076 | hdNdxiMCRec[i]->Write(); | |
5077 | hdNdzMCRec[i]->Write(); | |
5078 | ||
5079 | hCorrPt[i]->Write(); | |
5080 | hCorrXi[i]->Write(); | |
5081 | hCorrZ[i]->Write(); | |
5082 | } | |
5083 | ||
5084 | // out.Close(); | |
5085 | ||
5086 | delete fh1FFJetPtMCGen; | |
5087 | delete fh1FFJetPtMCRec; | |
5088 | ||
5089 | delete fh2FFTrackPtMCGen; | |
5090 | delete fh2FFZMCGen; | |
5091 | delete fh2FFXiMCGen; | |
5092 | ||
5093 | delete fh2FFTrackPtMCRec; | |
5094 | delete fh2FFZMCRec; | |
5095 | delete fh2FFXiMCRec; | |
5096 | } | |
5097 | ||
5098 | //________________________________________________________________________________________________________________________________ | |
5099 | void AliFragmentationFunctionCorrections::ReadBgrBinShiftCorr(TString strfile, TString strBgrID, TString strdir, TString strlist) | |
5100 | { | |
5101 | ||
5102 | ReadBinShiftCorr(strfile, strdir, strlist, kTRUE, strBgrID); | |
5103 | } | |
5104 | ||
5105 | //___________________________________________________________________________________________________________________________________________ | |
5106 | void AliFragmentationFunctionCorrections::ReadBinShiftCorr(TString strfile, TString strdir, TString strlist, Bool_t readBgr, TString strBgrID) | |
5107 | { | |
5108 | ||
5109 | if((readBgr && strBgrID.Length() == 0) || (!readBgr && strBgrID.Length()>0) ){ | |
5110 | Printf("%s:%d -- inconsistent arguments to ReadBinShiftCorr FF/UE", (char*)__FILE__,__LINE__); | |
5111 | return; | |
5112 | } | |
5113 | ||
5114 | // temporary histos to hold histos from file | |
5115 | TH1F* hCorrPt[fNJetPtSlices]; | |
5116 | TH1F* hCorrZ[fNJetPtSlices]; | |
5117 | TH1F* hCorrXi[fNJetPtSlices]; | |
5118 | ||
5119 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrPt[i] = 0; | |
5120 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrZ[i] = 0; | |
5121 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrXi[i] = 0; | |
5122 | ||
5123 | TFile f(strfile,"READ"); | |
5124 | ||
5125 | if(!f.IsOpen()){ | |
5126 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
5127 | return; | |
5128 | } | |
5129 | ||
5130 | if(fDebug>0) Printf("%s:%d -- read FF / UE bin shift correction from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
5131 | ||
5132 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
5133 | ||
5134 | TList* list = 0; | |
5135 | ||
5136 | if(strlist && strlist.Length()){ | |
5137 | ||
5138 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
5139 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
5140 | return; | |
5141 | } | |
5142 | } | |
5143 | ||
5144 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5145 | ||
5146 | Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i)); | |
5147 | Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1)); | |
5148 | ||
5149 | TString strNameCorrPt(Form("hBbBCorrPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
5150 | TString strNameCorrZ(Form("hBbBCorrZ_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
5151 | TString strNameCorrXi(Form("hBbBCorrXi_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
5152 | ||
5153 | if(readBgr){ | |
5154 | strNameCorrPt.Form("hBbBCorrBgrPt_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
5155 | strNameCorrZ.Form("hBbBCorrBgrZ_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
5156 | strNameCorrXi.Form("hBbBCorrBgrXi_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data()); | |
5157 | } | |
5158 | ||
5159 | ||
5160 | if(list){ | |
5161 | hCorrPt[i] = (TH1F*) list->FindObject(strNameCorrPt); | |
5162 | hCorrZ[i] = (TH1F*) list->FindObject(strNameCorrZ); | |
5163 | hCorrXi[i] = (TH1F*) list->FindObject(strNameCorrXi); | |
5164 | } | |
5165 | else{ | |
5166 | hCorrPt[i] = (TH1F*) gDirectory->Get(strNameCorrPt); | |
5167 | hCorrZ[i] = (TH1F*) gDirectory->Get(strNameCorrZ); | |
5168 | hCorrXi[i] = (TH1F*) gDirectory->Get(strNameCorrXi); | |
5169 | } | |
5170 | ||
5171 | if(!hCorrPt[i]){ | |
5172 | Printf("%s:%d -- error retrieving bin by bin correction %s", (char*)__FILE__,__LINE__,strNameCorrPt.Data()); | |
5173 | } | |
5174 | ||
5175 | if(!hCorrZ[i]){ | |
5176 | Printf("%s:%d -- error retrieving bin by bin correction %s", (char*)__FILE__,__LINE__,strNameCorrZ.Data()); | |
5177 | } | |
5178 | ||
5179 | if(!hCorrXi[i]){ | |
5180 | Printf("%s:%d -- error retrieving bin by bin correction %s", (char*)__FILE__,__LINE__,strNameCorrXi.Data()); | |
5181 | } | |
5182 | ||
5183 | ||
5184 | if(fNHistoBinsPt[i]) hCorrPt[i] = (TH1F*) hCorrPt[i]->Rebin(fNHistoBinsPt[i],strNameCorrPt+"_rebin",fHistoBinsPt[i]->GetArray()); | |
5185 | if(fNHistoBinsZ[i]) hCorrZ[i] = (TH1F*) hCorrZ[i]->Rebin(fNHistoBinsZ[i],strNameCorrZ+"_rebin",fHistoBinsZ[i]->GetArray()); | |
5186 | if(fNHistoBinsXi[i]) hCorrXi[i] = (TH1F*) hCorrXi[i]->Rebin(fNHistoBinsXi[i],strNameCorrXi+"_rebin",fHistoBinsXi[i]->GetArray()); | |
5187 | ||
5188 | if(hCorrPt[i]) hCorrPt[i]->SetDirectory(0); | |
5189 | if(hCorrZ[i]) hCorrZ[i]->SetDirectory(0); | |
5190 | if(hCorrXi[i]) hCorrXi[i]->SetDirectory(0); | |
5191 | ||
5192 | } // jet slices loop | |
5193 | ||
5194 | f.Close(); | |
5195 | ||
5196 | if(readBgr){ | |
5197 | for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos | |
5198 | if(hCorrPt[i]) new(fh1BbBBgrPt[i]) TH1F(*hCorrPt[i]); | |
5199 | if(hCorrZ[i]) new(fh1BbBBgrZ[i]) TH1F(*hCorrZ[i]); | |
5200 | if(hCorrXi[i]) new(fh1BbBBgrXi[i]) TH1F(*hCorrXi[i]); | |
5201 | } | |
5202 | } | |
5203 | else{ | |
5204 | for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos | |
5205 | if(hCorrPt[i]) new(fh1BbBPt[i]) TH1F(*hCorrPt[i]); | |
5206 | if(hCorrZ[i]) new(fh1BbBZ[i]) TH1F(*hCorrZ[i]); | |
5207 | if(hCorrXi[i]) new(fh1BbBXi[i]) TH1F(*hCorrXi[i]); | |
5208 | } | |
5209 | } | |
5210 | } | |
5211 | ||
5212 | // ________________________________________________ | |
5213 | void AliFragmentationFunctionCorrections::BbBCorr() | |
5214 | { | |
5215 | // apply bin-by-bin correction | |
5216 | ||
5217 | AddCorrectionLevel("BbB"); | |
5218 | ||
5219 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5220 | ||
5221 | TH1F* histPt = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i); | |
5222 | TH1F* histZ = fCorrFF[fNCorrectionLevels-2]->GetZ(i); | |
5223 | TH1F* histXi = fCorrFF[fNCorrectionLevels-2]->GetXi(i); | |
5224 | ||
5225 | TString histNamePt = histPt->GetName(); | |
5226 | TString histNameZ = histZ->GetName(); | |
5227 | TString histNameXi = histXi->GetName(); | |
5228 | ||
5229 | TH1F* hFFTrackPtBbBCorr = (TH1F*) histPt->Clone(histNamePt); | |
5230 | hFFTrackPtBbBCorr->Multiply(histPt,fh1BbBPt[i],1,1,""); | |
5231 | ||
5232 | TH1F* hFFZBbBCorr = (TH1F*) histZ->Clone(histNameZ); | |
5233 | hFFZBbBCorr->Multiply(histZ,fh1BbBZ[i],1,1,""); | |
5234 | ||
5235 | TH1F* hFFXiBbBCorr = (TH1F*) histXi->Clone(histNameXi); | |
5236 | hFFXiBbBCorr->Multiply(histXi,fh1BbBXi[i],1,1,""); | |
5237 | ||
5238 | fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hFFTrackPtBbBCorr,hFFZBbBCorr,hFFXiBbBCorr); | |
5239 | } | |
5240 | } | |
5241 | ||
5242 | // ___________________________________________________ | |
5243 | void AliFragmentationFunctionCorrections::BbBCorrBgr() | |
5244 | { | |
5245 | // apply bin-by-bin correction | |
5246 | ||
5247 | AddCorrectionLevelBgr("BbB"); | |
5248 | ||
5249 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5250 | ||
5251 | TH1F* histPt = fCorrBgr[fNCorrectionLevelsBgr-2]->GetTrackPt(i); | |
5252 | TH1F* histZ = fCorrBgr[fNCorrectionLevelsBgr-2]->GetZ(i); | |
5253 | TH1F* histXi = fCorrBgr[fNCorrectionLevelsBgr-2]->GetXi(i); | |
5254 | ||
5255 | TString histNamePt = histPt->GetName(); | |
5256 | TString histNameZ = histZ->GetName(); | |
5257 | TString histNameXi = histXi->GetName(); | |
5258 | ||
5259 | TH1F* hBgrTrackPtBbBCorr = (TH1F*) histPt->Clone(histNamePt); | |
5260 | hBgrTrackPtBbBCorr->Multiply(histPt,fh1BbBBgrPt[i],1,1,""); | |
5261 | ||
5262 | TH1F* hBgrZBbBCorr = (TH1F*) histZ->Clone(histNameZ); | |
5263 | hBgrZBbBCorr->Multiply(histZ,fh1BbBBgrZ[i],1,1,""); | |
5264 | ||
5265 | TH1F* hBgrXiBbBCorr = (TH1F*) histXi->Clone(histNameXi); | |
5266 | hBgrXiBbBCorr->Multiply(histXi,fh1BbBBgrXi[i],1,1,""); | |
5267 | ||
5268 | fCorrBgr[fNCorrectionLevelsBgr-1]->AddCorrHistos(i,hBgrTrackPtBbBCorr,hBgrZBbBCorr,hBgrXiBbBCorr); | |
5269 | } | |
5270 | } | |
5271 | ||
5272 | //_______________________________________________________________________________________________________ | |
5273 | void AliFragmentationFunctionCorrections::ReadFoldingCorr(TString strfile, TString strdir, TString strlist) | |
5274 | { | |
5275 | ||
5276 | // temporary histos to hold histos from file | |
5277 | TH1F* hCorrPt[fNJetPtSlices]; | |
5278 | TH1F* hCorrZ[fNJetPtSlices]; | |
5279 | TH1F* hCorrXi[fNJetPtSlices]; | |
5280 | ||
5281 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrPt[i] = 0; | |
5282 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrZ[i] = 0; | |
5283 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrXi[i] = 0; | |
5284 | ||
5285 | TFile f(strfile,"READ"); | |
5286 | ||
5287 | if(!f.IsOpen()){ | |
5288 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
5289 | return; | |
5290 | } | |
5291 | ||
5292 | if(fDebug>0) Printf("%s:%d -- read bin shift correction from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
5293 | ||
5294 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
5295 | ||
5296 | TList* list = 0; | |
5297 | ||
5298 | if(strlist && strlist.Length()){ | |
5299 | ||
5300 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
5301 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
5302 | return; | |
5303 | } | |
5304 | } | |
5305 | ||
5306 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5307 | ||
5308 | Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i)); | |
5309 | Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1)); | |
5310 | ||
5311 | TString strNameCorrPt(Form("hCorrFoldingPt_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
5312 | TString strNameCorrZ(Form("hCorrFoldingZ_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
5313 | TString strNameCorrXi(Form("hCorrFoldingXi_%02d_%02d",jetPtLoLim,jetPtUpLim)); | |
5314 | ||
5315 | ||
5316 | if(list){ | |
5317 | hCorrPt[i] = (TH1F*) list->FindObject(strNameCorrPt); | |
5318 | hCorrZ[i] = (TH1F*) list->FindObject(strNameCorrZ); | |
5319 | hCorrXi[i] = (TH1F*) list->FindObject(strNameCorrXi); | |
5320 | } | |
5321 | else{ | |
5322 | hCorrPt[i] = (TH1F*) gDirectory->Get(strNameCorrPt); | |
5323 | hCorrZ[i] = (TH1F*) gDirectory->Get(strNameCorrZ); | |
5324 | hCorrXi[i] = (TH1F*) gDirectory->Get(strNameCorrXi); | |
5325 | } | |
5326 | ||
5327 | if(!hCorrPt[i]){ | |
5328 | //Printf("%s:%d -- error retrieving folding correction %s", (char*)__FILE__,__LINE__,strNameCorrPt.Data()); | |
5329 | } | |
5330 | ||
5331 | if(!hCorrZ[i]){ | |
5332 | //Printf("%s:%d -- error retrieving folding correction %s", (char*)__FILE__,__LINE__,strNameCorrZ.Data()); | |
5333 | } | |
5334 | ||
5335 | if(!hCorrXi[i]){ | |
5336 | Printf("%s:%d -- error retrieving folding correction %s", (char*)__FILE__,__LINE__,strNameCorrXi.Data()); | |
5337 | } | |
5338 | ||
5339 | if(hCorrPt[i]) hCorrPt[i]->SetDirectory(0); | |
5340 | if(hCorrZ[i]) hCorrZ[i]->SetDirectory(0); | |
5341 | if(hCorrXi[i]) hCorrXi[i]->SetDirectory(0); | |
5342 | ||
5343 | } // jet slices loop | |
5344 | ||
5345 | f.Close(); | |
5346 | ||
5347 | for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos | |
5348 | if(hCorrPt[i]) new(fh1FoldingCorrPt[i]) TH1F(*hCorrPt[i]); | |
5349 | if(hCorrZ[i]) new(fh1FoldingCorrZ[i]) TH1F(*hCorrZ[i]); | |
5350 | if(hCorrXi[i]) new(fh1FoldingCorrXi[i]) TH1F(*hCorrXi[i]); | |
5351 | } | |
5352 | } | |
5353 | ||
5354 | // ___________________________________________________ | |
5355 | void AliFragmentationFunctionCorrections::FoldingCorr() | |
5356 | { | |
5357 | // apply bin-by-bin correction | |
5358 | ||
5359 | AddCorrectionLevel("FoldingCorr"); | |
5360 | ||
5361 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5362 | ||
5363 | TH1F* histPt = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i); | |
5364 | TH1F* histZ = fCorrFF[fNCorrectionLevels-2]->GetZ(i); | |
5365 | TH1F* histXi = fCorrFF[fNCorrectionLevels-2]->GetXi(i); | |
5366 | ||
5367 | TString histNamePt = histPt->GetName(); | |
5368 | TString histNameZ = histZ->GetName(); | |
5369 | TString histNameXi = histXi->GetName(); | |
5370 | ||
5371 | std::cout<<" foldingCorr: i "<<i<<" corr pt "<<fh1FoldingCorrPt[i]<<" z "<<fh1FoldingCorrZ[i]<<" xi " | |
5372 | <<fh1FoldingCorrXi[i]<<std::endl; | |
5373 | ||
5374 | std::cout<<" foldingCorr: i "<<i<<" mean corr pt "<<fh1FoldingCorrPt[i]->GetMean()<<" z "<<fh1FoldingCorrZ[i]->GetMean()<<" xi " | |
5375 | <<fh1FoldingCorrXi[i]->GetMean()<<std::endl; | |
5376 | ||
5377 | ||
5378 | ||
5379 | TH1F* hFFTrackPtFoldingCorr = (TH1F*) histPt->Clone(histNamePt); | |
5380 | if(fh1FoldingCorrPt[i] && fh1FoldingCorrPt[i]->GetMean()>0) hFFTrackPtFoldingCorr->Multiply(histPt,fh1FoldingCorrPt[i],1,1,""); | |
5381 | else hFFTrackPtFoldingCorr->Reset(); | |
5382 | ||
5383 | TH1F* hFFZFoldingCorr = (TH1F*) histZ->Clone(histNameZ); | |
5384 | if(fh1FoldingCorrZ[i] && fh1FoldingCorrZ[i]->GetMean()>0) hFFZFoldingCorr->Multiply(histZ,fh1FoldingCorrZ[i],1,1,""); | |
5385 | else hFFZFoldingCorr->Reset(); | |
5386 | ||
5387 | TH1F* hFFXiFoldingCorr = (TH1F*) histXi->Clone(histNameXi); | |
5388 | if(fh1FoldingCorrXi[i]&& fh1FoldingCorrXi[i]->GetMean()>0) hFFXiFoldingCorr->Multiply(histXi,fh1FoldingCorrXi[i],1,1,""); | |
5389 | else hFFXiFoldingCorr->Reset(); | |
5390 | ||
5391 | fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hFFTrackPtFoldingCorr,hFFZFoldingCorr,hFFXiFoldingCorr); | |
5392 | } | |
5393 | } | |
5394 | ||
5395 | //________________________________________________________________________________________________________________________________ | |
5396 | void AliFragmentationFunctionCorrections::ReadBgrJetSecCorr(TString strfile, TString strBgrID, TString strdir, TString strlist, | |
5397 | Bool_t useScaledStrangeness) | |
5398 | { | |
5399 | ||
5400 | ReadJetSecCorr(strfile, strdir, strlist, useScaledStrangeness, kTRUE, strBgrID); | |
5401 | } | |
5402 | ||
5403 | //_______________________________________________________________________________________________________ | |
5404 | void AliFragmentationFunctionCorrections::ReadJetSecCorr(TString strfile, TString strdir, TString strlist, Bool_t useScaledStrangeness, | |
5405 | Bool_t readBgr, TString strBgrID){ | |
5406 | ||
5407 | // read reconstruction efficiency from file | |
5408 | // argument strlist optional - read from directory strdir if not specified | |
5409 | ||
5410 | // temporary histos to hold histos from file | |
5411 | TH1F* hCorrPt[fNJetPtSlices]; | |
5412 | TH1F* hCorrZ[fNJetPtSlices]; | |
5413 | TH1F* hCorrXi[fNJetPtSlices]; | |
5414 | ||
5415 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrPt[i] = 0; | |
5416 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrZ[i] = 0; | |
5417 | for(Int_t i=0; i<fNJetPtSlices; i++) hCorrXi[i] = 0; | |
5418 | ||
5419 | TFile f(strfile,"READ"); | |
5420 | ||
5421 | if(!f.IsOpen()){ | |
5422 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
5423 | return; | |
5424 | } | |
5425 | ||
5426 | if(fDebug>0) Printf("%s:%d -- read secondary correction from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
5427 | ||
5428 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
5429 | ||
5430 | TList* list = 0; | |
5431 | ||
5432 | if(strlist && strlist.Length()){ | |
5433 | ||
5434 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
5435 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
5436 | return; | |
5437 | } | |
5438 | } | |
5439 | ||
5440 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5441 | ||
5442 | Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i)); | |
5443 | Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1)); | |
5444 | ||
5445 | TString strNameCorrPt(""); | |
5446 | TString strNameCorrZ(""); | |
5447 | TString strNameCorrXi(""); | |
5448 | ||
5449 | if(readBgr){ | |
5450 | strNameCorrPt.Form("hSecCorrBgrPt_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data()); | |
5451 | strNameCorrZ.Form("hSecCorrBgrZ_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data()); | |
5452 | strNameCorrXi.Form("hSecCorrBgrXi_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data()); | |
5453 | ||
5454 | if(!useScaledStrangeness){ | |
5455 | Printf("%s:%d -- readJetSecCorr bgr: using naive Pythia strangenss ", (char*)__FILE__,__LINE__); | |
5456 | strNameCorrPt.Form("hSecCorrBgrPt_nonSc_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data()); | |
5457 | strNameCorrZ.Form("hSecCorrBgrZ_nonSc_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data()); | |
5458 | strNameCorrXi.Form("hSecCorrBgrXi_nonSc_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data()); | |
5459 | } | |
5460 | } | |
5461 | else{ | |
5462 | strNameCorrPt.Form("hSecCorrPt_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
5463 | strNameCorrZ.Form("hSecCorrZ_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
5464 | strNameCorrXi.Form("hSecCorrXi_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
5465 | ||
5466 | if(!useScaledStrangeness){ | |
5467 | Printf("%s:%d -- readJetSecCorr: using naive Pythia strangenss ", (char*)__FILE__,__LINE__); | |
5468 | strNameCorrPt.Form("hSecCorrPt_nonSc_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
5469 | strNameCorrZ.Form("hSecCorrZ_nonSc_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
5470 | strNameCorrXi.Form("hSecCorrXi_nonSc_%02d_%02d",jetPtLoLim,jetPtUpLim); | |
5471 | } | |
5472 | } | |
5473 | ||
5474 | if(list){ | |
5475 | hCorrPt[i] = (TH1F*) list->FindObject(strNameCorrPt); | |
5476 | hCorrZ[i] = (TH1F*) list->FindObject(strNameCorrZ); | |
5477 | hCorrXi[i] = (TH1F*) list->FindObject(strNameCorrXi); | |
5478 | } | |
5479 | else{ | |
5480 | hCorrPt[i] = (TH1F*) gDirectory->Get(strNameCorrPt); | |
5481 | hCorrZ[i] = (TH1F*) gDirectory->Get(strNameCorrZ); | |
5482 | hCorrXi[i] = (TH1F*) gDirectory->Get(strNameCorrXi); | |
5483 | } | |
5484 | ||
5485 | if(!hCorrPt[i]){ | |
5486 | Printf("%s:%d -- error retrieving secondaries correction %s", (char*)__FILE__,__LINE__,strNameCorrPt.Data()); | |
5487 | } | |
5488 | ||
5489 | if(!hCorrZ[i]){ | |
5490 | Printf("%s:%d -- error retrieving secondaries correction %s", (char*)__FILE__,__LINE__,strNameCorrZ.Data()); | |
5491 | } | |
5492 | ||
5493 | if(!hCorrXi[i]){ | |
5494 | Printf("%s:%d -- error retrieving secondaries correction %s", (char*)__FILE__,__LINE__,strNameCorrXi.Data()); | |
5495 | } | |
5496 | ||
5497 | if(fNHistoBinsPt[i]) hCorrPt[i] = (TH1F*) hCorrPt[i]->Rebin(fNHistoBinsPt[i],strNameCorrPt+"_rebin",fHistoBinsPt[i]->GetArray()); | |
5498 | if(fNHistoBinsZ[i]) hCorrZ[i] = (TH1F*) hCorrZ[i]->Rebin(fNHistoBinsZ[i],strNameCorrZ+"_rebin",fHistoBinsZ[i]->GetArray()); | |
5499 | if(fNHistoBinsXi[i]) hCorrXi[i] = (TH1F*) hCorrXi[i]->Rebin(fNHistoBinsXi[i],strNameCorrXi+"_rebin",fHistoBinsXi[i]->GetArray()); | |
5500 | ||
5501 | if(hCorrPt[i]) hCorrPt[i]->SetDirectory(0); | |
5502 | if(hCorrZ[i]) hCorrZ[i]->SetDirectory(0); | |
5503 | if(hCorrXi[i]) hCorrXi[i]->SetDirectory(0); | |
5504 | ||
5505 | } // jet slices loop | |
5506 | ||
5507 | f.Close(); | |
5508 | ||
5509 | for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos | |
5510 | ||
5511 | if(readBgr){ | |
5512 | if(hCorrPt[i]) new(fh1SecCorrBgrPt[i]) TH1F(*hCorrPt[i]); | |
5513 | if(hCorrZ[i]) new(fh1SecCorrBgrZ[i]) TH1F(*hCorrZ[i]); | |
5514 | if(hCorrXi[i]) new(fh1SecCorrBgrXi[i]) TH1F(*hCorrXi[i]); | |
5515 | } | |
5516 | else{ | |
5517 | if(hCorrPt[i]) new(fh1SecCorrPt[i]) TH1F(*hCorrPt[i]); | |
5518 | if(hCorrZ[i]) new(fh1SecCorrZ[i]) TH1F(*hCorrZ[i]); | |
5519 | if(hCorrXi[i]) new(fh1SecCorrXi[i]) TH1F(*hCorrXi[i]); | |
5520 | } | |
5521 | } | |
5522 | } | |
5523 | ||
5524 | // ___________________________________________________ | |
5525 | void AliFragmentationFunctionCorrections::JetSecCorr() | |
5526 | { | |
5527 | // apply secondaries correction | |
5528 | ||
5529 | AddCorrectionLevel("SecCorr"); | |
5530 | ||
5531 | Printf("%s:%d -- apply jet secondaries correction", (char*)__FILE__,__LINE__); | |
5532 | ||
5533 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5534 | ||
5535 | TH1F* histPt = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i); | |
5536 | TH1F* histZ = fCorrFF[fNCorrectionLevels-2]->GetZ(i); | |
5537 | TH1F* histXi = fCorrFF[fNCorrectionLevels-2]->GetXi(i); | |
5538 | ||
5539 | TString histNamePt = histPt->GetName(); | |
5540 | TString histNameZ = histZ->GetName(); | |
5541 | TString histNameXi = histXi->GetName(); | |
5542 | ||
5543 | TH1F* hFFTrackPtSecCorr = (TH1F*) histPt->Clone(histNamePt); | |
5544 | hFFTrackPtSecCorr->Multiply(histPt,fh1SecCorrPt[i],1,1,""); | |
5545 | ||
5546 | TH1F* hFFZSecCorr = (TH1F*) histZ->Clone(histNameZ); | |
5547 | hFFZSecCorr->Multiply(histZ,fh1SecCorrZ[i],1,1,""); | |
5548 | ||
5549 | TH1F* hFFXiSecCorr = (TH1F*) histXi->Clone(histNameXi); | |
5550 | hFFXiSecCorr->Multiply(histXi,fh1SecCorrXi[i],1,1,""); | |
5551 | ||
5552 | fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hFFTrackPtSecCorr,hFFZSecCorr,hFFXiSecCorr); | |
5553 | } | |
5554 | } | |
5555 | ||
5556 | ||
5557 | ||
5558 | // ___________________________________________________ | |
5559 | void AliFragmentationFunctionCorrections::JetSecCorrBgr() | |
5560 | { | |
5561 | // apply secondaries correction to UE | |
5562 | ||
5563 | AddCorrectionLevelBgr("SecCorr"); | |
5564 | ||
5565 | Printf("%s:%d -- apply jet secondaries correction", (char*)__FILE__,__LINE__); | |
5566 | ||
5567 | for(Int_t i=0; i<fNJetPtSlices; i++){ | |
5568 | ||
5569 | TH1F* histPt = fCorrBgr[fNCorrectionLevelsBgr-2]->GetTrackPt(i); | |
5570 | TH1F* histZ = fCorrBgr[fNCorrectionLevelsBgr-2]->GetZ(i); | |
5571 | TH1F* histXi = fCorrBgr[fNCorrectionLevelsBgr-2]->GetXi(i); | |
5572 | ||
5573 | TString histNamePt = histPt->GetName(); | |
5574 | TString histNameZ = histZ->GetName(); | |
5575 | TString histNameXi = histXi->GetName(); | |
5576 | ||
5577 | TH1F* hFFTrackPtSecCorr = (TH1F*) histPt->Clone(histNamePt); | |
5578 | hFFTrackPtSecCorr->Multiply(histPt,fh1SecCorrBgrPt[i],1,1,""); | |
5579 | ||
5580 | TH1F* hFFZSecCorr = (TH1F*) histZ->Clone(histNameZ); | |
5581 | hFFZSecCorr->Multiply(histZ,fh1SecCorrBgrZ[i],1,1,""); | |
5582 | ||
5583 | TH1F* hFFXiSecCorr = (TH1F*) histXi->Clone(histNameXi); | |
5584 | hFFXiSecCorr->Multiply(histXi,fh1SecCorrBgrXi[i],1,1,""); | |
5585 | ||
5586 | fCorrBgr[fNCorrectionLevelsBgr-1]->AddCorrHistos(i,hFFTrackPtSecCorr,hFFZSecCorr,hFFXiSecCorr); | |
5587 | } | |
5588 | } | |
5589 | ||
5590 | ||
5591 | //________________________________________________________________________________________________________________ | |
5592 | void AliFragmentationFunctionCorrections::WriteBinShiftCorrSinglePt(TString strInfile, TString strIDGen, TString strIDRec, | |
5593 | TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, | |
5594 | TString strOutDir) | |
5595 | { | |
5596 | TString strdirGen = "PWGJE_FragmentationFunction_" + strIDGen; | |
5597 | TString strlistGen = "fracfunc_" + strIDGen; | |
5598 | ||
5599 | TString strdirRec = "PWGJE_FragmentationFunction_" + strIDRec; | |
5600 | TString strlistRec = "fracfunc_" + strIDRec; | |
5601 | ||
5602 | WriteBinShiftCorrSinglePt(strInfile,strdirGen,strlistGen,strdirRec,strlistRec,strOutfile,updateOutfile,useRecPrim,strOutDir); | |
5603 | } | |
5604 | ||
5605 | //___________________________________________________________________________________________________________________________________ | |
5606 | void AliFragmentationFunctionCorrections::WriteBinShiftCorrSinglePt(TString strInfile, TString strdirGen, TString strlistGen, | |
5607 | TString strdirRec, TString strlistRec, | |
5608 | TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim, | |
5609 | TString strOutDir){ | |
5610 | ||
5611 | ||
5612 | TH1F* hCorrPt = 0; | |
5613 | TH1F* hdNdptTracksMCGen = 0; | |
5614 | TH1F* hdNdptTracksMCRec = 0; | |
5615 | ||
5616 | // gen level FF | |
5617 | ||
5618 | TFile f(strInfile,"READ"); | |
5619 | ||
5620 | if(!f.IsOpen()){ | |
5621 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
5622 | return; | |
5623 | } | |
5624 | ||
5625 | if(fDebug>0) Printf("%s:%d -- writeBinShiftCorrSinglePt: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data()); | |
5626 | ||
5627 | if(strdirGen && strdirGen.Length()) gDirectory->cd(strdirGen); | |
5628 | ||
5629 | TList* listGen = 0; | |
5630 | ||
5631 | if(strlistGen && strlistGen.Length()){ | |
5632 | ||
5633 | if(!(listGen = (TList*) gDirectory->Get(strlistGen))){ | |
5634 | Printf("%s:%d -- error retrieving listGen %s from directory %s", (char*)__FILE__,__LINE__,strlistGen.Data(),strdirGen.Data()); | |
5635 | return; | |
5636 | } | |
5637 | } | |
5638 | ||
5639 | if(listGen){ | |
5640 | hdNdptTracksMCGen = (TH1F*) listGen->FindObject("fh1TrackQAPtGen"); | |
5641 | } | |
5642 | else{ | |
5643 | hdNdptTracksMCGen = (TH1F*) gDirectory->Get("fh1TrackQAPtGen"); | |
5644 | } | |
5645 | ||
5646 | hdNdptTracksMCGen->SetDirectory(0); | |
5647 | ||
5648 | f.Close(); | |
5649 | ||
5650 | // rec level FF | |
5651 | ||
5652 | TFile g(strInfile,"READ"); | |
5653 | ||
5654 | if(!g.IsOpen()){ | |
5655 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data()); | |
5656 | return; | |
5657 | } | |
5658 | ||
5659 | if(fDebug>0) Printf("%s:%d -- writeBinShiftCorrSinglePt: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data()); | |
5660 | ||
5661 | if(strdirRec && strdirRec.Length()) gDirectory->cd(strdirRec); | |
5662 | ||
5663 | TList* listRec = 0; | |
5664 | ||
5665 | if(strlistRec && strlistRec.Length()){ | |
5666 | ||
5667 | if(!(listRec = (TList*) gDirectory->Get(strlistRec))){ | |
5668 | Printf("%s:%d -- error retrieving listRec %s from directory %s", (char*)__FILE__,__LINE__,strlistRec.Data(),strdirRec.Data()); | |
5669 | return; | |
5670 | } | |
5671 | } | |
5672 | ||
5673 | ||
5674 | if(useRecPrim){ | |
5675 | if(listRec){ | |
5676 | hdNdptTracksMCRec = (TH1F*) listRec->FindObject("fh1TrackQAPtRecEffRec"); | |
5677 | } | |
5678 | else{ | |
5679 | hdNdptTracksMCRec = (TH1F*) gDirectory->Get("fh1TrackQAPtRecEffRec"); | |
5680 | } | |
5681 | } | |
5682 | else{ | |
5683 | if(listRec){ | |
5684 | hdNdptTracksMCRec = (TH1F*) listRec->FindObject("fh1TrackQAPtRecCuts"); | |
5685 | } | |
5686 | else{ | |
5687 | hdNdptTracksMCRec = (TH1F*) gDirectory->Get("fh1TrackQAPtRecCuts"); | |
5688 | } | |
5689 | } | |
5690 | ||
5691 | hdNdptTracksMCRec->SetDirectory(0); | |
5692 | ||
5693 | g.Close(); | |
5694 | ||
5695 | TString strNamePtGen = "fh1SinglePtGenBbB"; | |
5696 | TString strNamePtRec = "fh1SinglePtRecBbB"; | |
5697 | ||
5698 | // rebin | |
5699 | if(fNHistoBinsSinglePt) hdNdptTracksMCGen = (TH1F*) hdNdptTracksMCGen->Rebin(fNHistoBinsSinglePt,strNamePtGen+"_rebin",fHistoBinsSinglePt->GetArray()); | |
5700 | if(fNHistoBinsSinglePt) hdNdptTracksMCRec = (TH1F*) hdNdptTracksMCRec->Rebin(fNHistoBinsSinglePt,strNamePtRec+"_rebin",fHistoBinsSinglePt->GetArray()); | |
5701 | ||
5702 | hdNdptTracksMCGen->SetNameTitle(strNamePtGen,""); | |
5703 | hdNdptTracksMCRec->SetNameTitle(strNamePtRec,""); | |
5704 | ||
5705 | // corr fac | |
5706 | TString strTitCorr = "hBbBCorrSinglePt"; | |
5707 | if(useRecPrim) strTitCorr = "hBbBCorrRecPrimSinglePt"; | |
5708 | ||
5709 | hCorrPt = (TH1F*) hdNdptTracksMCGen->Clone(strTitCorr); | |
5710 | hCorrPt->Divide(hdNdptTracksMCGen,hdNdptTracksMCRec,1,1,"B"); // binominal errors | |
5711 | ||
5712 | // write | |
5713 | ||
5714 | TString outfileOption = "RECREATE"; | |
5715 | if(updateOutfile) outfileOption = "UPDATE"; | |
5716 | ||
5717 | TFile out(strOutfile,outfileOption); | |
5718 | ||
5719 | if(!out.IsOpen()){ | |
5720 | Printf("%s:%d -- error opening efficiency output file %s", (char*)__FILE__,__LINE__,strOutfile.Data()); | |
5721 | return; | |
5722 | } | |
5723 | ||
5724 | if(fDebug>0) Printf("%s:%d -- write bin shift correction to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data()); | |
5725 | ||
5726 | if(strOutDir && strOutDir.Length()){ | |
5727 | ||
5728 | TDirectory* dir; | |
5729 | if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd(); | |
5730 | else{ | |
5731 | dir = out.mkdir(strOutDir); | |
5732 | dir->cd(); | |
5733 | } | |
5734 | } | |
5735 | ||
5736 | ||
5737 | hdNdptTracksMCGen->Write(); | |
5738 | hdNdptTracksMCRec->Write(); | |
5739 | hCorrPt->Write(); | |
5740 | ||
5741 | out.Close(); | |
5742 | ||
5743 | delete hdNdptTracksMCGen; | |
5744 | delete hdNdptTracksMCRec; | |
5745 | delete hCorrPt; | |
5746 | } | |
5747 | ||
5748 | //___________________________________________________________________________________________________________________________________ | |
5749 | void AliFragmentationFunctionCorrections::ReadBinShiftCorrSinglePt(TString strfile, TString strdir, TString strlist, Bool_t useRecPrim) | |
5750 | { | |
5751 | // read reconstruction efficiency from file | |
5752 | // argument strlist optional - read from directory strdir if not specified | |
5753 | ||
5754 | // temporary histos to hold histos from file | |
5755 | TH1F* hBbBCorrPt = 0; | |
5756 | ||
5757 | TFile f(strfile,"READ"); | |
5758 | ||
5759 | if(!f.IsOpen()){ | |
5760 | Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data()); | |
5761 | return; | |
5762 | } | |
5763 | ||
5764 | if(fDebug>0) Printf("%s:%d -- read BbB corr from file %s ",(char*)__FILE__,__LINE__,strfile.Data()); | |
5765 | ||
5766 | if(strdir && strdir.Length()) gDirectory->cd(strdir); | |
5767 | ||
5768 | TList* list = 0; | |
5769 | ||
5770 | if(strlist && strlist.Length()){ | |
5771 | ||
5772 | if(!(list = (TList*) gDirectory->Get(strlist))){ | |
5773 | Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data()); | |
5774 | return; | |
5775 | } | |
5776 | } | |
5777 | ||
5778 | ||
5779 | TString strNameBbBCorrPt = "hBbBCorrSinglePt"; | |
5780 | if(useRecPrim) strNameBbBCorrPt = "hBbBCorrRecPrimSinglePt"; | |
5781 | ||
5782 | if(list){ | |
5783 | hBbBCorrPt = (TH1F*) list->FindObject(strNameBbBCorrPt); | |
5784 | } | |
5785 | else{ | |
5786 | hBbBCorrPt = (TH1F*) gDirectory->Get(strNameBbBCorrPt); | |
5787 | } | |
5788 | ||
5789 | if(!hBbBCorrPt){ | |
5790 | Printf("%s:%d -- error retrieving BbB corr single pt %s", (char*)__FILE__,__LINE__,strNameBbBCorrPt.Data()); | |
5791 | } | |
5792 | ||
5793 | ||
5794 | if(fNHistoBinsPt) hBbBCorrPt = (TH1F*) hBbBCorrPt->Rebin(fNHistoBinsSinglePt,strNameBbBCorrPt+"_rebin",fHistoBinsSinglePt->GetArray()); | |
5795 | ||
5796 | if(hBbBCorrPt) hBbBCorrPt->SetDirectory(0); | |
5797 | ||
5798 | f.Close(); | |
5799 | ||
5800 | fh1BbBCorrSinglePt = hBbBCorrPt; | |
5801 | } | |
5802 | ||
5803 | // ------------------------------------------------------------------ | |
5804 | ||
5805 | void AliFragmentationFunctionCorrections::BbBCorrSinglePt() | |
5806 | { | |
5807 | // apply efficiency correction to inclusive track pt spec | |
5808 | ||
5809 | AddCorrectionLevelSinglePt("BbB"); | |
5810 | ||
5811 | TH1F* histPt = fCorrSinglePt[fNCorrectionLevelsSinglePt-2]->GetTrackPt(0); | |
5812 | ||
5813 | if(histPt->GetNbinsX() != fh1BbBCorrSinglePt->GetNbinsX()){ | |
5814 | Printf("%s:%d: inconsistency pt spec and BbB corr binning ", (char*)__FILE__,__LINE__); | |
5815 | return; | |
5816 | } | |
5817 | ||
5818 | TString histNamePt = histPt->GetName(); | |
5819 | TH1F* hTrackPtBbBCorr = (TH1F*) histPt->Clone(histNamePt); | |
5820 | ||
5821 | hTrackPtBbBCorr->Multiply(histPt,fh1BbBCorrSinglePt,1,1,""); | |
5822 | ||
5823 | fCorrSinglePt[fNCorrectionLevelsSinglePt-1]->AddCorrHistos(0,hTrackPtBbBCorr); | |
5824 | } | |
5825 |