]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/GammaConv/AliAnalysisTaskdPhi.cxx
o fix sign
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliAnalysisTaskdPhi.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                                                                                        *
4  * Authors: Svein Lindal                                                  *
5  * Version 1.0                                                                    *
6  *                                                                                                                                        *
7  *                                                                                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is                  *
14  * provided "as is" without express or implied warranty.                                  *
15  **************************************************************************/
16
17 ////////////////////////////////////////////////
18 //--------------------------------------------- 
19 // Class doing conversion gamma dPhi correlations
20 // Gamma Conversion analysis
21 //---------------------------------------------
22 ////////////////////////////////////////////////
23
24 #include "AliAnalysisTaskdPhi.h"
25
26 #include <TH2I.h>
27 #include <TList.h>
28 #include <TChain.h>
29
30 #include <AliAnalysisManager.h>
31 #include <AliInputEventHandler.h>
32 #include <AliESDInputHandler.h>
33 #include <AliAODInputHandler.h>
34
35 #include "AliConversionTrackCuts.h"
36 #include "AliConversionCuts.h"
37 #include "AliConversionMesonCuts.h"
38 #include "AliAODConversionPhoton.h"
39 #include "AliAODConversionMother.h"
40 #include "AliAnaConvCorrPhoton.h"
41 #include "AliAnaConvCorrPion.h"
42 #include "AliAnaConvIsolation.h"
43 #include "AliV0ReaderV1.h"
44 // Author Svein Lindal <slindal@fys.uio.no>
45 using namespace std;
46
47 ClassImp(AliAnalysisTaskdPhi)
48
49
50 //________________________________________________________________________
51 AliAnalysisTaskdPhi::AliAnalysisTaskdPhi(const char *name) : AliAnalysisTaskSE(name),
52   fHistograms(NULL),
53   fHistoGamma(NULL),
54   fHistoPion(NULL),
55   fV0Reader(NULL),
56   fV0Filter(NULL),
57   fPhotonFilter(NULL),
58   fMesonFilter(NULL),
59   fTrackCuts(NULL),
60   fGammas(NULL),
61   fPions(NULL),
62   hMETracks(NULL), 
63   hMEPhotons(NULL), 
64   hMEPions(NULL),
65   hMEvents(NULL),
66   fPhotonCorr(NULL),
67   fPionCorr(NULL), 
68 //  fIsoAna(NULL),
69   fDeltaAODBranchName("AliAODGammaConversion_gamma"), 
70   fAxistPt(),
71   fAxiscPt(),
72   fAxisEta(),
73   fAxisPhi(),
74   fAxisCent(),
75   fAxisZ(), 
76   fAxisPiM()
77 {
78   //constructor
79   fAxistPt.SetNameTitle("tPtAxis", "tPt");
80   fAxistPt.Set(20, 0, 100);
81
82   fAxiscPt.SetNameTitle("cPtAxis", "cPt");
83   fAxiscPt.Set(20, 0, 100);
84
85   fAxisEta.SetNameTitle("EtaAxis", "Eta");
86   fAxisEta.Set(160, -0.8, 0.8);
87
88   fAxisPhi.SetNameTitle("PhiAxis", "Phi");
89   fAxisPhi.Set(128, 0, TMath::TwoPi());
90
91   fAxisZ.SetNameTitle("ZAxis", "Z");
92   fAxisZ.Set(4, -10, 10);
93
94   fAxisCent.SetNameTitle("CentAxis", "Cent");
95
96   Double_t centbins[5] = {0, 10, 30, 60, 100.1};
97   fAxisCent.Set(4, centbins);
98
99   Double_t mbins[7] = {0.1, 0.11, 0.12, 0.15, 0.16, 0.18, 0.2};
100   fAxisPiM.SetNameTitle("InvMassPi0", "Invariant mass");
101   fAxisPiM.Set(6, mbins);
102
103   fGammas = new TObjArray();
104   fGammas->SetOwner(kFALSE);
105
106   fPions = new TObjArray();
107   fPions->SetOwner(kFALSE);
108
109   // Define input and output slots here
110   DefineInput(0, TChain::Class());
111   //DefineInput(1, TClonesArray::Class());
112   DefineOutput(1, TList::Class());
113   DefineOutput(2, TList::Class());
114   DefineOutput(3, TList::Class());
115 }
116
117
118
119 //________________________________________________________________________
120 AliAnalysisTaskdPhi::~AliAnalysisTaskdPhi(){
121   //destructor
122   if(fPions)
123         delete fPions;
124   fPions = NULL;
125
126   if(fGammas)
127         delete fGammas;
128   fGammas = NULL;
129   
130   // if(fIsoAna)
131   //    delete fIsoAna;
132   // fIsoAna = NULL;
133
134   if(fV0Filter)
135         delete fV0Filter;
136   fV0Filter = NULL;
137
138   if(fMesonFilter)
139         delete fMesonFilter;
140   fMesonFilter = NULL;
141
142   if(fPhotonFilter)
143         delete fPhotonFilter;
144   fPhotonFilter = NULL;
145
146   if(fHistograms)
147         delete fHistograms;
148   fHistograms = NULL;
149
150 if(fHistoPion)
151         delete fHistoPion;
152   fHistoPion = NULL;
153
154   if(fHistoGamma)
155         delete fHistoGamma;
156   fHistoGamma = NULL;
157
158 }
159
160 ///________________________________________________________________________
161 void AliAnalysisTaskdPhi::SetUpCorrObjects() {
162   ///Creat corr obj
163   //  fIsoAna = new AliAnaConvIsolation();
164   
165   AliDebug(AliLog::kDebug + 5, "Set Up corr objects");
166
167   fPhotonCorr = new TObjArray();
168   fPionCorr = new TObjArray();
169   
170   TList * hPhoton = new TList();
171   hPhoton->SetName("hPhotonCorr");
172   hPhoton->SetOwner(kTRUE);
173   fHistoGamma->Add(hPhoton);
174
175   TList * hPion = new TList();
176   hPion->SetName("hPionCorr");
177   hPion->SetOwner(kTRUE);
178   fHistoPion->Add(hPion);
179
180
181   for(Int_t binc = 0; binc < fAxisCent.GetNbins(); binc++) {
182     TObjArray * photonArray = new TObjArray();
183     photonArray->SetOwner(kTRUE);
184     fPhotonCorr->AddAt(photonArray, binc);
185     
186     TObjArray * pionArray = new TObjArray();
187     pionArray->SetOwner(kTRUE);
188     fPionCorr->AddAt(pionArray, binc);
189     
190     TList * photonList = new TList();
191     photonList->SetName(Form("photon_%d", binc));
192     photonList->SetOwner(kTRUE);
193     hPhoton->AddAt(photonList, binc);
194         
195     TList * pionList = new TList();
196     pionList->SetName(Form("pion_%d", binc));
197     pionList->SetOwner(kTRUE);
198     hPion->AddAt(pionList, binc);
199         
200     for(Int_t binz = 0; binz < fAxisZ.GetNbins(); binz++) {
201           
202       TString nameString = Form("%d_%d", binc, binz);
203       TString titleString = Form("%f < Z < %f ... %f cent %f", 
204                                  fAxisZ.GetBinLowEdge(binz+1), fAxisZ.GetBinUpEdge(binz+1), 
205                                  fAxisCent.GetBinLowEdge(binc+1), fAxisCent.GetBinUpEdge(binc+1));
206
207       AliAnaConvCorrPhoton * photonCorr = new AliAnaConvCorrPhoton(Form("PhotonCorr_%s", nameString.Data()), Form("photon %s", titleString.Data()));
208       photonArray->AddAt(photonCorr, binz);
209       photonCorr->GetAxistPt().Set(fAxistPt.GetNbins(), fAxistPt.GetXbins()->GetArray());
210       photonCorr->GetAxiscPt().Set(fAxiscPt.GetNbins(), fAxiscPt.GetXbins()->GetArray());
211       photonCorr->CreateHistograms();
212       photonList->Add(photonCorr->GetHistograms());
213
214       AliAnaConvCorrPion * pionCorr = new AliAnaConvCorrPion(Form("PionCorr_%s", nameString.Data()), Form("pion %s", titleString.Data()));
215       pionArray->AddAt(pionCorr, binz);
216       pionCorr->GetAxistPt().Set(fAxistPt.GetNbins(), fAxistPt.GetXbins()->GetArray());
217       pionCorr->GetAxiscPt().Set(fAxiscPt.GetNbins(), fAxiscPt.GetXbins()->GetArray());
218       pionCorr->GetAxisM().Set(fAxisPiM.GetNbins(), fAxisPiM.GetXbins()->GetArray());
219       pionCorr->CreateHistograms();
220       pionList->Add(pionCorr->GetHistograms());
221     }
222   }
223 }
224
225 //________________________________________________________________________
226 void AliAnalysisTaskdPhi::UserCreateOutputObjects() {
227   // Create histograms
228   
229   fHistograms = new TList();
230   fHistograms->SetName("dPhi_histograms");
231   fHistograms->SetOwner(kTRUE);
232
233   fHistoGamma = new TList();
234   fHistoGamma->SetName("Gamma_histo");
235   fHistoGamma->SetOwner(kTRUE);
236
237   fHistoPion = new TList();
238   fHistoPion->SetName("Pion_histo");
239   fHistoPion->SetOwner(kTRUE);
240
241
242    fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
243    if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
244
245    AliConversionCuts * v0cuts = fV0Reader->GetConversionCuts();
246    if(v0cuts) {
247      TList * histograms = v0cuts->GetCutHistograms();
248      if(histograms) {
249        fHistograms->Add(histograms);
250      }
251    }
252
253   if(fV0Filter) {
254     fV0Filter->InitCutHistograms();
255     fHistograms->Add(fV0Filter->GetCutHistograms());
256   }
257   if(fMesonFilter) {
258     fMesonFilter->InitCutHistograms();
259     fHistograms->Add(fMesonFilter->GetCutHistograms());
260   }
261   if(fPhotonFilter) {
262     fPhotonFilter->InitCutHistograms();
263     fHistograms->Add(fPhotonFilter->GetCutHistograms());
264   }
265   
266
267   AliConversionTrackCuts * tc = dynamic_cast<AliConversionTrackCuts*>(fTrackCuts);
268   if(tc) fHistograms->Add(tc->CreateHistograms());
269
270   SetUpCorrObjects();
271
272
273   ///Set up ME histograms
274   TList * MEHistograms = new TList();
275   MEHistograms->SetName("MEHistograms");
276   MEHistograms->SetOwner(kTRUE);
277   fHistograms->Add(MEHistograms);
278
279   // hMETracks = new TObjArray();
280   // hMETracks->SetName("TrackArray");
281   // hMETracks->SetOwner(kTRUE);
282   // hMEPhotons = new TObjArray();
283   // hMEPhotons->SetName("PhotonArray");
284   // hMEPhotons->SetOwner(kTRUE);
285   // hMEPions = new TObjArray();
286   // hMEPions->SetName("PionArray");
287   // hMEPions->SetOwner(kTRUE);
288
289   // MEHistograms->Add(hMETracks);
290   // MEHistograms->Add(hMEPions);
291   // MEHistograms->Add(hMEPhotons);
292
293   hMEvents = new TH2I("hMEvents", "Nevents vs centrality vertexz",
294                                           fAxisZ.GetNbins(), fAxisZ.GetBinLowEdge(1), fAxisZ.GetBinUpEdge(fAxisZ.GetNbins()),
295                                           fAxisCent.GetNbins(), fAxisCent.GetBinLowEdge(1), fAxisCent.GetBinUpEdge(fAxisCent.GetNbins()));
296   hMEvents->GetYaxis()->Set(fAxisCent.GetNbins(), fAxisCent.GetXbins()->GetArray());
297   MEHistograms->Add(hMEvents);
298
299
300   // TList axesList;
301   // axesList.AddAt(&GetAxisEta(), 0);
302   // axesList.AddAt(&GetAxisPhi(), 1);
303   // axesList.AddAt(&GetAxistPt(), 2);
304   // axesList.SetOwner(kFALSE);
305   
306   // TList piAxesList;
307   // piAxesList.AddAt(&GetAxisEta(), 0);
308   // piAxesList.AddAt(&GetAxisPhi(), 1);
309   // piAxesList.AddAt(&GetAxistPt(), 2);
310   // piAxesList.AddAt(&GetAxisPiMass(), 3);
311   // piAxesList.SetOwner(kFALSE);
312
313   // TList * outAxesList = new TList();
314   // outAxesList->Add(&fAxisCent);
315   // outAxesList->Add(&fAxisZ);
316   // fHistograms->Add(outAxesList);
317
318   // for(Int_t iz = 0; iz < fAxisZ.GetNbins(); iz++) {
319   //    TObjArray * trackArray = new TObjArray();
320   //    trackArray->SetName(Form("METracks_%d", iz));
321   //    trackArray->SetOwner(kTRUE);
322   //    TObjArray * photonArray = new TObjArray();
323   //    photonArray->SetName(Form("MEPhotons_%d", iz));
324   //    photonArray->SetOwner(kTRUE);
325   //    TObjArray * pionArray = new TObjArray();
326   //    pionArray->SetName(Form("MEPions_%d", iz));
327   //    pionArray->SetOwner(kTRUE);
328
329
330   //    hMEPions->AddAt(pionArray, iz);
331   //    hMETracks->AddAt(trackArray, iz);
332   //    hMEPhotons->AddAt(photonArray, iz);
333
334   //    for(Int_t ic = 0; ic < fAxisCent.GetNbins(); ic++) {
335
336   //      TString nameString = Form("%d_%d", iz, ic);
337   //      TString titleString = Form("%f < Z < %f ... %f cent %f", 
338   //                                                             fAxisZ.GetBinLowEdge(iz+1), fAxisZ.GetBinUpEdge(iz+1), 
339   //                                                             fAxisCent.GetBinLowEdge(ic+1), fAxisCent.GetBinUpEdge(ic+1));
340
341
342   //      THnSparseF * trackHistogram = CreateSparse(Form("tracks_%s", nameString.Data()), 
343   //                                                                                             Form("tracks %s", titleString.Data()), &axesList );
344   //      trackArray->AddAt(trackHistogram, ic);
345
346   //      THnSparseF * photonHistogram = CreateSparse(Form("photons_%s", nameString.Data()), 
347   //                                                                                             Form("photons %s", titleString.Data()), &axesList );
348   //      photonArray->AddAt(photonHistogram, ic);
349
350   //      THnSparseF * pionHistogram = CreateSparse(Form("pions_%s", nameString.Data()), 
351   //                                                                                             Form("pions %s", titleString.Data()), &piAxesList );
352   //      pionArray->AddAt(pionHistogram, ic);
353   //    }
354   // }
355
356   PostData(1, fHistograms);
357   PostData(2, fHistoGamma);
358   PostData(3, fHistoPion);
359
360 }
361
362 ///________________________________________________________________________
363 THnSparseF * AliAnalysisTaskdPhi::CreateSparse(TString nameString, TString titleString, TList * axesList) {
364   ///Create sparse
365   const Int_t dim = axesList->GetSize();
366
367   TAxis * axes[dim];
368   Int_t bins[dim];
369   Double_t min[dim];
370   Double_t max[dim];
371
372   for(Int_t i = 0; i<dim; i++) {
373         TAxis * axis = dynamic_cast<TAxis*>(axesList->At(i));
374         if(axis) {
375           axes[i] = axis;
376         } else {
377           cout << "AliAnalysisTaskdPhi::CreateSparse: Error error, all the axes are not present in axis list" << endl;
378           return NULL;
379         }
380   }
381
382   for(Int_t i = 0; i<dim; i++) {
383         bins[i] = axes[i]->GetNbins(); 
384         min[i] = axes[i]->GetBinLowEdge(1);
385         max[i] = axes[i]->GetBinUpEdge(axes[i]->GetNbins());
386   }
387
388   THnSparseF * sparse = new THnSparseF(Form("METracks_%s", nameString.Data()), 
389                                                                                            Form("tracks %s", titleString.Data()), 
390                                                                                            dim, bins, min, max);
391   
392   for(Int_t i = 0; i<dim; i++) {
393         sparse->GetAxis(i)->SetNameTitle(axes[i]->GetName(), axes[i]->GetTitle() );
394         if(axes[i]->GetXbins()->GetSize() > 0) {
395           sparse->SetBinEdges(i, axes[i]->GetXbins()->GetArray() );
396         }
397   }
398
399   return sparse;
400 }
401
402 //________________________________________________________________________
403 void AliAnalysisTaskdPhi::UserExec(Option_t *) {
404   ///User exec. 
405
406   //if(! fV0Filter->EventIsSelected(fInputEvent)) return;
407
408
409   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
410   Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class();
411   
412   AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
413   if (!inputHandler) {
414         cout << "cout no input event handler"<<endl;
415         return;
416   }
417
418   
419   if ( fV0Filter && !fV0Filter->GetPIDResponse() ) {
420     cout << "aaaa"<<endl;
421         if ( inputHandler->GetPIDResponse() ){
422           fV0Filter->SetPIDResponse( inputHandler->GetPIDResponse() );
423         } else {
424           
425           //AOD case
426           if (isAOD){
427                 if (!fV0Filter->GetPIDResponse()){
428                   fV0Filter->InitAODpidUtil(1);
429                 }
430           }
431         }
432   }
433
434   Double_t centrality = 0.0;
435   Double_t eventPlane = 0.0;
436   Double_t vertexz = fInputEvent->GetPrimaryVertex()->GetZ();
437   if(isAOD) {
438     AliAODHeader * header = static_cast<AliAODHeader*>(fInputEvent->GetHeader());
439         centrality = header->GetCentrality();
440         eventPlane = header->GetEventplane();
441   } else {
442         centrality = static_cast<AliESDEvent*>(fInputEvent)->GetCentrality()->GetCentralityPercentile("V0M");
443         eventPlane = fInputEvent->GetEventplane()->GetEventplane("Q");
444   }
445
446
447   const Int_t centBin = GetBin(fAxisCent, centrality);
448   const Int_t vertexBin = GetBin(fAxisZ, vertexz);
449
450
451   if(DebugLevel () > 4) {
452         cout << "centrality: " << centrality <<  " " << GetBin(fAxisCent, centrality) << endl;
453         cout << "vertexz: " << vertexz <<  " " << GetBin(fAxisZ, vertexz) << endl;
454         cout << "eventPlane: " << eventPlane <<  " " << endl;
455   }
456
457
458
459   if(centBin < 0 || vertexBin < 0) {
460         AliError("bin out of range");
461         return;
462   }
463
464   fGammas->Clear();
465   fPions->Clear();
466
467   //TClonesArray * aodGammas = GetConversionGammas(isAOD);
468   TClonesArray * aodGammas = fV0Reader->GetReconstructedGammas();
469   if(!aodGammas) {
470         AliError("no aod gammas found!");
471         return;
472   }
473
474   // if(aodGammas->GetEntriesFast() > 0) {
475   //   if( static_cast<AliAODConversionParticle*>(aodGammas->At(0))->GetLabel(0) == fL1 && 
476   //    static_cast<AliAODConversionParticle*>(aodGammas->At(0))->GetLabel(1) == fL2 
477   //    ) {
478   //     return;
479   //   }
480   //   fL1 = static_cast<AliAODConversionParticle*>(aodGammas->At(0))->GetLabel(0);
481   //   fL2 = static_cast<AliAODConversionParticle*>(aodGammas->At(0))->GetLabel(1);
482   //   //cout << aodGammas->GetEntriesFast() << " " << fInputEvent->GetNumberOfTracks() << "c" << endl;
483   // }
484   
485   if(DebugLevel() > 1) printf("Number of conversion gammas %d \n", aodGammas->GetEntriesFast());
486   for(Int_t ig = 0; ig < aodGammas->GetEntriesFast(); ig++) {
487     AliAODConversionPhoton * photon = dynamic_cast<AliAODConversionPhoton*>(aodGammas->At(ig));
488     
489     if(!photon) continue;
490     if(!fV0Filter || fV0Filter->PhotonIsSelected(static_cast<AliConversionPhotonBase*>(photon), fInputEvent)) {
491       fGammas->Add(static_cast<TObject*>(photon));
492     }
493   }
494   
495   if(DebugLevel() > 4) printf("Number of accepted gammas %d \n", fGammas->GetEntriesFast());
496   hMEvents->Fill(vertexz, centrality);
497   
498   
499   
500   ///create track array
501   TObjArray tracks;
502   const Double_t etalim[2] = { fAxisEta.GetBinLowEdge(1), fAxisEta.GetBinUpEdge(fAxisEta.GetNbins())};
503   for(Int_t iTrack = 0; iTrack < fInputEvent->GetNumberOfTracks(); iTrack++) {
504
505         AliVTrack * track = static_cast<AliVTrack*>(fInputEvent->GetTrack(iTrack));
506         if(track->Pt() < fAxiscPt.GetBinLowEdge(1) ) continue;
507         if(track->Eta() < etalim[0] || track->Eta() > etalim[1]) continue;
508
509         
510         if(fTrackCuts && fTrackCuts->IsSelected((track))) {
511           tracks.Add(track);
512         }
513   }
514
515   Process(fGammas, &tracks, vertexBin, centBin);
516
517   PostData(1, fHistograms);
518   PostData(2, fHistoGamma);
519   PostData(3, fHistoPion);
520   
521 }
522
523 //________________________________________________________________________
524 void AliAnalysisTaskdPhi::Process(TObjArray * gammas, TObjArray * tracks, Int_t vertexBin, Int_t centBin) {
525   ///Process stuff
526
527   if(DebugLevel() > 4) printf("Number of accepted gammas, tracks %d  %d \n", gammas->GetEntriesFast(), tracks->GetEntriesFast());
528  
529   AliAnaConvCorrBase * gCorr = GetCorrObject(vertexBin, centBin, fPhotonCorr);
530   AliAnaConvCorrPion * piCorr = static_cast<AliAnaConvCorrPion*>(GetCorrObject(vertexBin, centBin, fPionCorr));
531   
532   if(!gCorr || !piCorr) {
533         AliError("corr object missing");
534         return;
535   }
536   
537   TObjArray photons;
538   TObjArray pions;
539
540   for(Int_t i1 = 0; i1 < gammas->GetEntriesFast(); i1++) {
541     AliAODConversionPhoton * ph1 = static_cast<AliAODConversionPhoton*>(gammas->UncheckedAt(i1));
542     Int_t tIDs[4] = {ph1->GetLabel(0), ph1->GetLabel(1), -1, -1};
543         
544     Int_t leading = 0;//fIsoAna->IsLeading(static_cast<AliAODConversionParticle*>(ph1), tracks, tIDs);
545     if(!fPhotonFilter || fPhotonFilter->PhotonIsSelected(static_cast<AliConversionPhotonBase*>(ph1), fInputEvent)) {
546       if(ph1->Pt() > fAxistPt.GetBinLowEdge(1)) {
547         gCorr->CorrelateWithTracks( static_cast<AliAODConversionParticle*>(ph1), tracks, tIDs, leading);
548         photons.Add(ph1);
549       }
550     }
551
552     for(Int_t i2 = 0; i2 < i1; i2++) {
553       AliAODConversionPhoton * ph2 = static_cast<AliAODConversionPhoton*>(gammas->UncheckedAt(i2));
554           
555       if( ph2->GetTrackLabelPositive()==ph1->GetTrackLabelPositive() 
556           || ph2->GetTrackLabelNegative()==ph1->GetTrackLabelNegative()
557           || ph2->GetTrackLabelNegative()==ph1->GetTrackLabelPositive()
558           || ph2->GetTrackLabelPositive()==ph1->GetTrackLabelNegative()) {
559         continue;
560       }
561
562       AliAODConversionMother * pion = new AliAODConversionMother(ph1, ph2);
563       pion->SetLabels(i1, i2);
564       pion->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
565       
566       if(!fMesonFilter || fMesonFilter->MesonIsSelected(pion, kTRUE) ) {
567         tIDs[2] = ph2->GetLabel(0);
568         tIDs[3] = ph2->GetLabel(1);
569         Int_t leadingpi = 0;//fIsoAna->IsLeading(static_cast<AliAODConversionParticle*>(pion), tracks, tIDs);
570         piCorr->FillTriggerCounters(pion, leadingpi);
571         AliDebug(AliLog::kDebug + 5, "We have a pion");
572         if(pion->Pt() > fAxistPt.GetBinLowEdge(1) && 
573            pion->M() > fAxisPiM.GetBinLowEdge(1) && 
574            pion->M() < fAxisPiM.GetBinUpEdge(fAxisPiM.GetNbins())) {
575           piCorr->CorrelateWithTracks(pion, tracks, tIDs, leadingpi);
576           pions.Add(static_cast<TObject*>(pion));
577         }
578       }
579     }
580   }
581
582   piCorr->FillCounters(&pions, tracks);
583   gCorr->FillCounters(&photons, tracks);
584
585 }
586
587 //________________________________________________________________________
588 void AliAnalysisTaskdPhi::Terminate(Option_t *) {
589  
590   // Draw result to the screen
591   // Called once at the end of the query
592 }
593
594 //________________________________________________________________________
595 TClonesArray * AliAnalysisTaskdPhi::GetConversionGammas(Bool_t isAOD) {
596   
597
598   if(isAOD) {
599
600         TClonesArray * gammas = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(fDeltaAODBranchName.Data()));
601         if(gammas) {
602           return gammas;
603         }
604
605         FindDeltaAODBranchName(fInputEvent);
606         gammas = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(fDeltaAODBranchName.Data()));
607         return gammas;
608
609   } else {
610     TClonesArray * gammas = dynamic_cast<TClonesArray*>(GetInputData(1));
611     return gammas;
612   }
613
614 }
615
616 //________________________________________________________________________
617 void AliAnalysisTaskdPhi::FindDeltaAODBranchName(AliVEvent * event){
618   ///Find aod branch
619   TList *list=event->GetList();
620   for(Int_t ii=0;ii<list->GetEntries();ii++){
621         TString name((list->At(ii))->GetName());
622         if(name.BeginsWith("GammaConv")&&name.EndsWith("gamma")){
623           fDeltaAODBranchName=name;
624           AliDebug(AliLog::kDebug + 5, Form("Set DeltaAOD BranchName to: %s",fDeltaAODBranchName.Data()));
625           return;
626         }
627   }
628 }
629   
630