missed file in revision 43011
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / AliAnalysisTaskFragmentationFunction.cxx
1 /*************************************************************************
2  *                                                                       *
3  * Task for Fragmentation Function Analysis in PWG4 Jet Task Force Train *
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 "TList.h"
26 #include "TH1F.h"
27 #include "TH2F.h"
28 #include "TString.h"
29 #include "THnSparse.h"
30
31 #include "AliAODInputHandler.h" 
32 #include "AliAODHandler.h" 
33 #include "AliESDEvent.h"
34 #include "AliAODMCParticle.h"
35 #include "AliAODJet.h"
36 #include "AliGenPythiaEventHeader.h"
37 #include "AliInputEventHandler.h"
38
39 #include "AliAnalysisHelperJetTasks.h"
40 #include "AliAnalysisManager.h"
41 #include "AliAnalysisTaskSE.h"
42
43 #include "AliAnalysisTaskFragmentationFunction.h"
44
45
46 ClassImp(AliAnalysisTaskFragmentationFunction)
47
48 //____________________________________________________________________________
49 AliAnalysisTaskFragmentationFunction::AliAnalysisTaskFragmentationFunction()
50    : AliAnalysisTaskSE()
51    ,fESD(0)
52    ,fAOD(0)
53    ,fMCEvent(0)
54    ,fBranchRecJets("jets")
55    ,fBranchGenJets("")
56    ,fTrackTypeGen(0)
57    ,fJetTypeGen(0)
58    ,fJetTypeRecEff(0)
59    ,fFilterMask(0)
60    ,fTrackPtCut(0)
61    ,fTrackEtaMin(0)
62    ,fTrackEtaMax(0)
63    ,fTrackPhiMin(0)
64    ,fTrackPhiMax(0)
65    ,fJetPtCut(0)
66    ,fJetEtaMin(0)
67    ,fJetEtaMax(0)
68    ,fJetPhiMin(0)
69    ,fJetPhiMax(0)
70    ,fDiJetCut(0)
71    ,fDiJetDeltaPhiCut(0)
72    ,fDiJetPtFractionCut(0)
73    ,fDiJetCDFCut(0)
74    ,fDiJetKindBins(0)
75    ,fFFRadius(0)
76    ,fTracksRec(0)
77    ,fTracksRecCuts(0)
78    ,fTracksGen(0)
79    ,fTracksAODMCCharged(0)
80    ,fTracksRecQualityCuts(0)
81    ,fJetsRec(0)
82    ,fJetsRecCuts(0)
83    ,fJetsGen(0)
84    ,fJetsRecEff(0)
85    ,fQATrackHistosRec(0)
86    ,fQATrackHistosRecCuts(0)
87    ,fQATrackHistosGen(0)
88    ,fQAJetHistosRec(0)
89    ,fQAJetHistosRecCuts(0)
90    ,fQAJetHistosRecCutsLeading(0)
91    ,fQAJetHistosGen(0)
92    ,fQAJetHistosGenLeading(0)
93    ,fQAJetHistosRecEffLeading(0)
94    ,fFFHistosRecCuts(0)
95    ,fFFHistosRecLeading(0)
96    ,fFFHistosRecLeadingTrack(0)
97    ,fFFHistosGen(0)
98    ,fFFHistosGenLeading(0)
99    ,fFFHistosGenLeadingTrack(0)
100    ,fIJHistosRecCuts(0)
101    ,fIJHistosRecLeading(0)
102    ,fIJHistosRecLeadingTrack(0)
103    ,fIJHistosGen(0)
104    ,fIJHistosGenLeading(0)
105    ,fIJHistosGenLeadingTrack(0)
106    ,fFFDiJetHistosRecCuts(0)
107    ,fFFDiJetHistosRecLeading(0)
108    ,fFFDiJetHistosRecLeadingTrack(0)
109    ,fFFDiJetHistosGen(0)
110    ,fFFDiJetHistosGenLeading(0)
111    ,fFFDiJetHistosGenLeadingTrack(0)
112    ,fQADiJetHistosRecCuts(0)
113    ,fQADiJetHistosGen(0)
114    ,fQATrackHighPtThreshold(0)
115    ,fFFNBinsJetPt(0)    
116    ,fFFJetPtMin(0) 
117    ,fFFJetPtMax(0)
118    ,fFFNBinsPt(0)      
119    ,fFFPtMin(0)        
120    ,fFFPtMax(0)        
121    ,fFFNBinsXi(0)      
122    ,fFFXiMin(0)        
123    ,fFFXiMax(0)        
124    ,fFFNBinsZ(0)       
125    ,fFFZMin(0)         
126    ,fFFZMax(0)         
127    ,fQAJetNBinsPt(0)   
128    ,fQAJetPtMin(0)     
129    ,fQAJetPtMax(0)     
130    ,fQAJetNBinsEta(0)  
131    ,fQAJetEtaMin(0)    
132    ,fQAJetEtaMax(0)    
133    ,fQAJetNBinsPhi(0)  
134    ,fQAJetPhiMin(0)    
135    ,fQAJetPhiMax(0)    
136    ,fQATrackNBinsPt(0) 
137    ,fQATrackPtMin(0)   
138    ,fQATrackPtMax(0)   
139    ,fQATrackNBinsEta(0)
140    ,fQATrackEtaMin(0)  
141    ,fQATrackEtaMax(0)  
142    ,fQATrackNBinsPhi(0)
143    ,fQATrackPhiMin(0)  
144    ,fQATrackPhiMax(0)
145    ,fIJNBinsJetPt(0)
146    ,fIJJetPtMin(0)
147    ,fIJJetPtMax(0)
148    ,fIJNBinsPt(0)
149    ,fIJPtMin(0)
150    ,fIJPtMax(0)
151    ,fIJNBinsZ(0)
152    ,fIJZMin(0)
153    ,fIJZMax(0)
154    ,fIJNBinsCosTheta(0)
155    ,fIJCosThetaMin(0)
156    ,fIJCosThetaMax(0)
157    ,fIJNBinsTheta(0)
158    ,fIJThetaMin(0)
159    ,fIJThetaMax(0)
160    ,fIJNBinsJt(0)
161    ,fIJJtMin(0)
162    ,fIJJtMax(0)
163    ,fDiJetNBinsJetInvMass(0)
164    ,fDiJetJetInvMassMin(0)
165    ,fDiJetJetInvMassMax(0)
166    ,fDiJetNBinsJetPt(0)
167    ,fDiJetJetPtMin(0)
168    ,fDiJetJetPtMax(0)
169    ,fDiJetNBinsPt(0)
170    ,fDiJetPtMin(0)
171    ,fDiJetPtMax(0)
172    ,fDiJetNBinsXi(0)
173    ,fDiJetXiMin(0)
174    ,fDiJetXiMax(0)
175    ,fDiJetNBinsZ(0)
176    ,fDiJetZMin(0)
177    ,fDiJetZMax(0)
178    ,fQADiJetNBinsInvMass(0)
179    ,fQADiJetInvMassMin(0)
180    ,fQADiJetInvMassMax(0)
181    ,fQADiJetNBinsJetPt(0)
182    ,fQADiJetJetPtMin(0)
183    ,fQADiJetJetPtMax(0)
184    ,fQADiJetNBinsDeltaPhi(0)
185    ,fQADiJetDeltaPhiMin(0)
186    ,fQADiJetDeltaPhiMax(0)
187    ,fQADiJetNBinsDeltaEta(0)
188    ,fQADiJetDeltaEtaMin(0)
189    ,fQADiJetDeltaEtaMax(0)
190    ,fQADiJetNBinsDeltaPt(0)
191    ,fQADiJetDeltaPtMin(0)
192    ,fQADiJetDeltaPtMax(0)
193    ,fCommonHistList(0)
194    ,fh1EvtSelection(0)
195    ,fh1VertexNContributors(0)
196    ,fh1VertexZ(0)
197    ,fh1EvtMult(0)
198    ,fh1nRecJetsCuts(0)
199    ,fh1nGenJets(0)
200    ,fh1nRecEffJets(0)
201    ,fhnSingleTrackRecEffHisto(0)
202    ,fhnJetTrackRecEffHisto(0)
203 {
204    // default constructor
205 }
206
207 //__________________________________________________________________________________________
208 AliAnalysisTaskFragmentationFunction::AliAnalysisTaskFragmentationFunction(const char *name) 
209   : AliAnalysisTaskSE(name)
210   ,fESD(0)
211   ,fAOD(0)
212   ,fMCEvent(0)
213   ,fBranchRecJets("jets")
214   ,fBranchGenJets("")
215   ,fTrackTypeGen(0)
216   ,fJetTypeGen(0)
217   ,fJetTypeRecEff(0)
218   ,fFilterMask(0)
219   ,fTrackPtCut(0)
220   ,fTrackEtaMin(0)
221   ,fTrackEtaMax(0)
222   ,fTrackPhiMin(0)
223   ,fTrackPhiMax(0)
224   ,fJetPtCut(0)
225   ,fJetEtaMin(0)
226   ,fJetEtaMax(0)
227   ,fJetPhiMin(0)
228   ,fJetPhiMax(0)
229   ,fDiJetCut(0)
230   ,fDiJetDeltaPhiCut(0)
231   ,fDiJetPtFractionCut(0)
232   ,fDiJetCDFCut(0)
233   ,fDiJetKindBins(0)
234   ,fFFRadius(0)
235   ,fTracksRec(0)
236   ,fTracksRecCuts(0)
237   ,fTracksGen(0)
238   ,fTracksAODMCCharged(0)
239   ,fTracksRecQualityCuts(0)
240   ,fJetsRec(0)
241   ,fJetsRecCuts(0)
242   ,fJetsGen(0)
243   ,fJetsRecEff(0)
244   ,fQATrackHistosRec(0)
245   ,fQATrackHistosRecCuts(0)
246   ,fQATrackHistosGen(0)
247   ,fQAJetHistosRec(0)
248   ,fQAJetHistosRecCuts(0)
249   ,fQAJetHistosRecCutsLeading(0)
250   ,fQAJetHistosGen(0)
251   ,fQAJetHistosGenLeading(0)
252   ,fQAJetHistosRecEffLeading(0)
253   ,fFFHistosRecCuts(0)
254   ,fFFHistosRecLeading(0)
255   ,fFFHistosRecLeadingTrack(0)
256   ,fFFHistosGen(0)
257   ,fFFHistosGenLeading(0)
258   ,fFFHistosGenLeadingTrack(0)
259   ,fIJHistosRecCuts(0)
260   ,fIJHistosRecLeading(0)
261   ,fIJHistosRecLeadingTrack(0)
262   ,fIJHistosGen(0)
263   ,fIJHistosGenLeading(0)
264   ,fIJHistosGenLeadingTrack(0)
265   ,fFFDiJetHistosRecCuts(0)
266   ,fFFDiJetHistosRecLeading(0)
267   ,fFFDiJetHistosRecLeadingTrack(0)
268   ,fFFDiJetHistosGen(0)
269   ,fFFDiJetHistosGenLeading(0)
270   ,fFFDiJetHistosGenLeadingTrack(0)
271   ,fQADiJetHistosRecCuts(0)
272   ,fQADiJetHistosGen(0)
273   ,fQATrackHighPtThreshold(0) 
274   ,fFFNBinsJetPt(0)    
275   ,fFFJetPtMin(0) 
276   ,fFFJetPtMax(0)
277   ,fFFNBinsPt(0)      
278   ,fFFPtMin(0)        
279   ,fFFPtMax(0)        
280   ,fFFNBinsXi(0)      
281   ,fFFXiMin(0)        
282   ,fFFXiMax(0)        
283   ,fFFNBinsZ(0)       
284   ,fFFZMin(0)         
285   ,fFFZMax(0)         
286   ,fQAJetNBinsPt(0)   
287   ,fQAJetPtMin(0)     
288   ,fQAJetPtMax(0)     
289   ,fQAJetNBinsEta(0)  
290   ,fQAJetEtaMin(0)    
291   ,fQAJetEtaMax(0)    
292   ,fQAJetNBinsPhi(0)  
293   ,fQAJetPhiMin(0)    
294   ,fQAJetPhiMax(0)    
295   ,fQATrackNBinsPt(0) 
296   ,fQATrackPtMin(0)   
297   ,fQATrackPtMax(0)   
298   ,fQATrackNBinsEta(0)
299   ,fQATrackEtaMin(0)  
300   ,fQATrackEtaMax(0)  
301   ,fQATrackNBinsPhi(0)
302   ,fQATrackPhiMin(0)  
303   ,fQATrackPhiMax(0)  
304   ,fIJNBinsJetPt(0)
305   ,fIJJetPtMin(0)
306   ,fIJJetPtMax(0)
307   ,fIJNBinsPt(0)
308   ,fIJPtMin(0)
309   ,fIJPtMax(0)
310   ,fIJNBinsZ(0)
311   ,fIJZMin(0)
312   ,fIJZMax(0)
313   ,fIJNBinsCosTheta(0)
314   ,fIJCosThetaMin(0)
315   ,fIJCosThetaMax(0)
316   ,fIJNBinsTheta(0)
317   ,fIJThetaMin(0)
318   ,fIJThetaMax(0)
319   ,fIJNBinsJt(0)
320   ,fIJJtMin(0)
321   ,fIJJtMax(0)
322   ,fDiJetNBinsJetInvMass(0)
323   ,fDiJetJetInvMassMin(0)
324   ,fDiJetJetInvMassMax(0)
325   ,fDiJetNBinsJetPt(0)
326   ,fDiJetJetPtMin(0)
327   ,fDiJetJetPtMax(0)
328   ,fDiJetNBinsPt(0)
329   ,fDiJetPtMin(0)
330   ,fDiJetPtMax(0)
331   ,fDiJetNBinsXi(0)
332   ,fDiJetXiMin(0)
333   ,fDiJetXiMax(0)
334   ,fDiJetNBinsZ(0)
335   ,fDiJetZMin(0)
336   ,fDiJetZMax(0)
337   ,fQADiJetNBinsInvMass(0)
338   ,fQADiJetInvMassMin(0)
339   ,fQADiJetInvMassMax(0)
340   ,fQADiJetNBinsJetPt(0)
341   ,fQADiJetJetPtMin(0)
342   ,fQADiJetJetPtMax(0)
343   ,fQADiJetNBinsDeltaPhi(0)
344   ,fQADiJetDeltaPhiMin(0)
345   ,fQADiJetDeltaPhiMax(0)
346   ,fQADiJetNBinsDeltaEta(0)
347   ,fQADiJetDeltaEtaMin(0)
348   ,fQADiJetDeltaEtaMax(0)
349   ,fQADiJetNBinsDeltaPt(0)
350   ,fQADiJetDeltaPtMin(0)
351   ,fQADiJetDeltaPtMax(0)
352   ,fCommonHistList(0)
353   ,fh1EvtSelection(0)
354   ,fh1VertexNContributors(0)
355   ,fh1VertexZ(0)
356   ,fh1EvtMult(0)
357   ,fh1nRecJetsCuts(0)
358   ,fh1nGenJets(0)
359   ,fh1nRecEffJets(0)
360   ,fhnSingleTrackRecEffHisto(0)
361   ,fhnJetTrackRecEffHisto(0)
362 {
363   // constructor
364   
365   DefineOutput(1,TList::Class());
366   
367
368 }
369
370 //__________________________________________________________________________________________________________________________
371 AliAnalysisTaskFragmentationFunction::AliAnalysisTaskFragmentationFunction(const  AliAnalysisTaskFragmentationFunction &copy)
372   : AliAnalysisTaskSE()
373   ,fESD(copy.fESD)
374   ,fAOD(copy.fAOD)
375   ,fMCEvent(copy.fMCEvent)
376   ,fBranchRecJets(copy.fBranchRecJets)
377   ,fBranchGenJets(copy.fBranchGenJets)
378   ,fTrackTypeGen(copy.fTrackTypeGen)
379   ,fJetTypeGen(copy.fJetTypeGen)
380   ,fJetTypeRecEff(copy.fJetTypeRecEff)
381   ,fFilterMask(copy.fFilterMask)
382   ,fTrackPtCut(copy.fTrackPtCut)
383   ,fTrackEtaMin(copy.fTrackEtaMin)
384   ,fTrackEtaMax(copy.fTrackEtaMax)
385   ,fTrackPhiMin(copy.fTrackPhiMin)
386   ,fTrackPhiMax(copy.fTrackPhiMax)
387   ,fJetPtCut(copy.fJetPtCut)
388   ,fJetEtaMin(copy.fJetEtaMin)
389   ,fJetEtaMax(copy.fJetEtaMax)
390   ,fJetPhiMin(copy.fJetPhiMin)
391   ,fJetPhiMax(copy.fJetPhiMax)
392   ,fDiJetCut(copy.fDiJetCut)
393   ,fDiJetDeltaPhiCut(copy.fDiJetDeltaPhiCut)
394   ,fDiJetPtFractionCut(copy.fDiJetPtFractionCut)
395   ,fDiJetCDFCut(copy.fDiJetCDFCut)
396   ,fDiJetKindBins(copy.fDiJetKindBins)
397   ,fFFRadius(copy.fFFRadius)
398   ,fTracksRec(copy.fTracksRec)
399   ,fTracksRecCuts(copy.fTracksRecCuts)
400   ,fTracksGen(copy.fTracksGen)
401   ,fTracksAODMCCharged(copy.fTracksAODMCCharged)
402   ,fTracksRecQualityCuts(copy.fTracksRecQualityCuts)
403   ,fJetsRec(copy.fJetsRec)
404   ,fJetsRecCuts(copy.fJetsRecCuts)
405   ,fJetsGen(copy.fJetsGen)
406   ,fJetsRecEff(copy.fJetsRecEff)
407   ,fQATrackHistosRec(copy.fQATrackHistosRec)
408   ,fQATrackHistosRecCuts(copy.fQATrackHistosRecCuts)
409   ,fQATrackHistosGen(copy.fQATrackHistosGen)
410   ,fQAJetHistosRec(copy.fQAJetHistosRec)
411   ,fQAJetHistosRecCuts(copy.fQAJetHistosRecCuts)
412   ,fQAJetHistosRecCutsLeading(copy.fQAJetHistosRecCutsLeading)
413   ,fQAJetHistosGen(copy.fQAJetHistosGen)
414   ,fQAJetHistosGenLeading(copy.fQAJetHistosGenLeading)
415   ,fQAJetHistosRecEffLeading(copy.fQAJetHistosRecEffLeading)
416   ,fFFHistosRecCuts(copy.fFFHistosRecCuts)
417   ,fFFHistosRecLeading(copy.fFFHistosRecLeading)
418   ,fFFHistosRecLeadingTrack(copy.fFFHistosRecLeadingTrack)
419   ,fFFHistosGen(copy.fFFHistosGen)
420   ,fFFHistosGenLeading(copy.fFFHistosGenLeading)
421   ,fFFHistosGenLeadingTrack(copy.fFFHistosGenLeadingTrack)
422   ,fIJHistosRecCuts(copy.fIJHistosRecCuts)
423   ,fIJHistosRecLeading(copy.fIJHistosRecLeading)
424   ,fIJHistosRecLeadingTrack(copy.fIJHistosRecLeadingTrack)
425   ,fIJHistosGen(copy.fIJHistosGen)
426   ,fIJHistosGenLeading(copy.fIJHistosGenLeading)
427   ,fIJHistosGenLeadingTrack(copy.fIJHistosGenLeadingTrack)
428   ,fFFDiJetHistosRecCuts(copy.fFFDiJetHistosRecCuts)
429   ,fFFDiJetHistosRecLeading(copy.fFFDiJetHistosRecLeading)
430   ,fFFDiJetHistosRecLeadingTrack(copy.fFFDiJetHistosRecLeadingTrack)
431   ,fFFDiJetHistosGen(copy.fFFDiJetHistosGen)
432   ,fFFDiJetHistosGenLeading(copy.fFFDiJetHistosGenLeading)
433   ,fFFDiJetHistosGenLeadingTrack(copy.fFFDiJetHistosGenLeadingTrack)
434   ,fQADiJetHistosRecCuts(copy.fQADiJetHistosRecCuts)
435   ,fQADiJetHistosGen(copy.fQADiJetHistosGen)
436   ,fQATrackHighPtThreshold(copy.fQATrackHighPtThreshold) 
437   ,fFFNBinsJetPt(copy.fFFNBinsJetPt)    
438   ,fFFJetPtMin(copy.fFFJetPtMin) 
439   ,fFFJetPtMax(copy.fFFJetPtMax)
440   ,fFFNBinsPt(copy.fFFNBinsPt)      
441   ,fFFPtMin(copy.fFFPtMin)        
442   ,fFFPtMax(copy.fFFPtMax)        
443   ,fFFNBinsXi(copy.fFFNBinsXi)      
444   ,fFFXiMin(copy.fFFXiMin)        
445   ,fFFXiMax(copy.fFFXiMax)        
446   ,fFFNBinsZ(copy.fFFNBinsZ)       
447   ,fFFZMin(copy.fFFZMin)         
448   ,fFFZMax(copy.fFFZMax)         
449   ,fQAJetNBinsPt(copy.fQAJetNBinsPt)   
450   ,fQAJetPtMin(copy.fQAJetPtMin)     
451   ,fQAJetPtMax(copy.fQAJetPtMax)     
452   ,fQAJetNBinsEta(copy.fQAJetNBinsEta)  
453   ,fQAJetEtaMin(copy.fQAJetEtaMin)    
454   ,fQAJetEtaMax(copy.fQAJetEtaMax)    
455   ,fQAJetNBinsPhi(copy.fQAJetNBinsPhi)  
456   ,fQAJetPhiMin(copy.fQAJetPhiMin)    
457   ,fQAJetPhiMax(copy.fQAJetPhiMax)    
458   ,fQATrackNBinsPt(copy.fQATrackNBinsPt) 
459   ,fQATrackPtMin(copy.fQATrackPtMin)   
460   ,fQATrackPtMax(copy.fQATrackPtMax)   
461   ,fQATrackNBinsEta(copy.fQATrackNBinsEta)
462   ,fQATrackEtaMin(copy.fQATrackEtaMin)  
463   ,fQATrackEtaMax(copy.fQATrackEtaMax)  
464   ,fQATrackNBinsPhi(copy.fQATrackNBinsPhi)
465   ,fQATrackPhiMin(copy.fQATrackPhiMin)  
466   ,fQATrackPhiMax(copy.fQATrackPhiMax)
467   ,fIJNBinsJetPt(copy.fIJNBinsJetPt)
468   ,fIJJetPtMin(copy.fIJJetPtMin)
469   ,fIJJetPtMax(copy.fIJJetPtMax)
470   ,fIJNBinsPt(copy.fIJNBinsPt)
471   ,fIJPtMin(copy.fIJPtMin)
472   ,fIJPtMax(copy.fIJPtMax)
473   ,fIJNBinsZ(copy.fIJNBinsZ)
474   ,fIJZMin(copy.fIJZMin)
475   ,fIJZMax(copy.fIJZMax)
476   ,fIJNBinsCosTheta(copy.fIJNBinsCosTheta)
477   ,fIJCosThetaMin(copy.fIJCosThetaMin)
478   ,fIJCosThetaMax(copy.fIJCosThetaMax)
479   ,fIJNBinsTheta(copy.fIJNBinsTheta)
480   ,fIJThetaMin(copy.fIJThetaMin)
481   ,fIJThetaMax(copy.fIJThetaMax)
482   ,fIJNBinsJt(copy.fIJNBinsJt)
483   ,fIJJtMin(copy.fIJJtMin)
484   ,fIJJtMax(copy.fIJJtMax)
485   ,fDiJetNBinsJetInvMass(copy.fDiJetNBinsJetInvMass)
486   ,fDiJetJetInvMassMin(copy.fDiJetJetInvMassMin)
487   ,fDiJetJetInvMassMax(copy.fDiJetJetInvMassMax)
488   ,fDiJetNBinsJetPt(copy.fDiJetNBinsJetPt)
489   ,fDiJetJetPtMin(copy.fDiJetJetPtMin)
490   ,fDiJetJetPtMax(copy.fDiJetJetPtMax)
491   ,fDiJetNBinsPt(copy.fDiJetNBinsPt)
492   ,fDiJetPtMin(copy.fDiJetPtMin)
493   ,fDiJetPtMax(copy.fDiJetPtMax)
494   ,fDiJetNBinsXi(copy.fDiJetNBinsXi)
495   ,fDiJetXiMin(copy.fDiJetXiMin)
496   ,fDiJetXiMax(copy.fDiJetXiMax)
497   ,fDiJetNBinsZ(copy.fDiJetNBinsZ)
498   ,fDiJetZMin(copy.fDiJetZMin)
499   ,fDiJetZMax(copy.fDiJetZMax)
500   ,fQADiJetNBinsInvMass(copy.fQADiJetNBinsInvMass)
501   ,fQADiJetInvMassMin(copy.fQADiJetInvMassMin)
502   ,fQADiJetInvMassMax(copy.fQADiJetInvMassMax)
503   ,fQADiJetNBinsJetPt(copy.fQADiJetNBinsJetPt)
504   ,fQADiJetJetPtMin(copy.fQADiJetJetPtMin)
505   ,fQADiJetJetPtMax(copy.fQADiJetJetPtMax)
506   ,fQADiJetNBinsDeltaPhi(copy.fQADiJetNBinsDeltaPhi)
507   ,fQADiJetDeltaPhiMin(copy.fQADiJetDeltaPhiMin)
508   ,fQADiJetDeltaPhiMax(copy.fQADiJetDeltaPhiMax)
509   ,fQADiJetNBinsDeltaEta(copy.fQADiJetNBinsDeltaEta)
510   ,fQADiJetDeltaEtaMin(copy.fQADiJetDeltaEtaMin)
511   ,fQADiJetDeltaEtaMax(copy.fQADiJetDeltaEtaMax)
512   ,fQADiJetNBinsDeltaPt(copy.fQADiJetNBinsDeltaPt)
513   ,fQADiJetDeltaPtMin(copy.fQADiJetDeltaPtMin)
514   ,fQADiJetDeltaPtMax(copy.fQADiJetDeltaPtMax)
515   ,fCommonHistList(copy.fCommonHistList)
516   ,fh1EvtSelection(copy.fh1EvtSelection)
517   ,fh1VertexNContributors(copy.fh1VertexNContributors)
518   ,fh1VertexZ(copy.fh1VertexZ)
519   ,fh1EvtMult(copy.fh1EvtMult)
520   ,fh1nRecJetsCuts(copy.fh1nRecJetsCuts)
521   ,fh1nGenJets(copy.fh1nGenJets)
522   ,fh1nRecEffJets(copy.fh1nRecEffJets)
523   ,fhnSingleTrackRecEffHisto(copy.fhnSingleTrackRecEffHisto)
524   ,fhnJetTrackRecEffHisto(copy.fhnJetTrackRecEffHisto)
525 {
526   // copy constructor
527
528 }
529
530 // _________________________________________________________________________________________________________________________________
531 AliAnalysisTaskFragmentationFunction& AliAnalysisTaskFragmentationFunction::operator=(const AliAnalysisTaskFragmentationFunction& o)
532 {
533   // assignment
534   
535   if(this!=&o){
536
537     AliAnalysisTaskSE::operator=(o);
538     fESD                          = o.fESD;
539     fAOD                          = o.fAOD;
540     fMCEvent                      = o.fMCEvent;
541     fBranchRecJets                = o.fBranchRecJets;
542     fBranchGenJets                = o.fBranchGenJets;
543     fTrackTypeGen                 = o.fTrackTypeGen;
544     fJetTypeGen                   = o.fJetTypeGen;
545     fJetTypeRecEff                = o.fJetTypeRecEff;
546     fFilterMask                   = o.fFilterMask;
547     fTrackPtCut                   = o.fTrackPtCut;
548     fTrackEtaMin                  = o.fTrackEtaMin;
549     fTrackEtaMax                  = o.fTrackEtaMax;
550     fTrackPhiMin                  = o.fTrackPhiMin;
551     fTrackPhiMax                  = o.fTrackPhiMax;
552     fJetPtCut                     = o.fJetPtCut;
553     fJetEtaMin                    = o.fJetEtaMin;
554     fJetEtaMax                    = o.fJetEtaMax;
555     fJetPhiMin                    = o.fJetPhiMin;
556     fJetPhiMax                    = o.fJetPhiMin;
557     fDiJetCut                     = o.fDiJetCut;
558     fDiJetDeltaPhiCut             = o.fDiJetDeltaPhiCut;
559     fDiJetPtFractionCut           = o.fDiJetPtFractionCut;
560     fDiJetCDFCut                  = o.fDiJetCDFCut;
561     fDiJetKindBins                = o.fDiJetKindBins;
562     fFFRadius                     = o.fFFRadius;
563     fTracksRec                    = o.fTracksRec;
564     fTracksRecCuts                = o.fTracksRecCuts;
565     fTracksGen                    = o.fTracksGen;
566     fTracksAODMCCharged           = o.fTracksAODMCCharged;
567     fTracksRecQualityCuts         = o.fTracksRecQualityCuts;
568     fJetsRec                      = o.fJetsRec;
569     fJetsRecCuts                  = o.fJetsRecCuts;
570     fJetsGen                      = o.fJetsGen;
571     fJetsRecEff                   = o.fJetsRecEff;
572     fQATrackHistosRec             = o.fQATrackHistosRec;
573     fQATrackHistosRecCuts         = o.fQATrackHistosRecCuts;
574     fQATrackHistosGen             = o.fQATrackHistosGen;
575     fQAJetHistosRec               = o.fQAJetHistosRec;
576     fQAJetHistosRecCuts           = o.fQAJetHistosRecCuts;
577     fQAJetHistosRecCutsLeading    = o.fQAJetHistosRecCutsLeading;
578     fQAJetHistosGen               = o.fQAJetHistosGen;
579     fQAJetHistosGenLeading        = o.fQAJetHistosGenLeading;
580     fQAJetHistosRecEffLeading     = o.fQAJetHistosRecEffLeading;
581     fFFHistosRecCuts              = o.fFFHistosRecCuts;
582     fFFHistosRecLeading           = o.fFFHistosRecLeading;
583     fFFHistosRecLeadingTrack      = o.fFFHistosRecLeadingTrack;
584     fFFHistosGen                  = o.fFFHistosGen;
585     fFFHistosGenLeading           = o.fFFHistosGenLeading;
586     fFFHistosGenLeadingTrack      = o.fFFHistosGenLeadingTrack;
587     fIJHistosRecCuts              = o.fIJHistosRecCuts;
588     fIJHistosRecLeading           = o.fIJHistosRecLeading;
589     fIJHistosRecLeadingTrack      = o.fIJHistosRecLeadingTrack;
590     fIJHistosGen                  = o.fIJHistosGen;
591     fIJHistosGenLeading           = o.fIJHistosGenLeading;
592     fIJHistosGenLeadingTrack      = o.fIJHistosGenLeadingTrack;
593     fFFDiJetHistosRecCuts         = o.fFFDiJetHistosRecCuts;
594     fFFDiJetHistosRecLeading      = o.fFFDiJetHistosRecLeading;
595     fFFDiJetHistosRecLeadingTrack = o.fFFDiJetHistosRecLeadingTrack;
596     fFFDiJetHistosGen             = o.fFFDiJetHistosGen;
597     fFFDiJetHistosGenLeading      = o.fFFDiJetHistosGenLeading;
598     fFFDiJetHistosGenLeadingTrack = o.fFFDiJetHistosGenLeadingTrack;
599     fQADiJetHistosRecCuts         = o.fQADiJetHistosRecCuts;
600     fQADiJetHistosGen             = o.fQADiJetHistosGen;
601     fQATrackHighPtThreshold       = o.fQATrackHighPtThreshold; 
602     fFFNBinsJetPt                 = o.fFFNBinsJetPt;    
603     fFFJetPtMin                   = o.fFFJetPtMin; 
604     fFFJetPtMax                   = o.fFFJetPtMax;
605     fFFNBinsPt                    = o.fFFNBinsPt;      
606     fFFPtMin                      = o.fFFPtMin;        
607     fFFPtMax                      = o.fFFPtMax;        
608     fFFNBinsXi                    = o.fFFNBinsXi;      
609     fFFXiMin                      = o.fFFXiMin;        
610     fFFXiMax                      = o.fFFXiMax;        
611     fFFNBinsZ                     = o.fFFNBinsZ;       
612     fFFZMin                       = o.fFFZMin;         
613     fFFZMax                       = o.fFFZMax;         
614     fQAJetNBinsPt                 = o.fQAJetNBinsPt;   
615     fQAJetPtMin                   = o.fQAJetPtMin;     
616     fQAJetPtMax                   = o.fQAJetPtMax;     
617     fQAJetNBinsEta                = o.fQAJetNBinsEta;  
618     fQAJetEtaMin                  = o.fQAJetEtaMin;    
619     fQAJetEtaMax                  = o.fQAJetEtaMax;    
620     fQAJetNBinsPhi                = o.fQAJetNBinsPhi;  
621     fQAJetPhiMin                  = o.fQAJetPhiMin;    
622     fQAJetPhiMax                  = o.fQAJetPhiMax;    
623     fQATrackNBinsPt               = o.fQATrackNBinsPt; 
624     fQATrackPtMin                 = o.fQATrackPtMin;   
625     fQATrackPtMax                 = o.fQATrackPtMax;   
626     fQATrackNBinsEta              = o.fQATrackNBinsEta;
627     fQATrackEtaMin                = o.fQATrackEtaMin;  
628     fQATrackEtaMax                = o.fQATrackEtaMax;  
629     fQATrackNBinsPhi              = o.fQATrackNBinsPhi;
630     fQATrackPhiMin                = o.fQATrackPhiMin;  
631     fQATrackPhiMax                = o.fQATrackPhiMax;  
632     fIJNBinsJetPt                 = o.fIJNBinsJetPt;
633     fIJJetPtMin                   = o.fIJJetPtMin;
634     fIJJetPtMax                   = o.fIJJetPtMax;
635     fIJNBinsPt                    = o.fIJNBinsPt;
636     fIJPtMin                      = o.fIJPtMin;
637     fIJPtMax                      = o.fIJPtMax;
638     fIJNBinsZ                     = o.fIJNBinsZ;
639     fIJZMin                       = o.fIJZMin;
640     fIJZMax                       = o.fIJZMax;
641     fIJNBinsCosTheta              = o.fIJNBinsCosTheta;
642     fIJCosThetaMin                = o.fIJCosThetaMin;
643     fIJCosThetaMax                = o.fIJCosThetaMax;
644     fIJNBinsTheta                 = o.fIJNBinsTheta;
645     fIJThetaMin                   = o.fIJThetaMin;
646     fIJThetaMax                   = o.fIJThetaMax;
647     fIJNBinsJt                    = o.fIJNBinsJt;
648     fIJJtMin                      = o.fIJJtMin;
649     fIJJtMax                      = o.fIJJtMax;
650     fDiJetNBinsJetInvMass         = o.fDiJetNBinsJetInvMass;
651     fDiJetJetInvMassMin           = o.fDiJetJetInvMassMin;
652     fDiJetJetInvMassMax           = o.fDiJetJetInvMassMax;
653     fDiJetNBinsJetPt              = o.fDiJetNBinsJetPt;
654     fDiJetJetPtMin                = o.fDiJetJetPtMin;
655     fDiJetJetPtMax                = o.fDiJetJetPtMax;
656     fDiJetNBinsPt                 = o.fDiJetNBinsPt;
657     fDiJetPtMin                   = o.fDiJetPtMin;
658     fDiJetPtMax                   = o.fDiJetPtMax;
659     fDiJetNBinsXi                 = o.fDiJetNBinsXi;
660     fDiJetXiMin                   = o.fDiJetXiMin;
661     fDiJetXiMax                   = o.fDiJetXiMax;
662     fDiJetNBinsZ                  = o.fDiJetNBinsZ;
663     fDiJetZMin                    = o.fDiJetZMin;
664     fDiJetZMax                    = o.fDiJetZMax;
665     fQADiJetNBinsInvMass          = o.fQADiJetNBinsInvMass;
666     fQADiJetInvMassMin            = o.fQADiJetInvMassMin;
667     fQADiJetInvMassMax            = o.fQADiJetInvMassMax;
668     fQADiJetNBinsJetPt            = o.fQADiJetNBinsJetPt;
669     fQADiJetJetPtMin              = o.fQADiJetJetPtMin;
670     fQADiJetJetPtMax              = o.fQADiJetJetPtMax;
671     fQADiJetNBinsDeltaPhi         = o.fQADiJetNBinsDeltaPhi;
672     fQADiJetDeltaPhiMin           = o.fQADiJetDeltaPhiMin;
673     fQADiJetDeltaPhiMax           = o.fQADiJetDeltaPhiMax;
674     fQADiJetNBinsDeltaEta         = o.fQADiJetNBinsDeltaEta;
675     fQADiJetDeltaEtaMin           = o.fQADiJetDeltaEtaMin;
676     fQADiJetDeltaEtaMax           = o.fQADiJetDeltaEtaMax;
677     fQADiJetNBinsDeltaPt          = o.fQADiJetNBinsDeltaPt;
678     fQADiJetDeltaPtMin            = o.fQADiJetDeltaPtMin;
679     fQADiJetDeltaPtMax            = o.fQADiJetDeltaPtMax;
680     fCommonHistList               = o.fCommonHistList;
681     fh1EvtSelection               = o.fh1EvtSelection;
682     fh1VertexNContributors        = o.fh1VertexNContributors;
683     fh1VertexZ                    = o.fh1VertexZ;
684     fh1EvtMult                    = o.fh1EvtMult;
685     fh1nRecJetsCuts               = o.fh1nRecJetsCuts;
686     fh1nGenJets                   = o.fh1nGenJets; 
687     fh1nRecEffJets                = o.fh1nRecEffJets;
688     fhnSingleTrackRecEffHisto     = o.fhnSingleTrackRecEffHisto;
689     fhnJetTrackRecEffHisto        = o.fhnJetTrackRecEffHisto;
690   }
691     
692   return *this;
693 }
694
695 //___________________________________________________________________________
696 AliAnalysisTaskFragmentationFunction::~AliAnalysisTaskFragmentationFunction()
697 {
698   // destructor
699   
700   if(fTracksRec)            delete fTracksRec;
701   if(fTracksRecCuts)        delete fTracksRecCuts;
702   if(fTracksGen)            delete fTracksGen;
703   if(fTracksAODMCCharged)   delete fTracksAODMCCharged;  
704   if(fTracksRecQualityCuts) delete fTracksRecQualityCuts; 
705   if(fJetsRec)              delete fJetsRec;
706   if(fJetsRecCuts)          delete fJetsRecCuts;
707   if(fJetsGen)              delete fJetsGen;
708   if(fJetsRecEff)           delete fJetsRecEff;
709
710   //  if(fDiJetBins)     delete fDiJetBins;
711
712 }
713
714 //______________________________________________________________________________________________________
715 AliAnalysisTaskFragmentationFunction::AliFragFuncHistos::AliFragFuncHistos(const char* name, 
716                                                          Int_t nJetPt, Float_t jetPtMin, Float_t jetPtMax,  
717                                                          Int_t nPt, Float_t ptMin, Float_t ptMax,
718                                                          Int_t nXi, Float_t xiMin, Float_t xiMax,
719                                                          Int_t nZ , Float_t zMin , Float_t zMax )
720   : TObject()
721   ,fNBinsJetPt(nJetPt)
722   ,fJetPtMin(jetPtMin)
723   ,fJetPtMax(jetPtMax)
724   ,fNBinsPt(nPt) 
725   ,fPtMin(ptMin)   
726   ,fPtMax(ptMax)   
727   ,fNBinsXi(nXi) 
728   ,fXiMin(xiMin)   
729   ,fXiMax(xiMax)   
730   ,fNBinsZ(nZ)  
731   ,fZMin(zMin)    
732   ,fZMax(zMax)    
733   ,fh2TrackPt(0)
734   ,fh2Xi(0)
735   ,fh2Z(0)
736   ,fh1JetPt(0)
737   ,fName(name)
738 {
739   // default constructor
740
741 }
742
743 //___________________________________________________________________________
744 AliAnalysisTaskFragmentationFunction::AliFragFuncHistos::AliFragFuncHistos(const AliFragFuncHistos& copy)
745   : TObject()
746   ,fNBinsJetPt(copy.fNBinsJetPt)
747   ,fJetPtMin(copy.fJetPtMin)
748   ,fJetPtMax(copy.fJetPtMax)
749   ,fNBinsPt(copy.fNBinsPt) 
750   ,fPtMin(copy.fPtMin)   
751   ,fPtMax(copy.fPtMax)   
752   ,fNBinsXi(copy.fNBinsXi) 
753   ,fXiMin(copy.fXiMin)   
754   ,fXiMax(copy.fXiMax)   
755   ,fNBinsZ(copy.fNBinsZ)  
756   ,fZMin(copy.fZMin)    
757   ,fZMax(copy.fZMax)    
758   ,fh2TrackPt(copy.fh2TrackPt)
759   ,fh2Xi(copy.fh2Xi)
760   ,fh2Z(copy.fh2Z)
761   ,fh1JetPt(copy.fh1JetPt)
762   ,fName(copy.fName)
763 {
764   // copy constructor
765 }
766
767 //_______________________________________________________________________________________________________________________________________________________________
768 AliAnalysisTaskFragmentationFunction::AliFragFuncHistos& AliAnalysisTaskFragmentationFunction::AliFragFuncHistos::operator=(const AliAnalysisTaskFragmentationFunction::AliFragFuncHistos& o)
769 {
770   // assignment
771   
772   if(this!=&o){
773     TObject::operator=(o);
774     fNBinsJetPt = o.fNBinsJetPt;
775     fJetPtMin   = o.fJetPtMin;
776     fJetPtMax   = o.fJetPtMax;
777     fNBinsPt    = o.fNBinsPt; 
778     fPtMin      = o.fPtMin;   
779     fPtMax      = o.fPtMax;   
780     fNBinsXi    = o.fNBinsXi; 
781     fXiMin      = o.fXiMin;   
782     fXiMax      = o.fXiMax;   
783     fNBinsZ     = o.fNBinsZ;  
784     fZMin       = o.fZMin;    
785     fZMax       = o.fZMax;    
786     fh2TrackPt  = o.fh2TrackPt;
787     fh2Xi       = o.fh2Xi;
788     fh2Z        = o.fh2Z;
789     fh1JetPt    = o.fh1JetPt;
790     fName       = o.fName;
791   }
792     
793   return *this;
794 }
795
796 //_________________________________________________________
797 AliAnalysisTaskFragmentationFunction::AliFragFuncHistos::~AliFragFuncHistos()
798 {
799   // destructor 
800
801   if(fh1JetPt)   delete fh1JetPt;
802   if(fh2TrackPt) delete fh2TrackPt;
803   if(fh2Xi)      delete fh2Xi;
804   if(fh2Z)       delete fh2Z;
805 }
806
807 //_________________________________________________________________
808 void AliAnalysisTaskFragmentationFunction::AliFragFuncHistos::DefineHistos()
809 {
810   // book FF histos
811
812   fh1JetPt   = new TH1F(Form("fh1FFJetPt%s", fName.Data()),"",fNBinsJetPt,fJetPtMin,fJetPtMax);
813   fh2TrackPt = new TH2F(Form("fh2FFTrackPt%s",fName.Data()),"",fNBinsJetPt, fJetPtMin, fJetPtMax,fNBinsPt, fPtMin, fPtMax);
814   fh2Xi      = new TH2F(Form("fh2FFXi%s",fName.Data()),"",fNBinsJetPt, fJetPtMin, fJetPtMax, fNBinsXi, fXiMin, fXiMax);
815   fh2Z       = new TH2F(Form("fh2FFZ%s",fName.Data()),"",fNBinsJetPt, fJetPtMin, fJetPtMax, fNBinsZ, fZMin, fZMax);
816
817   AliAnalysisTaskFragmentationFunction::SetProperties(fh1JetPt, "p_{T} [GeV/c]", "entries"); 
818   AliAnalysisTaskFragmentationFunction::SetProperties(fh2TrackPt,"jet p_{T} [GeV/c]","p_{T} [GeV/c]","entries");
819   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Xi,"jet p_{T} [GeV/c]","#xi", "entries");
820   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Z,"jet p_{T} [GeV/c]","z","entries");
821 }
822
823 //_______________________________________________________________________________________________________________
824 void AliAnalysisTaskFragmentationFunction::AliFragFuncHistos::FillFF(Float_t trackPt, Float_t jetPt, Bool_t incrementJetPt)
825 {
826   // fill FF
827  
828   if(incrementJetPt) fh1JetPt->Fill(jetPt);    
829   fh2TrackPt->Fill(jetPt,trackPt);
830   
831   Double_t z = 0.;
832   if(jetPt>0) z = trackPt / jetPt;
833   Double_t xi = 0;
834   if(z>0) xi = TMath::Log(1/z);
835   
836   fh2Xi->Fill(jetPt,xi);
837   fh2Z->Fill(jetPt,z);
838 }
839
840 //_________________________________________________________________________________
841 void AliAnalysisTaskFragmentationFunction::AliFragFuncHistos::AddToOutput(TList* list) const
842 {
843   // add histos to list
844
845   list->Add(fh1JetPt);
846   
847   list->Add(fh2TrackPt);
848   list->Add(fh2Xi);
849   list->Add(fh2Z);
850 }
851
852 //_________________________________________________________________________________________________________
853 AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos::AliFragFuncQAJetHistos(const char* name,
854                                                                Int_t nPt,   Float_t ptMin,   Float_t ptMax,
855                                                                Int_t nEta,  Float_t etaMin,  Float_t etaMax,
856                                                                Int_t nPhi,  Float_t phiMin,  Float_t phiMax)
857   : TObject()
858   ,fNBinsPt(nPt)
859   ,fPtMin(ptMin)
860   ,fPtMax(ptMax)
861   ,fNBinsEta(nEta)
862   ,fEtaMin(etaMin)
863   ,fEtaMax(etaMax)
864   ,fNBinsPhi(nPhi)
865   ,fPhiMin(phiMin)
866   ,fPhiMax(phiMax)
867   ,fh2EtaPhi(0)
868   ,fh1Pt(0)
869   ,fName(name)
870 {
871   // default constructor
872 }
873
874 //____________________________________________________________________________________
875 AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos::AliFragFuncQAJetHistos(const AliFragFuncQAJetHistos& copy)
876   : TObject()
877   ,fNBinsPt(copy.fNBinsPt)
878   ,fPtMin(copy.fPtMin)
879   ,fPtMax(copy.fPtMax)
880   ,fNBinsEta(copy.fNBinsEta)
881   ,fEtaMin(copy.fEtaMin)
882   ,fEtaMax(copy.fEtaMax)
883   ,fNBinsPhi(copy.fNBinsPhi)
884   ,fPhiMin(copy.fPhiMin)
885   ,fPhiMax(copy.fPhiMax)
886   ,fh2EtaPhi(copy.fh2EtaPhi)
887   ,fh1Pt(copy.fh1Pt)
888   ,fName(copy.fName)
889 {
890   // copy constructor
891 }
892
893 //________________________________________________________________________________________________________________________________________________________________________
894 AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos& AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos::operator=(const AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos& o)
895 {
896   // assignment
897   
898   if(this!=&o){
899     TObject::operator=(o);
900     fNBinsPt  = o.fNBinsPt;
901     fPtMin    = o.fPtMin;
902     fPtMax    = o.fPtMax;
903     fNBinsEta = o.fNBinsEta;
904     fEtaMin   = o.fEtaMin;
905     fEtaMax   = o.fEtaMax;
906     fNBinsPhi = o.fNBinsPhi;
907     fPhiMin   = o.fPhiMin;
908     fPhiMax   = o.fPhiMax;
909     fh2EtaPhi = o.fh2EtaPhi;
910     fh1Pt     = o.fh1Pt;
911     fName     = o.fName;
912   }
913   
914   return *this;
915 }
916
917 //______________________________________________________________
918 AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos::~AliFragFuncQAJetHistos()
919 {
920   // destructor 
921   
922   if(fh2EtaPhi) delete fh2EtaPhi;
923   if(fh1Pt)     delete fh1Pt;
924 }
925
926 //____________________________________________________________________
927 void AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos::DefineHistos()
928 {
929   // book jet QA histos
930
931   fh2EtaPhi  = new TH2F(Form("fh2JetQAEtaPhi%s", fName.Data()), Form("%s: #eta - #phi distribution", fName.Data()), fNBinsEta, fEtaMin, fEtaMax, fNBinsPhi, fPhiMin, fPhiMax);
932   fh1Pt      = new TH1F(Form("fh1JetQAPt%s", fName.Data()), Form("%s: p_{T} distribution", fName.Data()), fNBinsPt, fPtMin, fPtMax);
933         
934   AliAnalysisTaskFragmentationFunction::SetProperties(fh2EtaPhi, "#eta", "#phi"); 
935   AliAnalysisTaskFragmentationFunction::SetProperties(fh1Pt, "p_{T} [GeV/c]", "entries");
936 }
937
938 //____________________________________________________________________________________________________
939 void AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos::FillJetQA(Float_t eta, Float_t phi, Float_t pt)
940 {
941   // fill jet QA histos 
942
943   fh2EtaPhi->Fill( eta, phi);
944   fh1Pt->Fill( pt );
945 }
946
947 //____________________________________________________________________________________
948 void AliAnalysisTaskFragmentationFunction::AliFragFuncQAJetHistos::AddToOutput(TList* list) const 
949 {
950   // add histos to list
951
952   list->Add(fh2EtaPhi);
953   list->Add(fh1Pt);
954 }
955
956 //___________________________________________________________________________________________________________
957 AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos::AliFragFuncQATrackHistos(const char* name,
958                                                                    Int_t nPt, Float_t ptMin, Float_t ptMax,
959                                                                    Int_t nEta, Float_t etaMin, Float_t etaMax,
960                                                                    Int_t nPhi, Float_t phiMin, Float_t phiMax,
961                                                                    Float_t ptThresh) 
962   : TObject()
963   ,fNBinsPt(nPt)
964   ,fPtMin(ptMin)
965   ,fPtMax(ptMax)
966   ,fNBinsEta(nEta)
967   ,fEtaMin(etaMin)
968   ,fEtaMax(etaMax)
969   ,fNBinsPhi(nPhi)
970   ,fPhiMin(phiMin)
971   ,fPhiMax(phiMax)
972   ,fHighPtThreshold(ptThresh)
973   ,fh2EtaPhi(0)
974   ,fh1Pt(0)
975   ,fh2HighPtEtaPhi(0)
976   ,fName(name)
977 {
978   // default constructor
979 }
980
981 //__________________________________________________________________________________________
982 AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos::AliFragFuncQATrackHistos(const AliFragFuncQATrackHistos& copy)
983   : TObject()
984   ,fNBinsPt(copy.fNBinsPt)
985   ,fPtMin(copy.fPtMin)
986   ,fPtMax(copy.fPtMax)
987   ,fNBinsEta(copy.fNBinsEta)
988   ,fEtaMin(copy.fEtaMin)
989   ,fEtaMax(copy.fEtaMax)
990   ,fNBinsPhi(copy.fNBinsPhi)
991   ,fPhiMin(copy.fPhiMin)
992   ,fPhiMax(copy.fPhiMax)
993   ,fHighPtThreshold(copy.fHighPtThreshold)
994   ,fh2EtaPhi(copy.fh2EtaPhi)
995   ,fh1Pt(copy.fh1Pt)
996   ,fh2HighPtEtaPhi(copy.fh2HighPtEtaPhi)
997   ,fName(copy.fName)
998 {
999   // copy constructor
1000 }
1001
1002 // _____________________________________________________________________________________________________________________________________________________________________________
1003 AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos& AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos::operator=(const AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos& o)
1004 {
1005   // assignment
1006   
1007   if(this!=&o){
1008     TObject::operator=(o);
1009     fNBinsPt         = o.fNBinsPt;
1010     fPtMin           = o.fPtMin;
1011     fPtMax           = o.fPtMax;
1012     fNBinsEta        = o.fNBinsEta;
1013     fEtaMin          = o.fEtaMin;
1014     fEtaMax          = o.fEtaMax;
1015     fNBinsPhi        = o.fNBinsPhi;
1016     fPhiMin          = o.fPhiMin;
1017     fPhiMax          = o.fPhiMax;
1018     fHighPtThreshold = o.fHighPtThreshold;
1019     fh2EtaPhi        = o.fh2EtaPhi;
1020     fh1Pt            = o.fh1Pt;
1021     fh2HighPtEtaPhi  = o.fh2HighPtEtaPhi;
1022     fName            = o.fName;
1023   }
1024   
1025   return *this;
1026 }
1027
1028 //___________________________________________________________________
1029 AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos::~AliFragFuncQATrackHistos()
1030 {
1031   // destructor 
1032   
1033   if(fh2EtaPhi)       delete fh2EtaPhi;
1034   if(fh2HighPtEtaPhi) delete fh2HighPtEtaPhi;
1035   if(fh1Pt)           delete fh1Pt;
1036 }
1037
1038 //______________________________________________________________________
1039 void AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos::DefineHistos()
1040 {
1041   // book track QA histos
1042
1043   fh2EtaPhi       = new TH2F(Form("fh2TrackQAEtaPhi%s", fName.Data()), Form("%s: #eta - #phi distribution", fName.Data()), fNBinsEta, fEtaMin, fEtaMax, fNBinsPhi, fPhiMin, fPhiMax);
1044   fh2HighPtEtaPhi = new TH2F(Form("fh2TrackQAHighPtEtaPhi%s", fName.Data()), Form("%s: #eta - #phi distribution for high-p_{T}", fName.Data()), fNBinsEta, fEtaMin, fEtaMax, fNBinsPhi, fPhiMin, fPhiMax);
1045   fh1Pt           = new TH1F(Form("fh1TrackQAPt%s", fName.Data()), Form("%s: p_{T} distribution", fName.Data()), fNBinsPt, fPtMin, fPtMax);
1046   
1047   AliAnalysisTaskFragmentationFunction::SetProperties(fh2EtaPhi, "#eta", "#phi"); 
1048   AliAnalysisTaskFragmentationFunction::SetProperties(fh2HighPtEtaPhi, "#eta", "#phi");
1049   AliAnalysisTaskFragmentationFunction::SetProperties(fh1Pt, "p_{T} [GeV/c]", "entries");
1050 }
1051
1052 //________________________________________________________________________________________________________
1053 void AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos::FillTrackQA(Float_t eta, Float_t phi, Float_t pt)
1054 {
1055   // fill track QA histos
1056     
1057   fh2EtaPhi->Fill( eta, phi);
1058   if(pt > fHighPtThreshold) fh2HighPtEtaPhi->Fill( eta, phi);
1059   fh1Pt->Fill( pt );    
1060 }
1061
1062 //______________________________________________________________________________________
1063 void AliAnalysisTaskFragmentationFunction::AliFragFuncQATrackHistos::AddToOutput(TList* list) const
1064 {
1065   // add histos to list
1066
1067   list->Add(fh2EtaPhi);
1068   list->Add(fh2HighPtEtaPhi);
1069   list->Add(fh1Pt);
1070 }
1071
1072 //______________________________________________________________________________________________________
1073 AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos::AliFragFuncIntraJetHistos(const char* name, 
1074                                                          Int_t nJetPt, Float_t jetPtMin, Float_t jetPtMax,  
1075                                                          Int_t nPt, Float_t ptMin, Float_t ptMax,
1076                                                          Int_t nZ , Float_t zMin , Float_t zMax,
1077                                                          Int_t nCosTheta , Float_t costhetaMin , Float_t costhetaMax,
1078                                                          Int_t nTheta , Float_t thetaMin , Float_t thetaMax,
1079                                                          Int_t nJt , Float_t jtMin , Float_t jtMax)
1080   : TObject()
1081   ,fNBinsJetPt(nJetPt)
1082   ,fJetPtMin(jetPtMin)
1083   ,fJetPtMax(jetPtMax)
1084   ,fNBinsPt(nPt) 
1085   ,fPtMin(ptMin)   
1086   ,fPtMax(ptMax)   
1087   ,fNBinsZ(nZ) 
1088   ,fZMin(zMin)   
1089   ,fZMax(zMax)   
1090   ,fNBinsJt(nJt)
1091   ,fJtMin(jtMin)
1092   ,fJtMax(jtMax)
1093   ,fNBinsTheta(nTheta)
1094   ,fThetaMin(thetaMin)
1095   ,fThetaMax(thetaMax)
1096   ,fNBinsCosTheta(nCosTheta)
1097   ,fCosThetaMin(costhetaMin)
1098   ,fCosThetaMax(costhetaMax)
1099   ,fh2Theta(0)
1100   ,fh2CosTheta(0)
1101   ,fh2Jt(0)
1102   ,fh2PtvsZ(0)
1103   ,fhnIntraJet(0)
1104   ,fnDim(6)
1105   ,fName(name)
1106 {
1107   // default constructor
1108
1109 }
1110
1111 //___________________________________________________________________________
1112 AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos::AliFragFuncIntraJetHistos(const AliFragFuncIntraJetHistos& copy)
1113   : TObject()
1114   ,fNBinsJetPt(copy.fNBinsJetPt)
1115   ,fJetPtMin(copy.fJetPtMin)
1116   ,fJetPtMax(copy.fJetPtMax)
1117   ,fNBinsPt(copy.fNBinsPt) 
1118   ,fPtMin(copy.fPtMin)   
1119   ,fPtMax(copy.fPtMax)   
1120   ,fNBinsZ(copy.fNBinsZ) 
1121   ,fZMin(copy.fZMin)   
1122   ,fZMax(copy.fZMax)   
1123   ,fNBinsJt(copy.fNBinsJt)
1124   ,fJtMin(copy.fJtMin)
1125   ,fJtMax(copy.fJtMax)
1126   ,fNBinsTheta(copy.fNBinsTheta)
1127   ,fThetaMin(copy.fThetaMin)
1128   ,fThetaMax(copy.fThetaMax)
1129   ,fNBinsCosTheta(copy.fNBinsCosTheta)
1130   ,fCosThetaMin(copy.fCosThetaMin)
1131   ,fCosThetaMax(copy.fCosThetaMax)
1132   ,fh2Theta(copy.fh2Theta)
1133   ,fh2CosTheta(copy.fh2CosTheta)
1134   ,fh2Jt(copy.fh2Jt)
1135   ,fh2PtvsZ(copy.fh2PtvsZ)
1136   ,fhnIntraJet(copy.fhnIntraJet)
1137   ,fnDim(copy.fnDim)
1138   ,fName(copy.fName)
1139 {
1140   // copy constructor
1141 }
1142
1143 //_______________________________________________________________________________________________________________________________________________________________
1144 AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos& AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos::operator=(const AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos& o)
1145 {
1146   // assignment
1147   
1148   if(this!=&o){
1149     TObject::operator=(o);
1150     fNBinsJetPt       = o.fNBinsJetPt;
1151     fJetPtMin         = o.fJetPtMin;
1152     fJetPtMax         = o.fJetPtMax;
1153     fNBinsPt          = o.fNBinsPt; 
1154     fPtMin            = o.fPtMin;   
1155     fPtMax            = o.fPtMax;   
1156     fNBinsZ           = o.fNBinsZ; 
1157     fZMin             = o.fZMin;   
1158     fZMax             = o.fZMax;   
1159     fNBinsJt          = o.fNBinsJt;
1160     fJtMin            = o.fJtMin;
1161     fJtMax            = o.fJtMax;
1162     fNBinsTheta       = o.fNBinsTheta;
1163     fThetaMin         = o.fThetaMin;
1164     fThetaMax         = o.fThetaMax;
1165     fNBinsCosTheta    = o.fNBinsCosTheta;
1166     fCosThetaMin      = o.fCosThetaMin;
1167     fCosThetaMax      = o.fCosThetaMax;
1168     fh2Theta          = o.fh2Theta;
1169     fh2CosTheta       = o.fh2CosTheta;
1170     fh2Jt             = o.fh2Jt;
1171     fh2PtvsZ          = o.fh2PtvsZ;
1172     fhnIntraJet       = o.fhnIntraJet;
1173     fnDim             = o.fnDim;
1174     fName             = o.fName;
1175   }
1176     
1177   return *this;
1178 }
1179
1180 //_________________________________________________________
1181 AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos::~AliFragFuncIntraJetHistos()
1182 {
1183   // destructor 
1184
1185
1186   if(fh2Theta)          delete fh2Theta;
1187   if(fh2CosTheta)       delete fh2CosTheta;
1188   if(fh2Jt)             delete fh2Jt;
1189   if(fh2PtvsZ)          delete fh2PtvsZ;
1190   if(fhnIntraJet)       delete fhnIntraJet;
1191
1192 }
1193
1194 //_________________________________________________________________
1195 void AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos::DefineHistos()
1196 {
1197   // book FF histos
1198
1199   fh2Theta    = new TH2F(Form("fh2IJTheta%s",fName.Data()),"",fNBinsJetPt, fJetPtMin, fJetPtMax,fNBinsTheta, fThetaMin, fThetaMax);
1200   fh2CosTheta = new TH2F(Form("fh2IJcosTheta%s",fName.Data()),"",fNBinsJetPt, fJetPtMin, fJetPtMax,fNBinsCosTheta, fCosThetaMin, fCosThetaMax);
1201   fh2Jt       = new TH2F(Form("fh2IJJt%s",fName.Data()),"",fNBinsJetPt, fJetPtMin, fJetPtMax, fNBinsJt, fJtMin, fJtMax);
1202
1203   // Create 3D histograms
1204   Int_t    *iBin = new Int_t[fnDim];
1205   Double_t *min  = new Double_t[fnDim];
1206   Double_t *max  = new Double_t[fnDim];
1207
1208   iBin[0] = fNBinsJetPt; iBin[1] = fNBinsTheta; iBin[2] = fNBinsCosTheta; iBin[3] = fNBinsJt; iBin[4] = fNBinsZ; iBin[5] = fNBinsPt;
1209   min[0]  = fJetPtMin; min[1] = fThetaMin; min[2] = fCosThetaMin; min[3] = fJtMin; min[4] = fZMin; min[5] = fPtMin; 
1210   max[0]  = fJetPtMax; max[1] = fThetaMax; max[2] = fCosThetaMax; max[3] = fJtMax; max[4] = fZMax; max[5] = fPtMax;
1211
1212   const char* title = Form("fhnIntraJetPart%s",fName.Data());
1213   const char* comment = "THnSparseF p_{T} jet [GeV/c] : #Theta : cos(#Theta) : j_{T} : Z : p_{T} part [GeV/c]";
1214   fhnIntraJet = new THnSparseF(title,comment,fnDim,iBin,min,max);
1215
1216   const char** axisTitle = new const char*[fnDim];
1217   axisTitle[0] = "p_{T}^{jet} [GeV/c]";
1218   axisTitle[1] = "#Theta";
1219   axisTitle[2] = "Cos(#Theta)";
1220   axisTitle[3] = "j_{T} [GeV]";
1221   axisTitle[4] = "z = p_{T}^{had}/p_{T}^{jet}";
1222   axisTitle[5] = "p_{T}^{had} [GeV/c]";
1223   
1224   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Theta,"jet p_{T} [GeV/c]","#Theta","entries");
1225   AliAnalysisTaskFragmentationFunction::SetProperties(fh2CosTheta,"jet p_{T} [GeV/c]","cos(#Theta)", "entries");
1226   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Jt,"jet p_{T} [GeV/c]","j_{T}","entries");
1227   AliAnalysisTaskFragmentationFunction::SetProperties(fhnIntraJet,fnDim,axisTitle);
1228   delete[] iBin;
1229   delete[] min;
1230   delete[] max;
1231   delete[] axisTitle;
1232 }
1233
1234 //_______________________________________________________________________________________________________________
1235 void AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos::FillIntraJet(TLorentzVector* trackV, TLorentzVector* jetV)
1236 {
1237   // fill IntraJet histos
1238  
1239   Float_t cosTheta = 0.; Float_t theta = 0.; 
1240   Float_t jt = 0.; Float_t z = 0.; 
1241   // For Theta distribution
1242   Float_t pxT  = trackV->Px();
1243   Float_t pyT  = trackV->Py();
1244   Float_t pzT  = trackV->Pz();
1245   Float_t ptT  = trackV->Pt();
1246   Float_t pT   = trackV->P();
1247   Float_t etaT = trackV->Eta();
1248   Float_t phiT = trackV->Phi(); // Check the value returned
1249   Float_t pxJ = jetV->Px();
1250   Float_t pyJ = jetV->Py();
1251   Float_t pzJ = jetV->Pz();
1252   Float_t ptJ = jetV->Pt();
1253   Float_t pJ  = jetV->P();
1254
1255   // Compute z
1256   z = (Float_t)(ptT/ptJ);
1257
1258   // Compute theta
1259   cosTheta = (pxT*pxJ+pyT*pyJ+pzT*pzJ)/(pT*pJ);
1260   theta = TMath::ACos(cosTheta);
1261
1262   // Compute jt
1263   TVector3 trackP; TVector3 jetP;
1264   jetP[0] = pxJ;
1265   jetP[1] = pyJ;
1266   jetP[2] = pzJ;
1267   trackP.SetPtEtaPhi(ptT,etaT,phiT);
1268   jt = TMath::Sin(trackP.Angle(jetP))*trackP.Mag();
1269
1270   // Fill histos and THnSparse
1271   fh2CosTheta->Fill(ptJ,cosTheta);
1272   fh2Theta->Fill(ptJ,theta);
1273   fh2Jt->Fill(ptJ,jt);
1274
1275   // Fill THnSparse
1276   Double_t *content = new Double_t[fnDim];
1277   content[0]= ptJ; content[1] = theta; content[2] = cosTheta; content[3] = jt; content[4] = z; content[5] = ptT; 
1278
1279   fhnIntraJet->Fill(content);
1280
1281   delete content;
1282
1283 }
1284
1285 //______________________________________________________________________________________________________
1286 AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos::AliFragFuncDiJetHistos(const char* name, Int_t kindSlices,
1287                                                          Int_t nJetInvMass, Float_t jetInvMassMin, Float_t jetInvMassMax,  
1288                                                          Int_t nJetPt, Float_t jetPtMin, Float_t jetPtMax,  
1289                                                          Int_t nPt, Float_t ptMin, Float_t ptMax,
1290                                                          Int_t nXi, Float_t xiMin, Float_t xiMax,
1291                                                          Int_t nZ , Float_t zMin , Float_t zMax)
1292   : TObject()
1293   ,fKindSlices(kindSlices)
1294   ,fNBinsJetInvMass(nJetInvMass)
1295   ,fJetInvMassMin(jetInvMassMin)
1296   ,fJetInvMassMax(jetInvMassMax)
1297   ,fNBinsJetPt(nJetPt)
1298   ,fJetPtMin(jetPtMin)
1299   ,fJetPtMax(jetPtMax)
1300   ,fNBinsPt(nPt) 
1301   ,fPtMin(ptMin)   
1302   ,fPtMax(ptMax)   
1303   ,fNBinsXi(nXi) 
1304   ,fXiMin(xiMin)   
1305   ,fXiMax(xiMax)   
1306   ,fNBinsZ(nZ)  
1307   ,fZMin(zMin)    
1308   ,fZMax(zMax)
1309   ,fh2TrackPtJet1(0)
1310   ,fh2TrackPtJet2(0)
1311   ,fh2TrackPtJet(0)
1312   ,fh1Jet1Pt(0)
1313   ,fh1Jet2Pt(0)
1314   ,fh1JetPt(0)
1315   ,fh2Xi1(0)
1316   ,fh2Xi2(0)
1317   ,fh2Xi(0)
1318   ,fh2Z1(0)
1319   ,fh2Z2(0)
1320   ,fh2Z(0)
1321   ,fh2Pt1(0)
1322   ,fh2Pt2(0)
1323   ,fh2Pt(0)
1324   ,fName(name)
1325 {
1326   // default constructor
1327
1328 }
1329
1330 //______________________________________________________________________________________________________
1331 AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos::AliFragFuncDiJetHistos(const AliFragFuncDiJetHistos& copy)
1332   : TObject()
1333   ,fKindSlices(copy.fKindSlices)
1334   ,fNBinsJetInvMass(copy.fNBinsJetInvMass)
1335   ,fJetInvMassMin(copy.fJetInvMassMin)
1336   ,fJetInvMassMax(copy.fJetInvMassMax)
1337   ,fNBinsJetPt(copy.fNBinsJetPt)
1338   ,fJetPtMin(copy.fJetPtMin)
1339   ,fJetPtMax(copy.fJetPtMax)
1340   ,fNBinsPt(copy.fNBinsPt) 
1341   ,fPtMin(copy.fPtMin)   
1342   ,fPtMax(copy.fPtMax)   
1343   ,fNBinsXi(copy.fNBinsXi) 
1344   ,fXiMin(copy.fXiMin)   
1345   ,fXiMax(copy.fXiMax)   
1346   ,fNBinsZ(copy.fNBinsZ)  
1347   ,fZMin(copy.fZMin)    
1348   ,fZMax(copy.fZMax)
1349   ,fh2TrackPtJet1(copy.fh2TrackPtJet1)
1350   ,fh2TrackPtJet2(copy.fh2TrackPtJet2)
1351   ,fh2TrackPtJet(copy.fh2TrackPtJet)
1352   ,fh1Jet1Pt(copy.fh1Jet1Pt)
1353   ,fh1Jet2Pt(copy.fh1Jet2Pt)
1354   ,fh1JetPt(copy.fh1JetPt)
1355   ,fh2Xi1(copy.fh2Xi1)
1356   ,fh2Xi2(copy.fh2Xi2)
1357   ,fh2Xi(copy.fh2Xi2)
1358   ,fh2Z1(copy.fh2Z1)
1359   ,fh2Z2(copy.fh2Z2)
1360   ,fh2Z(copy.fh2Z)
1361   ,fh2Pt1(copy.fh2Pt1)
1362   ,fh2Pt2(copy.fh2Pt2)
1363   ,fh2Pt(copy.fh2Pt)
1364   ,fName(copy.fName)
1365 {
1366   // default constructor
1367
1368 }
1369
1370 //_______________________________________________________________________________________________________________________________________________________________
1371 AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos& AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos::operator=(const AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos& o)
1372 {
1373   // assignment
1374   
1375   if(this!=&o){
1376     TObject::operator=(o);
1377     fKindSlices      = o.fKindSlices;
1378     fNBinsJetInvMass = o.fNBinsJetInvMass;
1379     fJetInvMassMin   = o.fJetInvMassMin;
1380     fJetInvMassMax   = o.fJetInvMassMax;
1381     fNBinsJetPt      = o.fNBinsJetPt;
1382     fJetPtMin        = o.fJetPtMin;
1383     fJetPtMax        = o.fJetPtMax;
1384     fNBinsPt         = o.fNBinsPt; 
1385     fPtMin           = o.fPtMin;   
1386     fPtMax           = o.fPtMax;   
1387     fNBinsXi         = o.fNBinsXi; 
1388     fXiMin           = o.fXiMin;   
1389     fXiMax           = o.fXiMax;   
1390     fNBinsZ          = o.fNBinsZ;  
1391     fZMin            = o.fZMin;    
1392     fZMax            = o.fZMax;   
1393     fh2TrackPtJet1   = o.fh2TrackPtJet1;
1394     fh2TrackPtJet2   = o.fh2TrackPtJet2;
1395     fh2TrackPtJet    = o.fh2TrackPtJet;
1396     fh1Jet1Pt        = o.fh1Jet1Pt;
1397     fh1Jet2Pt        = o.fh1Jet2Pt;
1398     fh1JetPt         = o.fh1JetPt;
1399     fh2Xi1           = o.fh2Xi1;
1400     fh2Xi2           = o.fh2Xi2;
1401     fh2Xi            = o.fh2Xi;
1402     fh2Z1            = o.fh2Z1;
1403     fh2Z2            = o.fh2Z2;
1404     fh2Z             = o.fh2Z;
1405     fh2Pt1           = o.fh2Pt1;
1406     fh2Pt2           = o.fh2Pt2;
1407     fh2Pt            = o.fh2Pt;
1408     fName            = o.fName;
1409   }
1410     
1411   return *this;
1412 }
1413
1414 //_________________________________________________________
1415 AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos::~AliFragFuncDiJetHistos()
1416 {
1417   // destructor 
1418
1419   if(fh2TrackPtJet1) delete fh2TrackPtJet1;
1420   if(fh2TrackPtJet2) delete fh2TrackPtJet2;
1421   if(fh2TrackPtJet ) delete fh2TrackPtJet;
1422   if(fh1Jet1Pt)      delete fh1Jet1Pt;
1423   if(fh1Jet2Pt)      delete fh1Jet2Pt;
1424   if(fh1JetPt)       delete fh1JetPt;
1425   if(fh2Xi1)         delete fh2Xi1;
1426   if(fh2Xi2)         delete fh2Xi2;
1427   if(fh2Xi)          delete fh2Xi;
1428   if(fh2Z1)          delete fh2Z1;
1429   if(fh2Z2)          delete fh2Z2;
1430   if(fh2Z)           delete fh2Z;
1431   if(fh2Pt1)         delete fh2Pt1;
1432   if(fh2Pt2)         delete fh2Pt2;
1433   if(fh2Pt)          delete fh2Pt;
1434 }
1435
1436 //________________________________________________________________________
1437 void AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos::DefineDiJetHistos()
1438 {
1439
1440   Int_t nBins = 0;
1441   Double_t min = 0.;
1442   Double_t max = 0.;
1443   const char *xaxis = "";
1444   if(fKindSlices == 1)
1445     {
1446       nBins = fNBinsJetInvMass;
1447       min   = fJetInvMassMin;
1448       max   = fJetInvMassMax;
1449       xaxis = "M_{JJ} [GeV]";
1450     }
1451   if(fKindSlices == 2 || fKindSlices == 3)
1452     {
1453       nBins = fNBinsJetPt;
1454       min   = fJetPtMin;
1455       max   = fJetPtMax;
1456       if(fKindSlices == 2) xaxis = "E_{Tmean} [GeV]";
1457       if(fKindSlices == 3) xaxis ="leading jet p_{T} [GeV/c]";
1458     }
1459   
1460   fh1Jet1Pt      = new TH1F(Form("fh1DJJet1Pt%s", fName.Data()), "", fNBinsJetPt, fJetPtMin, fJetPtMax);
1461   fh1Jet2Pt      = new TH1F(Form("fh1DJJet2Pt%s", fName.Data()), "", fNBinsJetPt, fJetPtMin, fJetPtMax);
1462   fh1JetPt       = new TH1F(Form("fh1DJJetPt%s",  fName.Data()), "", fNBinsJetPt, fJetPtMin, fJetPtMax);
1463   
1464   fh2TrackPtJet1 = new TH2F(Form("fh2DJTrackPtJet1%s", fName.Data()), "",nBins, min, max, fNBinsPt, fPtMin, fPtMax);
1465   fh2TrackPtJet2 = new TH2F(Form("fh2DJTrackPtJet2%s", fName.Data()), "",nBins, min, max, fNBinsPt, fPtMin, fPtMax);
1466   fh2TrackPtJet  = new TH2F(Form("fh2DJTrackPtJet%s", fName.Data()),  "",nBins, min, max, fNBinsPt, fPtMin, fPtMax);
1467   
1468   fh2Xi1         = new TH2F(Form("fh2DJXi1%s", fName.Data()), "",nBins, min, max, fNBinsXi, fXiMin, fXiMax);
1469   fh2Xi2         = new TH2F(Form("fh2DJXi2%s", fName.Data()), "",nBins, min, max, fNBinsXi, fXiMin, fXiMax);
1470   fh2Xi          = new TH2F(Form("fh2DJXi%s", fName.Data()),  "",nBins, min, max, fNBinsXi, fXiMin, fXiMax);
1471   
1472   fh2Z1          = new TH2F(Form("fh2DJZ1%s", fName.Data()), "",nBins, min, max, fNBinsZ, fZMin, fZMax);
1473   fh2Z2          = new TH2F(Form("fh2DJZ2%s", fName.Data()), "",nBins, min, max, fNBinsZ, fZMin, fZMax);
1474   fh2Z           = new TH2F(Form("fh2DJZ%s", fName.Data()),  "",nBins, min, max, fNBinsZ, fZMin, fZMax);
1475   
1476   fh2Pt1         = new TH2F(Form("fh2DJPt1%s", fName.Data()), "",nBins, min, max, fNBinsPt, fPtMin, fPtMax);
1477   fh2Pt2         = new TH2F(Form("fh2DJPt2%s", fName.Data()), "",nBins, min, max, fNBinsPt, fPtMin, fPtMax);
1478   fh2Pt          = new TH2F(Form("fh2DJPtZ%s", fName.Data()),  "",nBins, min, max, fNBinsPt, fPtMin, fPtMax);
1479       
1480   AliAnalysisTaskFragmentationFunction::SetProperties(fh1Jet1Pt, "p_{T} [GeV/c]", "entries");
1481   AliAnalysisTaskFragmentationFunction::SetProperties(fh1Jet2Pt, "p_{T} [GeV/c]", "entries");
1482   AliAnalysisTaskFragmentationFunction::SetProperties(fh1JetPt, "p_{T} [GeV/c]", "entries");
1483
1484   AliAnalysisTaskFragmentationFunction::SetProperties(fh2TrackPtJet1, xaxis, "p_{T} [GeV/c]", "Entries");
1485   AliAnalysisTaskFragmentationFunction::SetProperties(fh2TrackPtJet2, xaxis, "p_{T} [GeV/c]", "Entries");
1486   AliAnalysisTaskFragmentationFunction::SetProperties(fh2TrackPtJet, xaxis, "p_{T} [GeV/c]", "Entries");
1487   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Xi1, xaxis, "#xi", "Entries");
1488   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Xi2, xaxis, "#xi", "Entries");
1489   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Xi, xaxis, "#xi", "Entries");
1490   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Z1, xaxis, "z", "Entries");
1491   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Z2, xaxis, "z", "Entries");
1492   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Z, xaxis, "z", "Entries");
1493   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Pt1, xaxis, "p_{T} [GeV/c]", "Entries");
1494   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Pt2, xaxis, "p_{T} [GeV/c]", "Entries");
1495   AliAnalysisTaskFragmentationFunction::SetProperties(fh2Pt, xaxis, "p_{T} [GeV/c]", "Entries");
1496   
1497 }
1498
1499 //________________________________________________________________________
1500 void AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos::FillDiJetFF(Int_t jetType, Float_t trackPt, Float_t jetPt, Double_t jetBin, Bool_t incrementJetPt)
1501 {
1502   if(jetType == 0)
1503     {
1504       if(incrementJetPt) fh1JetPt->Fill(jetPt);  
1505       
1506       fh2TrackPtJet->Fill(jetBin, trackPt);
1507       
1508       Double_t z = trackPt / jetPt;
1509       Double_t xi = 0;
1510       if(z!=0) xi = TMath::Log(1/z);
1511       
1512       fh2Xi->Fill(jetBin, xi);
1513       fh2Z->Fill(jetBin, z);
1514     }
1515   if(jetType == 1)
1516     {
1517       if(incrementJetPt) fh1Jet1Pt->Fill(jetPt);
1518       
1519       fh2TrackPtJet1->Fill(jetBin, trackPt);
1520       
1521       Double_t z = trackPt / jetPt;
1522       Double_t xi = 0;
1523       if(z!=0) xi = TMath::Log(1/z);
1524       
1525       fh2Xi1->Fill(jetBin, xi);
1526       fh2Z1->Fill(jetBin, z);
1527     }
1528   if(jetType == 2)
1529     {
1530       if(incrementJetPt) fh1Jet2Pt->Fill(jetPt);
1531       
1532       fh2TrackPtJet2->Fill(jetBin, trackPt);
1533       
1534       Double_t z = trackPt / jetPt;
1535       Double_t xi = 0;
1536       if(z!=0) xi = TMath::Log(1/z);
1537       
1538       fh2Xi2->Fill(jetBin, xi);
1539       fh2Z2->Fill(jetBin, z);
1540     }
1541
1542
1543 }
1544
1545 //________________________________________________________________________
1546 void AliAnalysisTaskFragmentationFunction::AliFragFuncDiJetHistos::AddToOutput(TList* list)const
1547 {
1548   list->Add(fh1Jet1Pt);
1549   list->Add(fh1Jet2Pt);
1550   list->Add(fh1JetPt);
1551   list->Add(fh2TrackPtJet1);
1552   list->Add(fh2TrackPtJet2);
1553   list->Add(fh2TrackPtJet);
1554   list->Add(fh2Xi1);
1555   list->Add(fh2Xi2);
1556   list->Add(fh2Xi);
1557   list->Add(fh2Z1);
1558   list->Add(fh2Z2);
1559   list->Add(fh2Z);
1560 }
1561
1562 //______________________________________________________________________________________________________
1563 AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos::AliFragFuncQADiJetHistos(const char* name, Int_t kindSlices,
1564                                             Int_t nInvMass, Float_t invMassMin, Float_t invMassMax, 
1565                                              Int_t nJetPt, Float_t jetPtMin, Float_t jetPtMax,  
1566                                             Int_t nDeltaPhi, Float_t deltaPhiMin, Float_t deltaPhiMax, 
1567                                            Int_t nDeltaEta, Float_t deltaEtaMin, Float_t deltaEtaMax, 
1568                                           Int_t nDeltaPt, Float_t deltaPtMin, Float_t deltaPtMax)
1569   : TObject()
1570   ,fKindSlices(kindSlices)
1571   ,fNBinsJetInvMass(nInvMass)
1572   ,fJetInvMassMin(invMassMin)
1573   ,fJetInvMassMax(invMassMax)
1574   ,fNBinsJetPt(nJetPt)
1575   ,fJetPtMin(jetPtMin)
1576   ,fJetPtMax(jetPtMax)
1577   ,fNBinsDeltaPhi(nDeltaPhi)
1578   ,fDeltaPhiMin(deltaPhiMin)
1579   ,fDeltaPhiMax(deltaPhiMax)
1580   ,fNBinsDeltaEta(nDeltaEta)
1581   ,fDeltaEtaMin(deltaEtaMin)
1582   ,fDeltaEtaMax(deltaEtaMax)
1583   ,fNBinsDeltaPt(nDeltaPt)
1584   ,fDeltaPtMin(deltaPtMin)
1585   ,fDeltaPtMax(deltaPtMax)
1586   ,fh2InvMass(0)
1587   ,fh2DeltaPhi(0)
1588   ,fh2DeltaEta(0)
1589   ,fh2DeltaPt(0)
1590   ,fName(name)
1591 {
1592   // default constructor
1593
1594 }
1595
1596 //______________________________________________________________________________________________________
1597 AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos::AliFragFuncQADiJetHistos(const AliFragFuncQADiJetHistos& copy)
1598   : TObject()
1599   ,fKindSlices(copy.fKindSlices)
1600   ,fNBinsJetInvMass(copy.fNBinsJetInvMass)
1601   ,fJetInvMassMin(copy.fJetInvMassMin)
1602   ,fJetInvMassMax(copy.fJetInvMassMax)
1603   ,fNBinsJetPt(copy.fNBinsJetPt)
1604   ,fJetPtMin(copy.fJetPtMin)
1605   ,fJetPtMax(copy.fJetPtMax)
1606   ,fNBinsDeltaPhi(copy.fNBinsDeltaPhi)
1607   ,fDeltaPhiMin(copy.fDeltaPhiMin)
1608   ,fDeltaPhiMax(copy.fDeltaPhiMax)
1609   ,fNBinsDeltaEta(copy.fNBinsDeltaEta)
1610   ,fDeltaEtaMin(copy.fDeltaEtaMin)
1611   ,fDeltaEtaMax(copy.fDeltaEtaMax)
1612   ,fNBinsDeltaPt(copy.fNBinsDeltaPt)
1613   ,fDeltaPtMin(copy.fDeltaPtMin)
1614   ,fDeltaPtMax(copy.fDeltaPtMax)
1615   ,fh2InvMass(copy.fh2InvMass)
1616   ,fh2DeltaPhi(copy.fh2DeltaPhi)
1617   ,fh2DeltaEta(copy.fh2DeltaEta)
1618   ,fh2DeltaPt(copy.fh2DeltaPt)
1619   ,fName(copy.fName)
1620 {
1621   // default constructor
1622
1623 }
1624
1625 //_______________________________________________________________________________________________________________________________________________________________
1626 AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos& AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos::operator=(const AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos& o)
1627 {
1628   // assignment
1629   
1630   if(this!=&o){
1631     TObject::operator=(o);
1632     fKindSlices       = o.fKindSlices;
1633     fNBinsJetInvMass  = o.fNBinsJetInvMass;
1634     fJetInvMassMin    = o.fJetInvMassMin;
1635     fJetInvMassMax    = o.fJetInvMassMax;
1636     fNBinsJetPt       = o.fNBinsJetPt;
1637     fJetPtMin         = o.fJetPtMin;
1638     fJetPtMax         = o.fJetPtMax;
1639     fNBinsDeltaPhi    = o.fNBinsDeltaPhi;
1640     fDeltaPhiMin      = o.fDeltaPhiMin;
1641     fDeltaPhiMax      = o.fDeltaPhiMax;
1642     fNBinsDeltaEta    = o.fNBinsDeltaEta;
1643     fDeltaEtaMin      = o.fDeltaEtaMin;
1644     fDeltaEtaMax      = o.fDeltaEtaMax;
1645     fNBinsDeltaPt     = o.fNBinsDeltaPt;
1646     fDeltaPtMin       = o.fDeltaPtMin;
1647     fDeltaPtMax       = o.fDeltaPtMax;
1648     fh2InvMass        = o.fh2InvMass;
1649     fh2DeltaPhi       = o.fh2DeltaPhi;
1650     fh2DeltaEta       = o.fh2DeltaEta;
1651     fh2DeltaPt        = o.fh2DeltaPt;
1652     fName             = o.fName;
1653   }
1654     
1655   return *this;
1656 }
1657
1658 //_________________________________________________________
1659 AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos::~AliFragFuncQADiJetHistos()
1660 {
1661   // destructor 
1662
1663   if(fh2InvMass)  delete fh2InvMass;
1664   if(fh2DeltaPhi) delete fh2DeltaPhi;
1665   if(fh2DeltaEta) delete fh2DeltaEta;
1666   if(fh2DeltaPt)  delete fh2DeltaPt;
1667 }
1668
1669 //________________________________________________________________________
1670 void AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos::DefineQADiJetHistos()
1671 {
1672
1673   Int_t nBins = 0;
1674   Double_t min = 0.;
1675   Double_t max = 0.;
1676   const char *xaxis = "";
1677   if(fKindSlices == 1)
1678     {
1679       nBins = fNBinsJetInvMass;
1680       min   = fJetInvMassMin;
1681       max   = fJetInvMassMax;
1682       xaxis = "M_{JJ} [GeV]";
1683     }
1684   if(fKindSlices == 2 || fKindSlices == 3)
1685     {
1686       nBins = fNBinsJetPt;
1687       min   = fJetPtMin;
1688       max   = fJetPtMax;
1689       if(fKindSlices == 2) xaxis = "E_{Tmean} [GeV]";
1690       if(fKindSlices == 3) xaxis ="leading jet p_{T} [GeV/c]";
1691     }
1692   
1693   
1694   fh2InvMass  = new TH2F(Form("fh2DJInvMassPositionCut%s",  fName.Data()), "",nBins, min, max, fNBinsJetInvMass, fJetInvMassMin, fJetInvMassMax);
1695   fh2DeltaPhi = new TH2F(Form("fh2DJDeltaPhiPositionCut%s", fName.Data()), "",nBins, min, max, fNBinsDeltaPhi, fDeltaPhiMin, fDeltaPhiMax);
1696   fh2DeltaEta = new TH2F(Form("fh2DJDeltaEtaPositionCut%s", fName.Data()), "",nBins, min, max, fNBinsDeltaEta, fDeltaEtaMin, fDeltaEtaMax);
1697   fh2DeltaPt  = new TH2F(Form("fh2DJDeltaPtPositionCut%s",  fName.Data()), "",nBins, min, max, fNBinsDeltaPt, fDeltaPtMin, fDeltaPtMax);
1698   
1699   AliAnalysisTaskFragmentationFunction::SetProperties(fh2InvMass, xaxis, "Invariant Mass", "Entries");
1700   AliAnalysisTaskFragmentationFunction::SetProperties(fh2DeltaPhi, xaxis, "#Delta #phi", "Entries");
1701   AliAnalysisTaskFragmentationFunction::SetProperties(fh2DeltaEta, xaxis, "#Delta #eta", "Entries");
1702   AliAnalysisTaskFragmentationFunction::SetProperties(fh2DeltaPt, xaxis, "#Delta p_{T}", "Entries");
1703
1704 }
1705
1706 //________________________________________________________________________
1707 void AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos::FillDiJetQA(Double_t invMass, Double_t deltaPhi, Double_t deltaEta,Double_t deltaPt, Double_t jetBin)
1708 {
1709   fh2InvMass->Fill(jetBin, invMass);
1710   fh2DeltaPhi->Fill(jetBin, deltaPhi);
1711   fh2DeltaEta->Fill(jetBin, deltaEta);
1712   fh2DeltaPt->Fill(jetBin, deltaPt);
1713 }
1714
1715 //________________________________________________________________________
1716 void AliAnalysisTaskFragmentationFunction::AliFragFuncQADiJetHistos::AddToOutput(TList* list)const
1717 {
1718   list->Add(fh2InvMass);
1719   list->Add(fh2DeltaPhi);
1720   list->Add(fh2DeltaEta);
1721   list->Add(fh2DeltaPt);
1722 }
1723
1724 //_________________________________________________________________________________
1725 void AliAnalysisTaskFragmentationFunction::AliFragFuncIntraJetHistos::AddToOutput(TList* list) const
1726 {
1727   // add histos to list
1728
1729   list->Add(fh2CosTheta);
1730   list->Add(fh2Theta);
1731   list->Add(fh2Jt);
1732
1733   list->Add(fhnIntraJet);
1734
1735 }
1736
1737 //__________________________________________________________________
1738 void AliAnalysisTaskFragmentationFunction::UserCreateOutputObjects()
1739 {
1740   // create output objects
1741
1742   if(fDebug > 1) Printf("AliAnalysisTaskFragmentationFunction::UserCreateOutputObjects()");
1743  
1744   // create list of tracks and jets 
1745   
1746   fTracksRec = new TList();
1747   fTracksRec->SetOwner(kFALSE);  
1748
1749   fTracksRecCuts = new TList();
1750   fTracksRecCuts->SetOwner(kFALSE);  
1751
1752   fTracksGen = new TList();
1753   fTracksGen->SetOwner(kFALSE);
1754
1755   fTracksAODMCCharged = new TList();
1756   fTracksAODMCCharged->SetOwner(kFALSE);
1757     
1758   fTracksRecQualityCuts = new TList(); 
1759   fTracksRecQualityCuts->SetOwner(kFALSE);
1760
1761   fJetsRec = new TList();
1762   fJetsRec->SetOwner(kFALSE);
1763
1764   fJetsRecCuts = new TList();
1765   fJetsRecCuts->SetOwner(kFALSE);
1766
1767   fJetsGen = new TList();
1768   fJetsGen->SetOwner(kFALSE);
1769
1770   fJetsRecEff = new TList();
1771   fJetsRecEff->SetOwner(kFALSE);
1772
1773   // fJetsKine = new TList();
1774   // fJetsKine->SetOwner(kTRUE); // delete AOD jets using mom from Kine Tree via TList::Clear()
1775
1776
1777   //
1778   // Create histograms / output container
1779   //
1780
1781   OpenFile(1);
1782   fCommonHistList = new TList();
1783   
1784   Bool_t oldStatus = TH1::AddDirectoryStatus();
1785   TH1::AddDirectory(kFALSE);
1786   
1787   
1788   // Histograms 
1789   fh1EvtSelection            = new TH1F("fh1EvtSelection", "Event Selection", 6, -0.5, 5.5);
1790   fh1VertexNContributors     = new TH1F("fh1VertexNContributors", "Vertex N contributors", 11,-.5, 10.5);
1791   fh1VertexZ                 = new TH1F("fh1VertexZ", "Vertex z distribution", 30, -15., 15.);
1792   fh1EvtMult                 = new TH1F("fh1EvtMult","Event multiplicity, track pT cut > 150 MeV/c, |#eta| < 0.9",100,0.,100.);
1793   fh1nRecJetsCuts            = new TH1F("fh1nRecJetsCuts","reconstructed jets per event",10,-0.5,9.5);
1794   fh1nGenJets                = new TH1F("fh1nGenJets","generated jets per event",10,-0.5,9.5);
1795   fh1nRecEffJets             = new TH1F("fh1nRecEffJets","reconstruction effiency: jets per event",10,-0.5,9.5);
1796
1797   // 5D single track eff histo: phi:eta:gen pt:rec pt:isReconstructed -  use binning as for track QA
1798   Int_t   nBinsSingleTrackEffHisto[5]      = { fQATrackNBinsPhi, fQATrackNBinsEta, fQATrackNBinsPt, fQATrackNBinsPt, 2 };
1799   Double_t binMinSingleTrackEffHisto[5]    = { fQATrackPhiMin, fQATrackEtaMin, fQATrackPtMin, fQATrackPtMin, 0 };
1800   Double_t binMaxSingleTrackEffHisto[5]    = { fQATrackPhiMax, fQATrackEtaMax, fQATrackPtMax, fQATrackPtMax, 2 };
1801   const char* labelsSingleTrackEffHisto[5] = {"#phi","#eta","gen p_{T} [GeV/c]", "rec p_{T} [GeV/c]", "isRec"};
1802
1803   fhnSingleTrackRecEffHisto = new THnSparseF("fhnSingleTrackRecEffHisto","generated tracks phi:eta:pt:isReconstructed",5,
1804                                              nBinsSingleTrackEffHisto,binMinSingleTrackEffHisto,binMaxSingleTrackEffHisto);
1805   
1806   AliAnalysisTaskFragmentationFunction::SetProperties(fhnSingleTrackRecEffHisto,5,labelsSingleTrackEffHisto); 
1807   
1808   
1809   // 7D jets track eff histo: jet phi:eta:pt:track pt:z:xi:isReconstructed - use binning as for track/jet QA
1810   Int_t    nBinsJetTrackEffHisto[7]     = { fQAJetNBinsPhi, fQAJetNBinsEta, fFFNBinsJetPt, fFFNBinsPt, fFFNBinsZ, fFFNBinsXi, 2};
1811   Double_t binMinJetTrackEffHisto[7]    = { fQAJetPhiMin, fQAJetEtaMin, fFFJetPtMin , fFFPtMin, fFFZMin ,  fFFXiMin, 0 };
1812   Double_t binMaxJetTrackEffHisto[7]    = { fQAJetPhiMax, fQAJetEtaMax, fFFJetPtMax , fFFPtMax, fFFZMax ,  fFFXiMax, 2 };
1813   const char* labelsJetTrackEffHisto[7] = {"jet #phi","jet #eta","jet p_{T} [GeV/c]","track p_{T} [GeV/c]","z","#xi","isRec"};
1814
1815   fhnJetTrackRecEffHisto       = new THnSparseF("fhnJetTrackRecEffHisto","generated tracks - jet phi:jet eta:jet pt:track pt:z:xi:isReconstructed",7,
1816                                                 nBinsJetTrackEffHisto,binMinJetTrackEffHisto,binMaxJetTrackEffHisto);
1817
1818   AliAnalysisTaskFragmentationFunction::SetProperties(fhnJetTrackRecEffHisto,7,labelsJetTrackEffHisto);
1819
1820
1821   fQATrackHistosRec          = new AliFragFuncQATrackHistos("Rec", fQATrackNBinsPt, fQATrackPtMin, fQATrackPtMax, 
1822                                                             fQATrackNBinsEta, fQATrackEtaMin, fQATrackEtaMax,
1823                                                             fQATrackNBinsPhi, fQATrackPhiMin, fQATrackPhiMax, 
1824                                                             fQATrackHighPtThreshold);
1825   fQATrackHistosRecCuts      = new AliFragFuncQATrackHistos("RecCuts", fQATrackNBinsPt, fQATrackPtMin, fQATrackPtMax, 
1826                                                             fQATrackNBinsEta, fQATrackEtaMin, fQATrackEtaMax,
1827                                                             fQATrackNBinsPhi, fQATrackPhiMin, fQATrackPhiMax, 
1828                                                             fQATrackHighPtThreshold);
1829   fQATrackHistosGen          = new AliFragFuncQATrackHistos("Gen", fQATrackNBinsPt, fQATrackPtMin, fQATrackPtMax, 
1830                                                             fQATrackNBinsEta, fQATrackEtaMin, fQATrackEtaMax,
1831                                                             fQATrackNBinsPhi, fQATrackPhiMin, fQATrackPhiMax, 
1832                                                             fQATrackHighPtThreshold);
1833   
1834
1835   fQAJetHistosRec            = new AliFragFuncQAJetHistos("Rec", fQAJetNBinsPt, fQAJetPtMin, fQAJetPtMax, 
1836                                                           fQAJetNBinsEta, fQAJetEtaMin, fQAJetEtaMax,
1837                                                           fQAJetNBinsPhi, fQAJetPhiMin, fQAJetPhiMax);
1838   fQAJetHistosRecCuts        = new AliFragFuncQAJetHistos("RecCuts", fQAJetNBinsPt, fQAJetPtMin, fQAJetPtMax, 
1839                                                           fQAJetNBinsEta, fQAJetEtaMin, fQAJetEtaMax,
1840                                                           fQAJetNBinsPhi, fQAJetPhiMin, fQAJetPhiMax);
1841   fQAJetHistosRecCutsLeading = new AliFragFuncQAJetHistos("RecCutsLeading", fQAJetNBinsPt, fQAJetPtMin, fQAJetPtMax, 
1842                                                           fQAJetNBinsEta, fQAJetEtaMin, fQAJetEtaMax,
1843                                                           fQAJetNBinsPhi, fQAJetPhiMin, fQAJetPhiMax);
1844   fQAJetHistosGen            = new AliFragFuncQAJetHistos("Gen", fQAJetNBinsPt, fQAJetPtMin, fQAJetPtMax, 
1845                                                           fQAJetNBinsEta, fQAJetEtaMin, fQAJetEtaMax,
1846                                                           fQAJetNBinsPhi, fQAJetPhiMin, fQAJetPhiMax);
1847   fQAJetHistosGenLeading     = new AliFragFuncQAJetHistos("GenLeading", fQAJetNBinsPt, fQAJetPtMin, fQAJetPtMax, 
1848                                                           fQAJetNBinsEta, fQAJetEtaMin, fQAJetEtaMax,
1849                                                           fQAJetNBinsPhi, fQAJetPhiMin, fQAJetPhiMax);  
1850   fQAJetHistosRecEffLeading  = new AliFragFuncQAJetHistos("RecEffLeading", fQAJetNBinsPt, fQAJetPtMin, fQAJetPtMax, 
1851                                                           fQAJetNBinsEta, fQAJetEtaMin, fQAJetEtaMax,fQAJetNBinsPhi, fQAJetPhiMin, fQAJetPhiMax);
1852
1853
1854   fFFHistosRecCuts           = new AliFragFuncHistos("RecCuts", fFFNBinsJetPt, fFFJetPtMin, fFFJetPtMax, 
1855                                                      fFFNBinsPt, fFFPtMin, fFFPtMax, 
1856                                                      fFFNBinsXi, fFFXiMin, fFFXiMax,  
1857                                                      fFFNBinsZ , fFFZMin , fFFZMax);
1858   fFFHistosRecLeading        = new AliFragFuncHistos("RecLeading", fFFNBinsJetPt, fFFJetPtMin, fFFJetPtMax, 
1859                                                      fFFNBinsPt, fFFPtMin, fFFPtMax, 
1860                                                      fFFNBinsXi, fFFXiMin, fFFXiMax,  
1861                                                      fFFNBinsZ , fFFZMin , fFFZMax);
1862   fFFHistosRecLeadingTrack   = new AliFragFuncHistos("RecLeadingTrack", fFFNBinsJetPt, fFFJetPtMin, fFFJetPtMax, 
1863                                                      fFFNBinsPt, fFFPtMin, fFFPtMax, 
1864                                                      fFFNBinsXi, fFFXiMin, fFFXiMax,  
1865                                                      fFFNBinsZ , fFFZMin , fFFZMax);
1866   fFFHistosGen               = new AliFragFuncHistos("Gen", fFFNBinsJetPt, fFFJetPtMin, fFFJetPtMax, 
1867                                                      fFFNBinsPt, fFFPtMin, fFFPtMax, 
1868                                                      fFFNBinsXi, fFFXiMin, fFFXiMax,  
1869                                                      fFFNBinsZ , fFFZMin , fFFZMax);
1870   fFFHistosGenLeading        = new AliFragFuncHistos("GenLeading", fFFNBinsJetPt, fFFJetPtMin, fFFJetPtMax, 
1871                                                      fFFNBinsPt, fFFPtMin, fFFPtMax, 
1872                                                      fFFNBinsXi, fFFXiMin, fFFXiMax,  
1873                                                      fFFNBinsZ , fFFZMin , fFFZMax);
1874   fFFHistosGenLeadingTrack   = new AliFragFuncHistos("GenLeadingTrack", fFFNBinsJetPt, fFFJetPtMin, fFFJetPtMax, 
1875                                                      fFFNBinsPt, fFFPtMin, fFFPtMax, 
1876                                                      fFFNBinsXi, fFFXiMin, fFFXiMax,  
1877                                                      fFFNBinsZ , fFFZMin , fFFZMax);
1878
1879
1880   fIJHistosRecCuts           = new AliFragFuncIntraJetHistos("RecCuts", fIJNBinsJetPt, fIJJetPtMin, fIJJetPtMax, 
1881                                                              fIJNBinsPt, fIJPtMin, fIJPtMax, 
1882                                                              fIJNBinsZ, fIJZMin, fIJZMax,  
1883                                                              fIJNBinsCosTheta , fIJCosThetaMin , fIJCosThetaMax, 
1884                                                              fIJNBinsTheta , fIJThetaMin , fIJThetaMax,
1885                                                              fIJNBinsJt , fIJJtMin , fIJJtMax);
1886   fIJHistosRecLeading        = new AliFragFuncIntraJetHistos("RecLeading", fIJNBinsJetPt, fIJJetPtMin, fIJJetPtMax, 
1887                                                              fIJNBinsPt, fIJPtMin, fIJPtMax, 
1888                                                              fIJNBinsZ, fIJZMin, fIJZMax,  
1889                                                              fIJNBinsCosTheta , fIJCosThetaMin , fIJCosThetaMax, 
1890                                                              fIJNBinsTheta , fIJThetaMin , fIJThetaMax, 
1891                                                              fIJNBinsJt , fIJJtMin , fIJJtMax);
1892   fIJHistosRecLeadingTrack   = new AliFragFuncIntraJetHistos("RecLeadingTrack", fIJNBinsJetPt, fIJJetPtMin, fIJJetPtMax, 
1893                                                              fIJNBinsPt, fIJPtMin, fIJPtMax, 
1894                                                              fIJNBinsZ, fIJZMin, fIJZMax,  
1895                                                              fIJNBinsCosTheta , fIJCosThetaMin , fIJCosThetaMax, 
1896                                                              fIJNBinsTheta , fIJThetaMin , fIJThetaMax, 
1897                                                              fIJNBinsJt , fIJJtMin , fIJJtMax);
1898   fIJHistosGen               = new AliFragFuncIntraJetHistos("Gen", fIJNBinsJetPt, fIJJetPtMin, fIJJetPtMax, 
1899                                                              fIJNBinsPt, fIJPtMin, fIJPtMax, 
1900                                                              fIJNBinsZ, fIJZMin, fIJZMax,  
1901                                                              fIJNBinsCosTheta , fIJCosThetaMin , fIJCosThetaMax, 
1902                                                              fIJNBinsTheta , fIJThetaMin , fIJThetaMax, 
1903                                                              fIJNBinsJt , fIJJtMin , fIJJtMax);
1904   fIJHistosGenLeading        = new AliFragFuncIntraJetHistos("GenLeading", fIJNBinsJetPt, fIJJetPtMin, fIJJetPtMax, 
1905                                                              fIJNBinsPt, fIJPtMin, fIJPtMax, 
1906                                                              fIJNBinsZ, fIJZMin, fIJZMax,  
1907                                                              fIJNBinsCosTheta , fIJCosThetaMin , fIJCosThetaMax, 
1908                                                              fIJNBinsTheta , fIJThetaMin , fIJThetaMax, 
1909                                                              fIJNBinsJt , fIJJtMin , fIJJtMax);
1910   fIJHistosGenLeadingTrack   = new AliFragFuncIntraJetHistos("GenLeadingTrack", fIJNBinsJetPt, fIJJetPtMin, fIJJetPtMax, 
1911                                                              fIJNBinsPt, fIJPtMin, fIJPtMax, 
1912                                                              fIJNBinsZ, fIJZMin, fIJZMax,  
1913                                                              fIJNBinsCosTheta , fIJCosThetaMin , fIJCosThetaMax, 
1914                                                              fIJNBinsTheta , fIJThetaMin , fIJThetaMax, 
1915                                                              fIJNBinsJt , fIJJtMin , fIJJtMax);
1916
1917
1918   fFFDiJetHistosRecCuts         = new AliFragFuncDiJetHistos("RecCuts", fDiJetKindBins, 
1919                                                              fDiJetNBinsJetInvMass, fDiJetJetInvMassMin, fDiJetJetInvMassMax,
1920                                                              fDiJetNBinsJetPt, fDiJetJetPtMin, fDiJetJetPtMax,
1921                                                              fDiJetNBinsPt, fDiJetPtMin, fDiJetPtMax, 
1922                                                              fDiJetNBinsXi, fDiJetXiMin, fDiJetXiMax, 
1923                                                              fDiJetNBinsZ, fDiJetZMin, fDiJetZMax);
1924   fFFDiJetHistosRecLeading      = new AliFragFuncDiJetHistos("RecLeading", fDiJetKindBins, 
1925                                                              fDiJetNBinsJetInvMass, fDiJetJetInvMassMin, fDiJetJetInvMassMax,
1926                                                              fDiJetNBinsJetPt, fDiJetJetPtMin, fDiJetJetPtMax, 
1927                                                              fDiJetNBinsPt, fDiJetPtMin, fDiJetPtMax, 
1928                                                              fDiJetNBinsXi, fDiJetXiMin, fDiJetXiMax, 
1929                                                              fDiJetNBinsZ, fDiJetZMin, fDiJetZMax); 
1930   fFFDiJetHistosRecLeadingTrack = new AliFragFuncDiJetHistos("RecLeadingTrack", fDiJetKindBins, 
1931                                                              fDiJetNBinsJetInvMass, fDiJetJetInvMassMin, fDiJetJetInvMassMax,
1932                                                              fDiJetNBinsJetPt, fDiJetJetPtMin, fDiJetJetPtMax, 
1933                                                              fDiJetNBinsPt, fDiJetPtMin, fDiJetPtMax, 
1934                                                              fDiJetNBinsXi, fDiJetXiMin, fDiJetXiMax, 
1935                                                              fDiJetNBinsZ, fDiJetZMin, fDiJetZMax);
1936
1937   fFFDiJetHistosGen             = new AliFragFuncDiJetHistos("Gen", fDiJetKindBins, 
1938                                                              fDiJetNBinsJetInvMass, fDiJetJetInvMassMin, fDiJetJetInvMassMax,
1939                                                              fDiJetNBinsJetPt, fDiJetJetPtMin, fDiJetJetPtMax,
1940                                                              fDiJetNBinsPt, fDiJetPtMin, fDiJetPtMax, 
1941                                                              fDiJetNBinsXi, fDiJetXiMin, fDiJetXiMax,
1942                                                              fDiJetNBinsZ, fDiJetZMin, fDiJetZMax);
1943   fFFDiJetHistosGenLeading      = new AliFragFuncDiJetHistos("GenLeading", fDiJetKindBins, 
1944                                                              fDiJetNBinsJetInvMass, fDiJetJetInvMassMin, fDiJetJetInvMassMax,
1945                                                              fDiJetNBinsJetPt, fDiJetJetPtMin, fDiJetJetPtMax,
1946                                                              fDiJetNBinsPt, fDiJetPtMin, fDiJetPtMax,
1947                                                              fDiJetNBinsXi, fDiJetXiMin, fDiJetXiMax,
1948                                                              fDiJetNBinsZ, fDiJetZMin, fDiJetZMax);
1949   fFFDiJetHistosGenLeadingTrack = new AliFragFuncDiJetHistos("GenLeadingTrack", fDiJetKindBins, 
1950                                                              fDiJetNBinsJetInvMass, fDiJetJetInvMassMin, fDiJetJetInvMassMax,
1951                                                              fDiJetNBinsJetPt, fDiJetJetPtMin, fDiJetJetPtMax, 
1952                                                              fDiJetNBinsPt, fDiJetPtMin, fDiJetPtMax, 
1953                                                              fDiJetNBinsXi, fDiJetXiMin, fDiJetXiMax, 
1954                                                              fDiJetNBinsZ, fDiJetZMin, fDiJetZMax);
1955
1956   fQADiJetHistosRecCuts = new AliFragFuncQADiJetHistos("RecCuts", fDiJetKindBins, 
1957                                                        fQADiJetNBinsInvMass, fQADiJetInvMassMin, fQADiJetInvMassMax,
1958                                                        fQADiJetNBinsJetPt, fQADiJetJetPtMin, fQADiJetJetPtMax,
1959                                                        fQADiJetNBinsDeltaPhi, fQADiJetDeltaPhiMin, fQADiJetDeltaPhiMax , 
1960                                                        fQADiJetNBinsDeltaEta, fQADiJetDeltaEtaMin, fQADiJetDeltaEtaMax , 
1961                                                        fQADiJetNBinsDeltaPt, fQADiJetDeltaPtMin, fQADiJetDeltaPtMax);
1962   fQADiJetHistosGen     = new AliFragFuncQADiJetHistos("Gen", fDiJetKindBins, 
1963                                                        fQADiJetNBinsInvMass, fQADiJetInvMassMin,  fQADiJetInvMassMax, 
1964                                                        fDiJetNBinsJetPt, fDiJetJetPtMin, fDiJetJetPtMax,
1965                                                        fQADiJetNBinsDeltaPhi, fQADiJetDeltaPhiMin, fQADiJetDeltaPhiMax,
1966                                                        fQADiJetNBinsDeltaEta, fQADiJetDeltaEtaMin, fQADiJetDeltaEtaMax,
1967                                                        fQADiJetNBinsDeltaPt, fQADiJetDeltaPtMin, fQADiJetDeltaPtMax);
1968
1969
1970   fQATrackHistosRec->DefineHistos();
1971   fQATrackHistosRecCuts->DefineHistos();
1972   fQATrackHistosGen->DefineHistos();
1973
1974   fQAJetHistosRec->DefineHistos();
1975   fQAJetHistosRecCuts->DefineHistos();
1976   fQAJetHistosRecCutsLeading->DefineHistos();
1977   fQAJetHistosGen->DefineHistos();
1978   fQAJetHistosGenLeading->DefineHistos();
1979   fQAJetHistosRecEffLeading->DefineHistos();
1980
1981   fFFHistosRecCuts->DefineHistos();
1982   fFFHistosRecLeading->DefineHistos();
1983   fFFHistosRecLeadingTrack->DefineHistos();
1984   fFFHistosGen->DefineHistos();
1985   fFFHistosGenLeading->DefineHistos();
1986   fFFHistosGenLeadingTrack->DefineHistos();
1987
1988   fIJHistosRecCuts->DefineHistos();
1989   fIJHistosRecLeading->DefineHistos();
1990   fIJHistosRecLeadingTrack->DefineHistos();
1991   fIJHistosGen->DefineHistos();
1992   fIJHistosGenLeading->DefineHistos();
1993   fIJHistosGenLeadingTrack->DefineHistos();
1994   
1995   fFFDiJetHistosRecCuts->DefineDiJetHistos();
1996   fFFDiJetHistosRecLeading->DefineDiJetHistos();
1997   fFFDiJetHistosRecLeadingTrack->DefineDiJetHistos();
1998   fFFDiJetHistosGen->DefineDiJetHistos();
1999   fFFDiJetHistosGenLeading->DefineDiJetHistos();
2000   fFFDiJetHistosGenLeadingTrack->DefineDiJetHistos();
2001   fQADiJetHistosRecCuts->DefineQADiJetHistos();
2002   fQADiJetHistosGen->DefineQADiJetHistos();
2003
2004   const Int_t saveLevel = 5;
2005   if(saveLevel>0){
2006     fCommonHistList->Add(fh1EvtSelection);
2007     fFFHistosRecCuts->AddToOutput(fCommonHistList);
2008     fFFHistosRecLeading->AddToOutput(fCommonHistList);
2009     fFFHistosRecLeadingTrack->AddToOutput(fCommonHistList);
2010     fFFHistosGen->AddToOutput(fCommonHistList);
2011     fFFHistosGenLeading->AddToOutput(fCommonHistList);
2012     fFFHistosGenLeadingTrack->AddToOutput(fCommonHistList);
2013   }
2014   if(saveLevel>1){
2015     fQATrackHistosRec->AddToOutput(fCommonHistList);
2016     fQATrackHistosRecCuts->AddToOutput(fCommonHistList);
2017     fQATrackHistosGen->AddToOutput(fCommonHistList);
2018     
2019     fQAJetHistosRec->AddToOutput(fCommonHistList);
2020     fQAJetHistosRecCuts->AddToOutput(fCommonHistList);
2021     fQAJetHistosRecCutsLeading->AddToOutput(fCommonHistList);
2022     fQAJetHistosGen->AddToOutput(fCommonHistList);
2023     fQAJetHistosGenLeading->AddToOutput(fCommonHistList);
2024     fQAJetHistosRecEffLeading->AddToOutput(fCommonHistList); 
2025
2026     fCommonHistList->Add(fh1EvtMult);
2027     fCommonHistList->Add(fh1nRecJetsCuts);
2028     fCommonHistList->Add(fh1nGenJets);
2029   }
2030   if(saveLevel>2){
2031     fCommonHistList->Add(fh1VertexNContributors);
2032     fCommonHistList->Add(fh1VertexZ);    
2033   }
2034   if(saveLevel>3){
2035     fIJHistosRecCuts->AddToOutput(fCommonHistList);
2036     fIJHistosRecLeading->AddToOutput(fCommonHistList);
2037     fIJHistosRecLeadingTrack->AddToOutput(fCommonHistList);
2038     fIJHistosGen->AddToOutput(fCommonHistList);
2039     fIJHistosGenLeading->AddToOutput(fCommonHistList);
2040     fIJHistosGenLeadingTrack->AddToOutput(fCommonHistList);
2041   }
2042   if(saveLevel>4){
2043     fFFDiJetHistosRecCuts->AddToOutput(fCommonHistList);
2044     fFFDiJetHistosRecLeading->AddToOutput(fCommonHistList);
2045     fFFDiJetHistosRecLeadingTrack->AddToOutput(fCommonHistList);
2046     fFFDiJetHistosGen->AddToOutput(fCommonHistList);
2047     fFFDiJetHistosGenLeading->AddToOutput(fCommonHistList);
2048     fFFDiJetHistosGenLeadingTrack->AddToOutput(fCommonHistList);
2049     fQADiJetHistosRecCuts->AddToOutput(fCommonHistList);
2050     fQADiJetHistosGen->AddToOutput(fCommonHistList); 
2051     fCommonHistList->Add(fhnSingleTrackRecEffHisto);
2052     fCommonHistList->Add(fhnJetTrackRecEffHisto);
2053     fCommonHistList->Add(fh1nRecEffJets);
2054   }
2055
2056   // =========== Switch on Sumw2 for all histos ===========
2057   for (Int_t i=0; i<fCommonHistList->GetEntries(); ++i){
2058     TH1 *h1 = dynamic_cast<TH1*>(fCommonHistList->At(i));
2059     if (h1) h1->Sumw2();
2060     else{
2061       THnSparse *hnSparse = dynamic_cast<THnSparse*>(fCommonHistList->At(i));
2062       if(hnSparse) hnSparse->Sumw2();
2063     }
2064   }
2065   
2066   TH1::AddDirectory(oldStatus);
2067 }
2068
2069 //_______________________________________________
2070 void AliAnalysisTaskFragmentationFunction::Init()
2071 {
2072   // Initialization
2073   if(fDebug > 1) Printf("AliAnalysisTaskFragmentationFunction::Init()");
2074
2075 }
2076
2077 //_____________________________________________________________
2078 void AliAnalysisTaskFragmentationFunction::UserExec(Option_t *) 
2079 {
2080   // Main loop
2081   // Called for each event
2082   if(fDebug > 1) Printf("AliAnalysisTaskFragmentationFunction::UserExec()");
2083         
2084
2085   if(fDebug > 1) Printf("Analysis event #%5d", (Int_t) fEntry);
2086   // Trigger selection
2087   
2088   AliInputEventHandler* inputHandler = (AliInputEventHandler*)
2089     ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
2090   if(inputHandler->IsEventSelected() & AliVEvent::kMB){
2091     if(fDebug > 1)  Printf(" Trigger Selection: event ACCEPTED ... ");
2092     fh1EvtSelection->Fill(1.);
2093   } else {
2094     fh1EvtSelection->Fill(0.);
2095     if(inputHandler->InheritsFrom("AliESDInputHandler")){ // PhysicsSelection only with ESD input
2096       if (fDebug > 1 ) Printf(" Trigger Selection: event REJECTED ... ");
2097       PostData(1, fCommonHistList);
2098       return;
2099     }
2100   }
2101   
2102   fESD = dynamic_cast<AliESDEvent*>(InputEvent());
2103   if(!fESD){
2104     if(fDebug>3) Printf("%s:%d ESDEvent not found in the input", (char*)__FILE__,__LINE__);
2105   }
2106   
2107   fMCEvent = MCEvent();
2108   if(!fMCEvent){
2109     if(fDebug>3) Printf("%s:%d MCEvent not found in the input", (char*)__FILE__,__LINE__);
2110   }
2111   
2112   // get AOD event from input/ouput
2113   TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
2114   if( handler && handler->InheritsFrom("AliAODInputHandler") ) {
2115     fAOD  =  ((AliAODInputHandler*)handler)->GetEvent();
2116     if (fDebug > 1)  Printf("%s:%d AOD event from input", (char*)__FILE__,__LINE__);
2117   }
2118   else {
2119     handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
2120     if( handler && handler->InheritsFrom("AliAODHandler") ) {
2121       fAOD  = ((AliAODHandler*)handler)->GetAOD();
2122       if (fDebug > 1)  Printf("%s:%d AOD event from output", (char*)__FILE__,__LINE__);
2123     }
2124   }
2125   
2126   if(!fAOD){
2127     Printf("%s:%d AODEvent not found", (char*)__FILE__,__LINE__);
2128     return;
2129   }
2130   
2131
2132   // event selection (vertex) *****************************************
2133   
2134   AliAODVertex* primVtx = fAOD->GetPrimaryVertex();
2135   Int_t nTracksPrim = primVtx->GetNContributors();
2136   fh1VertexNContributors->Fill(nTracksPrim);
2137   
2138   if (fDebug > 1) Printf("%s:%d primary vertex selection: %d", (char*)__FILE__,__LINE__,nTracksPrim);
2139   if(!nTracksPrim){
2140     if (fDebug > 1) Printf("%s:%d primary vertex selection: event REJECTED...",(char*)__FILE__,__LINE__); 
2141     fh1EvtSelection->Fill(2.);
2142     PostData(1, fCommonHistList);
2143     return;
2144   }
2145
2146   fh1VertexZ->Fill(primVtx->GetZ());
2147   
2148   if(TMath::Abs(primVtx->GetZ())>10){
2149     if (fDebug > 1) Printf("%s:%d primary vertex z = %f: event REJECTED...",(char*)__FILE__,__LINE__,primVtx->GetZ()); 
2150     fh1EvtSelection->Fill(3.);
2151     PostData(1, fCommonHistList);
2152     return; 
2153   }
2154
2155   TString primVtxName(primVtx->GetName());
2156
2157   if(primVtxName.CompareTo("TPCVertex",TString::kIgnoreCase) == 1){
2158     if (fDebug > 1) Printf("%s:%d primary vertex selection: TPC vertex, event REJECTED...",(char*)__FILE__,__LINE__);
2159     fh1EvtSelection->Fill(4.);
2160     PostData(1, fCommonHistList);
2161     return;
2162   }
2163   if (fDebug > 1) Printf("%s:%d primary vertex selection: event ACCEPTED ...",(char*)__FILE__,__LINE__); 
2164   fh1EvtSelection->Fill(5.);
2165   
2166   
2167   //___ fetch jets __________________________________________________________________________
2168   
2169   Int_t nJ = GetListOfJets(fJetsRec, kJetsRec);
2170   Int_t nRecJets = 0;
2171   if(nJ>=0) nRecJets = fJetsRec->GetEntries();
2172   if(fDebug>2)Printf("%s:%d Selected Rec jets: %d %d",(char*)__FILE__,__LINE__,nJ,nRecJets);
2173   if(nJ != nRecJets) Printf("%s:%d Mismatch Selected Rec Jets: %d %d",(char*)__FILE__,__LINE__,nJ,nRecJets);
2174
2175   Int_t nJCuts = GetListOfJets(fJetsRecCuts, kJetsRecAcceptance);
2176   Int_t nRecJetsCuts = 0;
2177   if(nJCuts>=0) nRecJetsCuts = fJetsRecCuts->GetEntries();
2178   if(fDebug>2)Printf("%s:%d Selected Rec jets after cuts: %d %d",(char*)__FILE__,__LINE__,nJCuts,nRecJetsCuts);
2179   if(nRecJetsCuts != nJCuts) Printf("%s:%d Mismatch selected Rec jets after cuts: %d %d",(char*)__FILE__,__LINE__,nJCuts,nRecJetsCuts);
2180   fh1nRecJetsCuts->Fill(nRecJetsCuts);
2181
2182   
2183   if(fJetTypeGen==kJetsKine || fJetTypeGen == kJetsKineAcceptance) fJetsGen->SetOwner(kTRUE); // kine aod jets allocated on heap, delete them with TList::Clear() 
2184   Int_t nJGen  = GetListOfJets(fJetsGen, fJetTypeGen);
2185   Int_t nGenJets = 0;
2186   if(nJGen>=0) nGenJets = fJetsGen->GetEntries();
2187   if(fDebug>2)Printf("%s:%d Selected Gen jets: %d %d",(char*)__FILE__,__LINE__,nJGen,nGenJets);
2188   if(nJGen != nGenJets) Printf("%s:%d Mismatch selected Gen jets: %d %d",(char*)__FILE__,__LINE__,nJGen,nGenJets);
2189   fh1nGenJets->Fill(nGenJets);
2190
2191
2192   if(fJetTypeRecEff==kJetsKine || fJetTypeRecEff == kJetsKineAcceptance) fJetsRecEff->SetOwner(kTRUE); // kine aod jets allocated on heap, delete them with TList::Clear() 
2193   Int_t nJRecEff  = GetListOfJets(fJetsRecEff, fJetTypeRecEff);
2194   Int_t nRecEffJets = 0;
2195   if(nJRecEff>=0) nRecEffJets = fJetsRecEff->GetEntries();
2196   if(fDebug>2)Printf("%s:%d Selected RecEff jets: %d %d",(char*)__FILE__,__LINE__,nJRecEff,nRecEffJets);
2197   if(nJRecEff != nRecEffJets) Printf("%s:%d Mismatch selected RecEff jets: %d %d",(char*)__FILE__,__LINE__,nJRecEff,nRecEffJets);
2198   fh1nRecEffJets->Fill(nRecEffJets);
2199
2200
2201   //____ fetch particles __________________________________________________________
2202   
2203   Int_t nT = GetListOfTracks(fTracksRec, kTrackAOD);
2204   Int_t nRecPart = 0;
2205   if(nT>=0) nRecPart = fTracksRec->GetEntries();
2206   if(fDebug>2)Printf("%s:%d Selected Rec tracks: %d %d",(char*)__FILE__,__LINE__,nT,nRecPart);
2207   if(nRecPart != nT) Printf("%s:%d Mismatch selected Rec tracks: %d %d",(char*)__FILE__,__LINE__,nT,nRecPart);
2208   
2209
2210   Int_t nTCuts = GetListOfTracks(fTracksRecCuts, kTrackAODCuts);
2211   Int_t nRecPartCuts = 0;
2212   if(nTCuts>=0) nRecPartCuts = fTracksRecCuts->GetEntries();
2213   if(fDebug>2)Printf("%s:%d Selected Rec tracks after cuts: %d %d",(char*)__FILE__,__LINE__,nTCuts,nRecPartCuts);
2214   if(nRecPartCuts != nTCuts) Printf("%s:%d Mismatch selected Rec tracks after cuts: %d %d",(char*)__FILE__,__LINE__,nTCuts,nRecPartCuts);
2215   fh1EvtMult->Fill(nRecPartCuts);
2216
2217
2218   Int_t nTGen = GetListOfTracks(fTracksGen,fTrackTypeGen);
2219   Int_t nGenPart = 0;
2220   if(nTGen>=0) nGenPart = fTracksGen->GetEntries();
2221   if(fDebug>2)Printf("%s:%d Selected Gen tracks: %d %d",(char*)__FILE__,__LINE__,nTGen,nGenPart);
2222   if(nGenPart != nTGen) Printf("%s:%d Mismatch selected Gen tracks: %d %d",(char*)__FILE__,__LINE__,nTGen,nGenPart);
2223   
2224   
2225   //____ analysis, fill histos ___________________________________________________
2226   
2227   // loop over tracks
2228
2229   for(Int_t it=0; it<nRecPart; ++it){
2230     AliVParticle *part = dynamic_cast<AliVParticle*>(fTracksRec->At(it));
2231     fQATrackHistosRec->FillTrackQA( part->Eta(), TVector2::Phi_0_2pi(part->Phi()), part->Pt());
2232   }
2233   for(Int_t it=0; it<nRecPartCuts; ++it){
2234     AliVParticle *part = dynamic_cast<AliVParticle*>(fTracksRecCuts->At(it));
2235     fQATrackHistosRecCuts->FillTrackQA( part->Eta(), TVector2::Phi_0_2pi(part->Phi()), part->Pt());
2236   }
2237   for(Int_t it=0; it<nGenPart; ++it){
2238     AliVParticle *part = dynamic_cast<AliVParticle*>(fTracksGen->At(it));
2239     fQATrackHistosGen->FillTrackQA( part->Eta(), TVector2::Phi_0_2pi(part->Phi()), part->Pt());
2240   }
2241   
2242   // loop over jets
2243
2244   for(Int_t ij=0; ij<nRecJets; ++ij){
2245
2246     AliAODJet* jet = dynamic_cast<AliAODJet*>(fJetsRec->At(ij));
2247     fQAJetHistosRec->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt());
2248   }
2249   
2250
2251   for(Int_t ij=0; ij<nRecJetsCuts; ++ij){
2252
2253     AliAODJet* jet = dynamic_cast<AliAODJet*>(fJetsRecCuts->At(ij));
2254     fQAJetHistosRecCuts->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt());
2255
2256     if(ij==0){ // leading jet
2257       
2258       fQAJetHistosRecCutsLeading->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt() );
2259       
2260       TList* jettracklist = new TList();
2261       Double_t sumPt = 0.;
2262       Float_t leadTrackPx = 0.;
2263       Float_t leadTrackPy = 0.;
2264       Float_t leadTrackPz = 0.;
2265       Float_t leadTrackP  = 0.;
2266       Float_t leadTrackPt = 0.;
2267       TLorentzVector* leadTrackV = new TLorentzVector();
2268       
2269       if(GetFFRadius()<=0){
2270         GetJetTracksTrackrefs(jettracklist, jet);
2271        } else {
2272         GetJetTracksPointing(fTracksRecCuts, jettracklist, jet, GetFFRadius(), sumPt);
2273       }
2274       
2275       for(Int_t it=0; it<jettracklist->GetSize(); ++it){
2276         Float_t trackPx = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->Px();
2277         Float_t trackPy = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->Py();
2278         Float_t trackPz = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->Pz();
2279         Float_t trackP = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->P();
2280         Float_t trackPt = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->Pt();
2281         Float_t jetPx = jet->Px();
2282         Float_t jetPy = jet->Py();
2283         Float_t jetPz = jet->Pz();
2284         Float_t jetP  = jet->P();
2285         Float_t jetPt = jet->Pt();
2286         TLorentzVector* trackV = new TLorentzVector();
2287         TLorentzVector *jetV = new TLorentzVector();
2288         trackV->SetPxPyPzE(trackPx,trackPy,trackPz,trackP);
2289         jetV->SetPxPyPzE(jetPx,jetPy,jetPz,jetP);
2290
2291         Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2292         
2293         fFFHistosRecCuts->FillFF( trackPt, jetPt, incrementJetPt);
2294         fIJHistosRecCuts->FillIntraJet( trackV, jetV );
2295         
2296         if(it==0){ 
2297           leadTrackPx = trackPx;
2298           leadTrackPy = trackPy;
2299           leadTrackPz = trackPz;
2300           leadTrackP  = trackP;
2301           leadTrackPt = trackPt;
2302           fFFHistosRecLeadingTrack->FillFF( leadTrackPt, jetPt, kTRUE);
2303
2304           leadTrackV->SetPxPyPzE(leadTrackPx,leadTrackPy,leadTrackPz,leadTrackP);
2305           fIJHistosRecLeadingTrack->FillIntraJet( leadTrackV, jetV );
2306         }
2307         fFFHistosRecLeading->FillFF( trackPt, leadTrackPt , incrementJetPt);
2308         fIJHistosRecLeading->FillIntraJet( trackV, leadTrackV );
2309
2310         delete trackV;
2311         delete jetV;
2312       }
2313       
2314       delete leadTrackV;
2315       delete jettracklist;
2316     }
2317   }
2318         
2319
2320   for(Int_t ij=0; ij<nGenJets; ++ij){
2321
2322     AliAODJet* jet = dynamic_cast<AliAODJet*>(fJetsGen->At(ij));
2323     fQAJetHistosGen->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt());
2324     
2325     if(ij==0){ // leading jet
2326     
2327       fQAJetHistosGenLeading->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt());
2328       
2329       TList* jettracklist = new TList();
2330       Double_t sumPt = 0.;
2331       Float_t leadTrackPx = 0.;
2332       Float_t leadTrackPy = 0.;
2333       Float_t leadTrackPz = 0.;
2334       Float_t leadTrackP  = 0.;
2335       Float_t leadTrackPt = 0.;
2336       TLorentzVector* leadTrackV = new TLorentzVector();
2337
2338       if(GetFFRadius()<=0){
2339         GetJetTracksTrackrefs(jettracklist, jet);
2340       } else {
2341         GetJetTracksPointing(fTracksGen, jettracklist, jet, GetFFRadius(), sumPt);
2342       }
2343       
2344       for(Int_t it=0; it<jettracklist->GetSize(); ++it){
2345         Float_t trackPx = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->Px();
2346         Float_t trackPy = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->Py();
2347         Float_t trackPz = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->Pz();
2348         Float_t trackP  = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->P();
2349         Float_t trackPt = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->Pt();
2350         Float_t jetPx = jet->Px();
2351         Float_t jetPy = jet->Py();
2352         Float_t jetPz = jet->Pz();
2353         Float_t jetP  = jet->P();
2354         Float_t jetPt = jet->Pt();
2355         TLorentzVector* trackV = new TLorentzVector();
2356         TLorentzVector  *jetV = new TLorentzVector();
2357         trackV->SetPxPyPzE(trackPx,trackPy,trackPz,trackP);
2358         jetV->SetPxPyPzE(jetPx,jetPy,jetPz,jetP);
2359
2360         Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2361
2362         fFFHistosGen->FillFF( trackPt, jetPt, incrementJetPt);
2363         fIJHistosGen->FillIntraJet( trackV, jetV );
2364         
2365         if(it==0){ 
2366           leadTrackPx = trackPx;
2367           leadTrackPy = trackPy;
2368           leadTrackPz = trackPz;
2369           leadTrackP  = trackP;
2370           leadTrackPt = trackPt;
2371           fFFHistosGenLeadingTrack->FillFF( leadTrackPt, jetPt, kTRUE);
2372
2373           leadTrackV->SetPxPyPzE(leadTrackPx,leadTrackPy,leadTrackPz,leadTrackP);
2374           fIJHistosGenLeadingTrack->FillIntraJet( leadTrackV, jetV );
2375         }
2376         fFFHistosGenLeading->FillFF( trackPt, leadTrackPt, incrementJetPt);
2377         fIJHistosGenLeading->FillIntraJet( trackV, leadTrackV );
2378
2379         delete trackV;
2380         delete jetV;
2381       }
2382       
2383       delete leadTrackV;
2384       delete jettracklist;
2385     }
2386   }
2387
2388   //_______ DiJet part _____________________________________________________
2389
2390   if (nRecJetsCuts > 1)  // OB: debugged this
2391   {
2392
2393     AliAODJet* jet1 = dynamic_cast<AliAODJet*>(fJetsRecCuts->At(0));
2394     AliAODJet* jet2 = dynamic_cast<AliAODJet*>(fJetsRecCuts->At(1));
2395     
2396     // DiJet deltaphi calculation
2397     Double_t phi1 = TVector2::Phi_0_2pi(jet1->Phi());
2398     Double_t phi2 = TVector2::Phi_0_2pi(jet2->Phi());
2399     Double_t deltaPhi = TMath::Abs(phi1-phi2); 
2400     if (deltaPhi > TMath::Pi() && deltaPhi < 2*TMath::Pi()) deltaPhi = 2*TMath::Pi() - deltaPhi;
2401     
2402     // DiJet CDF cut calculation
2403     Double_t Et1     = TMath::Abs(jet1->E()*TMath::Sin(jet1->Theta()));
2404     Double_t Et2     = TMath::Abs(jet2->E()*TMath::Sin(jet2->Theta()));
2405     Double_t sumEt   = Et1 + Et2;
2406     Double_t normEt1PlusEt2   = TMath::Sqrt(Et1*Et1+Et2*Et2+2*Et1*Et2*TMath::Cos(deltaPhi));
2407     Double_t ratio = (Double_t)(normEt1PlusEt2/sumEt);
2408     
2409     // DiJet events selection
2410     Bool_t positionCut       = 0;
2411     Bool_t positionEnergyCut = 0;
2412     Bool_t cdfCut            = 0; 
2413
2414     // Position cut :
2415     if (deltaPhi > fDiJetDeltaPhiCut) positionCut = 1;
2416     // Position-Energy cut :
2417     if ((deltaPhi > fDiJetDeltaPhiCut) && ((jet2->Pt()) >= fDiJetPtFractionCut*(jet1->Pt()))) positionEnergyCut = 1;
2418     // CDF cut :
2419     if (ratio < fDiJetCDFCut) cdfCut = 1;
2420     
2421     Int_t go = 0;
2422     
2423     if (fDiJetCut == 1 && positionCut == 1) go = 1;
2424     if (fDiJetCut == 2 && positionEnergyCut == 1) go = 1;
2425     if (fDiJetCut == 3 && cdfCut == 1) go = 1;
2426
2427     if (go)
2428       {
2429         Double_t deltaEta      = TMath::Abs(jet1->Eta()-jet2->Eta());
2430         Double_t deltaPt       = TMath::Abs(jet1->Pt()-jet2->Pt());
2431         Double_t meanEt        = (Double_t)((Et1+Et2)/2.);
2432         Double_t invariantMass = (Double_t)InvMass(jet1,jet2);
2433         
2434         Double_t  jetBin = GetDiJetBin(invariantMass, jet1->Pt(), meanEt, fDiJetKindBins);
2435
2436         if (jetBin > 0)
2437           {
2438             fQADiJetHistosRecCuts->FillDiJetQA(invariantMass, deltaPhi, deltaEta, deltaPt, jetBin);
2439             
2440             TList* jettracklist1 = new TList();
2441             Double_t sumPt1      = 0.;
2442             Float_t leadTrackPt1 = 0;
2443             
2444             TList* jettracklist2 = new TList();
2445             Double_t sumPt2      = 0.;
2446             Float_t leadTrackPt2 = 0;
2447             
2448             if(GetFFRadius()<=0)
2449               {
2450                 GetJetTracksTrackrefs(jettracklist1, jet1);
2451                 GetJetTracksTrackrefs(jettracklist2, jet2);
2452               }
2453             else
2454               {
2455                 GetJetTracksPointing(fTracksRecCuts, jettracklist1, jet1, GetFFRadius(), sumPt1);
2456                 GetJetTracksPointing(fTracksRecCuts, jettracklist2, jet2, GetFFRadius(), sumPt2);
2457               }
2458             
2459             Int_t nTracks = jettracklist1->GetSize(); 
2460             if (jettracklist1->GetSize() < jettracklist2->GetSize()) nTracks = jettracklist2->GetSize();
2461             
2462             for(Int_t it=0; it<nTracks; ++it)
2463               {
2464                 if (it < jettracklist1->GetSize())
2465                   { 
2466                     Float_t trackPt1 = (dynamic_cast<AliVParticle*> (jettracklist1->At(it)))->Pt();
2467                     Float_t jetPt1   = jet1->Pt();
2468                     
2469                     Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2470                     
2471                     fFFDiJetHistosRecCuts->FillDiJetFF(1, trackPt1, jetPt1, jetBin, incrementJetPt);
2472                     fFFDiJetHistosRecCuts->FillDiJetFF(0, trackPt1, jetPt1, jetBin, incrementJetPt);
2473                     
2474                     if (it == 0)
2475                       {
2476                         leadTrackPt1 = trackPt1;
2477                         
2478                         fFFDiJetHistosRecLeadingTrack->FillDiJetFF(1, leadTrackPt1, jetPt1, jetBin, kTRUE); 
2479                         fFFDiJetHistosRecLeadingTrack->FillDiJetFF(0, leadTrackPt1, jetPt1, jetBin, kTRUE); 
2480                       }
2481                     
2482                     fFFDiJetHistosRecLeading->FillDiJetFF(1, trackPt1, leadTrackPt1, jetBin, incrementJetPt); 
2483                     fFFDiJetHistosRecLeading->FillDiJetFF(0, trackPt1, leadTrackPt1, jetBin, incrementJetPt); 
2484                   }
2485                 
2486                 if (it < jettracklist2->GetSize())
2487                   { 
2488                     Float_t trackPt2   = (dynamic_cast<AliVParticle*>(jettracklist2->At(it)))->Pt();
2489                     Float_t jetPt2     = jet2->Pt();
2490                     
2491                     Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2492                     
2493                     fFFDiJetHistosRecCuts->FillDiJetFF(2, trackPt2, jetPt2, jetBin, incrementJetPt);
2494                     fFFDiJetHistosRecCuts->FillDiJetFF(0, trackPt2, jetPt2, jetBin, incrementJetPt);
2495                     
2496                     if (it == 0)
2497                       {
2498                         leadTrackPt2 = trackPt2;
2499                         
2500                         fFFDiJetHistosRecLeadingTrack->FillDiJetFF(2, leadTrackPt2, jetPt2, jetBin, kTRUE);
2501                         fFFDiJetHistosRecLeadingTrack->FillDiJetFF(0, leadTrackPt2, jetPt2, jetBin, kTRUE);
2502                       }
2503                     
2504                     fFFDiJetHistosRecLeading->FillDiJetFF(2, trackPt2, leadTrackPt2, jetBin, incrementJetPt);
2505                     fFFDiJetHistosRecLeading->FillDiJetFF(0, trackPt2, leadTrackPt2, jetBin, incrementJetPt);
2506                   }
2507               } // End loop on tracks
2508
2509             delete jettracklist1;
2510             delete jettracklist2;
2511
2512           } // End if(jetBin > 0)
2513         else { Printf("Jet bins for di-jet studies not set !");}
2514       } // End if(go)
2515   } // End if(nRecJets > 1)
2516
2517   if (nGenJets > 1)
2518   {
2519     AliAODJet* jet1 = dynamic_cast<AliAODJet*>(fJetsGen->At(0));
2520     AliAODJet* jet2 = dynamic_cast<AliAODJet*>(fJetsGen->At(1));
2521
2522     Double_t deltaPhi = 0;
2523     Double_t phi1 = TVector2::Phi_0_2pi(jet1->Phi());
2524     Double_t phi2 = TVector2::Phi_0_2pi(jet2->Phi());
2525     deltaPhi      = TMath::Abs(phi1-phi2); 
2526     if (deltaPhi > TMath::Pi() && deltaPhi < 2*TMath::Pi()) deltaPhi = 2*TMath::Pi() - deltaPhi;
2527
2528     Double_t Et1            = TMath::Abs(jet1->E()*TMath::Sin(jet1->Theta()));
2529     Double_t Et2            = TMath::Abs(jet2->E()*TMath::Sin(jet2->Theta()));
2530     Double_t sumEt          = Et1 + Et2;
2531     Double_t normEt1PlusEt2 = TMath::Sqrt(Et1*Et1+Et2*Et2+2*Et1*Et2*TMath::Cos(deltaPhi));
2532     Double_t ratio          = (Double_t)(normEt1PlusEt2/sumEt);
2533
2534     // DiJet events selection
2535     Bool_t positionCut       = 0;
2536     Bool_t positionEnergyCut = 0;
2537     Bool_t cdfCut            = 0; 
2538
2539     // Position cut :
2540     if (deltaPhi > fDiJetDeltaPhiCut) positionCut = 1;
2541     // Position-Energy cut :
2542     if ((deltaPhi > fDiJetDeltaPhiCut) && ((jet2->Pt()) >= fDiJetPtFractionCut*(jet1->Pt()))) positionEnergyCut = 1;
2543     // CDF cut :
2544     if (ratio < fDiJetCDFCut) cdfCut = 1;    
2545
2546     Int_t go = 0;
2547
2548     if (fDiJetCut == 1 && positionCut == 1) go = 1;
2549     if (fDiJetCut == 2 && positionEnergyCut == 1) go = 1;
2550     if (fDiJetCut == 3 && cdfCut == 1) go = 1;
2551
2552     if (go)
2553     {
2554       Double_t deltaEta      = TMath::Abs(jet1->Eta()-jet2->Eta());
2555       Double_t deltaPt       = TMath::Abs(jet1->Pt()-jet2->Pt());
2556       Double_t meanEt        = (Double_t)((Et1+Et2)/2.);
2557       Double_t invariantMass = (Double_t)InvMass(jet1,jet2);
2558
2559       Double_t jetBin = GetDiJetBin(invariantMass, jet1->Pt(), meanEt, fDiJetKindBins);
2560
2561       if(jetBin > 0)
2562       {
2563         fQADiJetHistosGen->FillDiJetQA(invariantMass, deltaPhi, deltaEta, deltaPt, jetBin);
2564
2565         TList* jettracklist1 = new TList();
2566         Double_t sumPt1 = 0.;
2567         Float_t leadTrackPt1 = 0.;
2568
2569         TList* jettracklist2 = new TList();
2570         Double_t sumPt2 = 0.;
2571         Float_t leadTrackPt2 = 0.;
2572       
2573         if(GetFFRadius()<=0)
2574         {
2575           GetJetTracksTrackrefs(jettracklist1, jet1);
2576           GetJetTracksTrackrefs(jettracklist2, jet2);
2577         }
2578         else
2579         {
2580           GetJetTracksPointing(fTracksGen, jettracklist1, jet1, GetFFRadius(), sumPt1);
2581           GetJetTracksPointing(fTracksGen, jettracklist2, jet2, GetFFRadius(), sumPt2);
2582         }
2583       
2584         Int_t nTracks = jettracklist1->GetSize(); 
2585         if (jettracklist1->GetSize() < jettracklist2->GetSize()) nTracks = jettracklist2->GetSize();
2586
2587         for(Int_t it=0; it<nTracks; ++it)
2588         {
2589           if (it < jettracklist1->GetSize())
2590           { 
2591             Float_t trackPt1 = (dynamic_cast<AliAODTrack*>(jettracklist1->At(it)))->Pt();
2592             Float_t jetPt1 = jet1->Pt();
2593
2594             Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2595
2596             fFFDiJetHistosGen->FillDiJetFF( 1, trackPt1, jetPt1, jetBin, incrementJetPt);
2597             fFFDiJetHistosGen->FillDiJetFF( 0, trackPt1, jetPt1, jetBin, incrementJetPt);
2598
2599             if(it==0)
2600             { 
2601               leadTrackPt1 = trackPt1;
2602
2603               fFFDiJetHistosGenLeadingTrack->FillDiJetFF( 1, leadTrackPt1, jetPt1, jetBin, kTRUE);
2604               fFFDiJetHistosGenLeadingTrack->FillDiJetFF( 0, leadTrackPt1, jetPt1, jetBin, kTRUE);
2605             }
2606
2607             fFFDiJetHistosGenLeading->FillDiJetFF( 1, trackPt1, leadTrackPt1, jetBin, incrementJetPt);
2608             fFFDiJetHistosGenLeading->FillDiJetFF( 0, trackPt1, leadTrackPt1, jetBin, incrementJetPt);
2609           }
2610       
2611           if (it < jettracklist2->GetSize())
2612           { 
2613             Float_t trackPt2 = (dynamic_cast<AliAODTrack*>(jettracklist2->At(it)))->Pt();
2614             Float_t jetPt2 = jet2->Pt();
2615
2616             Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2617
2618             fFFDiJetHistosGen->FillDiJetFF( 2, trackPt2, jetPt2, jetBin, incrementJetPt);
2619             fFFDiJetHistosGen->FillDiJetFF( 0, trackPt2, jetPt2, jetBin, incrementJetPt);
2620         
2621             if (it==0)
2622             { 
2623               leadTrackPt2 = trackPt2;
2624
2625               fFFDiJetHistosGenLeadingTrack->FillDiJetFF( 2, leadTrackPt2, jetPt2, jetBin, kTRUE);
2626               fFFDiJetHistosGenLeadingTrack->FillDiJetFF( 0, leadTrackPt2, jetPt2, jetBin, kTRUE);
2627             }
2628
2629             fFFDiJetHistosGenLeading->FillDiJetFF( 2, trackPt2, leadTrackPt2, jetBin, incrementJetPt);
2630             fFFDiJetHistosGenLeading->FillDiJetFF( 0, trackPt2, leadTrackPt2, jetBin, incrementJetPt);
2631           }
2632         } // End loop on tracks
2633
2634         delete jettracklist1;
2635         delete jettracklist2;
2636
2637       } // End if(jetBin > 0)
2638       else { Printf("Jet bins for di-jet studies not set !");}
2639     } // End if (go)
2640   } // End if(nGenJets > 1)
2641
2642   
2643   // ____ efficiency _______________________________
2644
2645   // arrays for generated particles: reconstructed AOD track index, isPrimary flag
2646   TArrayI indexAODTr; 
2647   TArrayS isGenPrim; 
2648   
2649   // array for reconcstructed AOD tracks: generated particle index
2650   TArrayI indexMCTr; 
2651   
2652   Int_t  nTracksAODMCCharged = GetListOfTracks(fTracksAODMCCharged, kTrackAODMCCharged);
2653   if(fDebug>2)Printf("%s:%d selected AODMC tracks: %d ",(char*)__FILE__,__LINE__,nTracksAODMCCharged);
2654   
2655   Int_t  nTracksRecQualityCuts = GetListOfTracks(fTracksRecQualityCuts, kTrackAODQualityCuts);
2656   if(fDebug>2)Printf("%s:%d selected rec tracks quality after cuts, full acceptance/pt : %d ",(char*)__FILE__,__LINE__,nTracksRecQualityCuts);
2657   
2658   // associate gen and rec tracks, store indices in TArrays 
2659   AssociateGenRec(fTracksAODMCCharged,fTracksRecQualityCuts,indexAODTr,indexMCTr,isGenPrim);
2660   
2661   // single track eff
2662   FillSingleTrackRecEffHisto(fhnSingleTrackRecEffHisto,fTracksAODMCCharged,fTracksRecQualityCuts,indexAODTr,isGenPrim);
2663
2664   // jet track eff
2665   for(Int_t ij=0; ij<nRecEffJets; ++ij){ 
2666     
2667     AliAODJet* jet = dynamic_cast<AliAODJet*>(fJetsRecEff->At(ij));
2668     
2669     if(ij==0){ // leading jet
2670       
2671       TList* jettracklist = new TList();
2672       Double_t sumPt = 0.;
2673       
2674       GetJetTracksPointing(fTracksGen, jettracklist, jet, GetFFRadius(), sumPt); // for efficiency: gen tracks from pointing with gen/rec jet
2675       
2676       Double_t jetEta = jet->Eta();
2677       Double_t jetPhi = TVector2::Phi_0_2pi(jet->Phi());
2678       Double_t jetPt  = sumPt;
2679       
2680       fQAJetHistosRecEffLeading->FillJetQA( jetEta, jetPhi, jetPt );
2681       FillJetTrackRecEffHisto(fhnJetTrackRecEffHisto,jetPhi,jetEta,jetPt,jettracklist,fTracksAODMCCharged,indexAODTr,isGenPrim);
2682       
2683       delete jettracklist;
2684     }
2685   }
2686    
2687   //___________________
2688   
2689   fTracksRec->Clear();
2690   fTracksRecCuts->Clear();
2691   fTracksGen->Clear();
2692   fTracksAODMCCharged->Clear();
2693   fTracksRecQualityCuts->Clear();
2694
2695   fJetsRec->Clear();
2696   fJetsRecCuts->Clear();
2697   fJetsGen->Clear();
2698   fJetsRecEff->Clear();
2699
2700   //Post output data.
2701   PostData(1, fCommonHistList);
2702   
2703 }
2704
2705 //________________________________________________________________________________________
2706 Double_t AliAnalysisTaskFragmentationFunction::InvMass(AliAODJet* jet1, AliAODJet* jet2)
2707 {
2708
2709   Double_t invMass = 0.;
2710   invMass = TMath::Sqrt(pow(jet1->E()+jet2->E(),2) - pow(jet1->Px()+jet2->Px(),2) - 
2711                         pow(jet1->Py()+jet2->Py(),2) - pow(jet1->Pz()+jet2->Pz(),2));
2712
2713   return invMass;
2714
2715 }
2716
2717 //________________________________________________________________________________________
2718 Double_t AliAnalysisTaskFragmentationFunction::GetDiJetBin(Double_t invMass, Double_t leadingJetPt, Double_t EtMean, Int_t kindBins)
2719 {
2720   Double_t jetBinOk = 0.;
2721   Double_t jetBin = 0.;
2722
2723   Float_t stepInvMass = (fDiJetJetInvMassMax - fDiJetJetInvMassMin)/fDiJetNBinsJetInvMass;
2724   Float_t stepPt = (fDiJetJetPtMax - fDiJetJetPtMin)/fDiJetNBinsJetPt;
2725
2726   if (kindBins == 1)
2727     {
2728       for(Int_t i=0; i<fDiJetNBinsJetInvMass; ++i)
2729         {
2730           jetBin = fDiJetJetInvMassMin + i*stepInvMass/2.;
2731           if(((fDiJetJetInvMassMin+i*stepInvMass) <= invMass) &&
2732              (fDiJetJetInvMassMin + (i+1)*stepInvMass) > invMass) jetBinOk = jetBin;
2733         }
2734       jetBinOk = -1.;
2735     }
2736   else if (kindBins == 3)
2737     {
2738       for(Int_t i=0; i<fDiJetNBinsJetPt; ++i)
2739         {
2740           jetBin = fDiJetJetPtMin + i*stepPt/2.;
2741           if(((fDiJetJetPtMin+i*stepPt) <= EtMean) &&
2742              (fDiJetJetPtMin + (i+1)*stepPt) > EtMean) jetBinOk = jetBin;
2743         }
2744       jetBinOk = -1.;
2745     }
2746   else if (kindBins == 2)
2747     {
2748       for(Int_t i=0; i<fDiJetNBinsJetPt; ++i)
2749         {
2750           jetBin = fDiJetJetPtMin + i*stepPt/2.;
2751           if(((fDiJetJetPtMin+i*stepPt) <= leadingJetPt) &&
2752              (fDiJetJetPtMin + (i+1)*stepPt) > leadingJetPt) jetBinOk = jetBin;
2753         }
2754       jetBinOk = -1.;
2755     }
2756   else {Printf("WARNING: kindBins wrongly set ! Please make sure to call SetKindSlices() and set the kind parameter to 1, 2 or 3.\n");}
2757
2758   return jetBinOk;
2759
2760 }
2761
2762
2763 //______________________________________________________________
2764 void AliAnalysisTaskFragmentationFunction::Terminate(Option_t *) 
2765 {
2766   // terminated
2767
2768   if(fDebug > 1) printf("AliAnalysisTaskFragmentationFunction::Terminate() \n");
2769 }  
2770
2771 //_________________________________________________________________________________
2772 Int_t AliAnalysisTaskFragmentationFunction::GetListOfTracks(TList *list, Int_t type)
2773 {
2774   // fill list of tracks selected according to type
2775
2776   if(fDebug > 2) Printf("%s:%d Selecting tracks with %d", (char*)__FILE__,__LINE__,type);
2777   
2778   if(!list){
2779     if(fDebug>1) Printf("%s:%d no input list", (char*)__FILE__,__LINE__);
2780     return -1;
2781   }
2782
2783   if(type==kTrackUndef) return 0;
2784   
2785   Int_t iCount = 0;
2786   if(type==kTrackAODCuts || type==kTrackAOD){
2787
2788     // all rec. tracks, esd filter mask, eta range
2789     if(!fAOD) return -1;
2790     
2791     for(Int_t it=0; it<fAOD->GetNumberOfTracks(); ++it){
2792       AliAODTrack *tr = fAOD->GetTrack(it);
2793       
2794       if(type == kTrackAODCuts){
2795         if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))   continue;
2796         if(tr->Eta() < fTrackEtaMin || tr->Eta() > fTrackEtaMax) continue;
2797         if(tr->Phi() < fTrackPhiMin || tr->Phi() > fTrackPhiMax) continue;
2798         if(tr->Pt()  < fTrackPtCut) continue;
2799       }
2800       list->Add(tr);
2801       iCount++;
2802     }
2803   }
2804   else if (type==kTrackKineAll || type==kTrackKineCharged || type==kTrackKineChargedAcceptance){
2805     // kine particles, all or rather charged
2806     if(!fMCEvent) return iCount;
2807     
2808     for(Int_t it=0; it<fMCEvent->GetNumberOfTracks(); ++it){
2809       AliMCParticle* part = (AliMCParticle*) fMCEvent->GetTrack(it);
2810       
2811       if(type == kTrackKineCharged || type == kTrackKineChargedAcceptance){
2812         if(part->Charge()==0) continue;
2813         
2814         if(type == kTrackKineChargedAcceptance && 
2815            (       part->Eta() < fTrackEtaMin
2816                 || part->Eta() > fTrackEtaMax
2817                 || part->Phi() < fTrackPhiMin
2818                 || part->Phi() > fTrackPhiMax 
2819                 || part->Pt()  < fTrackPtCut)) continue;
2820       }
2821       
2822       list->Add(part);
2823       iCount++;
2824     }
2825   }
2826   else if (type==kTrackAODMCCharged || type==kTrackAODMCAll || type==kTrackAODMCChargedAcceptance) {
2827     // MC particles (from AOD), physical primaries, all or rather charged or rather charged within acceptance
2828     if(!fAOD) return -1;
2829     
2830     TClonesArray *tca = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName()));
2831     if(!tca)return iCount;
2832     
2833     for(int it=0; it<tca->GetEntriesFast(); ++it){
2834       AliAODMCParticle *part = dynamic_cast<AliAODMCParticle*>(tca->At(it));
2835       if(!part->IsPhysicalPrimary())continue;
2836       
2837       if (type==kTrackAODMCCharged || type==kTrackAODMCChargedAcceptance){
2838         if(part->Charge()==0) continue;
2839         if(type==kTrackAODMCChargedAcceptance && 
2840            (     part->Eta() > fTrackEtaMax
2841               || part->Eta() < fTrackEtaMin
2842               || part->Phi() > fTrackPhiMax
2843               || part->Phi() < fTrackPhiMin
2844               || part->Pt()  < fTrackPtCut)) continue;
2845       }
2846       
2847       list->Add(part);
2848       iCount++;
2849     }
2850   }
2851   
2852   list->Sort();
2853   return iCount;
2854   
2855 }
2856 // _______________________________________________________________________________
2857 Int_t AliAnalysisTaskFragmentationFunction::GetListOfJets(TList *list, Int_t type)
2858 {
2859   // fill list of jets selected according to type
2860   
2861   if(!list){
2862     if(fDebug>1) Printf("%s:%d no input list", (char*)__FILE__,__LINE__);
2863     return -1;
2864   }
2865
2866   if(type == kJetsRec || type == kJetsRecAcceptance){ // reconstructed jets
2867
2868     if(fBranchRecJets.Length()==0){
2869       Printf("%s:%d no rec jet branch specified", (char*)__FILE__,__LINE__);
2870       if(fDebug>1)fAOD->Print();
2871       return 0;
2872     }
2873
2874     TClonesArray *aodRecJets = new TClonesArray();
2875     if(fBranchRecJets.Length()) aodRecJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchRecJets.Data()));\r
2876     if(!aodRecJets)             aodRecJets = dynamic_cast<TClonesArray*>(fAOD->GetList()->FindObject(fBranchRecJets.Data()));\r
2877
2878     if(!aodRecJets){
2879       if(fBranchRecJets.Length()) Printf("%s:%d no reconstructed jet array with name %s in AOD", (char*)__FILE__,__LINE__,fBranchRecJets.Data());
2880
2881       if(fDebug>1)fAOD->Print();
2882       return 0;
2883     }
2884
2885     Int_t nRecJets = 0;
2886     
2887     for(Int_t ij=0; ij<aodRecJets->GetEntries(); ++ij){
2888
2889       AliAODJet *tmp = dynamic_cast<AliAODJet*>(aodRecJets->At(ij));
2890       if(!tmp) continue;
2891         
2892       if( tmp->Pt() < fJetPtCut ) continue;
2893       if( type == kJetsRecAcceptance &&
2894           (    tmp->Eta() < fJetEtaMin
2895             || tmp->Eta() > fJetEtaMax
2896             || tmp->Phi() < fJetPhiMin
2897             || tmp->Phi() > fJetPhiMax )) continue;
2898       
2899       list->Add(tmp);
2900           
2901       nRecJets++;
2902     }
2903
2904     list->Sort();
2905     return nRecJets;
2906     delete aodRecJets;
2907   }
2908   else if(type == kJetsKine || type == kJetsKineAcceptance){
2909     
2910     // generated jets
2911     Int_t nGenJets = 0;
2912     
2913     if(!fMCEvent){
2914       if(fDebug>1) Printf("%s:%d no mcEvent",(char*)__FILE__,__LINE__);
2915       return 0;
2916     }
2917     
2918     AliGenPythiaEventHeader*  pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(fMCEvent);
2919     if(!pythiaGenHeader){
2920       Printf("%s:%d no pythiaGenHeader found", (char*)__FILE__,__LINE__);
2921       return 0;
2922     }
2923     
2924     // fetch the pythia generated jets
2925     for(int ip=0; ip<pythiaGenHeader->NTriggerJets(); ++ip){
2926       
2927       Float_t p[4];
2928       AliAODJet *jet = new AliAODJet();
2929       pythiaGenHeader->TriggerJet(ip, p);
2930       jet->SetPxPyPzE(p[0], p[1], p[2], p[3]);
2931
2932       if( type == kJetsKineAcceptance &&
2933           (    jet->Eta() < fJetEtaMin
2934             || jet->Eta() > fJetEtaMax
2935             || jet->Phi() < fJetPhiMin
2936             || jet->Phi() > fJetPhiMax )) continue;
2937       
2938       list->Add(jet);
2939       nGenJets++;
2940     }
2941     list->Sort();
2942     return nGenJets;
2943   }
2944   else if(type == kJetsGen || type == kJetsGenAcceptance ){
2945
2946     if(fBranchGenJets.Length()==0){
2947       if(fDebug>1) Printf("%s:%d no gen jet branch specified", (char*)__FILE__,__LINE__);
2948       return 0;
2949     }
2950     
2951     TClonesArray *aodGenJets = new TClonesArray();
2952     if(fBranchGenJets.Length()) aodGenJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchGenJets.Data()));\r
2953     if(!aodGenJets)             aodGenJets = dynamic_cast<TClonesArray*>(fAOD->GetList()->FindObject(fBranchGenJets.Data()));\r
2954
2955     if(!aodGenJets){
2956       if(fDebug>0){
2957         if(fBranchGenJets.Length())         Printf("%s:%d Generated jet branch %s not found",(char*)__FILE__,__LINE__,fBranchGenJets.Data());
2958       }
2959       if(fDebug>1)fAOD->Print();
2960       return 0;
2961     }
2962
2963     Int_t nGenJets = 0;
2964     
2965     for(Int_t ig=0; ig<aodGenJets->GetEntries(); ++ig){
2966           
2967       AliAODJet *tmp = dynamic_cast<AliAODJet*>(aodGenJets->At(ig));
2968       if(!tmp) continue;
2969           
2970       if( tmp->Pt() < fJetPtCut ) continue;
2971       if( type == kJetsGenAcceptance &&
2972           (    tmp->Eta() < fJetEtaMin
2973             || tmp->Eta() > fJetEtaMax
2974             || tmp->Phi() < fJetPhiMin
2975             || tmp->Phi() > fJetPhiMax )) continue;
2976       
2977       list->Add(tmp);
2978       
2979       nGenJets++;
2980     }
2981     list->Sort();
2982     return nGenJets;
2983     delete aodGenJets;
2984   } 
2985   else{
2986     if(fDebug>0)Printf("%s:%d no such type %d",(char*)__FILE__,__LINE__,type);
2987     return 0;
2988   }
2989 }
2990
2991 // _________________________________________________________________________________________________________
2992 void AliAnalysisTaskFragmentationFunction::SetProperties(THnSparse* h,const Int_t dim, const char** labels)
2993 {
2994   //Set properties of THnSparse 
2995
2996   for(Int_t i=0; i<dim; i++){
2997
2998     h->GetAxis(i)->SetTitle(labels[i]);
2999     h->GetAxis(i)->SetTitleColor(1);
3000   }
3001 }
3002
3003 // __________________________________________________________________________________________
3004 void AliAnalysisTaskFragmentationFunction::SetProperties(TH1* h,const char* x, const char* y)
3005 {
3006   //Set properties of histos (x and y title)
3007
3008   h->SetXTitle(x);
3009   h->SetYTitle(y);
3010   h->GetXaxis()->SetTitleColor(1);
3011   h->GetYaxis()->SetTitleColor(1);
3012 }
3013
3014 // _________________________________________________________________________________________________________
3015 void AliAnalysisTaskFragmentationFunction::SetProperties(TH2* h,const char* x, const char* y, const char* z)
3016 {
3017   //Set properties of histos (x,y and z title)
3018
3019   h->SetXTitle(x);
3020   h->SetYTitle(y);
3021   h->SetZTitle(z);
3022   h->GetXaxis()->SetTitleColor(1);
3023   h->GetYaxis()->SetTitleColor(1);
3024   h->GetZaxis()->SetTitleColor(1);
3025 }
3026
3027 // ________________________________________________________________________________________________________________________________________________________
3028 void AliAnalysisTaskFragmentationFunction::GetJetTracksPointing(TList* inputlist, TList* outputlist, AliAODJet* jet, const Double_t radius,Double_t& sumPt)
3029 {
3030   // fill list of tracks in cone around jet axis  
3031
3032   sumPt = 0;
3033
3034   Double_t jetMom[3];
3035   jet->PxPyPz(jetMom);
3036   TVector3 jet3mom(jetMom);
3037
3038   for (Int_t itrack=0; itrack<inputlist->GetSize(); itrack++){
3039
3040     AliVParticle* track = dynamic_cast<AliVParticle*>(inputlist->At(itrack));
3041
3042     Double_t trackMom[3];
3043     track->PxPyPz(trackMom);
3044     TVector3 track3mom(trackMom);
3045
3046     Double_t dR = jet3mom.DeltaR(track3mom);
3047
3048     if(dR<radius){
3049
3050       outputlist->Add(track);
3051       
3052       sumPt += track->Pt();
3053     }
3054   }
3055   
3056   outputlist->Sort();
3057 }
3058
3059 // ___________________________________________________________________________________________
3060 void AliAnalysisTaskFragmentationFunction::GetJetTracksTrackrefs(TList* list, AliAODJet* jet)
3061 {
3062   // list of jet tracks from trackrefs
3063   
3064   Int_t nTracks = jet->GetRefTracks()->GetEntriesFast();
3065
3066   for (Int_t itrack=0; itrack<nTracks; itrack++) {
3067     
3068     AliVParticle* track = dynamic_cast<AliVParticle*>(jet->GetRefTracks()->At(itrack));
3069     if(!track){
3070       AliError("expected ref track not found ");
3071       continue;
3072     }
3073         
3074     list->Add(track);
3075   }
3076   
3077   list->Sort();
3078 }
3079
3080 // _ ________________________________________________________________________________________________________________________________
3081 void  AliAnalysisTaskFragmentationFunction::AssociateGenRec(TList* tracksAODMCCharged,TList* tracksRec, TArrayI& indexAODTr,TArrayI& indexMCTr,TArrayS& isGenPrim)
3082 {
3083   // associate generated and reconstructed tracks, fill TArrays of list indices
3084
3085
3086   Int_t nTracksRec  = tracksRec->GetSize();
3087   Int_t nTracksGen  = tracksAODMCCharged->GetSize();
3088   TClonesArray *tca = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName()));
3089
3090   if(!nTracksGen) return;
3091   if(!tca)        return;
3092   
3093   // set size
3094   indexAODTr.Set(nTracksGen);
3095   indexMCTr.Set(nTracksRec);
3096   isGenPrim.Set(nTracksGen);
3097
3098   indexAODTr.Reset(-1);
3099   indexMCTr.Reset(-1);
3100   isGenPrim.Reset(0);
3101
3102   // loop over reconstructed tracks, get generated track 
3103
3104   for(Int_t iRec=0; iRec<nTracksRec; iRec++){ 
3105       
3106     AliAODTrack* rectrack = dynamic_cast<AliAODTrack*>(tracksRec->At(iRec)); 
3107
3108     Int_t label = rectrack->GetLabel();
3109
3110     // find MC track in our list
3111     AliAODMCParticle* gentrack = 0x0;
3112     if(label>=0) gentrack = dynamic_cast<AliAODMCParticle*> (tca->At(label));
3113
3114     Int_t listIndex = -1;
3115     if(gentrack) listIndex = tracksAODMCCharged->IndexOf(gentrack);
3116
3117     if(listIndex>=0){
3118
3119       indexAODTr[listIndex] = iRec;
3120       indexMCTr[iRec]       = listIndex;
3121     }
3122   } 
3123
3124
3125   // define primary sample for reconstruction efficiency
3126
3127   for(Int_t iGen=0; iGen<nTracksGen; iGen++){
3128
3129     AliAODMCParticle* gentrack =  dynamic_cast<AliAODMCParticle*> (tracksAODMCCharged->At(iGen));
3130
3131     Int_t pdg = gentrack->GetPdgCode();    
3132
3133     // 211 - pi, 2212 - proton, 321 - Kaon, 11 - electron, 13 - muon
3134     if(TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == 321 || 
3135        TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13){
3136       
3137       isGenPrim[iGen] = kTRUE;
3138     }
3139   }
3140 }
3141
3142 // _____________________________________________________________________________________________________________________________________________
3143 void AliAnalysisTaskFragmentationFunction::FillSingleTrackRecEffHisto(THnSparse* histo, TList* tracksGen, TList* tracksRec, TArrayI& indexAODTr, TArrayS& isGenPrim){
3144
3145   // fill THnSparse for single track reconstruction efficiency
3146
3147   Int_t nTracksGen  = tracksGen->GetSize();
3148
3149   if(!nTracksGen) return;
3150
3151   for(Int_t iGen=0; iGen<nTracksGen; iGen++){
3152
3153     if(isGenPrim[iGen] != 1) continue; // select primaries
3154
3155     AliAODMCParticle* gentrack =  dynamic_cast<AliAODMCParticle*> (tracksGen->At(iGen));
3156     
3157     Double_t ptGen  = gentrack->Pt();
3158     Double_t etaGen = gentrack->Eta();
3159     Double_t phiGen = TVector2::Phi_0_2pi(gentrack->Phi());
3160
3161     // apply same acc & pt cuts as for FF 
3162     // could in principle also be done setting THNsparse axis limits before projecting, 
3163     // but then the binning needs to be fine grained enough 
3164
3165     if(etaGen < fTrackEtaMin || etaGen > fTrackEtaMax) continue;
3166     if(phiGen < fTrackPhiMin || phiGen > fTrackPhiMax) continue;
3167     if(ptGen  < fTrackPtCut) continue;
3168
3169     Int_t iRec = indexAODTr[iGen]; // can be -1 if no good reconstructed track 
3170     Double_t isRec =  0;
3171     Double_t ptRec = -1;
3172
3173     if(iRec>=0){
3174
3175       AliAODTrack* rectrack = dynamic_cast<AliAODTrack*>(tracksRec->At(iRec)); 
3176       ptRec = rectrack->Pt();
3177       isRec = 1;
3178     }
3179
3180     Double_t entries[5] = {phiGen,etaGen,ptGen,ptRec,isRec};
3181     histo->Fill(entries);
3182   }
3183 }
3184
3185 // ______________________________________________________________________________________________________________________________________________________
3186 void AliAnalysisTaskFragmentationFunction::FillJetTrackRecEffHisto(THnSparse* histo,Double_t jetPhi, Double_t jetEta, Double_t jetPt, TList* jetTrackList, 
3187                                                                    TList* tracksGen, TArrayI& indexAODTr, TArrayS& isGenPrim)
3188 {
3189   // fill THnSparse for jet track reconstruction efficiency
3190
3191   Int_t nTracksJet = jetTrackList->GetSize(); // list with AODMC tracks
3192
3193   if(!nTracksJet) return; 
3194
3195   for(Int_t iTr=0; iTr<nTracksJet; iTr++){
3196
3197     AliAODMCParticle* gentrack =  dynamic_cast<AliAODMCParticle*> (jetTrackList->At(iTr));
3198
3199     // find jet track in gen tracks list
3200     Int_t iGen = tracksGen->IndexOf(gentrack); 
3201
3202     if(iGen<0){
3203       if(fDebug>0) Printf("%s:%d gen jet track not found ",(char*)__FILE__,__LINE__);
3204       continue;
3205     }
3206
3207     if(isGenPrim[iGen] != 1) continue; // select primaries
3208     
3209     Double_t ptGen  = gentrack->Pt();
3210     Double_t etaGen = gentrack->Eta();
3211     Double_t phiGen = TVector2::Phi_0_2pi(gentrack->Phi());
3212
3213     // apply same acc & pt cuts as for FF 
3214     // could in principle also be done setting THNsparse axis limits before projecting, 
3215     // but then the binning needs to be fine grained enough 
3216
3217     if(etaGen < fTrackEtaMin || etaGen > fTrackEtaMax) continue;
3218     if(phiGen < fTrackPhiMin || phiGen > fTrackPhiMax) continue;
3219     if(ptGen  < fTrackPtCut) continue;
3220
3221     Double_t z = ptGen / jetPt;
3222     Double_t xi = 0;
3223     if(z>0) xi = TMath::Log(1/z);
3224
3225     Double_t isRec =  0;
3226     Int_t iRec = indexAODTr[iGen]; // can be -1 if no good reconstructed track 
3227     if(iRec>=0) isRec = 1;
3228
3229     Double_t entries[7] = {jetPhi,jetEta,jetPt,ptGen,z,xi,isRec};
3230     histo->Fill(entries);
3231   }
3232 }