7ec53dd6280fe1b5488f440e3c3108ca1d949c7c
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliAnalysisTaskElecHadronCorrel.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *               
3  *                                                                        *               
4  * Author: The ALICE Off-line Project.                                    *               
5  * Contributors are mentioned in the code where appropriate.              *               
6  *                                                                        *               
7  * Permission to use, copy, modify and distribute this software and its   *               
8  * documentation strictly for non-commercial purposes is hereby granted   *               
9  * without fee, provided that the above copyright notice appears in all   *               
10  * copies and that both the copyright notice and this permission notice   *               
11  * appear in the supporting documentation. The authors make no claims     *               
12  * about the suitability of this software for any purpose. It is          *               
13  * provided "as is" without express or implied warranty.                  *               
14  **************************************************************************/
15
16
17 ////////////////////////////////////////////////////////////////////////
18 //                                                                    //
19 //  Task for Heavy Flavour Electron-Hadron DeltaPhi Correlation       //
20 //  Non-Photonic Electron identified with Invariant mass              //
21 //  analysis methos in function  SelectPhotonicElectron               //
22 //  DeltaPhi calculated in function  ElectronHadCorrel                // 
23 //                                                                    //
24 //  Author: Deepa Thomas (Utrecht University)                         //
25 //                                                                    //
26 ////////////////////////////////////////////////////////////////////////
27
28 #include "TChain.h"
29 #include "TTree.h"
30 #include "TH2F.h"
31 #include "TMath.h"
32 #include "TCanvas.h"
33 #include "THnSparse.h"
34 #include "TLorentzVector.h"
35 #include "TString.h"
36 #include "TFile.h"
37
38 #include "AliAnalysisTask.h"
39 #include "AliAnalysisManager.h"
40
41 #include "AliLog.h"
42 #include "AliESDEvent.h"
43 #include "AliESDHandler.h"
44 #include "AliAODEvent.h"
45 #include "AliAODHandler.h"
46
47 #include "AliAnalysisTaskElecHadronCorrel.h"
48 #include "TGeoGlobalMagField.h"
49 #include "AliLog.h"
50 #include "AliAnalysisTaskSE.h"
51 #include "TRefArray.h"
52 #include "TVector.h"
53 #include "AliESDInputHandler.h"
54 #include "AliESDpid.h"
55 #include "AliESDtrackCuts.h"
56 #include "AliPhysicsSelection.h"
57 #include "AliESDCaloCluster.h"
58 #include "AliAODCaloCluster.h"
59 #include "AliESDCaloTrigger.h"
60 #include "AliEMCALRecoUtils.h"
61 #include "AliEMCALGeometry.h"
62 #include "AliGeomManager.h"
63 #include "stdio.h"
64 #include "TGeoManager.h"
65 #include "iostream"
66 #include "fstream"
67
68 //#include "AliEventPoolManager.h"
69
70 #include "AliCentrality.h"
71 //#include "AliEMCALTrack.h"
72 //#include "AliEMCALTracker.h"
73 #include "AliMagF.h"
74
75 #include "AliKFParticle.h"
76 #include "AliKFVertex.h"
77
78 #include "AliPID.h"
79 #include "AliPIDResponse.h"
80 #include "AliHFEcontainer.h"
81 #include "AliHFEcuts.h"
82 #include "AliHFEpid.h"
83 #include "AliHFEpidBase.h"
84 #include "AliHFEpidQAmanager.h"
85 #include "AliHFEtools.h"
86 #include "AliCFContainer.h"
87 #include "AliCFManager.h"
88
89 ClassImp(AliAnalysisTaskElecHadronCorrel)
90 //ClassImp(AliehDPhiBasicParticle)  
91 //________________________________________________________________________
92   AliAnalysisTaskElecHadronCorrel::AliAnalysisTaskElecHadronCorrel(const char *name) 
93   : AliAnalysisTaskSE(name)
94   ,fESD(0)
95   ,fGeom(0)
96   ,fOutputList(0)
97   ,fTrackCuts1(new AliESDtrackCuts)
98   ,fTrackCuts2(new AliESDtrackCuts)
99   ,fCuts(0)
100   ,fIdentifiedAsOutInz(kFALSE)
101   ,fPassTheEventCut(kFALSE)
102   ,fRejectKinkMother(kFALSE)
103   ,fVz(0.0)
104   ,fCFM(0)      
105   ,fPID(0)
106   ,fPIDqa(0)           
107   ,fOpeningAngleCut(0.1)
108   ,fInvmassCut(0.01)    
109   ,fCentrality(0)
110   ,fCentralityMin(0)
111   ,fCentralityMax(0)
112   ,fkCentralityMethod(0)  
113 //  ,fPoolMgr(0x0)  
114   ,fNoEvents(0)
115 //  ,fTrkpt(0)
116   ,fTrkEovPBef(0)        
117   ,fTrkEovPBefHad(0)     
118 /*  ,fTrkEovPAft(0)     
119   ,fTrkEovPAftOwn(0)    
120   ,fdEdxBef(0)   
121   ,fdEdxAft(0)   
122   ,fdEdxAftOwn(0)        
123   ,fOpeningAngleLS(0)   
124   ,fOpeningAngleULS(0)  
125 */  ,fSemiIncElecDphi(0)        
126   ,fSemiIncElecDphi1(0)         
127   ,fSemiIncElecDphi2(0)         
128   ,fSemiIncElecDphi3(0)         
129   ,fSemiIncElecDphi4(0)         
130   ,fPhotElecDphi(0)     
131   ,fPhotElecDphi1(0)    
132   ,fPhotElecDphi2(0)    
133   ,fPhotElecDphi3(0)    
134   ,fPhotElecDphi4(0)    
135   ,fInclusiveElecDphi(0)        
136   ,fInclusiveElecDphi1(0)       
137   ,fInclusiveElecDphi2(0)       
138   ,fInclusiveElecDphi3(0)       
139   ,fInclusiveElecDphi4(0)       
140   ,fDphiULSMassLow(0)   
141   ,fDphiULSMassLow1(0)  
142   ,fDphiULSMassLow2(0)  
143   ,fDphiULSMassLow3(0)  
144   ,fDphiULSMassLow4(0)  
145   ,fDphiLSMassLow(0)
146   ,fDphiLSMassLow1(0)
147   ,fDphiLSMassLow2(0)
148   ,fDphiLSMassLow3(0)
149   ,fDphiLSMassLow4(0)
150   ,fDphiULSMassLowNoPartner(0)   
151   ,fDphiULSMassLowNoPartner1(0)   
152   ,fDphiULSMassLowNoPartner2(0)   
153   ,fDphiULSMassLowNoPartner3(0)   
154   ,fDphiULSMassLowNoPartner4(0)   
155   ,fDphiLSMassLowNoPartner(0)
156   ,fDphiLSMassLowNoPartner1(0)
157   ,fDphiLSMassLowNoPartner2(0)
158   ,fDphiLSMassLowNoPartner3(0)
159   ,fDphiLSMassLowNoPartner4(0)
160   ,fPhotoElecPt(0)
161   ,fSemiInclElecPt(0)
162   ,fInclusiveElecPt(0)
163   ,fULSElecPt(0)
164   ,fLSElecPt(0)  
165 //  ,fTrackPtBefTrkCuts(0)       
166 //  ,fTrackPtAftTrkCuts(0)
167   ,fTPCnsigma(0)
168 /*  ,fTPCnsigmaAft(0)
169   ,fTPCnsigmaAftOwn(0)
170   ,fNCellv1(0)
171   ,fClsEv1(0)
172   ,fNClusv1(0)
173   ,fKFParticleP(0)
174   ,fKFParticleE(0)
175 */  ,fInvmassLS1(0)       
176   ,fInvmassLS2(0)       
177   ,fInvmassLS3(0)       
178   ,fInvmassLS4(0)       
179   ,fInvmassLS5(0)       
180   ,fInvmassULS1(0)
181   ,fInvmassULS2(0)
182   ,fInvmassULS3(0)
183   ,fInvmassULS4(0)
184   ,fInvmassULS5(0)
185   ,fcentrality(0)     
186   ,fElecPhi(0)  
187   ,fElecPhiTPChalf(0)
188   ,fElecPhiPt(0)  
189 //  ,fElecPhiTPC(0)  
190 //  ,fElecPhiTPCEovP(0)  
191   ,fHadronPhi(0)  
192   ,fHadronPhiTPChalf(0)  
193   ,fHadronPhiPt(0)  
194 /*  ,fTrackHFEcuts(0)
195   ,fTrakPhiSPD1(0)
196   ,fTrakPhiSPD2(0)
197   ,fTrakPhiSPDOr(0)
198   ,fTrakPhiSPDAnd(0)
199   ,fTrackHFEcutsITS(0)  
200 */
201 /*  ,fNoMixedEvents(0)
202   ,fMixStat(0)       
203   ,fMixStat1(0)        
204   ,fMixedIncElecDphi(0)  
205   ,fMixedIncElecDphi1(0)  
206   ,fMixedIncElecDphi2(0)  
207   ,fMixedPhotElecDphi(0)
208   ,fMixedPhotElecDphi1(0)
209   ,fMixedPhotElecDphi2(0)
210   ,fMixedSemiIncElecDphi(0)  
211   ,fMixedSemiIncElecDphi1(0)  
212   ,fMixedSemiIncElecDphi2(0)  
213   ,fMixedDphiULSMassLow(0)  
214   ,fMixedDphiULSMassLow1(0)  
215   ,fMixedDphiULSMassLow2(0)  
216   ,fMixedDphiLSMassLow(0)  
217   ,fMixedDphiLSMassLow1(0)  
218   ,fMixedDphiLSMassLow2(0)  
219 */
220 /*  ,fNLSminus(0)
221   ,fNLSplus(0)
222   ,fNULS(0)  
223 */  ,fHadronIPxy(0)  
224   ,fHadronIPz(0)  
225   ,fHadronPt(0)  
226   ,fCentralityPass(0)
227   ,fCentralityNoPass(0)
228 //  ,fSparseElectron(0)  
229 //  ,fvalueElectron(0)   
230 {
231   //Named constructor
232
233   fPID = new AliHFEpid("hfePid");
234 //  fvalueElectron = new Double_t[8];
235
236   // Define input and output slots here
237   // Input slot #0 works with a TChain
238   DefineInput(0, TChain::Class());
239   // Output slot #0 id reserved by the base class for AOD
240   // Output slot #1 writes into a TH1 container
241   // DefineOutput(1, TH1I::Class());
242   DefineOutput(1, TList::Class());
243   //  DefineOutput(3, TTree::Class());
244 }
245
246 //________________________________________________________________________
247 AliAnalysisTaskElecHadronCorrel::AliAnalysisTaskElecHadronCorrel() 
248   : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisElecHadCorrel")
249   ,fESD(0)
250   ,fGeom(0)  
251   ,fOutputList(0)
252   ,fTrackCuts1(new AliESDtrackCuts)
253   ,fTrackCuts2(new AliESDtrackCuts)
254   ,fCuts(0)
255   ,fIdentifiedAsOutInz(kFALSE)
256   ,fPassTheEventCut(kFALSE)
257   ,fRejectKinkMother(kFALSE)
258   ,fVz(0.0)
259   ,fCFM(0)      
260   ,fPID(0)       
261   ,fPIDqa(0)           
262   ,fOpeningAngleCut(0.1)
263   ,fInvmassCut(0.01)    
264   ,fCentrality(0)
265   ,fCentralityMin(0)
266   ,fCentralityMax(0)
267   ,fkCentralityMethod(0)  
268 //  ,fPoolMgr(0x0)    
269   ,fNoEvents(0)
270 //  ,fTrkpt(0)
271   ,fTrkEovPBef(0)        
272   ,fTrkEovPBefHad(0)     
273 /*  ,fTrkEovPAft(0)      
274   ,fTrkEovPAftOwn(0)     
275   ,fdEdxBef(0)   
276   ,fdEdxAft(0)   
277   ,fdEdxAftOwn(0)        
278   ,fOpeningAngleLS(0)   
279   ,fOpeningAngleULS(0)  
280 */  ,fSemiIncElecDphi(0)        
281   ,fSemiIncElecDphi1(0)         
282   ,fSemiIncElecDphi2(0)         
283   ,fSemiIncElecDphi3(0)         
284   ,fSemiIncElecDphi4(0)         
285   ,fPhotElecDphi(0)     
286   ,fPhotElecDphi1(0)    
287   ,fPhotElecDphi2(0)    
288   ,fPhotElecDphi3(0)    
289   ,fPhotElecDphi4(0)    
290   ,fInclusiveElecDphi(0)        
291   ,fInclusiveElecDphi1(0)       
292   ,fInclusiveElecDphi2(0)       
293   ,fInclusiveElecDphi3(0)       
294   ,fInclusiveElecDphi4(0)       
295   ,fDphiULSMassLow(0)   
296   ,fDphiULSMassLow1(0)  
297   ,fDphiULSMassLow2(0)  
298   ,fDphiULSMassLow3(0)  
299   ,fDphiULSMassLow4(0)  
300   ,fDphiLSMassLow(0)
301   ,fDphiLSMassLow1(0)
302   ,fDphiLSMassLow2(0)
303   ,fDphiLSMassLow3(0)
304   ,fDphiLSMassLow4(0)
305   ,fDphiULSMassLowNoPartner(0)   
306   ,fDphiULSMassLowNoPartner1(0)   
307   ,fDphiULSMassLowNoPartner2(0)   
308   ,fDphiULSMassLowNoPartner3(0)   
309   ,fDphiULSMassLowNoPartner4(0)   
310   ,fDphiLSMassLowNoPartner(0)
311   ,fDphiLSMassLowNoPartner1(0)
312   ,fDphiLSMassLowNoPartner2(0)
313   ,fDphiLSMassLowNoPartner3(0)
314   ,fDphiLSMassLowNoPartner4(0)
315   ,fPhotoElecPt(0)
316   ,fSemiInclElecPt(0)
317   ,fInclusiveElecPt(0)
318   ,fULSElecPt(0)
319   ,fLSElecPt(0)  
320 //  ,fTrackPtBefTrkCuts(0)       
321 //  ,fTrackPtAftTrkCuts(0)                
322   ,fTPCnsigma(0)        
323 /*  ,fTPCnsigmaAft(0)   
324   ,fTPCnsigmaAftOwn(0)  
325   ,fNCellv1(0)  
326   ,fClsEv1(0)
327   ,fNClusv1(0)
328   ,fKFParticleP(0)
329   ,fKFParticleE(0)
330 */  ,fInvmassLS1(0)   
331   ,fInvmassLS2(0)   
332   ,fInvmassLS3(0)   
333   ,fInvmassLS4(0)   
334   ,fInvmassLS5(0)   
335   ,fInvmassULS1(0)  
336   ,fInvmassULS2(0)  
337   ,fInvmassULS3(0)  
338   ,fInvmassULS4(0)  
339   ,fInvmassULS5(0)  
340   ,fcentrality(0)     
341   ,fElecPhi(0)
342   ,fElecPhiTPChalf(0)  
343   ,fElecPhiPt(0)
344 //  ,fElecPhiTPC(0)
345 //  ,fElecPhiTPCEovP(0)  
346   ,fHadronPhi(0)
347   ,fHadronPhiTPChalf(0)
348   ,fHadronPhiPt(0)
349 /*  ,fTrackHFEcuts(0)
350   ,fTrakPhiSPD1(0)
351   ,fTrakPhiSPD2(0)
352   ,fTrakPhiSPDOr(0)
353   ,fTrakPhiSPDAnd(0)
354   ,fTrackHFEcutsITS(0)  
355 */
356 /*  ,fNoMixedEvents(0)
357   ,fMixStat(0)      
358   ,fMixStat1(0)     
359   ,fMixedIncElecDphi(0)  
360   ,fMixedIncElecDphi1(0)  
361   ,fMixedIncElecDphi2(0)  
362   ,fMixedPhotElecDphi(0)
363   ,fMixedPhotElecDphi1(0)
364   ,fMixedPhotElecDphi2(0)
365   ,fMixedSemiIncElecDphi(0)
366   ,fMixedSemiIncElecDphi1(0)
367   ,fMixedSemiIncElecDphi2(0)
368   ,fMixedDphiULSMassLow(0) 
369   ,fMixedDphiULSMassLow1(0) 
370   ,fMixedDphiULSMassLow2(0) 
371   ,fMixedDphiLSMassLow(0)      
372   ,fMixedDphiLSMassLow1(0)      
373   ,fMixedDphiLSMassLow2(0)      
374 */
375 /*  ,fNLSminus(0)
376   ,fNLSplus(0)    
377   ,fNULS(0)       
378 */  ,fHadronIPxy(0) 
379   ,fHadronIPz(0)      
380   ,fHadronPt(0)  
381   ,fCentralityPass(0)
382   ,fCentralityNoPass(0)
383     //  ,fSparseElectron(0)  
384     //    ,fvalueElectron(0)  
385 {
386   //Default constructor
387   fPID = new AliHFEpid("hfePid");
388   //  fvalueElectron = new Double_t[8];
389
390   // Constructor
391   // Define input and output slots here
392   // Input slot #0 works with a TChain
393   DefineInput(0, TChain::Class());
394   // Output slot #0 id reserved by the base class for AOD
395   // Output slot #1 writes into a TH1 container
396   // DefineOutput(1, TH1I::Class());
397   DefineOutput(1, TList::Class());
398   //DefineOutput(3, TTree::Class());
399 }
400 //_________________________________________
401
402 AliAnalysisTaskElecHadronCorrel::~AliAnalysisTaskElecHadronCorrel()
403 {
404   //Destructor 
405
406   delete fOutputList;
407   delete fGeom;
408   delete fPID;
409   delete fCFM;
410   delete fPIDqa;
411   delete fTrackCuts1;
412   delete fTrackCuts2;
413   //   delete fSparseElectron;
414   //   delete []fvalueElectron;
415 }
416 //_________________________________________
417
418 void AliAnalysisTaskElecHadronCorrel::UserExec(Option_t*)
419 {
420   //Main loop
421   //Called for each event
422
423   // create pointer to event
424   fESD = dynamic_cast<AliESDEvent*>(InputEvent());
425   if (!fESD) {
426     printf("ERROR: fESD not available\n");
427     return;
428   }
429
430   if(!fCuts){
431     AliError("HFE cuts not available");
432     return;
433   }
434
435   if(!fPID->IsInitialized()){ 
436     // Initialize PID with the given run number
437     AliWarning("PID not initialised, get from Run no");
438     fPID->InitializePID(fESD->GetRunNumber());
439   }
440
441   //-------trigger selection
442   UInt_t res = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
443   if (res==0)
444     return;
445
446   //    if( (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kFastOnly) )
447   //            return;
448
449   if(!(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & (AliVEvent::kCentral))) return;
450
451   //---------------CENTRALITY SELECTION-----------------------    
452   SetCentralityParameters(0., 10., "V0M");
453   Bool_t pass = kFALSE; //to select centrality
454   CheckCentrality(fESD,pass);
455
456   if(!pass)return;
457
458   /*  AliCentrality *fCentrality = (AliCentrality*)fESD->GetCentrality();
459
460   Float_t centvalue = fCentrality->GetCentralityPercentile("V0M");
461   fcentrality->Fill(centvalue);    
462   if(centvalue<0 || centvalue>10) return;
463 */
464   Int_t fNOtrks =  fESD->GetNumberOfTracks();
465   const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
466
467   Double_t pVtxZ = -999;
468   pVtxZ = pVtx->GetZ();
469
470   // Event cut
471   //    if(!fCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) return;
472
473   if(TMath::Abs(pVtxZ)>10) return;
474   fNoEvents->Fill(0);
475
476   if(fNOtrks<2) return;
477
478   AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse();
479   if(!pidResponse){
480     AliDebug(1, "Using default PID Response");
481      pidResponse = AliHFEtools::GetDefaultPID(kFALSE, fInputEvent->IsA() == AliAODEvent::Class()); 
482    }
483
484    fPID->SetPIDResponse(pidResponse);
485
486    fCFM->SetRecEventInfo(fESD);
487 /*
488    //Event mixing
489    AliEventPool* pool = fPoolMgr->GetEventPool(centvalue, pVtxZ); // Get the buffer associated with the current centrality and z-vtx
490    if (!pool)
491      AliFatal(Form("No pool found for centrality = %f, zVtx = %f", centvalue, pVtxZ));
492 */     
493
494    // Track loop 
495    for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
496      AliESDtrack* track = fESD->GetTrack(iTracks);
497      if (!track) {
498        printf("ERROR: Could not receive track %d\n", iTracks);
499        continue;
500      }
501
502      if(track->Pt()<1) continue;
503
504     // fTrackPtBefTrkCuts->Fill(track->Pt());           
505
506      // RecKine: ITSTPC cuts  
507      if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
508
509      //RecKink
510      if(fRejectKinkMother) { // Quick and dirty fix to reject both kink mothers and daughters
511        if(track->GetKinkIndex(0) != 0) continue;
512      } 
513
514      // RecPrim
515      if(!ProcessCutStep(AliHFEcuts::kStepRecPrim, track)) continue;
516
517      // HFE cuts: TPC PID cleanup
518      if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, track)) continue;
519
520     // fTrackHFEcuts->Fill(track->Phi());
521
522      //track phi distribution for diff ITS layer hit
523 //     if(track->HasPointOnITSLayer(0)) fTrakPhiSPD1->Fill(track->Phi());
524 //     if(track->HasPointOnITSLayer(1)) fTrakPhiSPD2->Fill(track->Phi());
525
526
527 //     if(track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) fTrakPhiSPDOr->Fill(track->Phi());
528 //     if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1)) fTrakPhiSPDAnd->Fill(track->Phi());
529
530      // HFEcuts: ITS layers cuts
531      if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsITS, track)) continue;
532
533 //     fTrackHFEcutsITS->Fill(track->Phi());
534
535 //     fTrackPtAftTrkCuts->Fill(track->Pt());           
536
537      Double_t fClsE = -999, p = -999, fEovP=-999, pt = -999, dEdx=-999, fTPCnSigma=0;
538      pt = track->Pt();
539      p = track->P();
540      dEdx = track->GetTPCsignal();
541      fTPCnSigma = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(track, AliPID::kElectron) : 1000;
542
543      //TPC electron phi
544      if(fTPCnSigma >= -2 && fTPCnSigma <= 2){
545 //       fElecPhiTPC->Fill(track->Phi());
546      }
547
548      //eta cut (-0.7,0.7)
549      if(track->Eta() < -0.7 || track->Eta() > 0.7) continue;
550
551      // Track extrapolation to EMCAL
552      Int_t fClsId = track->GetEMCALcluster();
553      if(fClsId <0) continue;
554      AliESDCaloCluster *cluster = fESD->GetCaloCluster(fClsId);
555      if(TMath::Abs(cluster->GetTrackDx())>0.05 || TMath::Abs(cluster->GetTrackDz())>0.05) continue;    
556 //     fdEdxBef->Fill(p,dEdx);
557      fTPCnsigma->Fill(p,fTPCnSigma);
558
559 //     fTrkpt->Fill(pt);
560      fClsE = cluster->E();
561      fEovP = fClsE/p;
562      /*
563         fvalueElectron[0] = pt;
564         fvalueElectron[1] = p;
565         fvalueElectron[2] = fTPCnSigma;
566         fvalueElectron[3] = dEdx;
567         fvalueElectron[4] = fEovP;
568         fvalueElectron[5] = cluster->GetM20();
569         fvalueElectron[6] = cluster->GetM02();
570         fvalueElectron[7] = cluster->GetDispersion();
571
572         fSparseElectron->Fill(fvalueElectron);
573       */
574      if(fTPCnSigma >= -2 && fTPCnSigma <= 2){
575        fTrkEovPBef->Fill(pt,fEovP);
576      }
577      if(fTPCnSigma < -3.5)fTrkEovPBefHad->Fill(pt,fEovP);
578      /*
579         Int_t pidpassed = 0;
580      //--- track accepted, do PID
581      AliHFEpidObject hfetrack;
582      hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
583      hfetrack.SetRecTrack(track);
584      hfetrack.SetPbPb();
585      if(fPID->IsSelected(&hfetrack, NULL, "", fPIDqa)) pidpassed = 1;
586
587      if(pidpassed==1){
588      cout << "dedx, E/p :  "<< dEdx << ", " << fEovP <<endl;
589      fTrkEovPAft->Fill(pt,fEovP);
590      fdEdxAft->Fill(p,dEdx);
591      fTPCnsigmaAft->Fill(p,fTPCnSigma);
592      }
593       */
594
595      //Electron id with TPC and E/p
596      if(fTPCnSigma >= -2 && fTPCnSigma <= 2 && fEovP >= 0.8 && fEovP <=1.2) {
597 //       fElecPhiTPCEovP->Fill(track->Phi());
598
599        //Electron id with shower shape  
600        if(cluster->GetM20()<0.2 && cluster->GetM02()< 0.5 && cluster->GetDispersion()<1){
601          
602          fElecPhi->Fill(track->Phi());
603          fElecPhiPt->Fill(track->Phi(),track->Pt());
604          if (track->Eta() >0 && track->Eta() <0.7) fElecPhiTPChalf->Fill(track->Phi());
605 //         fTrkEovPAftOwn->Fill(pt,fEovP);
606 //         fdEdxAftOwn->Fill(p,dEdx);
607 //         fTPCnsigmaAftOwn->Fill(p,fTPCnSigma);
608
609          HadronInfo(iTracks);
610
611          Bool_t fFlagPhotonicElec = kFALSE;
612          // select photonic electron
613          SelectPhotonicElectron(iTracks,track,fFlagPhotonicElec);
614          //Inclusive electron-hadron correlation
615          ElectronHadCorrel(iTracks, track, fInclusiveElecDphi, fInclusiveElecDphi1,fInclusiveElecDphi2,fInclusiveElecDphi3,fInclusiveElecDphi4);
616          fInclusiveElecPt->Fill(pt);
617 //         MixedEvent(track,fMixedIncElecDphi, fMixedIncElecDphi1,fMixedIncElecDphi2);
618          
619          // photonic electron
620          if(fFlagPhotonicElec){
621          //Electron hadron correlation
622          ElectronHadCorrel(iTracks, track, fPhotElecDphi,fPhotElecDphi1,fPhotElecDphi2,fPhotElecDphi3,fPhotElecDphi4);
623          fPhotoElecPt->Fill(pt);
624 //         MixedEvent(track,fMixedPhotElecDphi, fMixedPhotElecDphi1,fMixedPhotElecDphi2);
625          }
626
627          // Semi inclusive electron 
628          if(!fFlagPhotonicElec){
629            //Electron hadron correlation
630            ElectronHadCorrel(iTracks, track, fSemiIncElecDphi, fSemiIncElecDphi1,fSemiIncElecDphi2,fSemiIncElecDphi3,fSemiIncElecDphi4);
631            fSemiInclElecPt->Fill(pt);
632 //           MixedEvent(track,fMixedSemiIncElecDphi,fMixedSemiIncElecDphi1,fMixedSemiIncElecDphi2);
633          }
634          
635        }
636      }
637    }
638    /*
639    //EMC clusters  
640    Int_t clsNo = fESD->GetNumberOfCaloClusters();
641    fNClusv1->Fill(clsNo); 
642    for(Int_t iclus=0; iclus<clsNo ; iclus++){ 
643      AliESDCaloCluster* clus = fESD->GetCaloCluster(iclus);
644      if(!clus->IsEMCAL()) continue; 
645      fNCellv1->Fill(clus->GetNCells());
646      fClsEv1->Fill(clus->E());  
647    }
648 */
649 /*
650    TObjArray* tracksClone = CloneAndReduceTrackList();
651    tracksClone->SetOwner();
652    pool->UpdatePool(tracksClone);
653  */  
654    PostData(1, fOutputList);
655 }
656 //_________________________________________
657 void AliAnalysisTaskElecHadronCorrel::UserCreateOutputObjects()
658 {
659   //Create histograms
660   //  TGeoManager::Import("geometry.root");
661   //  fGeom =  AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
662
663   //--------Initialize PID
664   fPID->SetHasMCData(kFALSE);
665   if(!fPID->GetNumberOfPIDdetectors()) 
666   {
667     fPID->AddDetector("TPC", 0);
668     fPID->AddDetector("EMCAL", 1);
669   }
670
671   fPID->SortDetectors(); 
672   fPIDqa = new AliHFEpidQAmanager();
673   fPIDqa->Initialize(fPID);
674
675   //--------Initialize correction Framework and Cuts
676   fCFM = new AliCFManager;
677   const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
678   fCFM->SetNStepParticle(kNcutSteps);
679   for(Int_t istep = 0; istep < kNcutSteps; istep++)
680     fCFM->SetParticleCutsList(istep, NULL);
681
682   if(!fCuts){
683     AliWarning("Cuts not available. Default cuts will be used");
684     fCuts = new AliHFEcuts;
685     fCuts->CreateStandardCuts();
686   }
687   fCuts->Initialize(fCFM);
688 /*
689   //Mixed event initialising
690   Int_t trackDepth = 2000;
691   Int_t poolsize   = 1000;
692
693   Int_t nCentralityBins  = 5;
694   Double_t CentralityBins[] = {0,2,4,6,8,10};
695
696   Int_t nZvtxBins  = 4;
697   Double_t vertexBins[] = {-10,-5,0,5,10};
698
699   fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, (Double_t*) CentralityBins, nZvtxBins, (Double_t*) vertexBins);
700 */
701   //---------Output Tlist
702   fOutputList = new TList();
703   fOutputList->SetOwner();
704   fOutputList->Add(fPIDqa->MakeList("PIDQA"));
705
706   fNoEvents = new TH1F("fNoEvents","",1,0,1) ;
707   fOutputList->Add(fNoEvents);
708
709   fcentrality = new TH1F("fcentrality","centrality", 100,0,100);
710   fOutputList->Add(fcentrality);
711 /*
712   fTrkpt = new TH1F("fTrkpt","track pt",1000,0,50);
713   fOutputList->Add(fTrkpt);
714
715   fTrackPtBefTrkCuts = new TH1F("fTrackPtBefTrkCuts","track pt before track cuts",1000,0,50);
716   fOutputList->Add(fTrackPtBefTrkCuts);
717
718   fTrackPtAftTrkCuts = new TH1F("fTrackPtAftTrkCuts","track pt after track cuts",1000,0,50);
719   fOutputList->Add(fTrackPtAftTrkCuts);
720 */
721   fTPCnsigma = new TH2F("fTPCnsigma", "TPC - n sigma",1000,0,50,200,-10,10);
722   fOutputList->Add(fTPCnsigma);
723 /*
724   fTPCnsigmaAft = new TH2F("fTPCnsigmaAft", "TPC - n sigma after hfepid",1000,0,50,200,-10,10);
725   fOutputList->Add(fTPCnsigmaAft);
726
727   fTPCnsigmaAftOwn = new TH2F("fTPCnsigmaAftOwn", "TPC - n sigma after own pid",1000,0,50,200,-10,10);
728   fOutputList->Add(fTPCnsigmaAftOwn);
729 */
730   fTrkEovPBef = new TH2F("fTrkEovPBef","track E/p before HFE pid",1000,0,50,100,0,2);
731   fOutputList->Add(fTrkEovPBef);
732
733   fTrkEovPBefHad = new TH2F("fTrkEovPBefHad","track E/p for TPCnsig < 3.5",1000,0,50,100,0,2);
734   fOutputList->Add(fTrkEovPBefHad);
735 /*
736   fTrkEovPAft = new TH2F("fTrkEovPAft","track E/p after HFE pid",1000,0,50,100,0,2);
737   fOutputList->Add(fTrkEovPAft);
738
739   fTrkEovPAftOwn = new TH2F("fTrkEovPAftOwn","track E/p after own pid",1000,0,50,100,0,2);
740   fOutputList->Add(fTrkEovPAftOwn);
741
742   fdEdxBef = new TH2F("fdEdxBef","track dEdx vs p before HFE pid",1000,0,50,150,0,150);
743   fOutputList->Add(fdEdxBef);
744
745   fdEdxAft = new TH2F("fdEdxAft","track dEdx vs p after HFE pid",1000,0,50,150,0,150);
746   fOutputList->Add(fdEdxAft);
747
748   fdEdxAftOwn = new TH2F("fdEdxAftOwn","track dEdx vs p own HFE pid",1000,0,50,150,0,150);
749   fOutputList->Add(fdEdxAftOwn);
750 */
751   fElecPhi = new TH1F("fElecPhi", "Electron phi",1000,0,6.28);
752   fOutputList->Add(fElecPhi);
753
754   fElecPhiPt = new TH2F("fElecPhiPt", "Electron phi vs pt; Electron phi; pt (GeV/c)",1000,0,6.28,1000,0,100);
755   fOutputList->Add(fElecPhiPt);
756
757   fElecPhiTPChalf = new TH1F("fElecPhiTPChalf", "Electron phi for 0<eta<0.7",1000,0,6.28);                            
758   fOutputList->Add(fElecPhiTPChalf);
759
760 /*  fElecPhiTPC = new TH1F("fElecPhiTPC", "Electron phi after TPC cut",1000,0,6.28);
761   fOutputList->Add(fElecPhiTPC);
762
763   fElecPhiTPCEovP = new TH1F("fElecPhiTPCEovP", "Electron phi after TPC and E/p cut",1000,0,6.28);
764   fOutputList->Add(fElecPhiTPCEovP);
765 */
766   fHadronPhi = new TH1F("fHadronPhi", "Hadron phi",1000,0,6.28);
767   fOutputList->Add(fHadronPhi);
768
769   fHadronPhiTPChalf = new TH1F("fHadronPhiTPChalf", "Hadron phi for 0<eta<0.9",1000,0,6.28);                          
770   fOutputList->Add(fHadronPhiTPChalf);
771
772   fHadronPhiPt = new TH2F("fHadronPhiPt", "Hadron phi vs pt; hadron phi; pt (GeV/c)",1000,0,6.28,1000,0,100);
773   fOutputList->Add(fHadronPhiPt);
774
775 /*
776   fTrackHFEcuts = new TH1F("fTrackHFEcuts","Track phi for HFE cuts",1000,0,6.28);
777   fOutputList->Add(fTrackHFEcuts);
778
779   fTrakPhiSPD1 = new TH1F("fTrakPhiSPD1","Track phi for hit in SPD layer 1",1000,0,6.28);
780   fOutputList->Add(fTrakPhiSPD1);
781
782   fTrakPhiSPD2 = new TH1F("fTrakPhiSPD2","Track phi for hit in SPD layer 2",1000,0,6.28);
783   fOutputList->Add(fTrakPhiSPD2);
784
785   fTrakPhiSPDOr = new TH1F("fTrakPhiSPDOr","Track phi for hit in any SPD layer",1000,0,6.28);
786   fOutputList->Add(fTrakPhiSPDOr);
787
788   fTrakPhiSPDAnd = new TH1F("fTrakPhiSPDAnd","Track phi for hit in both SPD layer",1000,0,6.28);
789   fOutputList->Add(fTrakPhiSPDAnd);
790
791   fTrackHFEcutsITS = new TH1F("fTrackHFEcutsITS","Track phi for HFE cuts + ITS HFE cuts",1000,0,6.28);
792   fOutputList->Add(fTrackHFEcutsITS);
793
794   fOpeningAngleLS = new TH1F("fOpeningAngleLS","Opening angle for LS pairs",100,0,1);
795   fOutputList->Add(fOpeningAngleLS);
796
797   fOpeningAngleULS = new TH1F("fOpeningAngleULS","Opening angle for ULS pairs",100,0,1);
798   fOutputList->Add(fOpeningAngleULS);
799 */
800   fSemiIncElecDphi = new TH2F("fSemiIncElecDphi", "Semi Inclusive elec-had Dphi correlation",200,0,20,64,-1.57,4.71);
801   fOutputList->Add(fSemiIncElecDphi);
802
803   fSemiIncElecDphi1 = new TH2F("fSemiIncElecDphi1", "Semi Inclusive elec-had Dphi correlation for 1<pt^{asso}<3",200,0,20,64,-1.57,4.71);
804   fOutputList->Add(fSemiIncElecDphi1);
805
806   fSemiIncElecDphi2 = new TH2F("fSemiIncElecDphi2", "Semi Inclusive elec-had Dphi correlation for 3<pt^{asso}<5",200,0,20,64,-1.57,4.71);
807   fOutputList->Add(fSemiIncElecDphi2);
808
809   fSemiIncElecDphi3 = new TH2F("fSemiIncElecDphi3", "Semi Inclusive elec-had Dphi correlation for 5<pt^{asso}<7",200,0,20,64,-1.57,4.71);
810   fOutputList->Add(fSemiIncElecDphi3);
811
812   fSemiIncElecDphi4 = new TH2F("fSemiIncElecDphi4", "Semi Inclusive elec-had Dphi correlation for 7<pt^{asso}<9",200,0,20,64,-1.57,4.71);
813   fOutputList->Add(fSemiIncElecDphi4);
814
815   fPhotElecDphi = new TH2F("fPhotElecDphi", "Photon elec-had Dphi correlation",200,0,20,64,-1.57,4.71);
816   fOutputList->Add(fPhotElecDphi);
817
818   fPhotElecDphi1 = new TH2F("fPhotElecDphi1", "Photon elec-had Dphi correlation for 1<pt^{asso}<3",200,0,20,64,-1.57,4.71);
819   fOutputList->Add(fPhotElecDphi1);
820
821   fPhotElecDphi2 = new TH2F("fPhotElecDphi2", "Photon elec-had Dphi correlation for 3<pt^{asso}<5",200,0,20,64,-1.57,4.71);
822   fOutputList->Add(fPhotElecDphi2);
823
824   fPhotElecDphi3 = new TH2F("fPhotElecDphi3", "Photon elec-had Dphi correlation for 5<pt^{asso}<7",200,0,20,64,-1.57,4.71);
825   fOutputList->Add(fPhotElecDphi3);
826
827   fPhotElecDphi4 = new TH2F("fPhotElecDphi4", "Photon elec-had Dphi correlation for 7<pt^{asso}<9",200,0,20,64,-1.57,4.71);
828   fOutputList->Add(fPhotElecDphi4);
829
830   fInclusiveElecDphi = new TH2F("fInclusiveElecDphi", "Inclusive elec-had Dphi correlation",200,0,20,64,-1.57,4.71);
831   fOutputList->Add(fInclusiveElecDphi);
832
833   fInclusiveElecDphi1 = new TH2F("fInclusiveElecDphi1", "Inclusive elec-had Dphi correlation for 1<pt^{asso}<3",200,0,20,64,-1.57,4.71);
834   fOutputList->Add(fInclusiveElecDphi1);
835
836   fInclusiveElecDphi2 = new TH2F("fInclusiveElecDphi2", "Inclusive elec-had Dphi correlation for 3<pt^{asso}<5",200,0,20,64,-1.57,4.71);
837   fOutputList->Add(fInclusiveElecDphi2);
838
839   fInclusiveElecDphi3 = new TH2F("fInclusiveElecDphi3", "Inclusive elec-had Dphi correlation for 5<pt^{asso}<7",200,0,20,64,-1.57,4.71);
840   fOutputList->Add(fInclusiveElecDphi3);
841
842   fInclusiveElecDphi4 = new TH2F("fInclusiveElecDphi4", "Inclusive elec-had Dphi correlation for 7<pt^{asso}<9",200,0,20,64,-1.57,4.71);
843   fOutputList->Add(fInclusiveElecDphi4);
844
845   fDphiULSMassLow = new TH2F("fDphiULSMassLow", "e-h Dphi ULS, mass<cut",200,0,20,64,-1.57,4.71);
846   fOutputList->Add(fDphiULSMassLow);
847
848   fDphiULSMassLow1 = new TH2F("fDphiULSMassLow1", "e-h Dphi ULS, mass<cut for 1<pt^{asso}<3",200,0,20,64,-1.57,4.71);
849   fOutputList->Add(fDphiULSMassLow1);
850
851   fDphiULSMassLow2 = new TH2F("fDphiULSMassLow2", "e-h Dphi ULS, mass<cut for 3<pt^{asso}<5",200,0,20,64,-1.57,4.71);
852   fOutputList->Add(fDphiULSMassLow2);
853
854   fDphiULSMassLow3 = new TH2F("fDphiULSMassLow3", "e-h Dphi ULS, mass<cut for 5<pt^{asso}<7",200,0,20,64,-1.57,4.71);
855   fOutputList->Add(fDphiULSMassLow3);
856
857   fDphiULSMassLow4 = new TH2F("fDphiULSMassLow4", "e-h Dphi ULS, mass<cut for 7<pt^{asso}<9",200,0,20,64,-1.57,4.71);
858   fOutputList->Add(fDphiULSMassLow4);
859
860   fDphiLSMassLow = new TH2F("fDphiLSMassLow", "e-h Dphi LS, mass<cut",200,0,20,64,-1.57,4.71);
861   fOutputList->Add(fDphiLSMassLow);
862
863   fDphiLSMassLow1 = new TH2F("fDphiLSMassLow1", "e-h Dphi LS, mass<cut for 1<pt^{asso}<3",200,0,20,64,-1.57,4.71);
864   fOutputList->Add(fDphiLSMassLow1);
865
866   fDphiLSMassLow2 = new TH2F("fDphiLSMassLow2", "e-h Dphi LS, mass<cut for 3<pt^{asso}<5",200,0,20,64,-1.57,4.71);
867   fOutputList->Add(fDphiLSMassLow2);
868
869   fDphiLSMassLow3 = new TH2F("fDphiLSMassLow3", "e-h Dphi LS, mass<cut for 5<pt^{asso}<7",200,0,20,64,-1.57,4.71);
870   fOutputList->Add(fDphiLSMassLow3);
871
872   fDphiLSMassLow4 = new TH2F("fDphiLSMassLow4", "e-h Dphi LS, mass<cut for 7<pt^{asso}<9",200,0,20,64,-1.57,4.71);
873   fOutputList->Add(fDphiLSMassLow4);
874
875   fDphiULSMassLowNoPartner = new TH2F("fDphiULSMassLowNoPartner", "e-h Dphi ULS with no partner, mass<mass cut,",200,0,20,64,-1.57,4.71);
876   fOutputList->Add(fDphiULSMassLowNoPartner);
877
878   fDphiULSMassLowNoPartner1 = new TH2F("fDphiULSMassLowNoPartner1", "e-h Dphi ULS with no partner, mass<mass cut for 1<pt^{asso}<3,",200,0,20,64,-1.57,4.71);
879   fOutputList->Add(fDphiULSMassLowNoPartner1);
880
881   fDphiULSMassLowNoPartner2 = new TH2F("fDphiULSMassLowNoPartner2", "e-h Dphi ULS with no partner, mass<mass cut for 3<pt^{asso}<5,",200,0,20,64,-1.57,4.71);
882   fOutputList->Add(fDphiULSMassLowNoPartner2);
883
884   fDphiULSMassLowNoPartner3 = new TH2F("fDphiULSMassLowNoPartner3", "e-h Dphi ULS with no partner, mass<mass cut for 5<pt^{asso}<7,",200,0,20,64,-1.57,4.71);
885   fOutputList->Add(fDphiULSMassLowNoPartner3);
886
887   fDphiULSMassLowNoPartner4 = new TH2F("fDphiULSMassLowNoPartner4", "e-h Dphi ULS with no partner, mass<mass cut for 7<pt^{asso}<9,",200,0,20,64,-1.57,4.71);
888   fOutputList->Add(fDphiULSMassLowNoPartner4);
889
890   fDphiLSMassLowNoPartner = new TH2F("fDphiLSMassLowNoPartner", "e-h Dphi LS with no partner, mass<mass cut",200,0,20,64,-1.57,4.71);
891   fOutputList->Add(fDphiLSMassLowNoPartner);
892
893   fDphiLSMassLowNoPartner1 = new TH2F("fDphiLSMassLowNoPartner1", "e-h Dphi LS with no partner, mass<mass cut for 1<pt^{asso}<3,",200,0,20,64,-1.57,4.71);
894   fOutputList->Add(fDphiLSMassLowNoPartner1);                                            
895
896   fDphiLSMassLowNoPartner2 = new TH2F("fDphiLSMassLowNoPartner2", "e-h Dphi LS with no partner, mass<mass cut for 3<pt^{asso}<5,",200,0,20,64,-1.57,4.71);
897   fOutputList->Add(fDphiLSMassLowNoPartner2);
898
899   fDphiLSMassLowNoPartner3 = new TH2F("fDphiLSMassLowNoPartner3", "e-h Dphi LS with no partner, mass<mass cut for 5<pt^{asso}<7,",200,0,20,64,-1.57,4.71);
900   fOutputList->Add(fDphiLSMassLowNoPartner3);
901
902   fDphiLSMassLowNoPartner4 = new TH2F("fDphiLSMassLowNoPartner4", "e-h Dphi LS with no partner, mass<mass cut for 7<pt^{asso}<9,",200,0,20,64,-1.57,4.71);
903   fOutputList->Add(fDphiLSMassLowNoPartner4);
904
905   fPhotoElecPt = new TH1F("fPhotoElecPt", "photonic electron pt",1000,0,100);
906   fOutputList->Add(fPhotoElecPt);
907
908   fSemiInclElecPt = new TH1F("fSemiInclElecPt", "Semi-inclusive electron pt",1000,0,100);
909   fOutputList->Add(fSemiInclElecPt);
910
911   fInclusiveElecPt = new TH1F("fInclElecPt", "Inclusive electron pt",1000,0,100);
912   fOutputList->Add(fInclusiveElecPt);
913
914   fULSElecPt = new TH1F("fULSElecPt", "ULS electron pt",1000,0,100);
915   fOutputList->Add(fULSElecPt);
916
917   fLSElecPt = new TH1F("fLSElecPt", "LS electron pt",1000,0,100);
918   fOutputList->Add(fLSElecPt);
919 /*
920   fNCellv1 = new TH1F("fNCellv1","Ncell in clus (v1); NCell; count",100,0,100) ;
921   fOutputList->Add(fNCellv1);
922
923   fClsEv1 = new TH1F("fClsEv1", "Clus E(v1); Cls E; count",1000,0,100); 
924   fOutputList->Add(fClsEv1); 
925
926   fNClusv1 = new TH1F("fNClusv1","Nclus in event (v1); NClus; count",500,0,500) ; 
927   fOutputList->Add(fNClusv1);
928
929   fKFParticleP = new TH1F("fKFParticleP","KFparticle rec P; P(GeV/c)",1000,0,50);
930   fOutputList->Add(fKFParticleP);
931
932   fKFParticleE = new TH1F("fKFParticleE", "KfParticle rec E; E; count",1000,0,100); 
933   fOutputList->Add(fKFParticleE);
934 */
935   fInvmassLS1 = new TH1F("fInvmassLS1", "Inv mass of LS (e,e); mass(GeV/c^2); counts;", 1000,0,1.0);
936   fOutputList->Add(fInvmassLS1);
937
938   fInvmassULS1 = new TH1F("fInvmassULS1", "Inv mass of ULS (e,e); mass(GeV/c^2); counts;", 1000,0,1.0);
939   fOutputList->Add(fInvmassULS1);
940
941   fInvmassLS2 = new TH1F("fInvmassLS2", "Inv mass of LS (e,e) for pt^{e}>1; mass(GeV/c^2); counts;", 1000,0,1.0);
942   fOutputList->Add(fInvmassLS2);
943
944   fInvmassULS2 = new TH1F("fInvmassULS2", "Inv mass of ULS (e,e) for pt^{e}>1; mass(GeV/c^2); counts;", 1000,0,1.0);
945   fOutputList->Add(fInvmassULS2);
946
947   fInvmassLS3 = new TH1F("fInvmassLS3", "Inv mass of LS (e,e) for pt^{e}>2; mass(GeV/c^2); counts;", 1000,0,1.0);
948   fOutputList->Add(fInvmassLS3);                                                          
949
950   fInvmassULS3 = new TH1F("fInvmassULS3", "Inv mass of ULS (e,e) for pt^{e}>2; mass(GeV/c^2); counts;", 1000,0,1.0);
951   fOutputList->Add(fInvmassULS3);
952
953   fInvmassLS4 = new TH1F("fInvmassLS4", "Inv mass of LS (e,e) for pt^{e}>3; mass(GeV/c^2); counts;", 1000,0,1.0);
954   fOutputList->Add(fInvmassLS4);  
955
956   fInvmassULS4 = new TH1F("fInvmassULS4", "Inv mass of ULS (e,e) for pt^{e}>3; mass(GeV/c^2); counts;", 1000,0,1.0);
957   fOutputList->Add(fInvmassULS4);
958
959   fInvmassLS5 = new TH1F("fInvmassLS5", "Inv mass of LS (e,e) for pt^{e}>4; mass(GeV/c^2); counts;", 1000,0,1.0);
960   fOutputList->Add(fInvmassLS5);  
961
962   fInvmassULS5 = new TH1F("fInvmassULS5", "Inv mass of ULS (e,e) for pt^{e}>4; mass(GeV/c^2); counts;", 1000,0,1.0);
963   fOutputList->Add(fInvmassULS5);
964 /*
965   fNoMixedEvents = new TH1F("fNoMixedEvents","",1,0,1) ;
966   fOutputList->Add(fNoMixedEvents);
967
968   fMixStat = new TH2F("fMixStat","no of events in pool  vs Centrality;Nevent in pool;Centrality",200,0,200,5,0,10);
969   fOutputList->Add(fMixStat);                                                             
970
971   fMixStat1 = new TH2F("fMixStat1","no of events in pool  vs zvtx;Nevents in pool;zvtx",200,0,200,4,-10,10);
972   fOutputList->Add(fMixStat1);
973
974   fMixedIncElecDphi = new TH2F("fMixedIncElecDphi", "Mixed event - Inclusive elec-had Dphi correlation",200,0,20,100,-1.57,4.71);
975   fOutputList->Add(fMixedIncElecDphi);
976
977   fMixedIncElecDphi1 = new TH2F("fMixedIncElecDphi1", "Mixed event - Inclusive elec-had Dphi correlation 1<pt<3",200,0,20,100,-1.57,4.71);
978   fOutputList->Add(fMixedIncElecDphi1);
979
980   fMixedIncElecDphi2 = new TH2F("fMixedIncElecDphi2", "Mixed event - Inclusive elec-had Dphi correlation 3<pt<5",200,0,20,100,-1.57,4.71);
981   fOutputList->Add(fMixedIncElecDphi2);
982
983   fMixedSemiIncElecDphi = new TH2F("fMixedSemiIncElecDphi", "Mixed event - Semi Inclusive elec-had Dphi correlation",200,0,20,100,-1.57,4.71);
984   fOutputList->Add(fMixedSemiIncElecDphi);
985
986   fMixedSemiIncElecDphi1 = new TH2F("fMixedSemiIncElecDphi1", "Mixed event - Semi Inclusive elec-had Dphi correlation 1<pt<3",200,0,20,100,-1.57,4.71);
987   fOutputList->Add(fMixedSemiIncElecDphi1);
988
989   fMixedSemiIncElecDphi2 = new TH2F("fMixedSemiIncElecDphi2", "Mixed event - Semi Inclusive elec-had Dphi correlation 3<pt<5",200,0,20,100,-1.57,4.71);
990   fOutputList->Add(fMixedSemiIncElecDphi2);
991
992   fMixedPhotElecDphi = new TH2F("fMixedPhotElecDphi", "Mixed event - Photo elec-had Dphi correlation",200,0,20,100,-1.57,4.71);
993   fOutputList->Add(fMixedPhotElecDphi);
994
995   fMixedPhotElecDphi1 = new TH2F("fMixedPhotElecDphi1", "Mixed event - Photo elec-had Dphi correlation 1<pt<3",200,0,20,100,-1.57,4.71);
996   fOutputList->Add(fMixedPhotElecDphi1);
997
998   fMixedPhotElecDphi2 = new TH2F("fMixedPhotElecDphi2", "Mixed event - Photo elec-had Dphi correlation 3<pt<5",200,0,20,100,-1.57,4.71);
999   fOutputList->Add(fMixedPhotElecDphi2);
1000
1001   fMixedDphiULSMassLow = new TH2F("fMixedDphiULSMassLow", "Mixed event - ULS mass < cut elec-had Dphi correlation",200,0,20,100,-1.57,4.71);
1002   fOutputList->Add(fMixedDphiULSMassLow);
1003
1004   fMixedDphiULSMassLow1 = new TH2F("fMixedDphiULSMassLow1", "Mixed event - ULS mass < cut elec-had Dphi correlation 1<pt<3",200,0,20,100,-1.57,4.71);
1005   fOutputList->Add(fMixedDphiULSMassLow1);
1006
1007   fMixedDphiULSMassLow2 = new TH2F("fMixedDphiULSMassLow2", "Mixed event - ULS mass < cut elec-had Dphi correlation 3<pt<5",200,0,20,100,-1.57,4.71);
1008   fOutputList->Add(fMixedDphiULSMassLow2);
1009
1010   fMixedDphiLSMassLow = new TH2F("fMixedDphiLSMassLow", "Mixed event - LS mass < cut elec-had Dphi correlation",200,0,20,100,-1.57,4.71);
1011   fOutputList->Add(fMixedDphiLSMassLow);
1012
1013   fMixedDphiLSMassLow1 = new TH2F("fMixedDphiLSMassLow1", "Mixed event - LS mass < cut elec-had Dphi correlation 1<pt<3",200,0,20,100,-1.57,4.71);
1014   fOutputList->Add(fMixedDphiLSMassLow1);
1015
1016   fMixedDphiLSMassLow2 = new TH2F("fMixedDphiLSMassLow2", "Mixed event - LS mass < cut elec-had Dphi correlation 3<pt<5",200,0,20,100,-1.57,4.71);
1017   fOutputList->Add(fMixedDphiLSMassLow2);
1018 */
1019   /*
1020   fNLSminus = new TH1F("fNLSminus","No of LS negative pairs (e-,e-) ",1000,-0.5,999.5);
1021   fOutputList->Add(fNLSminus);
1022
1023   fNLSplus = new TH1F("fNLSplus","No of LS positive pairs (e+,e+)",1000,-0.5,999.5);
1024   fOutputList->Add(fNLSplus);
1025
1026   fNULS = new TH1F("fNULS","No of ULS pairs (e+,e-)",1000,-0.5,999.5);
1027   fOutputList->Add(fNULS);
1028 */
1029   fHadronIPxy = new TH1F("fHadronIPxy", "hadron impact paramter XY",1000,-5,5);
1030   fOutputList->Add(fHadronIPxy);
1031
1032   fHadronIPz = new TH1F("fHadronIPz", "hadron impact paramter Z",1000,-20,20);
1033   fOutputList->Add(fHadronIPz);
1034
1035   fHadronPt = new TH1F("fHadronPt","hadron pt distribution",1000,0,100);
1036   fOutputList->Add(fHadronPt);
1037
1038   fCentralityPass = new TH1F("fCentralityPass", "Centrality Pass", 101, -1, 100);
1039   fOutputList->Add(fCentralityPass);
1040
1041   fCentralityNoPass = new TH1F("fCentralityNoPass", "Centrality No Pass", 101, -1, 100);
1042   fOutputList->Add(fCentralityNoPass);
1043
1044   /*
1045      Int_t binsv1[8]={1000,1000,200,150,100,100,100,100}; //pt, p, TPCnsig, dEdx, E/p, M20, M02, dispersion 
1046      Double_t xminv1[8]={0,0,-10,0,0,0,0,0};
1047      Double_t xmaxv1[8]={50,50,10,150,2,2,2,2};
1048      fSparseElectron = new THnSparseD ("Electron","Electron",8,binsv1,xminv1,xmaxv1);
1049      fOutputList->Add(fSparseElectron);
1050    */
1051   PostData(1,fOutputList);
1052 }
1053
1054 //________________________________________________________________________
1055 void AliAnalysisTaskElecHadronCorrel::Terminate(Option_t *)
1056 {
1057   // Info("Terminate");
1058   AliAnalysisTaskSE::Terminate();
1059 }
1060
1061 //________________________________________________________________________
1062 Bool_t AliAnalysisTaskElecHadronCorrel::ProcessCutStep(Int_t cutStep, AliVParticle *track)
1063 {
1064   // Check single track cuts for a given cut step
1065   const Int_t kMCOffset = AliHFEcuts::kNcutStepsMCTrack;
1066   if(!fCFM->CheckParticleCuts(cutStep + kMCOffset, track)) return kFALSE;
1067   return kTRUE;
1068 }
1069 //_________________________________________
1070 void AliAnalysisTaskElecHadronCorrel::SelectPhotonicElectron(Int_t itrack, AliESDtrack *track, Bool_t &fFlagPhotonicElec)
1071 {
1072   //Identify non-heavy flavour electrons using Invariant mass method
1073
1074   fTrackCuts1->SetAcceptKinkDaughters(kFALSE);
1075   fTrackCuts1->SetRequireTPCRefit(kTRUE);
1076   fTrackCuts1->SetRequireITSRefit(kTRUE);
1077   fTrackCuts1->SetEtaRange(-0.9,0.9);
1078   fTrackCuts1->SetRequireSigmaToVertex(kTRUE);
1079   //fTrackCuts1->SetMaxChi2PerClusterTPC(3.5);
1080   fTrackCuts1->SetMaxChi2PerClusterTPC(4);
1081   fTrackCuts1->SetMinNClustersTPC(80);
1082
1083   //  const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
1084
1085   Bool_t flagPhotonicElec = kFALSE;
1086   Int_t NLS_plus=0, NLS_minus=0, NULS=0;
1087
1088   for(Int_t jTracks = 0; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1089     AliESDtrack* trackAsso = fESD->GetTrack(jTracks);
1090     if (!trackAsso) {
1091       printf("ERROR: Could not receive track %d\n", jTracks);
1092       continue;
1093     }
1094     if(jTracks==itrack) continue;
1095
1096     Double_t dEdxAsso = -999., ptAsso=-999., openingAngle = -999.,nsigma=-999.0;
1097     Double_t mass=-999., width = -999;
1098     Bool_t fFlagLS=kFALSE, fFlagULS=kFALSE;
1099
1100     dEdxAsso = trackAsso->GetTPCsignal();
1101     nsigma = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(trackAsso, AliPID::kElectron) : 1000;
1102     ptAsso = trackAsso->Pt();
1103     Int_t chargeAsso = trackAsso->Charge();
1104     Int_t charge = track->Charge();
1105
1106     if(ptAsso <0.3) continue;
1107     if(trackAsso->Eta()<-0.9 || trackAsso->Eta()>0.9) continue;
1108 //    if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, trackAsso)) continue;
1109 //    if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackAsso)) continue;
1110
1111     if(!fTrackCuts1->AcceptTrack(trackAsso)) continue;
1112     //    if(dEdxAsso <70 || dEdxAsso>100) continue; //11a pass1
1113     if(nsigma < -3 || nsigma > 3) continue;
1114
1115     Int_t fPDGe1 = 11; Int_t fPDGe2 = 11;
1116     if(charge>0) fPDGe1 = -11;
1117     if(chargeAsso>0) fPDGe2 = -11;
1118
1119     if(charge == chargeAsso) fFlagLS = kTRUE;
1120     if(charge != chargeAsso) fFlagULS = kTRUE;
1121
1122     AliKFParticle ge1 = AliKFParticle(*track, fPDGe1);
1123     AliKFParticle ge2 = AliKFParticle(*trackAsso, fPDGe2);
1124     AliKFParticle recg(ge1, ge2);
1125
1126     if(recg.GetNDF()<1) continue;
1127     Double_t chi2recg = recg.GetChi2()/recg.GetNDF();
1128     if(TMath::Sqrt(TMath::Abs(chi2recg))>3.) continue;
1129
1130     openingAngle = ge1.GetAngle(ge2);
1131     //    if(fFlagLS) fOpeningAngleLS->Fill(openingAngle);
1132     //    if(fFlagULS) fOpeningAngleULS->Fill(openingAngle);
1133
1134     //   if(openingAngle > fOpeningAngleCut) continue;
1135
1136     Int_t MassCorrect;
1137     MassCorrect = recg.GetMass(mass,width);
1138
1139     if(fFlagLS){
1140       if(track->Charge() > 0 ) NLS_plus++;
1141       if(track->Charge() < 0 ) NLS_minus++;
1142     }
1143     if(fFlagULS) NULS++;
1144
1145     if(fFlagLS) {
1146       fInvmassLS1->Fill(mass);
1147       if(track->Pt()> 1) fInvmassLS2->Fill(mass);
1148       if(track->Pt()>2) fInvmassLS3->Fill(mass);
1149       if(track->Pt()>3) fInvmassLS4->Fill(mass);
1150       if(track->Pt()>4) fInvmassLS5->Fill(mass);
1151     }
1152     if(fFlagULS) {
1153       fInvmassULS1->Fill(mass);
1154       if(track->Pt() >1) fInvmassULS2->Fill(mass);
1155       if(track->Pt() >2) fInvmassULS3->Fill(mass);
1156       if(track->Pt() >3) fInvmassULS4->Fill(mass);
1157       if(track->Pt() >4) fInvmassULS5->Fill(mass);
1158     }
1159
1160     if(mass<fInvmassCut){
1161       if(fFlagULS)
1162       {
1163         ElectronHadCorrel(itrack,track,fDphiULSMassLow, fDphiULSMassLow1,fDphiULSMassLow2,fDphiULSMassLow3,fDphiULSMassLow4);
1164         fULSElecPt->Fill(track->Pt());
1165 //        MixedEvent(track,fMixedDphiULSMassLow,fMixedDphiULSMassLow1,fMixedDphiULSMassLow2);
1166       }
1167       if(fFlagLS)
1168       {
1169         ElectronHadCorrel(itrack,track,fDphiLSMassLow,fDphiLSMassLow1,fDphiLSMassLow2,fDphiLSMassLow3,fDphiLSMassLow4);
1170         fLSElecPt->Fill(track->Pt());
1171 //        MixedEvent(track,fMixedDphiLSMassLow,fMixedDphiLSMassLow1,fMixedDphiLSMassLow2);
1172       }
1173       if(fFlagLS) ElectronHadCorrelNoPartner(itrack,jTracks,track,fDphiLSMassLowNoPartner, fDphiLSMassLowNoPartner1,fDphiLSMassLowNoPartner2,fDphiLSMassLowNoPartner3,fDphiLSMassLowNoPartner4);
1174       if(fFlagULS) ElectronHadCorrelNoPartner(itrack,jTracks,track,fDphiULSMassLowNoPartner, fDphiULSMassLowNoPartner1,fDphiULSMassLowNoPartner2,fDphiULSMassLowNoPartner3,fDphiULSMassLowNoPartner4);
1175     }
1176
1177     if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec){
1178       flagPhotonicElec = kTRUE;
1179     }
1180     //   }
1181
1182   }
1183   fFlagPhotonicElec = flagPhotonicElec;
1184
1185 //  fNLSminus->Fill(NLS_minus);
1186 //  fNLSplus->Fill(NLS_plus);
1187 //  fNULS->Fill(NULS);
1188
1189 }
1190 //_________________________________________
1191 void AliAnalysisTaskElecHadronCorrel::ElectronHadCorrel(Int_t itrack, AliESDtrack *track, TH2F *DphiPt, TH2F *DphiPt1,TH2F *DphiPt2,TH2F *DphiPt3,TH2F *DphiPt4)
1192 {
1193   //Construct Delta Phi between electrons and hadrons
1194
1195   fTrackCuts2->SetAcceptKinkDaughters(kFALSE);
1196   fTrackCuts2->SetRequireTPCRefit(kTRUE);
1197   fTrackCuts2->SetRequireITSRefit(kTRUE);
1198   fTrackCuts2->SetEtaRange(-0.9,0.9);
1199   fTrackCuts2->SetRequireSigmaToVertex(kTRUE);
1200 //  fTrackCuts2->SetMaxChi2PerClusterTPC(3.5);
1201   fTrackCuts2->SetMaxChi2PerClusterTPC(4);
1202   fTrackCuts2->SetMinNClustersTPC(80);
1203
1204   for(Int_t ktracks = 0; ktracks<fESD->GetNumberOfTracks(); ktracks++){
1205     AliESDtrack* trackHad = fESD->GetTrack(ktracks);
1206     if (!trackHad) {
1207       printf("ERROR: Could not receive track %d\n", ktracks);
1208       continue;
1209     }
1210     if(ktracks == itrack) continue; //do not select the same electron
1211
1212     Double_t ptHad= -999, pHad=-999., dEdxHad = -999;
1213     Double_t ptEle = -999;
1214     Double_t phiEle = -999, phiHad = -999, Dphi = -999;
1215     Double_t pi = 3.14;
1216     Float_t IPxy=-999.0, IPz=-999.0;
1217
1218     dEdxHad = trackHad->GetTPCsignal();
1219     ptHad = trackHad->Pt();
1220     pHad = trackHad->P();
1221     ptEle = track->Pt();
1222     trackHad->GetImpactParameters(IPxy,IPz);
1223
1224 //    if(ptHad <2) continue;
1225     if(ptHad > ptEle) continue;
1226     if(trackHad->Eta()<-0.9 || trackHad->Eta()>0.9) continue;
1227 //    if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, trackHad)) continue;
1228 //    if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackHad)) continue;
1229
1230     if(!fTrackCuts2->AcceptTrack(trackHad)) continue;
1231   
1232    // fHadronIPxy->Fill(IPxy);
1233    // fHadronIPz->Fill(IPz);
1234
1235    // if(TMath::Abs(IPxy)>2.5) continue;
1236    // fHadronPhi->Fill(trackHad->Phi());
1237     
1238     phiEle = track->Phi();
1239     phiHad = trackHad->Phi();
1240     Dphi = phiEle - phiHad;
1241     if (Dphi > 3*pi/2)
1242       Dphi = Dphi - 2*pi;
1243     if (Dphi < -pi/2)
1244       Dphi = Dphi + 2*pi;
1245
1246     if(ptHad>2) DphiPt->Fill(ptEle,Dphi);
1247     if(ptHad>2 && ptHad<4) DphiPt1->Fill(ptEle,Dphi);
1248     if(ptHad>4 && ptHad<6) DphiPt2->Fill(ptEle,Dphi);
1249     if(ptHad>6 && ptHad<8) DphiPt3->Fill(ptEle,Dphi);
1250     if(ptHad>8 && ptHad<10) DphiPt4->Fill(ptEle,Dphi);
1251
1252   }
1253 }
1254 //_________________________________________
1255 void AliAnalysisTaskElecHadronCorrel::ElectronHadCorrelNoPartner(Int_t itrack,Int_t jtrack, AliESDtrack *track, TH2F *DphiPtNew, TH2F *DphiPtNew1,TH2F *DphiPtNew2,TH2F *DphiPtNew3,TH2F *DphiPtNew4)
1256 {
1257   //Construct Delta Phi between electrons and hadrons for electrons from invariant mass calculation excluding associated track
1258
1259   fTrackCuts2->SetAcceptKinkDaughters(kFALSE);
1260   fTrackCuts2->SetRequireTPCRefit(kTRUE);
1261   fTrackCuts2->SetRequireITSRefit(kTRUE);
1262   fTrackCuts2->SetEtaRange(-0.9,0.9);
1263   fTrackCuts2->SetRequireSigmaToVertex(kTRUE);
1264  // fTrackCuts2->SetMaxChi2PerClusterTPC(3.5);
1265   fTrackCuts2->SetMaxChi2PerClusterTPC(4);
1266   fTrackCuts2->SetMinNClustersTPC(80);
1267
1268   for(Int_t ktracks = 0; ktracks<fESD->GetNumberOfTracks(); ktracks++){
1269     AliESDtrack* trackHad = fESD->GetTrack(ktracks);
1270     if (!trackHad) {
1271       printf("ERROR: Could not receive track %d\n", ktracks);
1272       continue;
1273     }
1274     if(ktracks == itrack || ktracks == jtrack) continue; //do not select the same electron and associated track from inv mass cal
1275
1276
1277     Double_t ptHad= -999, pHad=-999., dEdxHad = -999;
1278     Double_t ptEle = -999;
1279     Double_t phiEle = -999, phiHad = -999, Dphi = -999;
1280     Double_t pi = 3.14;
1281     Float_t IPxy=-999.0, IPz=-999.0;
1282
1283     dEdxHad = trackHad->GetTPCsignal();
1284     ptHad = trackHad->Pt();
1285     pHad = trackHad->P();
1286     ptEle = track->Pt();
1287     trackHad->GetImpactParameters(IPxy,IPz);
1288
1289 //    if(ptHad <2) continue;
1290     if(ptHad > ptEle) continue;
1291     if(trackHad->Eta()<-0.9 || trackHad->Eta()>0.9) continue;
1292 //    if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, trackHad)) continue;
1293 //    if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackHad)) continue;
1294
1295     if(!fTrackCuts2->AcceptTrack(trackHad)) continue;
1296 //    if(TMath::Abs(IPxy)>2.5) continue;
1297
1298     phiEle = track->Phi();
1299     phiHad = trackHad->Phi();
1300     Dphi = phiEle - phiHad;
1301     if (Dphi > 3*pi/2)
1302       Dphi = Dphi - 2*pi;
1303     if (Dphi < -pi/2)
1304       Dphi = Dphi + 2*pi;
1305
1306     if(ptHad>2) DphiPtNew->Fill(ptEle,Dphi);
1307     if(ptHad>2 && ptHad<4) DphiPtNew1->Fill(ptEle,Dphi);
1308     if(ptHad>4 && ptHad<6) DphiPtNew2->Fill(ptEle,Dphi);
1309     if(ptHad>6 && ptHad<8) DphiPtNew3->Fill(ptEle,Dphi);
1310     if(ptHad>8 && ptHad<10) DphiPtNew4->Fill(ptEle,Dphi);
1311   }
1312 }
1313 /*
1314 //_________________________________________
1315 void AliAnalysisTaskElecHadronCorrel::MixedEvent(AliESDtrack *track, TH2F *DphiPt, TH2F *DphiPt1,TH2F *DphiPt2)
1316 {
1317
1318   const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
1319   Double_t zVtx;
1320   zVtx = pVtx->GetZ();
1321
1322
1323   AliCentrality *fCentrality = (AliCentrality*)fESD->GetCentrality();
1324   Double_t centvalue = fCentrality->GetCentralityPercentile("V0M");
1325
1326   AliEventPool* pool = fPoolMgr->GetEventPool(centvalue, zVtx); // Get the buffer associated with the current centrality and z-vtx
1327   if (!pool)
1328     AliFatal(Form("No pool found for centrality = %f, zVtx = %f", centvalue, zVtx));
1329
1330   //  pool->PrintInfo();
1331   if (pool->GetCurrentNEvents() >= 5) // start mixing when 5 events are in the buffer
1332   {
1333     Int_t nMix = pool->GetCurrentNEvents();
1334     fNoMixedEvents->Fill(0);
1335     fMixStat->Fill(pool->GetCurrentNEvents(),centvalue);
1336     fMixStat1->Fill(pool->GetCurrentNEvents(),zVtx);
1337
1338    // cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl;
1339     for (Int_t jMix=0; jMix<nMix; jMix++)  // mix with each event in the buffer
1340     {
1341       TObjArray* bgTracks = pool->GetEvent(jMix);
1342       for (Int_t i=0;i<bgTracks->GetEntriesFast(); i++)
1343       {
1344         AliVParticle* mixtrk = (AliVParticle*) bgTracks->At(i);
1345
1346         Double_t mixtrkPhi = -999;
1347         Double_t ptEle = -999;
1348         Double_t phiEle = -999, Dphi = -999;
1349         Double_t pi = 3.14;
1350         Double_t ptmixtrk = -999;
1351
1352         ptEle = track->Pt();
1353         ptmixtrk = mixtrk->Pt();
1354         if(ptmixtrk > ptEle) continue;
1355
1356         mixtrkPhi = mixtrk->Phi();
1357         phiEle = track->Phi();
1358         Dphi = phiEle - mixtrkPhi;
1359
1360         if (Dphi > 3*pi/2)
1361           Dphi = Dphi - 2*pi;
1362         if (Dphi < -pi/2)
1363           Dphi = Dphi + 2*pi;
1364         DphiPt->Fill(ptEle,Dphi);
1365         if(ptmixtrk>2 && ptmixtrk<4) DphiPt1->Fill(ptEle,Dphi);
1366         if(ptmixtrk>4 && ptmixtrk<6) DphiPt2->Fill(ptEle,Dphi);
1367       }
1368     }
1369
1370   }
1371
1372 }
1373 //___________________________________________
1374 TObjArray*  AliAnalysisTaskElecHadronCorrel::CloneAndReduceTrackList()
1375 {
1376   // clones a track list by using AliehDPhiBasicParticle which uses much less memory (used for event mixing)
1377
1378   fTrackCuts2->SetAcceptKinkDaughters(kFALSE);
1379   fTrackCuts2->SetRequireTPCRefit(kTRUE);
1380   fTrackCuts2->SetRequireITSRefit(kTRUE);
1381   fTrackCuts2->SetEtaRange(-0.9,0.9);
1382   fTrackCuts2->SetRequireSigmaToVertex(kTRUE);
1383   fTrackCuts2->SetMaxChi2PerClusterTPC(3.5);
1384   fTrackCuts2->SetMinNClustersTPC(80);
1385
1386   TObjArray* tracksClone = new TObjArray;
1387   tracksClone->SetOwner(kTRUE);
1388
1389   for(Int_t ktracks = 0; ktracks<fESD->GetNumberOfTracks(); ktracks++){
1390     AliESDtrack* track = fESD->GetTrack(ktracks);
1391     if (!track) {
1392       printf("ERROR: Could not receive track %d\n", ktracks);
1393       continue;
1394     }
1395
1396     //   if(ktracks == iTrack) continue;
1397     Double_t eta=-999,ptHad= -999, pHad=-999., phi=-999.0;
1398     Int_t label=-9999, id=-999;
1399     eta = track->Eta();
1400     ptHad = track->Pt();
1401     pHad = track->P();
1402     phi= track->Phi();
1403     label= track->GetLabel();
1404     id=track->GetID();
1405     
1406     if(ptHad <2) continue;
1407     if(!fTrackCuts2->AcceptTrack(track)) continue;
1408
1409     AliVParticle* particle = (AliVParticle*) fESD->GetTrack(ktracks);
1410     tracksClone->Add(new AliehDPhiBasicParticle(particle->Eta(), particle->Phi(), particle->Pt(), particle->Charge()));
1411
1412   }
1413
1414   return tracksClone;
1415 }
1416 */
1417 //___________________________________________
1418 void AliAnalysisTaskElecHadronCorrel::HadronInfo(Int_t itrack)
1419 {
1420   //Hadron information
1421   fTrackCuts2->SetAcceptKinkDaughters(kFALSE);                                           
1422   fTrackCuts2->SetRequireTPCRefit(kTRUE);                                                
1423   fTrackCuts2->SetRequireITSRefit(kTRUE);                                                
1424   fTrackCuts2->SetEtaRange(-0.9,0.9);
1425   fTrackCuts2->SetRequireSigmaToVertex(kTRUE);                                           
1426  // fTrackCuts2->SetMaxChi2PerClusterTPC(3.5);                                             
1427   fTrackCuts2->SetMaxChi2PerClusterTPC(4);                                             
1428   fTrackCuts2->SetMinNClustersTPC(80);                                                   
1429
1430   for(Int_t ktracks = 0; ktracks<fESD->GetNumberOfTracks(); ktracks++){                  
1431     AliESDtrack* trackHad = fESD->GetTrack(ktracks);                                     
1432     if (!trackHad) {
1433       printf("ERROR: Could not receive track %d\n", ktracks);                            
1434       continue;                                                                          
1435     }
1436     
1437     if(ktracks == itrack) continue; //do not select the same electron
1438     
1439     Double_t ptHad= -999;
1440     Float_t IPxy=-999.0, IPz=-999.0;                                                     
1441     ptHad = trackHad->Pt();
1442     trackHad->GetImpactParameters(IPxy,IPz);
1443     
1444     if(trackHad->Eta()<-0.9 || trackHad->Eta()>0.9) continue;
1445 //    if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, trackHad)) continue;
1446 //    if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackHad)) continue;
1447
1448     if(!fTrackCuts2->AcceptTrack(trackHad)) continue;                                    
1449     if(ptHad<2) continue;
1450
1451     fHadronPhi->Fill(trackHad->Phi());
1452     fHadronPhiPt->Fill(trackHad->Phi(),ptHad);
1453     if (trackHad->Eta() >0 && trackHad->Eta() <0.9) fHadronPhiTPChalf->Fill(trackHad->Phi());
1454
1455     fHadronIPxy->Fill(IPxy);
1456     fHadronIPz->Fill(IPz);
1457     fHadronPt->Fill(ptHad);
1458   }
1459 }
1460 //_________________________________________
1461 void AliAnalysisTaskElecHadronCorrel::CheckCentrality(AliESDEvent* event, Bool_t &centralitypass)
1462 {
1463   // Check if event is within the set centrality range. Falls back to V0 centrality determination if no method is set
1464   if (!fkCentralityMethod) AliFatal("No centrality method set! FATAL ERROR!");
1465   fCentrality = event->GetCentrality()->GetCentralityPercentile(fkCentralityMethod);
1466 //  cout << "--------------Centrality evaluated-------------------------"<<endl;
1467
1468   if ((fCentrality <= fCentralityMin) || (fCentrality > fCentralityMax))
1469   {
1470     fCentralityNoPass->Fill(fCentrality);
1471 //    cout << "--------------Fill no pass-------------------------"<<endl;
1472     centralitypass = kFALSE;
1473   }else
1474   {
1475     fCentralityPass->Fill(fCentrality);
1476 //    cout << "--------------Fill pass-------------------------"<<endl;
1477     centralitypass = kTRUE;
1478   }
1479
1480 }
1481 //_____________________________________________________________________________
1482 void AliAnalysisTaskElecHadronCorrel::SetCentralityParameters(Double_t CentralityMin, Double_t CentralityMax, const char* CentralityMethod)
1483 {
1484   // Set a centrality range ]min, max] and define the method to use for centrality selection
1485   fCentralityMin = CentralityMin;
1486   fCentralityMax = CentralityMax;
1487   fkCentralityMethod = CentralityMethod;
1488 }