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