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