]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/AliAnalysisTaskElecHadronCorrel.cxx
updated
[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   //---------------CENTRALITY SELECTION-----------------------    
436 /*  SetCentralityParameters(0., 10., "V0M");
437   Bool_t pass = kFALSE; //to select centrality
438   CheckCentrality(fESD,pass);
439
440   if(!pass)return;
441 */
442   if(!fPID->IsInitialized()){ 
443     // Initialize PID with the given run number
444     AliWarning("PID not initialised, get from Run no");
445     fPID->InitializePID(fESD->GetRunNumber());
446   }
447
448   //-------trigger selection
449   UInt_t res = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
450   if (res==0)
451     return;
452
453   //    if( (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kFastOnly) )
454   //            return;
455
456   if(!(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & (AliVEvent::kCentral))) 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,100,-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,100,-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,100,-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,100,-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,100,-1.57,4.71);
813   fOutputList->Add(fSemiIncElecDphi4);
814
815   fPhotElecDphi = new TH2F("fPhotElecDphi", "Photon elec-had Dphi correlation",200,0,20,100,-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,100,-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,100,-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,100,-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,100,-1.57,4.71);
828   fOutputList->Add(fPhotElecDphi4);
829
830   fInclusiveElecDphi = new TH2F("fInclusiveElecDphi", "Inclusive elec-had Dphi correlation",200,0,20,100,-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,100,-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,100,-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,100,-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,100,-1.57,4.71);
843   fOutputList->Add(fInclusiveElecDphi4);
844
845   fDphiULSMassLow = new TH2F("fDphiULSMassLow", "e-h Dphi ULS, mass<cut",200,0,20,100,-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,100,-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,100,-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,100,-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,100,-1.57,4.71);
858   fOutputList->Add(fDphiULSMassLow4);
859
860   fDphiLSMassLow = new TH2F("fDphiLSMassLow", "e-h Dphi LS, mass<cut",200,0,20,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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,100,-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->SetEtaRange(-0.9,0.9);
1077   fTrackCuts1->SetRequireSigmaToVertex(kTRUE);
1078   fTrackCuts1->SetMaxChi2PerClusterTPC(3.5);
1079   fTrackCuts1->SetMinNClustersTPC(80);
1080
1081   //  const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
1082
1083   Bool_t flagPhotonicElec = kFALSE;
1084   Int_t NLS_plus=0, NLS_minus=0, NULS=0;
1085
1086   for(Int_t jTracks = itrack+1; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1087     AliESDtrack* trackAsso = fESD->GetTrack(jTracks);
1088     if (!trackAsso) {
1089       printf("ERROR: Could not receive track %d\n", jTracks);
1090       continue;
1091     }
1092
1093     Double_t dEdxAsso = -999., ptAsso=-999., openingAngle = -999.,nsigma=-999.0;
1094     Double_t mass=-999., width = -999;
1095     Bool_t fFlagLS=kFALSE, fFlagULS=kFALSE;
1096
1097     dEdxAsso = trackAsso->GetTPCsignal();
1098     nsigma = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(trackAsso, AliPID::kElectron) : 1000;
1099     ptAsso = trackAsso->Pt();
1100     Int_t chargeAsso = trackAsso->Charge();
1101     Int_t charge = track->Charge();
1102
1103     if(ptAsso <0.3) continue;
1104     if(trackAsso->Eta()<-0.9 || trackAsso->Eta()>0.9) continue;
1105     if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, trackAsso)) continue;
1106     if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackAsso)) continue;
1107
1108     //    if(!fTrackCuts1->AcceptTrack(trackAsso)) continue;
1109     //    if(dEdxAsso <70 || dEdxAsso>100) continue; //11a pass1
1110     if(nsigma < -3 || nsigma > 3) continue;
1111
1112     Int_t fPDGe1 = 11; Int_t fPDGe2 = 11;
1113     if(charge>0) fPDGe1 = -11;
1114     if(chargeAsso>0) fPDGe2 = -11;
1115
1116     if(charge == chargeAsso) fFlagLS = kTRUE;
1117     if(charge != chargeAsso) fFlagULS = kTRUE;
1118
1119     AliKFParticle ge1 = AliKFParticle(*track, fPDGe1);
1120     AliKFParticle ge2 = AliKFParticle(*trackAsso, fPDGe2);
1121     AliKFParticle recg(ge1, ge2);
1122
1123     if(recg.GetNDF()<1) continue;
1124     Double_t chi2recg = recg.GetChi2()/recg.GetNDF();
1125     if(TMath::Sqrt(TMath::Abs(chi2recg))>3.) continue;
1126
1127     openingAngle = ge1.GetAngle(ge2);
1128     //    if(fFlagLS) fOpeningAngleLS->Fill(openingAngle);
1129     //    if(fFlagULS) fOpeningAngleULS->Fill(openingAngle);
1130
1131     //   if(openingAngle > fOpeningAngleCut) continue;
1132
1133     Int_t MassCorrect;
1134     MassCorrect = recg.GetMass(mass,width);
1135
1136     if(fFlagLS){
1137       if(track->Charge() > 0 ) NLS_plus++;
1138       if(track->Charge() < 0 ) NLS_minus++;
1139     }
1140     if(fFlagULS) NULS++;
1141
1142     if(fFlagLS) {
1143       fInvmassLS1->Fill(mass);
1144       if(track->Pt()> 1) fInvmassLS2->Fill(mass);
1145       if(track->Pt()>2) fInvmassLS3->Fill(mass);
1146       if(track->Pt()>3) fInvmassLS4->Fill(mass);
1147       if(track->Pt()>4) fInvmassLS5->Fill(mass);
1148     }
1149     if(fFlagULS) {
1150       fInvmassULS1->Fill(mass);
1151       if(track->Pt() >1) fInvmassULS2->Fill(mass);
1152       if(track->Pt() >2) fInvmassULS3->Fill(mass);
1153       if(track->Pt() >3) fInvmassULS4->Fill(mass);
1154       if(track->Pt() >4) fInvmassULS5->Fill(mass);
1155     }
1156
1157     if(mass<fInvmassCut){
1158       if(fFlagULS)
1159       {
1160         ElectronHadCorrel(itrack,track,fDphiULSMassLow, fDphiULSMassLow1,fDphiULSMassLow2,fDphiULSMassLow3,fDphiULSMassLow4);
1161         fULSElecPt->Fill(track->Pt());
1162 //        MixedEvent(track,fMixedDphiULSMassLow,fMixedDphiULSMassLow1,fMixedDphiULSMassLow2);
1163       }
1164       if(fFlagLS)
1165       {
1166         ElectronHadCorrel(itrack,track,fDphiLSMassLow,fDphiLSMassLow1,fDphiLSMassLow2,fDphiLSMassLow3,fDphiLSMassLow4);
1167         fLSElecPt->Fill(track->Pt());
1168 //        MixedEvent(track,fMixedDphiLSMassLow,fMixedDphiLSMassLow1,fMixedDphiLSMassLow2);
1169       }
1170       if(fFlagLS) ElectronHadCorrelNoPartner(itrack,jTracks,track,fDphiLSMassLowNoPartner, fDphiLSMassLowNoPartner1,fDphiLSMassLowNoPartner2,fDphiLSMassLowNoPartner3,fDphiLSMassLowNoPartner4);
1171       if(fFlagULS) ElectronHadCorrelNoPartner(itrack,jTracks,track,fDphiULSMassLowNoPartner, fDphiULSMassLowNoPartner1,fDphiULSMassLowNoPartner2,fDphiULSMassLowNoPartner3,fDphiULSMassLowNoPartner4);
1172     }
1173
1174     if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec){
1175       flagPhotonicElec = kTRUE;
1176     }
1177     //   }
1178
1179   }
1180   fFlagPhotonicElec = flagPhotonicElec;
1181
1182 //  fNLSminus->Fill(NLS_minus);
1183 //  fNLSplus->Fill(NLS_plus);
1184 //  fNULS->Fill(NULS);
1185
1186 }
1187 //_________________________________________
1188 void AliAnalysisTaskElecHadronCorrel::ElectronHadCorrel(Int_t itrack, AliESDtrack *track, TH2F *DphiPt, TH2F *DphiPt1,TH2F *DphiPt2,TH2F *DphiPt3,TH2F *DphiPt4)
1189 {
1190   //Construct Delta Phi between electrons and hadrons
1191
1192   fTrackCuts2->SetAcceptKinkDaughters(kFALSE);
1193   fTrackCuts2->SetRequireTPCRefit(kTRUE);
1194   fTrackCuts2->SetRequireITSRefit(kTRUE);
1195   fTrackCuts2->SetEtaRange(-0.9,0.9);
1196   fTrackCuts2->SetRequireSigmaToVertex(kTRUE);
1197   fTrackCuts2->SetMaxChi2PerClusterTPC(3.5);
1198   fTrackCuts2->SetMinNClustersTPC(80);
1199
1200   for(Int_t ktracks = 0; ktracks<fESD->GetNumberOfTracks(); ktracks++){
1201     AliESDtrack* trackHad = fESD->GetTrack(ktracks);
1202     if (!trackHad) {
1203       printf("ERROR: Could not receive track %d\n", ktracks);
1204       continue;
1205     }
1206     if(ktracks == itrack) continue; //do not select the same electron
1207
1208     Double_t ptHad= -999, pHad=-999., dEdxHad = -999;
1209     Double_t ptEle = -999;
1210     Double_t phiEle = -999, phiHad = -999, Dphi = -999;
1211     Double_t pi = 3.14;
1212     Float_t IPxy=-999.0, IPz=-999.0;
1213
1214     dEdxHad = trackHad->GetTPCsignal();
1215     ptHad = trackHad->Pt();
1216     pHad = trackHad->P();
1217     ptEle = track->Pt();
1218     trackHad->GetImpactParameters(IPxy,IPz);
1219
1220 //    if(ptHad <2) continue;
1221     if(ptHad > ptEle) continue;
1222     if(trackHad->Eta()<-0.9 || trackHad->Eta()>0.9) continue;
1223     if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, trackHad)) continue;
1224     if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackHad)) continue;
1225
1226 //    if(!fTrackCuts2->AcceptTrack(trackHad)) continue;
1227   
1228    // fHadronIPxy->Fill(IPxy);
1229    // fHadronIPz->Fill(IPz);
1230
1231    // if(TMath::Abs(IPxy)>2.5) continue;
1232    // fHadronPhi->Fill(trackHad->Phi());
1233     
1234     phiEle = track->Phi();
1235     phiHad = trackHad->Phi();
1236     Dphi = phiEle - phiHad;
1237     if (Dphi > 3*pi/2)
1238       Dphi = Dphi - 2*pi;
1239     if (Dphi < -pi/2)
1240       Dphi = Dphi + 2*pi;
1241
1242     if(ptHad>2) DphiPt->Fill(ptEle,Dphi);
1243     if(ptHad>2 && ptHad<4) DphiPt1->Fill(ptEle,Dphi);
1244     if(ptHad>4 && ptHad<6) DphiPt2->Fill(ptEle,Dphi);
1245     if(ptHad>6 && ptHad<8) DphiPt3->Fill(ptEle,Dphi);
1246     if(ptHad>8 && ptHad<10) DphiPt4->Fill(ptEle,Dphi);
1247
1248   }
1249 }
1250 //_________________________________________
1251 void AliAnalysisTaskElecHadronCorrel::ElectronHadCorrelNoPartner(Int_t itrack,Int_t jtrack, AliESDtrack *track, TH2F *DphiPtNew, TH2F *DphiPtNew1,TH2F *DphiPtNew2,TH2F *DphiPtNew3,TH2F *DphiPtNew4)
1252 {
1253   //Construct Delta Phi between electrons and hadrons for electrons from invariant mass calculation excluding associated track
1254
1255   fTrackCuts2->SetAcceptKinkDaughters(kFALSE);
1256   fTrackCuts2->SetRequireTPCRefit(kTRUE);
1257   fTrackCuts2->SetRequireITSRefit(kTRUE);
1258   fTrackCuts2->SetEtaRange(-0.9,0.9);
1259   fTrackCuts2->SetRequireSigmaToVertex(kTRUE);
1260   fTrackCuts2->SetMaxChi2PerClusterTPC(3.5);
1261   fTrackCuts2->SetMinNClustersTPC(80);
1262
1263   for(Int_t ktracks = 0; ktracks<fESD->GetNumberOfTracks(); ktracks++){
1264     AliESDtrack* trackHad = fESD->GetTrack(ktracks);
1265     if (!trackHad) {
1266       printf("ERROR: Could not receive track %d\n", ktracks);
1267       continue;
1268     }
1269     if(ktracks == itrack || ktracks == jtrack) continue; //do not select the same electron and associated track from inv mass cal
1270
1271
1272     Double_t ptHad= -999, pHad=-999., dEdxHad = -999;
1273     Double_t ptEle = -999;
1274     Double_t phiEle = -999, phiHad = -999, Dphi = -999;
1275     Double_t pi = 3.14;
1276     Float_t IPxy=-999.0, IPz=-999.0;
1277
1278     dEdxHad = trackHad->GetTPCsignal();
1279     ptHad = trackHad->Pt();
1280     pHad = trackHad->P();
1281     ptEle = track->Pt();
1282     trackHad->GetImpactParameters(IPxy,IPz);
1283
1284 //    if(ptHad <2) continue;
1285     if(ptHad > ptEle) continue;
1286     if(trackHad->Eta()<-0.9 || trackHad->Eta()>0.9) continue;
1287     if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, trackHad)) continue;
1288     if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackHad)) continue;
1289
1290 //    if(!fTrackCuts2->AcceptTrack(trackHad)) continue;
1291 //    if(TMath::Abs(IPxy)>2.5) continue;
1292
1293     phiEle = track->Phi();
1294     phiHad = trackHad->Phi();
1295     Dphi = phiEle - phiHad;
1296     if (Dphi > 3*pi/2)
1297       Dphi = Dphi - 2*pi;
1298     if (Dphi < -pi/2)
1299       Dphi = Dphi + 2*pi;
1300
1301     if(ptHad>2) DphiPtNew->Fill(ptEle,Dphi);
1302     if(ptHad>2 && ptHad<4) DphiPtNew1->Fill(ptEle,Dphi);
1303     if(ptHad>4 && ptHad<6) DphiPtNew2->Fill(ptEle,Dphi);
1304     if(ptHad>6 && ptHad<8) DphiPtNew3->Fill(ptEle,Dphi);
1305     if(ptHad>8 && ptHad<10) DphiPtNew4->Fill(ptEle,Dphi);
1306   }
1307 }
1308 /*
1309 //_________________________________________
1310 void AliAnalysisTaskElecHadronCorrel::MixedEvent(AliESDtrack *track, TH2F *DphiPt, TH2F *DphiPt1,TH2F *DphiPt2)
1311 {
1312
1313   const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
1314   Double_t zVtx;
1315   zVtx = pVtx->GetZ();
1316
1317
1318   AliCentrality *fCentrality = (AliCentrality*)fESD->GetCentrality();
1319   Double_t centvalue = fCentrality->GetCentralityPercentile("V0M");
1320
1321   AliEventPool* pool = fPoolMgr->GetEventPool(centvalue, zVtx); // Get the buffer associated with the current centrality and z-vtx
1322   if (!pool)
1323     AliFatal(Form("No pool found for centrality = %f, zVtx = %f", centvalue, zVtx));
1324
1325   //  pool->PrintInfo();
1326   if (pool->GetCurrentNEvents() >= 5) // start mixing when 5 events are in the buffer
1327   {
1328     Int_t nMix = pool->GetCurrentNEvents();
1329     fNoMixedEvents->Fill(0);
1330     fMixStat->Fill(pool->GetCurrentNEvents(),centvalue);
1331     fMixStat1->Fill(pool->GetCurrentNEvents(),zVtx);
1332
1333    // cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl;
1334     for (Int_t jMix=0; jMix<nMix; jMix++)  // mix with each event in the buffer
1335     {
1336       TObjArray* bgTracks = pool->GetEvent(jMix);
1337       for (Int_t i=0;i<bgTracks->GetEntriesFast(); i++)
1338       {
1339         AliVParticle* mixtrk = (AliVParticle*) bgTracks->At(i);
1340
1341         Double_t mixtrkPhi = -999;
1342         Double_t ptEle = -999;
1343         Double_t phiEle = -999, Dphi = -999;
1344         Double_t pi = 3.14;
1345         Double_t ptmixtrk = -999;
1346
1347         ptEle = track->Pt();
1348         ptmixtrk = mixtrk->Pt();
1349         if(ptmixtrk > ptEle) continue;
1350
1351         mixtrkPhi = mixtrk->Phi();
1352         phiEle = track->Phi();
1353         Dphi = phiEle - mixtrkPhi;
1354
1355         if (Dphi > 3*pi/2)
1356           Dphi = Dphi - 2*pi;
1357         if (Dphi < -pi/2)
1358           Dphi = Dphi + 2*pi;
1359         DphiPt->Fill(ptEle,Dphi);
1360         if(ptmixtrk>2 && ptmixtrk<4) DphiPt1->Fill(ptEle,Dphi);
1361         if(ptmixtrk>4 && ptmixtrk<6) DphiPt2->Fill(ptEle,Dphi);
1362       }
1363     }
1364
1365   }
1366
1367 }
1368 //___________________________________________
1369 TObjArray*  AliAnalysisTaskElecHadronCorrel::CloneAndReduceTrackList()
1370 {
1371   // clones a track list by using AliehDPhiBasicParticle which uses much less memory (used for event mixing)
1372
1373   fTrackCuts2->SetAcceptKinkDaughters(kFALSE);
1374   fTrackCuts2->SetRequireTPCRefit(kTRUE);
1375   fTrackCuts2->SetRequireITSRefit(kTRUE);
1376   fTrackCuts2->SetEtaRange(-0.9,0.9);
1377   fTrackCuts2->SetRequireSigmaToVertex(kTRUE);
1378   fTrackCuts2->SetMaxChi2PerClusterTPC(3.5);
1379   fTrackCuts2->SetMinNClustersTPC(80);
1380
1381   TObjArray* tracksClone = new TObjArray;
1382   tracksClone->SetOwner(kTRUE);
1383
1384   for(Int_t ktracks = 0; ktracks<fESD->GetNumberOfTracks(); ktracks++){
1385     AliESDtrack* track = fESD->GetTrack(ktracks);
1386     if (!track) {
1387       printf("ERROR: Could not receive track %d\n", ktracks);
1388       continue;
1389     }
1390
1391     //   if(ktracks == iTrack) continue;
1392     Double_t eta=-999,ptHad= -999, pHad=-999., phi=-999.0;
1393     Int_t label=-9999, id=-999;
1394     eta = track->Eta();
1395     ptHad = track->Pt();
1396     pHad = track->P();
1397     phi= track->Phi();
1398     label= track->GetLabel();
1399     id=track->GetID();
1400     
1401     if(ptHad <2) continue;
1402     if(!fTrackCuts2->AcceptTrack(track)) continue;
1403
1404     AliVParticle* particle = (AliVParticle*) fESD->GetTrack(ktracks);
1405     tracksClone->Add(new AliehDPhiBasicParticle(particle->Eta(), particle->Phi(), particle->Pt(), particle->Charge()));
1406
1407   }
1408
1409   return tracksClone;
1410 }
1411 */
1412 //___________________________________________
1413 void AliAnalysisTaskElecHadronCorrel::HadronInfo(Int_t itrack)
1414 {
1415   //Hadron information
1416   fTrackCuts2->SetAcceptKinkDaughters(kFALSE);                                           
1417   fTrackCuts2->SetRequireTPCRefit(kTRUE);                                                
1418   fTrackCuts2->SetRequireITSRefit(kTRUE);                                                
1419   fTrackCuts2->SetEtaRange(-0.9,0.9);
1420   fTrackCuts2->SetRequireSigmaToVertex(kTRUE);                                           
1421   fTrackCuts2->SetMaxChi2PerClusterTPC(3.5);                                             
1422   fTrackCuts2->SetMinNClustersTPC(80);                                                   
1423
1424   for(Int_t ktracks = 0; ktracks<fESD->GetNumberOfTracks(); ktracks++){                  
1425     AliESDtrack* trackHad = fESD->GetTrack(ktracks);                                     
1426     if (!trackHad) {
1427       printf("ERROR: Could not receive track %d\n", ktracks);                            
1428       continue;                                                                          
1429     }
1430     
1431     if(ktracks == itrack) continue; //do not select the same electron
1432     
1433     Double_t ptHad= -999;
1434     Float_t IPxy=-999.0, IPz=-999.0;                                                     
1435     ptHad = trackHad->Pt();
1436     trackHad->GetImpactParameters(IPxy,IPz);
1437     
1438     if(trackHad->Eta()<-0.9 || trackHad->Eta()>0.9) continue;
1439     if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, trackHad)) continue;
1440     if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackHad)) continue;
1441
1442 //    if(!fTrackCuts2->AcceptTrack(trackHad)) continue;                                    
1443     if(ptHad<2) continue;
1444
1445     fHadronPhi->Fill(trackHad->Phi());
1446     fHadronPhiPt->Fill(trackHad->Phi(),ptHad);
1447     if (trackHad->Eta() >0 && trackHad->Eta() <0.9) fHadronPhiTPChalf->Fill(trackHad->Phi());
1448
1449     fHadronIPxy->Fill(IPxy);
1450     fHadronIPz->Fill(IPz);
1451     fHadronPt->Fill(ptHad);
1452   }
1453 }
1454 //_________________________________________
1455 void AliAnalysisTaskElecHadronCorrel::CheckCentrality(AliESDEvent* event, Bool_t &centralitypass)
1456 {
1457   // Check if event is within the set centrality range. Falls back to V0 centrality determination if no method is set
1458   if (!fkCentralityMethod) AliFatal("No centrality method set! FATAL ERROR!");
1459   fCentrality = event->GetCentrality()->GetCentralityPercentile(fkCentralityMethod);
1460 //  cout << "--------------Centrality evaluated-------------------------"<<endl;
1461
1462   if ((fCentrality <= fCentralityMin) || (fCentrality > fCentralityMax))
1463   {
1464     fCentralityNoPass->Fill(fCentrality);
1465 //    cout << "--------------Fill no pass-------------------------"<<endl;
1466     centralitypass = kFALSE;
1467   }else
1468   {
1469     fCentralityPass->Fill(fCentrality);
1470 //    cout << "--------------Fill pass-------------------------"<<endl;
1471     centralitypass = kTRUE;
1472   }
1473
1474 }
1475 //_____________________________________________________________________________
1476 void AliAnalysisTaskElecHadronCorrel::SetCentralityParameters(Double_t CentralityMin, Double_t CentralityMax, const char* CentralityMethod)
1477 {
1478   // Set a centrality range ]min, max] and define the method to use for centrality selection
1479   fCentralityMin = CentralityMin;
1480   fCentralityMax = CentralityMax;
1481   fkCentralityMethod = CentralityMethod;
1482 }