Limit printout from the helper task,Spectrum: Change range for jet shape, include...
[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   Bool_t genJets    = (fJetTypeGen != kJetsUndef) ? kTRUE : kFALSE;
2005   Bool_t genTracks  = (fTrackTypeGen != kTrackUndef) ? kTRUE : kFALSE;
2006   Bool_t recJetsEff = (fJetTypeRecEff != kJetsUndef) ? kTRUE : kFALSE;
2007
2008
2009   const Int_t saveLevel = 5;
2010   if(saveLevel>0){
2011     fCommonHistList->Add(fh1EvtSelection);
2012     fFFHistosRecCuts->AddToOutput(fCommonHistList);
2013     fFFHistosRecLeading->AddToOutput(fCommonHistList);
2014     fFFHistosRecLeadingTrack->AddToOutput(fCommonHistList);
2015
2016     if(genJets && genTracks){
2017        fFFHistosGen->AddToOutput(fCommonHistList);
2018        fFFHistosGenLeading->AddToOutput(fCommonHistList);
2019        fFFHistosGenLeadingTrack->AddToOutput(fCommonHistList);
2020     }
2021   }
2022   if(saveLevel>1){
2023     fQATrackHistosRec->AddToOutput(fCommonHistList);
2024     fQATrackHistosRecCuts->AddToOutput(fCommonHistList);
2025     if(genTracks) fQATrackHistosGen->AddToOutput(fCommonHistList);
2026     
2027     fQAJetHistosRec->AddToOutput(fCommonHistList);
2028     fQAJetHistosRecCuts->AddToOutput(fCommonHistList);
2029     fQAJetHistosRecCutsLeading->AddToOutput(fCommonHistList);
2030     if(recJetsEff) fQAJetHistosRecEffLeading->AddToOutput(fCommonHistList); 
2031
2032     if(genJets){
2033        fQAJetHistosGen->AddToOutput(fCommonHistList);
2034        fQAJetHistosGenLeading->AddToOutput(fCommonHistList);
2035     }
2036
2037     fCommonHistList->Add(fh1EvtMult);
2038     fCommonHistList->Add(fh1nRecJetsCuts);
2039     if(genJets) fCommonHistList->Add(fh1nGenJets);
2040   }
2041   if(saveLevel>2){
2042     fCommonHistList->Add(fh1VertexNContributors);
2043     fCommonHistList->Add(fh1VertexZ);    
2044   }
2045   if(saveLevel>3){
2046     fIJHistosRecCuts->AddToOutput(fCommonHistList);
2047     fIJHistosRecLeading->AddToOutput(fCommonHistList);
2048     fIJHistosRecLeadingTrack->AddToOutput(fCommonHistList);
2049
2050     if(genJets && genTracks){
2051        fIJHistosGen->AddToOutput(fCommonHistList);
2052        fIJHistosGenLeading->AddToOutput(fCommonHistList);
2053        fIJHistosGenLeadingTrack->AddToOutput(fCommonHistList);
2054     }
2055   }
2056   if(saveLevel>4){
2057     fFFDiJetHistosRecCuts->AddToOutput(fCommonHistList);
2058     fFFDiJetHistosRecLeading->AddToOutput(fCommonHistList);
2059     fFFDiJetHistosRecLeadingTrack->AddToOutput(fCommonHistList);
2060     fQADiJetHistosRecCuts->AddToOutput(fCommonHistList);
2061
2062     if(genJets && genTracks){
2063         fFFDiJetHistosGen->AddToOutput(fCommonHistList);
2064         fFFDiJetHistosGenLeading->AddToOutput(fCommonHistList);
2065         fFFDiJetHistosGenLeadingTrack->AddToOutput(fCommonHistList);
2066         fQADiJetHistosGen->AddToOutput(fCommonHistList);
2067     }
2068
2069     if(recJetsEff && genTracks){
2070        fCommonHistList->Add(fhnSingleTrackRecEffHisto);
2071        fCommonHistList->Add(fhnJetTrackRecEffHisto);
2072        fCommonHistList->Add(fh1nRecEffJets);
2073     }
2074   }
2075
2076   // =========== Switch on Sumw2 for all histos ===========
2077   for (Int_t i=0; i<fCommonHistList->GetEntries(); ++i){
2078     TH1 *h1 = dynamic_cast<TH1*>(fCommonHistList->At(i));
2079     if (h1) h1->Sumw2();
2080     else{
2081       THnSparse *hnSparse = dynamic_cast<THnSparse*>(fCommonHistList->At(i));
2082       if(hnSparse) hnSparse->Sumw2();
2083     }
2084   }
2085   
2086   TH1::AddDirectory(oldStatus);
2087 }
2088
2089 //_______________________________________________
2090 void AliAnalysisTaskFragmentationFunction::Init()
2091 {
2092   // Initialization
2093   if(fDebug > 1) Printf("AliAnalysisTaskFragmentationFunction::Init()");
2094
2095 }
2096
2097 //_____________________________________________________________
2098 void AliAnalysisTaskFragmentationFunction::UserExec(Option_t *) 
2099 {
2100   // Main loop
2101   // Called for each event
2102   if(fDebug > 1) Printf("AliAnalysisTaskFragmentationFunction::UserExec()");
2103         
2104
2105   if(fDebug > 1) Printf("Analysis event #%5d", (Int_t) fEntry);
2106   // Trigger selection
2107   
2108   AliInputEventHandler* inputHandler = (AliInputEventHandler*)
2109     ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
2110   if(inputHandler->IsEventSelected() & AliVEvent::kMB){
2111     if(fDebug > 1)  Printf(" Trigger Selection: event ACCEPTED ... ");
2112     fh1EvtSelection->Fill(1.);
2113   } else {
2114     fh1EvtSelection->Fill(0.);
2115     if(inputHandler->InheritsFrom("AliESDInputHandler")){ // PhysicsSelection only with ESD input
2116       if (fDebug > 1 ) Printf(" Trigger Selection: event REJECTED ... ");
2117       PostData(1, fCommonHistList);
2118       return;
2119     }
2120   }
2121   
2122   fESD = dynamic_cast<AliESDEvent*>(InputEvent());
2123   if(!fESD){
2124     if(fDebug>3) Printf("%s:%d ESDEvent not found in the input", (char*)__FILE__,__LINE__);
2125   }
2126   
2127   fMCEvent = MCEvent();
2128   if(!fMCEvent){
2129     if(fDebug>3) Printf("%s:%d MCEvent not found in the input", (char*)__FILE__,__LINE__);
2130   }
2131   
2132   // get AOD event from input/ouput
2133   TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
2134   if( handler && handler->InheritsFrom("AliAODInputHandler") ) {
2135     fAOD  =  ((AliAODInputHandler*)handler)->GetEvent();
2136     if (fDebug > 1)  Printf("%s:%d AOD event from input", (char*)__FILE__,__LINE__);
2137   }
2138   else {
2139     handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
2140     if( handler && handler->InheritsFrom("AliAODHandler") ) {
2141       fAOD  = ((AliAODHandler*)handler)->GetAOD();
2142       if (fDebug > 1)  Printf("%s:%d AOD event from output", (char*)__FILE__,__LINE__);
2143     }
2144   }
2145   
2146   if(!fAOD){
2147     Printf("%s:%d AODEvent not found", (char*)__FILE__,__LINE__);
2148     return;
2149   }
2150   
2151
2152   // event selection (vertex) *****************************************
2153   
2154   AliAODVertex* primVtx = fAOD->GetPrimaryVertex();
2155   Int_t nTracksPrim = primVtx->GetNContributors();
2156   fh1VertexNContributors->Fill(nTracksPrim);
2157   
2158   if (fDebug > 1) Printf("%s:%d primary vertex selection: %d", (char*)__FILE__,__LINE__,nTracksPrim);
2159   if(!nTracksPrim){
2160     if (fDebug > 1) Printf("%s:%d primary vertex selection: event REJECTED...",(char*)__FILE__,__LINE__); 
2161     fh1EvtSelection->Fill(2.);
2162     PostData(1, fCommonHistList);
2163     return;
2164   }
2165
2166   fh1VertexZ->Fill(primVtx->GetZ());
2167   
2168   if(TMath::Abs(primVtx->GetZ())>10){
2169     if (fDebug > 1) Printf("%s:%d primary vertex z = %f: event REJECTED...",(char*)__FILE__,__LINE__,primVtx->GetZ()); 
2170     fh1EvtSelection->Fill(3.);
2171     PostData(1, fCommonHistList);
2172     return; 
2173   }
2174
2175   TString primVtxName(primVtx->GetName());
2176
2177   if(primVtxName.CompareTo("TPCVertex",TString::kIgnoreCase) == 1){
2178     if (fDebug > 1) Printf("%s:%d primary vertex selection: TPC vertex, event REJECTED...",(char*)__FILE__,__LINE__);
2179     fh1EvtSelection->Fill(4.);
2180     PostData(1, fCommonHistList);
2181     return;
2182   }
2183   if (fDebug > 1) Printf("%s:%d primary vertex selection: event ACCEPTED ...",(char*)__FILE__,__LINE__); 
2184   fh1EvtSelection->Fill(5.);
2185   
2186   
2187   //___ fetch jets __________________________________________________________________________
2188   
2189   Int_t nJ = GetListOfJets(fJetsRec, kJetsRec);
2190   Int_t nRecJets = 0;
2191   if(nJ>=0) nRecJets = fJetsRec->GetEntries();
2192   if(fDebug>2)Printf("%s:%d Selected Rec jets: %d %d",(char*)__FILE__,__LINE__,nJ,nRecJets);
2193   if(nJ != nRecJets) Printf("%s:%d Mismatch Selected Rec Jets: %d %d",(char*)__FILE__,__LINE__,nJ,nRecJets);
2194
2195   Int_t nJCuts = GetListOfJets(fJetsRecCuts, kJetsRecAcceptance);
2196   Int_t nRecJetsCuts = 0;
2197   if(nJCuts>=0) nRecJetsCuts = fJetsRecCuts->GetEntries();
2198   if(fDebug>2)Printf("%s:%d Selected Rec jets after cuts: %d %d",(char*)__FILE__,__LINE__,nJCuts,nRecJetsCuts);
2199   if(nRecJetsCuts != nJCuts) Printf("%s:%d Mismatch selected Rec jets after cuts: %d %d",(char*)__FILE__,__LINE__,nJCuts,nRecJetsCuts);
2200   fh1nRecJetsCuts->Fill(nRecJetsCuts);
2201
2202   
2203   if(fJetTypeGen==kJetsKine || fJetTypeGen == kJetsKineAcceptance) fJetsGen->SetOwner(kTRUE); // kine aod jets allocated on heap, delete them with TList::Clear() 
2204   Int_t nJGen  = GetListOfJets(fJetsGen, fJetTypeGen);
2205   Int_t nGenJets = 0;
2206   if(nJGen>=0) nGenJets = fJetsGen->GetEntries();
2207   if(fDebug>2)Printf("%s:%d Selected Gen jets: %d %d",(char*)__FILE__,__LINE__,nJGen,nGenJets);
2208   if(nJGen != nGenJets) Printf("%s:%d Mismatch selected Gen jets: %d %d",(char*)__FILE__,__LINE__,nJGen,nGenJets);
2209   fh1nGenJets->Fill(nGenJets);
2210
2211
2212   if(fJetTypeRecEff==kJetsKine || fJetTypeRecEff == kJetsKineAcceptance) fJetsRecEff->SetOwner(kTRUE); // kine aod jets allocated on heap, delete them with TList::Clear() 
2213   Int_t nJRecEff  = GetListOfJets(fJetsRecEff, fJetTypeRecEff);
2214   Int_t nRecEffJets = 0;
2215   if(nJRecEff>=0) nRecEffJets = fJetsRecEff->GetEntries();
2216   if(fDebug>2)Printf("%s:%d Selected RecEff jets: %d %d",(char*)__FILE__,__LINE__,nJRecEff,nRecEffJets);
2217   if(nJRecEff != nRecEffJets) Printf("%s:%d Mismatch selected RecEff jets: %d %d",(char*)__FILE__,__LINE__,nJRecEff,nRecEffJets);
2218   fh1nRecEffJets->Fill(nRecEffJets);
2219
2220
2221   //____ fetch particles __________________________________________________________
2222   
2223   Int_t nT = GetListOfTracks(fTracksRec, kTrackAOD);
2224   Int_t nRecPart = 0;
2225   if(nT>=0) nRecPart = fTracksRec->GetEntries();
2226   if(fDebug>2)Printf("%s:%d Selected Rec tracks: %d %d",(char*)__FILE__,__LINE__,nT,nRecPart);
2227   if(nRecPart != nT) Printf("%s:%d Mismatch selected Rec tracks: %d %d",(char*)__FILE__,__LINE__,nT,nRecPart);
2228   
2229
2230   Int_t nTCuts = GetListOfTracks(fTracksRecCuts, kTrackAODCuts);
2231   Int_t nRecPartCuts = 0;
2232   if(nTCuts>=0) nRecPartCuts = fTracksRecCuts->GetEntries();
2233   if(fDebug>2)Printf("%s:%d Selected Rec tracks after cuts: %d %d",(char*)__FILE__,__LINE__,nTCuts,nRecPartCuts);
2234   if(nRecPartCuts != nTCuts) Printf("%s:%d Mismatch selected Rec tracks after cuts: %d %d",(char*)__FILE__,__LINE__,nTCuts,nRecPartCuts);
2235   fh1EvtMult->Fill(nRecPartCuts);
2236
2237
2238   Int_t nTGen = GetListOfTracks(fTracksGen,fTrackTypeGen);
2239   Int_t nGenPart = 0;
2240   if(nTGen>=0) nGenPart = fTracksGen->GetEntries();
2241   if(fDebug>2)Printf("%s:%d Selected Gen tracks: %d %d",(char*)__FILE__,__LINE__,nTGen,nGenPart);
2242   if(nGenPart != nTGen) Printf("%s:%d Mismatch selected Gen tracks: %d %d",(char*)__FILE__,__LINE__,nTGen,nGenPart);
2243   
2244   
2245   //____ analysis, fill histos ___________________________________________________
2246   
2247   // loop over tracks
2248
2249   for(Int_t it=0; it<nRecPart; ++it){
2250     AliVParticle *part = dynamic_cast<AliVParticle*>(fTracksRec->At(it));
2251     fQATrackHistosRec->FillTrackQA( part->Eta(), TVector2::Phi_0_2pi(part->Phi()), part->Pt());
2252   }
2253   for(Int_t it=0; it<nRecPartCuts; ++it){
2254     AliVParticle *part = dynamic_cast<AliVParticle*>(fTracksRecCuts->At(it));
2255     fQATrackHistosRecCuts->FillTrackQA( part->Eta(), TVector2::Phi_0_2pi(part->Phi()), part->Pt());
2256   }
2257   for(Int_t it=0; it<nGenPart; ++it){
2258     AliVParticle *part = dynamic_cast<AliVParticle*>(fTracksGen->At(it));
2259     fQATrackHistosGen->FillTrackQA( part->Eta(), TVector2::Phi_0_2pi(part->Phi()), part->Pt());
2260   }
2261   
2262   // loop over jets
2263
2264   for(Int_t ij=0; ij<nRecJets; ++ij){
2265
2266     AliAODJet* jet = dynamic_cast<AliAODJet*>(fJetsRec->At(ij));
2267     fQAJetHistosRec->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt());
2268   }
2269   
2270
2271   for(Int_t ij=0; ij<nRecJetsCuts; ++ij){
2272
2273     AliAODJet* jet = dynamic_cast<AliAODJet*>(fJetsRecCuts->At(ij));
2274     fQAJetHistosRecCuts->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt());
2275
2276     if(ij==0){ // leading jet
2277       
2278       fQAJetHistosRecCutsLeading->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt() );
2279       
2280       TList* jettracklist = new TList();
2281       Double_t sumPt = 0.;
2282       Float_t leadTrackPx = 0.;
2283       Float_t leadTrackPy = 0.;
2284       Float_t leadTrackPz = 0.;
2285       Float_t leadTrackP  = 0.;
2286       Float_t leadTrackPt = 0.;
2287       TLorentzVector* leadTrackV = new TLorentzVector();
2288       
2289       if(GetFFRadius()<=0){
2290         GetJetTracksTrackrefs(jettracklist, jet);
2291        } else {
2292         GetJetTracksPointing(fTracksRecCuts, jettracklist, jet, GetFFRadius(), sumPt);
2293       }
2294       
2295       for(Int_t it=0; it<jettracklist->GetSize(); ++it){
2296         Float_t trackPx = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->Px();
2297         Float_t trackPy = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->Py();
2298         Float_t trackPz = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->Pz();
2299         Float_t trackP = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->P();
2300         Float_t trackPt = (dynamic_cast<AliVParticle*> (jettracklist->At(it)))->Pt();
2301         Float_t jetPx = jet->Px();
2302         Float_t jetPy = jet->Py();
2303         Float_t jetPz = jet->Pz();
2304         Float_t jetP  = jet->P();
2305         Float_t jetPt = jet->Pt();
2306         TLorentzVector* trackV = new TLorentzVector();
2307         TLorentzVector *jetV = new TLorentzVector();
2308         trackV->SetPxPyPzE(trackPx,trackPy,trackPz,trackP);
2309         jetV->SetPxPyPzE(jetPx,jetPy,jetPz,jetP);
2310
2311         Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2312         
2313         fFFHistosRecCuts->FillFF( trackPt, jetPt, incrementJetPt);
2314         fIJHistosRecCuts->FillIntraJet( trackV, jetV );
2315         
2316         if(it==0){ 
2317           leadTrackPx = trackPx;
2318           leadTrackPy = trackPy;
2319           leadTrackPz = trackPz;
2320           leadTrackP  = trackP;
2321           leadTrackPt = trackPt;
2322           fFFHistosRecLeadingTrack->FillFF( leadTrackPt, jetPt, kTRUE);
2323
2324           leadTrackV->SetPxPyPzE(leadTrackPx,leadTrackPy,leadTrackPz,leadTrackP);
2325           fIJHistosRecLeadingTrack->FillIntraJet( leadTrackV, jetV );
2326         }
2327         fFFHistosRecLeading->FillFF( trackPt, leadTrackPt , incrementJetPt);
2328         fIJHistosRecLeading->FillIntraJet( trackV, leadTrackV );
2329
2330         delete trackV;
2331         delete jetV;
2332       }
2333       
2334       delete leadTrackV;
2335       delete jettracklist;
2336     }
2337   }
2338         
2339
2340   for(Int_t ij=0; ij<nGenJets; ++ij){
2341
2342     AliAODJet* jet = dynamic_cast<AliAODJet*>(fJetsGen->At(ij));
2343     fQAJetHistosGen->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt());
2344     
2345     if(ij==0){ // leading jet
2346     
2347       fQAJetHistosGenLeading->FillJetQA( jet->Eta(), TVector2::Phi_0_2pi(jet->Phi()), jet->Pt());
2348       
2349       TList* jettracklist = new TList();
2350       Double_t sumPt = 0.;
2351       Float_t leadTrackPx = 0.;
2352       Float_t leadTrackPy = 0.;
2353       Float_t leadTrackPz = 0.;
2354       Float_t leadTrackP  = 0.;
2355       Float_t leadTrackPt = 0.;
2356       TLorentzVector* leadTrackV = new TLorentzVector();
2357
2358       if(GetFFRadius()<=0){
2359         GetJetTracksTrackrefs(jettracklist, jet);
2360       } else {
2361         GetJetTracksPointing(fTracksGen, jettracklist, jet, GetFFRadius(), sumPt);
2362       }
2363       
2364       for(Int_t it=0; it<jettracklist->GetSize(); ++it){
2365         Float_t trackPx = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->Px();
2366         Float_t trackPy = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->Py();
2367         Float_t trackPz = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->Pz();
2368         Float_t trackP  = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->P();
2369         Float_t trackPt = (dynamic_cast<AliVParticle*>(jettracklist->At(it)))->Pt();
2370         Float_t jetPx = jet->Px();
2371         Float_t jetPy = jet->Py();
2372         Float_t jetPz = jet->Pz();
2373         Float_t jetP  = jet->P();
2374         Float_t jetPt = jet->Pt();
2375         TLorentzVector* trackV = new TLorentzVector();
2376         TLorentzVector  *jetV = new TLorentzVector();
2377         trackV->SetPxPyPzE(trackPx,trackPy,trackPz,trackP);
2378         jetV->SetPxPyPzE(jetPx,jetPy,jetPz,jetP);
2379
2380         Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2381
2382         fFFHistosGen->FillFF( trackPt, jetPt, incrementJetPt);
2383         fIJHistosGen->FillIntraJet( trackV, jetV );
2384         
2385         if(it==0){ 
2386           leadTrackPx = trackPx;
2387           leadTrackPy = trackPy;
2388           leadTrackPz = trackPz;
2389           leadTrackP  = trackP;
2390           leadTrackPt = trackPt;
2391           fFFHistosGenLeadingTrack->FillFF( leadTrackPt, jetPt, kTRUE);
2392
2393           leadTrackV->SetPxPyPzE(leadTrackPx,leadTrackPy,leadTrackPz,leadTrackP);
2394           fIJHistosGenLeadingTrack->FillIntraJet( leadTrackV, jetV );
2395         }
2396         fFFHistosGenLeading->FillFF( trackPt, leadTrackPt, incrementJetPt);
2397         fIJHistosGenLeading->FillIntraJet( trackV, leadTrackV );
2398
2399         delete trackV;
2400         delete jetV;
2401       }
2402       
2403       delete leadTrackV;
2404       delete jettracklist;
2405     }
2406   }
2407
2408   //_______ DiJet part _____________________________________________________
2409
2410   if (nRecJetsCuts > 1)  // OB: debugged this
2411   {
2412
2413     AliAODJet* jet1 = dynamic_cast<AliAODJet*>(fJetsRecCuts->At(0));
2414     AliAODJet* jet2 = dynamic_cast<AliAODJet*>(fJetsRecCuts->At(1));
2415     
2416     // DiJet deltaphi calculation
2417     Double_t phi1 = TVector2::Phi_0_2pi(jet1->Phi());
2418     Double_t phi2 = TVector2::Phi_0_2pi(jet2->Phi());
2419     Double_t deltaPhi = TMath::Abs(phi1-phi2); 
2420     if (deltaPhi > TMath::Pi() && deltaPhi < 2*TMath::Pi()) deltaPhi = 2*TMath::Pi() - deltaPhi;
2421     
2422     // DiJet CDF cut calculation
2423     Double_t Et1     = TMath::Abs(jet1->E()*TMath::Sin(jet1->Theta()));
2424     Double_t Et2     = TMath::Abs(jet2->E()*TMath::Sin(jet2->Theta()));
2425     Double_t sumEt   = Et1 + Et2;
2426     Double_t normEt1PlusEt2   = TMath::Sqrt(Et1*Et1+Et2*Et2+2*Et1*Et2*TMath::Cos(deltaPhi));
2427     Double_t ratio = (Double_t)(normEt1PlusEt2/sumEt);
2428     
2429     // DiJet events selection
2430     Bool_t positionCut       = 0;
2431     Bool_t positionEnergyCut = 0;
2432     Bool_t cdfCut            = 0; 
2433
2434     // Position cut :
2435     if (deltaPhi > fDiJetDeltaPhiCut) positionCut = 1;
2436     // Position-Energy cut :
2437     if ((deltaPhi > fDiJetDeltaPhiCut) && ((jet2->Pt()) >= fDiJetPtFractionCut*(jet1->Pt()))) positionEnergyCut = 1;
2438     // CDF cut :
2439     if (ratio < fDiJetCDFCut) cdfCut = 1;
2440     
2441     Int_t go = 0;
2442     
2443     if (fDiJetCut == 1 && positionCut == 1) go = 1;
2444     if (fDiJetCut == 2 && positionEnergyCut == 1) go = 1;
2445     if (fDiJetCut == 3 && cdfCut == 1) go = 1;
2446
2447     if (go)
2448       {
2449         Double_t deltaEta      = TMath::Abs(jet1->Eta()-jet2->Eta());
2450         Double_t deltaPt       = TMath::Abs(jet1->Pt()-jet2->Pt());
2451         Double_t meanEt        = (Double_t)((Et1+Et2)/2.);
2452         Double_t invariantMass = (Double_t)InvMass(jet1,jet2);
2453         
2454         Double_t  jetBin = GetDiJetBin(invariantMass, jet1->Pt(), meanEt, fDiJetKindBins);
2455
2456         if (jetBin > 0)
2457           {
2458             fQADiJetHistosRecCuts->FillDiJetQA(invariantMass, deltaPhi, deltaEta, deltaPt, jetBin);
2459             
2460             TList* jettracklist1 = new TList();
2461             Double_t sumPt1      = 0.;
2462             Float_t leadTrackPt1 = 0;
2463             
2464             TList* jettracklist2 = new TList();
2465             Double_t sumPt2      = 0.;
2466             Float_t leadTrackPt2 = 0;
2467             
2468             if(GetFFRadius()<=0)
2469               {
2470                 GetJetTracksTrackrefs(jettracklist1, jet1);
2471                 GetJetTracksTrackrefs(jettracklist2, jet2);
2472               }
2473             else
2474               {
2475                 GetJetTracksPointing(fTracksRecCuts, jettracklist1, jet1, GetFFRadius(), sumPt1);
2476                 GetJetTracksPointing(fTracksRecCuts, jettracklist2, jet2, GetFFRadius(), sumPt2);
2477               }
2478             
2479             Int_t nTracks = jettracklist1->GetSize(); 
2480             if (jettracklist1->GetSize() < jettracklist2->GetSize()) nTracks = jettracklist2->GetSize();
2481             
2482             for(Int_t it=0; it<nTracks; ++it)
2483               {
2484                 if (it < jettracklist1->GetSize())
2485                   { 
2486                     Float_t trackPt1 = (dynamic_cast<AliVParticle*> (jettracklist1->At(it)))->Pt();
2487                     Float_t jetPt1   = jet1->Pt();
2488                     
2489                     Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2490                     
2491                     fFFDiJetHistosRecCuts->FillDiJetFF(1, trackPt1, jetPt1, jetBin, incrementJetPt);
2492                     fFFDiJetHistosRecCuts->FillDiJetFF(0, trackPt1, jetPt1, jetBin, incrementJetPt);
2493                     
2494                     if (it == 0)
2495                       {
2496                         leadTrackPt1 = trackPt1;
2497                         
2498                         fFFDiJetHistosRecLeadingTrack->FillDiJetFF(1, leadTrackPt1, jetPt1, jetBin, kTRUE); 
2499                         fFFDiJetHistosRecLeadingTrack->FillDiJetFF(0, leadTrackPt1, jetPt1, jetBin, kTRUE); 
2500                       }
2501                     
2502                     fFFDiJetHistosRecLeading->FillDiJetFF(1, trackPt1, leadTrackPt1, jetBin, incrementJetPt); 
2503                     fFFDiJetHistosRecLeading->FillDiJetFF(0, trackPt1, leadTrackPt1, jetBin, incrementJetPt); 
2504                   }
2505                 
2506                 if (it < jettracklist2->GetSize())
2507                   { 
2508                     Float_t trackPt2   = (dynamic_cast<AliVParticle*>(jettracklist2->At(it)))->Pt();
2509                     Float_t jetPt2     = jet2->Pt();
2510                     
2511                     Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2512                     
2513                     fFFDiJetHistosRecCuts->FillDiJetFF(2, trackPt2, jetPt2, jetBin, incrementJetPt);
2514                     fFFDiJetHistosRecCuts->FillDiJetFF(0, trackPt2, jetPt2, jetBin, incrementJetPt);
2515                     
2516                     if (it == 0)
2517                       {
2518                         leadTrackPt2 = trackPt2;
2519                         
2520                         fFFDiJetHistosRecLeadingTrack->FillDiJetFF(2, leadTrackPt2, jetPt2, jetBin, kTRUE);
2521                         fFFDiJetHistosRecLeadingTrack->FillDiJetFF(0, leadTrackPt2, jetPt2, jetBin, kTRUE);
2522                       }
2523                     
2524                     fFFDiJetHistosRecLeading->FillDiJetFF(2, trackPt2, leadTrackPt2, jetBin, incrementJetPt);
2525                     fFFDiJetHistosRecLeading->FillDiJetFF(0, trackPt2, leadTrackPt2, jetBin, incrementJetPt);
2526                   }
2527               } // End loop on tracks
2528
2529             delete jettracklist1;
2530             delete jettracklist2;
2531
2532           } // End if(jetBin > 0)
2533         else { Printf("Jet bins for di-jet studies not set !");}
2534       } // End if(go)
2535   } // End if(nRecJets > 1)
2536
2537   if (nGenJets > 1)
2538   {
2539     AliAODJet* jet1 = dynamic_cast<AliAODJet*>(fJetsGen->At(0));
2540     AliAODJet* jet2 = dynamic_cast<AliAODJet*>(fJetsGen->At(1));
2541
2542     Double_t deltaPhi = 0;
2543     Double_t phi1 = TVector2::Phi_0_2pi(jet1->Phi());
2544     Double_t phi2 = TVector2::Phi_0_2pi(jet2->Phi());
2545     deltaPhi      = TMath::Abs(phi1-phi2); 
2546     if (deltaPhi > TMath::Pi() && deltaPhi < 2*TMath::Pi()) deltaPhi = 2*TMath::Pi() - deltaPhi;
2547
2548     Double_t Et1            = TMath::Abs(jet1->E()*TMath::Sin(jet1->Theta()));
2549     Double_t Et2            = TMath::Abs(jet2->E()*TMath::Sin(jet2->Theta()));
2550     Double_t sumEt          = Et1 + Et2;
2551     Double_t normEt1PlusEt2 = TMath::Sqrt(Et1*Et1+Et2*Et2+2*Et1*Et2*TMath::Cos(deltaPhi));
2552     Double_t ratio          = (Double_t)(normEt1PlusEt2/sumEt);
2553
2554     // DiJet events selection
2555     Bool_t positionCut       = 0;
2556     Bool_t positionEnergyCut = 0;
2557     Bool_t cdfCut            = 0; 
2558
2559     // Position cut :
2560     if (deltaPhi > fDiJetDeltaPhiCut) positionCut = 1;
2561     // Position-Energy cut :
2562     if ((deltaPhi > fDiJetDeltaPhiCut) && ((jet2->Pt()) >= fDiJetPtFractionCut*(jet1->Pt()))) positionEnergyCut = 1;
2563     // CDF cut :
2564     if (ratio < fDiJetCDFCut) cdfCut = 1;    
2565
2566     Int_t go = 0;
2567
2568     if (fDiJetCut == 1 && positionCut == 1) go = 1;
2569     if (fDiJetCut == 2 && positionEnergyCut == 1) go = 1;
2570     if (fDiJetCut == 3 && cdfCut == 1) go = 1;
2571
2572     if (go)
2573     {
2574       Double_t deltaEta      = TMath::Abs(jet1->Eta()-jet2->Eta());
2575       Double_t deltaPt       = TMath::Abs(jet1->Pt()-jet2->Pt());
2576       Double_t meanEt        = (Double_t)((Et1+Et2)/2.);
2577       Double_t invariantMass = (Double_t)InvMass(jet1,jet2);
2578
2579       Double_t jetBin = GetDiJetBin(invariantMass, jet1->Pt(), meanEt, fDiJetKindBins);
2580
2581       if(jetBin > 0)
2582       {
2583         fQADiJetHistosGen->FillDiJetQA(invariantMass, deltaPhi, deltaEta, deltaPt, jetBin);
2584
2585         TList* jettracklist1 = new TList();
2586         Double_t sumPt1 = 0.;
2587         Float_t leadTrackPt1 = 0.;
2588
2589         TList* jettracklist2 = new TList();
2590         Double_t sumPt2 = 0.;
2591         Float_t leadTrackPt2 = 0.;
2592       
2593         if(GetFFRadius()<=0)
2594         {
2595           GetJetTracksTrackrefs(jettracklist1, jet1);
2596           GetJetTracksTrackrefs(jettracklist2, jet2);
2597         }
2598         else
2599         {
2600           GetJetTracksPointing(fTracksGen, jettracklist1, jet1, GetFFRadius(), sumPt1);
2601           GetJetTracksPointing(fTracksGen, jettracklist2, jet2, GetFFRadius(), sumPt2);
2602         }
2603       
2604         Int_t nTracks = jettracklist1->GetSize(); 
2605         if (jettracklist1->GetSize() < jettracklist2->GetSize()) nTracks = jettracklist2->GetSize();
2606
2607         for(Int_t it=0; it<nTracks; ++it)
2608         {
2609           if (it < jettracklist1->GetSize())
2610           { 
2611             Float_t trackPt1 = (dynamic_cast<AliAODTrack*>(jettracklist1->At(it)))->Pt();
2612             Float_t jetPt1 = jet1->Pt();
2613
2614             Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2615
2616             fFFDiJetHistosGen->FillDiJetFF( 1, trackPt1, jetPt1, jetBin, incrementJetPt);
2617             fFFDiJetHistosGen->FillDiJetFF( 0, trackPt1, jetPt1, jetBin, incrementJetPt);
2618
2619             if(it==0)
2620             { 
2621               leadTrackPt1 = trackPt1;
2622
2623               fFFDiJetHistosGenLeadingTrack->FillDiJetFF( 1, leadTrackPt1, jetPt1, jetBin, kTRUE);
2624               fFFDiJetHistosGenLeadingTrack->FillDiJetFF( 0, leadTrackPt1, jetPt1, jetBin, kTRUE);
2625             }
2626
2627             fFFDiJetHistosGenLeading->FillDiJetFF( 1, trackPt1, leadTrackPt1, jetBin, incrementJetPt);
2628             fFFDiJetHistosGenLeading->FillDiJetFF( 0, trackPt1, leadTrackPt1, jetBin, incrementJetPt);
2629           }
2630       
2631           if (it < jettracklist2->GetSize())
2632           { 
2633             Float_t trackPt2 = (dynamic_cast<AliAODTrack*>(jettracklist2->At(it)))->Pt();
2634             Float_t jetPt2 = jet2->Pt();
2635
2636             Bool_t incrementJetPt = (it==0) ? kTRUE : kFALSE;
2637
2638             fFFDiJetHistosGen->FillDiJetFF( 2, trackPt2, jetPt2, jetBin, incrementJetPt);
2639             fFFDiJetHistosGen->FillDiJetFF( 0, trackPt2, jetPt2, jetBin, incrementJetPt);
2640         
2641             if (it==0)
2642             { 
2643               leadTrackPt2 = trackPt2;
2644
2645               fFFDiJetHistosGenLeadingTrack->FillDiJetFF( 2, leadTrackPt2, jetPt2, jetBin, kTRUE);
2646               fFFDiJetHistosGenLeadingTrack->FillDiJetFF( 0, leadTrackPt2, jetPt2, jetBin, kTRUE);
2647             }
2648
2649             fFFDiJetHistosGenLeading->FillDiJetFF( 2, trackPt2, leadTrackPt2, jetBin, incrementJetPt);
2650             fFFDiJetHistosGenLeading->FillDiJetFF( 0, trackPt2, leadTrackPt2, jetBin, incrementJetPt);
2651           }
2652         } // End loop on tracks
2653
2654         delete jettracklist1;
2655         delete jettracklist2;
2656
2657       } // End if(jetBin > 0)
2658       else { Printf("Jet bins for di-jet studies not set !");}
2659     } // End if (go)
2660   } // End if(nGenJets > 1)
2661
2662   
2663   // ____ efficiency _______________________________
2664
2665   // arrays for generated particles: reconstructed AOD track index, isPrimary flag
2666   TArrayI indexAODTr; 
2667   TArrayS isGenPrim; 
2668   
2669   // array for reconcstructed AOD tracks: generated particle index
2670   TArrayI indexMCTr; 
2671   
2672   Int_t  nTracksAODMCCharged = GetListOfTracks(fTracksAODMCCharged, kTrackAODMCCharged);
2673   if(fDebug>2)Printf("%s:%d selected AODMC tracks: %d ",(char*)__FILE__,__LINE__,nTracksAODMCCharged);
2674   
2675   Int_t  nTracksRecQualityCuts = GetListOfTracks(fTracksRecQualityCuts, kTrackAODQualityCuts);
2676   if(fDebug>2)Printf("%s:%d selected rec tracks quality after cuts, full acceptance/pt : %d ",(char*)__FILE__,__LINE__,nTracksRecQualityCuts);
2677   
2678   // associate gen and rec tracks, store indices in TArrays 
2679   AssociateGenRec(fTracksAODMCCharged,fTracksRecQualityCuts,indexAODTr,indexMCTr,isGenPrim);
2680   
2681   // single track eff
2682   FillSingleTrackRecEffHisto(fhnSingleTrackRecEffHisto,fTracksAODMCCharged,fTracksRecQualityCuts,indexAODTr,isGenPrim);
2683
2684   // jet track eff
2685   for(Int_t ij=0; ij<nRecEffJets; ++ij){ 
2686     
2687     AliAODJet* jet = dynamic_cast<AliAODJet*>(fJetsRecEff->At(ij));
2688     
2689     if(ij==0){ // leading jet
2690       
2691       TList* jettracklist = new TList();
2692       Double_t sumPt = 0.;
2693       
2694       GetJetTracksPointing(fTracksGen, jettracklist, jet, GetFFRadius(), sumPt); // for efficiency: gen tracks from pointing with gen/rec jet
2695       
2696       Double_t jetEta = jet->Eta();
2697       Double_t jetPhi = TVector2::Phi_0_2pi(jet->Phi());
2698       Double_t jetPt  = sumPt;
2699       
2700       fQAJetHistosRecEffLeading->FillJetQA( jetEta, jetPhi, jetPt );
2701       FillJetTrackRecEffHisto(fhnJetTrackRecEffHisto,jetPhi,jetEta,jetPt,jettracklist,fTracksAODMCCharged,indexAODTr,isGenPrim);
2702       
2703       delete jettracklist;
2704     }
2705   }
2706    
2707   //___________________
2708   
2709   fTracksRec->Clear();
2710   fTracksRecCuts->Clear();
2711   fTracksGen->Clear();
2712   fTracksAODMCCharged->Clear();
2713   fTracksRecQualityCuts->Clear();
2714
2715   fJetsRec->Clear();
2716   fJetsRecCuts->Clear();
2717   fJetsGen->Clear();
2718   fJetsRecEff->Clear();
2719
2720   //Post output data.
2721   PostData(1, fCommonHistList);
2722   
2723 }
2724
2725 //________________________________________________________________________________________
2726 Double_t AliAnalysisTaskFragmentationFunction::InvMass(AliAODJet* jet1, AliAODJet* jet2)
2727 {
2728
2729   Double_t invMass = 0.;
2730   invMass = TMath::Sqrt(pow(jet1->E()+jet2->E(),2) - pow(jet1->Px()+jet2->Px(),2) - 
2731                         pow(jet1->Py()+jet2->Py(),2) - pow(jet1->Pz()+jet2->Pz(),2));
2732
2733   return invMass;
2734
2735 }
2736
2737 //________________________________________________________________________________________
2738 Double_t AliAnalysisTaskFragmentationFunction::GetDiJetBin(Double_t invMass, Double_t leadingJetPt, Double_t EtMean, Int_t kindBins)
2739 {
2740   Double_t jetBinOk = 0.;
2741   Double_t jetBin = 0.;
2742
2743   Float_t stepInvMass = (fDiJetJetInvMassMax - fDiJetJetInvMassMin)/fDiJetNBinsJetInvMass;
2744   Float_t stepPt = (fDiJetJetPtMax - fDiJetJetPtMin)/fDiJetNBinsJetPt;
2745
2746   if (kindBins == 1)
2747     {
2748       for(Int_t i=0; i<fDiJetNBinsJetInvMass; ++i)
2749         {
2750           jetBin = fDiJetJetInvMassMin + i*stepInvMass/2.;
2751           if(((fDiJetJetInvMassMin+i*stepInvMass) <= invMass) &&
2752              (fDiJetJetInvMassMin + (i+1)*stepInvMass) > invMass) jetBinOk = jetBin;
2753         }
2754       jetBinOk = -1.;
2755     }
2756   else if (kindBins == 3)
2757     {
2758       for(Int_t i=0; i<fDiJetNBinsJetPt; ++i)
2759         {
2760           jetBin = fDiJetJetPtMin + i*stepPt/2.;
2761           if(((fDiJetJetPtMin+i*stepPt) <= EtMean) &&
2762              (fDiJetJetPtMin + (i+1)*stepPt) > EtMean) jetBinOk = jetBin;
2763         }
2764       jetBinOk = -1.;
2765     }
2766   else if (kindBins == 2)
2767     {
2768       for(Int_t i=0; i<fDiJetNBinsJetPt; ++i)
2769         {
2770           jetBin = fDiJetJetPtMin + i*stepPt/2.;
2771           if(((fDiJetJetPtMin+i*stepPt) <= leadingJetPt) &&
2772              (fDiJetJetPtMin + (i+1)*stepPt) > leadingJetPt) jetBinOk = jetBin;
2773         }
2774       jetBinOk = -1.;
2775     }
2776   else {Printf("WARNING: kindBins wrongly set ! Please make sure to call SetKindSlices() and set the kind parameter to 1, 2 or 3.\n");}
2777
2778   return jetBinOk;
2779
2780 }
2781
2782
2783 //______________________________________________________________
2784 void AliAnalysisTaskFragmentationFunction::Terminate(Option_t *) 
2785 {
2786   // terminated
2787
2788   if(fDebug > 1) printf("AliAnalysisTaskFragmentationFunction::Terminate() \n");
2789 }  
2790
2791 //_________________________________________________________________________________
2792 Int_t AliAnalysisTaskFragmentationFunction::GetListOfTracks(TList *list, Int_t type)
2793 {
2794   // fill list of tracks selected according to type
2795
2796   if(fDebug > 2) Printf("%s:%d Selecting tracks with %d", (char*)__FILE__,__LINE__,type);
2797   
2798   if(!list){
2799     if(fDebug>1) Printf("%s:%d no input list", (char*)__FILE__,__LINE__);
2800     return -1;
2801   }
2802
2803   if(type==kTrackUndef) return 0;
2804   
2805   Int_t iCount = 0;
2806   if(type==kTrackAODCuts || type==kTrackAOD){
2807
2808     // all rec. tracks, esd filter mask, eta range
2809     if(!fAOD) return -1;
2810     
2811     for(Int_t it=0; it<fAOD->GetNumberOfTracks(); ++it){
2812       AliAODTrack *tr = fAOD->GetTrack(it);
2813       
2814       if(type == kTrackAODCuts){
2815         if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))   continue;
2816         if(tr->Eta() < fTrackEtaMin || tr->Eta() > fTrackEtaMax) continue;
2817         if(tr->Phi() < fTrackPhiMin || tr->Phi() > fTrackPhiMax) continue;
2818         if(tr->Pt()  < fTrackPtCut) continue;
2819       }
2820       list->Add(tr);
2821       iCount++;
2822     }
2823   }
2824   else if (type==kTrackKineAll || type==kTrackKineCharged || type==kTrackKineChargedAcceptance){
2825     // kine particles, all or rather charged
2826     if(!fMCEvent) return iCount;
2827     
2828     for(Int_t it=0; it<fMCEvent->GetNumberOfTracks(); ++it){
2829       AliMCParticle* part = (AliMCParticle*) fMCEvent->GetTrack(it);
2830       
2831       if(type == kTrackKineCharged || type == kTrackKineChargedAcceptance){
2832         if(part->Charge()==0) continue;
2833         
2834         if(type == kTrackKineChargedAcceptance && 
2835            (       part->Eta() < fTrackEtaMin
2836                 || part->Eta() > fTrackEtaMax
2837                 || part->Phi() < fTrackPhiMin
2838                 || part->Phi() > fTrackPhiMax 
2839                 || part->Pt()  < fTrackPtCut)) continue;
2840       }
2841       
2842       list->Add(part);
2843       iCount++;
2844     }
2845   }
2846   else if (type==kTrackAODMCCharged || type==kTrackAODMCAll || type==kTrackAODMCChargedAcceptance) {
2847     // MC particles (from AOD), physical primaries, all or rather charged or rather charged within acceptance
2848     if(!fAOD) return -1;
2849     
2850     TClonesArray *tca = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName()));
2851     if(!tca)return iCount;
2852     
2853     for(int it=0; it<tca->GetEntriesFast(); ++it){
2854       AliAODMCParticle *part = dynamic_cast<AliAODMCParticle*>(tca->At(it));
2855       if(!part->IsPhysicalPrimary())continue;
2856       
2857       if (type==kTrackAODMCCharged || type==kTrackAODMCChargedAcceptance){
2858         if(part->Charge()==0) continue;
2859         if(type==kTrackAODMCChargedAcceptance && 
2860            (     part->Eta() > fTrackEtaMax
2861               || part->Eta() < fTrackEtaMin
2862               || part->Phi() > fTrackPhiMax
2863               || part->Phi() < fTrackPhiMin
2864               || part->Pt()  < fTrackPtCut)) continue;
2865       }
2866       
2867       list->Add(part);
2868       iCount++;
2869     }
2870   }
2871   
2872   list->Sort();
2873   return iCount;
2874   
2875 }
2876 // _______________________________________________________________________________
2877 Int_t AliAnalysisTaskFragmentationFunction::GetListOfJets(TList *list, Int_t type)
2878 {
2879   // fill list of jets selected according to type
2880   
2881   if(!list){
2882     if(fDebug>1) Printf("%s:%d no input list", (char*)__FILE__,__LINE__);
2883     return -1;
2884   }
2885
2886   if(type == kJetsRec || type == kJetsRecAcceptance){ // reconstructed jets
2887
2888     if(fBranchRecJets.Length()==0){
2889       Printf("%s:%d no rec jet branch specified", (char*)__FILE__,__LINE__);
2890       if(fDebug>1)fAOD->Print();
2891       return 0;
2892     }
2893
2894     TClonesArray *aodRecJets = new TClonesArray();
2895     if(fBranchRecJets.Length()) aodRecJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchRecJets.Data()));\r
2896     if(!aodRecJets)             aodRecJets = dynamic_cast<TClonesArray*>(fAOD->GetList()->FindObject(fBranchRecJets.Data()));\r
2897
2898     if(!aodRecJets){
2899       if(fBranchRecJets.Length()) Printf("%s:%d no reconstructed jet array with name %s in AOD", (char*)__FILE__,__LINE__,fBranchRecJets.Data());
2900
2901       if(fDebug>1)fAOD->Print();
2902       return 0;
2903     }
2904
2905     Int_t nRecJets = 0;
2906     
2907     for(Int_t ij=0; ij<aodRecJets->GetEntries(); ++ij){
2908
2909       AliAODJet *tmp = dynamic_cast<AliAODJet*>(aodRecJets->At(ij));
2910       if(!tmp) continue;
2911         
2912       if( tmp->Pt() < fJetPtCut ) continue;
2913       if( type == kJetsRecAcceptance &&
2914           (    tmp->Eta() < fJetEtaMin
2915             || tmp->Eta() > fJetEtaMax
2916             || tmp->Phi() < fJetPhiMin
2917             || tmp->Phi() > fJetPhiMax )) continue;
2918       
2919       list->Add(tmp);
2920           
2921       nRecJets++;
2922     }
2923
2924     list->Sort();
2925     return nRecJets;
2926     delete aodRecJets;
2927   }
2928   else if(type == kJetsKine || type == kJetsKineAcceptance){
2929     
2930     // generated jets
2931     Int_t nGenJets = 0;
2932     
2933     if(!fMCEvent){
2934       if(fDebug>1) Printf("%s:%d no mcEvent",(char*)__FILE__,__LINE__);
2935       return 0;
2936     }
2937     
2938     AliGenPythiaEventHeader*  pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(fMCEvent);
2939     if(!pythiaGenHeader){
2940       Printf("%s:%d no pythiaGenHeader found", (char*)__FILE__,__LINE__);
2941       return 0;
2942     }
2943     
2944     // fetch the pythia generated jets
2945     for(int ip=0; ip<pythiaGenHeader->NTriggerJets(); ++ip){
2946       
2947       Float_t p[4];
2948       AliAODJet *jet = new AliAODJet();
2949       pythiaGenHeader->TriggerJet(ip, p);
2950       jet->SetPxPyPzE(p[0], p[1], p[2], p[3]);
2951
2952       if( type == kJetsKineAcceptance &&
2953           (    jet->Eta() < fJetEtaMin
2954             || jet->Eta() > fJetEtaMax
2955             || jet->Phi() < fJetPhiMin
2956             || jet->Phi() > fJetPhiMax )) continue;
2957       
2958       list->Add(jet);
2959       nGenJets++;
2960     }
2961     list->Sort();
2962     return nGenJets;
2963   }
2964   else if(type == kJetsGen || type == kJetsGenAcceptance ){
2965
2966     if(fBranchGenJets.Length()==0){
2967       if(fDebug>1) Printf("%s:%d no gen jet branch specified", (char*)__FILE__,__LINE__);
2968       return 0;
2969     }
2970     
2971     TClonesArray *aodGenJets = new TClonesArray();
2972     if(fBranchGenJets.Length()) aodGenJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchGenJets.Data()));\r
2973     if(!aodGenJets)             aodGenJets = dynamic_cast<TClonesArray*>(fAOD->GetList()->FindObject(fBranchGenJets.Data()));\r
2974
2975     if(!aodGenJets){
2976       if(fDebug>0){
2977         if(fBranchGenJets.Length())         Printf("%s:%d Generated jet branch %s not found",(char*)__FILE__,__LINE__,fBranchGenJets.Data());
2978       }
2979       if(fDebug>1)fAOD->Print();
2980       return 0;
2981     }
2982
2983     Int_t nGenJets = 0;
2984     
2985     for(Int_t ig=0; ig<aodGenJets->GetEntries(); ++ig){
2986           
2987       AliAODJet *tmp = dynamic_cast<AliAODJet*>(aodGenJets->At(ig));
2988       if(!tmp) continue;
2989           
2990       if( tmp->Pt() < fJetPtCut ) continue;
2991       if( type == kJetsGenAcceptance &&
2992           (    tmp->Eta() < fJetEtaMin
2993             || tmp->Eta() > fJetEtaMax
2994             || tmp->Phi() < fJetPhiMin
2995             || tmp->Phi() > fJetPhiMax )) continue;
2996       
2997       list->Add(tmp);
2998       
2999       nGenJets++;
3000     }
3001     list->Sort();
3002     return nGenJets;
3003     delete aodGenJets;
3004   } 
3005   else{
3006     if(fDebug>0)Printf("%s:%d no such type %d",(char*)__FILE__,__LINE__,type);
3007     return 0;
3008   }
3009 }
3010
3011 // _________________________________________________________________________________________________________
3012 void AliAnalysisTaskFragmentationFunction::SetProperties(THnSparse* h,const Int_t dim, const char** labels)
3013 {
3014   //Set properties of THnSparse 
3015
3016   for(Int_t i=0; i<dim; i++){
3017
3018     h->GetAxis(i)->SetTitle(labels[i]);
3019     h->GetAxis(i)->SetTitleColor(1);
3020   }
3021 }
3022
3023 // __________________________________________________________________________________________
3024 void AliAnalysisTaskFragmentationFunction::SetProperties(TH1* h,const char* x, const char* y)
3025 {
3026   //Set properties of histos (x and y title)
3027
3028   h->SetXTitle(x);
3029   h->SetYTitle(y);
3030   h->GetXaxis()->SetTitleColor(1);
3031   h->GetYaxis()->SetTitleColor(1);
3032 }
3033
3034 // _________________________________________________________________________________________________________
3035 void AliAnalysisTaskFragmentationFunction::SetProperties(TH2* h,const char* x, const char* y, const char* z)
3036 {
3037   //Set properties of histos (x,y and z title)
3038
3039   h->SetXTitle(x);
3040   h->SetYTitle(y);
3041   h->SetZTitle(z);
3042   h->GetXaxis()->SetTitleColor(1);
3043   h->GetYaxis()->SetTitleColor(1);
3044   h->GetZaxis()->SetTitleColor(1);
3045 }
3046
3047 // ________________________________________________________________________________________________________________________________________________________
3048 void AliAnalysisTaskFragmentationFunction::GetJetTracksPointing(TList* inputlist, TList* outputlist, AliAODJet* jet, const Double_t radius,Double_t& sumPt)
3049 {
3050   // fill list of tracks in cone around jet axis  
3051
3052   sumPt = 0;
3053
3054   Double_t jetMom[3];
3055   jet->PxPyPz(jetMom);
3056   TVector3 jet3mom(jetMom);
3057
3058   for (Int_t itrack=0; itrack<inputlist->GetSize(); itrack++){
3059
3060     AliVParticle* track = dynamic_cast<AliVParticle*>(inputlist->At(itrack));
3061
3062     Double_t trackMom[3];
3063     track->PxPyPz(trackMom);
3064     TVector3 track3mom(trackMom);
3065
3066     Double_t dR = jet3mom.DeltaR(track3mom);
3067
3068     if(dR<radius){
3069
3070       outputlist->Add(track);
3071       
3072       sumPt += track->Pt();
3073     }
3074   }
3075   
3076   outputlist->Sort();
3077 }
3078
3079 // ___________________________________________________________________________________________
3080 void AliAnalysisTaskFragmentationFunction::GetJetTracksTrackrefs(TList* list, AliAODJet* jet)
3081 {
3082   // list of jet tracks from trackrefs
3083   
3084   Int_t nTracks = jet->GetRefTracks()->GetEntriesFast();
3085
3086   for (Int_t itrack=0; itrack<nTracks; itrack++) {
3087     
3088     AliVParticle* track = dynamic_cast<AliVParticle*>(jet->GetRefTracks()->At(itrack));
3089     if(!track){
3090       AliError("expected ref track not found ");
3091       continue;
3092     }
3093         
3094     list->Add(track);
3095   }
3096   
3097   list->Sort();
3098 }
3099
3100 // _ ________________________________________________________________________________________________________________________________
3101 void  AliAnalysisTaskFragmentationFunction::AssociateGenRec(TList* tracksAODMCCharged,TList* tracksRec, TArrayI& indexAODTr,TArrayI& indexMCTr,TArrayS& isGenPrim)
3102 {
3103   // associate generated and reconstructed tracks, fill TArrays of list indices
3104
3105
3106   Int_t nTracksRec  = tracksRec->GetSize();
3107   Int_t nTracksGen  = tracksAODMCCharged->GetSize();
3108   TClonesArray *tca = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName()));
3109
3110   if(!nTracksGen) return;
3111   if(!tca)        return;
3112   
3113   // set size
3114   indexAODTr.Set(nTracksGen);
3115   indexMCTr.Set(nTracksRec);
3116   isGenPrim.Set(nTracksGen);
3117
3118   indexAODTr.Reset(-1);
3119   indexMCTr.Reset(-1);
3120   isGenPrim.Reset(0);
3121
3122   // loop over reconstructed tracks, get generated track 
3123
3124   for(Int_t iRec=0; iRec<nTracksRec; iRec++){ 
3125       
3126     AliAODTrack* rectrack = dynamic_cast<AliAODTrack*>(tracksRec->At(iRec)); 
3127
3128     Int_t label = rectrack->GetLabel();
3129
3130     // find MC track in our list
3131     AliAODMCParticle* gentrack = 0x0;
3132     if(label>=0) gentrack = dynamic_cast<AliAODMCParticle*> (tca->At(label));
3133
3134     Int_t listIndex = -1;
3135     if(gentrack) listIndex = tracksAODMCCharged->IndexOf(gentrack);
3136
3137     if(listIndex>=0){
3138
3139       indexAODTr[listIndex] = iRec;
3140       indexMCTr[iRec]       = listIndex;
3141     }
3142   } 
3143
3144
3145   // define primary sample for reconstruction efficiency
3146
3147   for(Int_t iGen=0; iGen<nTracksGen; iGen++){
3148
3149     AliAODMCParticle* gentrack =  dynamic_cast<AliAODMCParticle*> (tracksAODMCCharged->At(iGen));
3150
3151     Int_t pdg = gentrack->GetPdgCode();    
3152
3153     // 211 - pi, 2212 - proton, 321 - Kaon, 11 - electron, 13 - muon
3154     if(TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == 321 || 
3155        TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13){
3156       
3157       isGenPrim[iGen] = kTRUE;
3158     }
3159   }
3160 }
3161
3162 // _____________________________________________________________________________________________________________________________________________
3163 void AliAnalysisTaskFragmentationFunction::FillSingleTrackRecEffHisto(THnSparse* histo, TList* tracksGen, TList* tracksRec, TArrayI& indexAODTr, TArrayS& isGenPrim){
3164
3165   // fill THnSparse for single track reconstruction efficiency
3166
3167   Int_t nTracksGen  = tracksGen->GetSize();
3168
3169   if(!nTracksGen) return;
3170
3171   for(Int_t iGen=0; iGen<nTracksGen; iGen++){
3172
3173     if(isGenPrim[iGen] != 1) continue; // select primaries
3174
3175     AliAODMCParticle* gentrack =  dynamic_cast<AliAODMCParticle*> (tracksGen->At(iGen));
3176     
3177     Double_t ptGen  = gentrack->Pt();
3178     Double_t etaGen = gentrack->Eta();
3179     Double_t phiGen = TVector2::Phi_0_2pi(gentrack->Phi());
3180
3181     // apply same acc & pt cuts as for FF 
3182     // could in principle also be done setting THNsparse axis limits before projecting, 
3183     // but then the binning needs to be fine grained enough 
3184
3185     if(etaGen < fTrackEtaMin || etaGen > fTrackEtaMax) continue;
3186     if(phiGen < fTrackPhiMin || phiGen > fTrackPhiMax) continue;
3187     if(ptGen  < fTrackPtCut) continue;
3188
3189     Int_t iRec = indexAODTr[iGen]; // can be -1 if no good reconstructed track 
3190     Double_t isRec =  0;
3191     Double_t ptRec = -1;
3192
3193     if(iRec>=0){
3194
3195       AliAODTrack* rectrack = dynamic_cast<AliAODTrack*>(tracksRec->At(iRec)); 
3196       ptRec = rectrack->Pt();
3197       isRec = 1;
3198     }
3199
3200     Double_t entries[5] = {phiGen,etaGen,ptGen,ptRec,isRec};
3201     histo->Fill(entries);
3202   }
3203 }
3204
3205 // ______________________________________________________________________________________________________________________________________________________
3206 void AliAnalysisTaskFragmentationFunction::FillJetTrackRecEffHisto(THnSparse* histo,Double_t jetPhi, Double_t jetEta, Double_t jetPt, TList* jetTrackList, 
3207                                                                    TList* tracksGen, TArrayI& indexAODTr, TArrayS& isGenPrim)
3208 {
3209   // fill THnSparse for jet track reconstruction efficiency
3210
3211   Int_t nTracksJet = jetTrackList->GetSize(); // list with AODMC tracks
3212
3213   if(!nTracksJet) return; 
3214
3215   for(Int_t iTr=0; iTr<nTracksJet; iTr++){
3216
3217     AliAODMCParticle* gentrack =  dynamic_cast<AliAODMCParticle*> (jetTrackList->At(iTr));
3218
3219     // find jet track in gen tracks list
3220     Int_t iGen = tracksGen->IndexOf(gentrack); 
3221
3222     if(iGen<0){
3223       if(fDebug>0) Printf("%s:%d gen jet track not found ",(char*)__FILE__,__LINE__);
3224       continue;
3225     }
3226
3227     if(isGenPrim[iGen] != 1) continue; // select primaries
3228     
3229     Double_t ptGen  = gentrack->Pt();
3230     Double_t etaGen = gentrack->Eta();
3231     Double_t phiGen = TVector2::Phi_0_2pi(gentrack->Phi());
3232
3233     // apply same acc & pt cuts as for FF 
3234     // could in principle also be done setting THNsparse axis limits before projecting, 
3235     // but then the binning needs to be fine grained enough 
3236
3237     if(etaGen < fTrackEtaMin || etaGen > fTrackEtaMax) continue;
3238     if(phiGen < fTrackPhiMin || phiGen > fTrackPhiMax) continue;
3239     if(ptGen  < fTrackPtCut) continue;
3240
3241     Double_t z = ptGen / jetPt;
3242     Double_t xi = 0;
3243     if(z>0) xi = TMath::Log(1/z);
3244
3245     Double_t isRec =  0;
3246     Int_t iRec = indexAODTr[iGen]; // can be -1 if no good reconstructed track 
3247     if(iRec>=0) isRec = 1;
3248
3249     Double_t entries[7] = {jetPhi,jetEta,jetPt,ptGen,z,xi,isRec};
3250     histo->Fill(entries);
3251   }
3252 }