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