1 /**************************************************************************
2 * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // AliAnalysisTaskSEHFv2 gives the needed tools for the D
19 // mesons v2 analysis with event plane method
20 // Authors: Chiara Bianchin, cbianchi@pd.infn.it,
21 // Robert Grajcarek, grajcarek@physi.uni-heidelberg.de
22 // Giacomo Ortona, ortona@to.infn.it
23 // Carlos Eugenio Perez Lara, carlos.eugenio.perez.lara@cern.ch
25 /////////////////////////////////////////////////////////////
29 #include <Riostream.h>
30 #include <TClonesArray.h>
37 #include <TGraphErrors.h>
39 #include <TDatabasePDG.h>
45 #include <AliAnalysisDataSlot.h>
46 #include <AliAnalysisDataContainer.h>
47 #include "AliAnalysisManager.h"
48 #include "AliAODHandler.h"
49 #include "AliAODEvent.h"
50 #include "AliAODVertex.h"
51 #include "AliAODTrack.h"
52 #include "AliAODMCHeader.h"
53 #include "AliAODMCParticle.h"
54 #include "AliAODRecoDecayHF3Prong.h"
55 #include "AliAODRecoDecayHF.h"
56 #include "AliAODRecoDecayHF2Prong.h"
57 #include "AliAODRecoDecayHF4Prong.h"
58 #include "AliAODRecoCascadeHF.h"
60 #include "AliAnalysisTaskSE.h"
61 #include "AliRDHFCutsDplustoKpipi.h"
62 #include "AliRDHFCutsD0toKpipipi.h"
63 #include "AliRDHFCutsDstoKKpi.h"
64 #include "AliRDHFCutsDStartoKpipi.h"
65 #include "AliRDHFCutsD0toKpi.h"
66 #include "AliRDHFCutsLctopKpi.h"
68 #include "AliHFMassFitter.h"
69 #include "AliEventplane.h"
70 #include "AliFlowTrack.h"
71 #include "AliFlowVector.h"
72 #include "AliFlowTrackCuts.h"
73 #include "AliFlowEvent.h"
75 #include "AliAnalysisTaskSEHFv2.h"
77 ClassImp(AliAnalysisTaskSEHFv2)
80 //________________________________________________________________________
81 AliAnalysisTaskSEHFv2::AliAnalysisTaskSEHFv2():
91 fUseAfterBurner(kFALSE),
94 fEventPlaneMeth(kTPCVZERO),
101 // Default constructor
104 //________________________________________________________________________
105 AliAnalysisTaskSEHFv2::AliAnalysisTaskSEHFv2(const char *name,AliRDHFCuts *rdCuts,Int_t decaychannel):
106 AliAnalysisTaskSE(name),
115 fUseAfterBurner(kFALSE),
116 fDecChannel(decaychannel),
118 fEventPlaneMeth(kTPCVZERO),
119 fEventPlanesComp(10),
125 // standard constructor
147 fAfterBurner = new AliHFAfterBurner(fDecChannel);
148 if(pdg==413) SetMassLimits((Float_t)0.135,(Float_t)0.165);
149 else SetMassLimits((Float_t)0.2,pdg); //check range
150 fNPtBins=fRDCuts->GetNPtBins();
152 if(fDebug>1)fRDCuts->PrintAll();
153 // Output slot #1 writes into a TH1F container
154 DefineOutput(1,TH1F::Class()); //Info on the number of events etc.
155 // Output slot #2 writes into a TList container
156 DefineOutput(2,TList::Class()); //Main output
157 // Output slot #3 writes into a AliRDHFCuts container (cuts)
160 DefineOutput(3,AliRDHFCutsDplustoKpipi::Class()); //Cut object for Dplus
163 DefineOutput(3,AliRDHFCutsD0toKpi::Class()); //Cut object for D0
166 DefineOutput(3,AliRDHFCutsDStartoKpipi::Class()); //Cut object for D*
169 //DefineOutput(4,AliFlowEventSimple::Class());
170 //DefineOutput(4,TList::Class());
173 //________________________________________________________________________
174 AliAnalysisTaskSEHFv2::~AliAnalysisTaskSEHFv2()
182 //_________________________________________________________________
183 void AliAnalysisTaskSEHFv2::SetMassLimits(Float_t range, Int_t pdg){
184 // Set limits for mass spectra plots
186 Int_t abspdg=TMath::Abs(pdg);
187 mass=TDatabasePDG::Instance()->GetParticle(abspdg)->Mass();
188 fUpmasslimit = mass+range;
189 fLowmasslimit = mass-range;
191 //_________________________________________________________________
192 void AliAnalysisTaskSEHFv2::SetMassLimits(Float_t lowlimit, Float_t uplimit){
193 // Set limits for mass spectra plots
196 fUpmasslimit = uplimit;
197 fLowmasslimit = lowlimit;
202 //________________________________________________________________________
203 void AliAnalysisTaskSEHFv2::LocalInit()
207 if(fDebug > 1) printf("AnalysisTaskSEHFv2::Init() \n");
209 fRDCuts->SetMinCentrality(fMinCentr);
210 fRDCuts->SetMaxCentrality(fMaxCentr);
215 AliRDHFCutsDplustoKpipi* copycut=new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fRDCuts)));
222 AliRDHFCutsD0toKpi* copycut=new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fRDCuts)));
229 AliRDHFCutsDStartoKpipi* copycut=new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fRDCuts)));
239 //________________________________________________________________________
240 void AliAnalysisTaskSEHFv2::UserCreateOutputObjects()
242 // Create the output container
244 if(fDebug > 1) printf("AnalysisTaskSEHFv2::UserCreateOutputObjects() \n");
246 fhEventsInfo=new TH1F(GetOutputSlot(1)->GetContainer()->GetName(), "Number of AODs scanned",6,-0.5,5.5);
247 fhEventsInfo->GetXaxis()->SetBinLabel(1,"nEventsAnal");
248 fhEventsInfo->GetXaxis()->SetBinLabel(2,"nEvSelected");
249 fhEventsInfo->GetXaxis()->SetBinLabel(3,"nCandidatesSelected");
250 fhEventsInfo->GetXaxis()->SetBinLabel(4,"out of pt bounds");
251 fhEventsInfo->GetXaxis()->SetBinLabel(5,Form("Ev Sel in Centr %.0f-%.0f%s",fRDCuts->GetMinCentrality(),fRDCuts->GetMaxCentrality(),"%"));
252 fhEventsInfo->GetXaxis()->SetBinLabel(6,"mismatch lab");
253 fhEventsInfo->GetXaxis()->SetNdivisions(1,kFALSE);
256 // Several histograms are more conveniently managed in a TList
257 fOutput = new TList();
259 fOutput->SetName("MainOutput");
261 for(Int_t icentr=fMinCentr+5;icentr<=fMaxCentr;icentr=icentr+5){
262 TString centrname;centrname.Form("centr%d_%d",icentr-5,icentr);
264 TH2F* hMPtCand=new TH2F(Form("hMPtCand%s",centrname.Data()),Form("Mass vs pt %s;pt (GeV);M (GeV/c^{2})",centrname.Data()),120,0,24.,fNMassBins,fLowmasslimit,fUpmasslimit);
265 fOutput->Add(hMPtCand);//For <pt> calculation
268 //Candidate distributions
269 for(Int_t i=0;i<fNPtBins;i++){
270 TH2F* hMc2phi=new TH2F(Form("hMc2phi_pt%d%s",i,centrname.Data()),Form("Mass vs cos2#Delta#phi (p_{t} bin %d %s);cos2#Delta#phi;M (GeV/c^{2})",i,centrname.Data()),100,-1.,1.,fNMassBins,fLowmasslimit,fUpmasslimit);
271 fOutput->Add(hMc2phi);//for 2D analysis
273 TH2F* hMphi=new TH2F(Form("hMphi_pt%d%s",i,centrname.Data()),Form("Mass vs #Delta#phi %s;#Delta#phi;M (GeV/c^{2})",centrname.Data()),96,0,TMath::Pi(),fNMassBins,fLowmasslimit,fUpmasslimit);
274 fOutput->Add(hMphi);//for phi bins analysis
277 TH2F* hMc2phiS=new TH2F(Form("hMc2phiS_pt%d%s",i,centrname.Data()),Form("Mass vs cos2#Delta#phi (p_{t} bin %d %s);cos2#Delta#phi;M (GeV/c^{2})",i,centrname.Data()),100,-1.,1.,fNMassBins,fLowmasslimit,fUpmasslimit);
278 fOutput->Add(hMc2phiS);
279 TH2F * hMphiS=new TH2F(Form("hMphiS_pt%d%s",i,centrname.Data()),Form("Mass vs #Delta#phi (p_{t} bin %d %s);#Delta#phi;M (GeV/c^{2})",i,centrname.Data()),96,0,2*TMath::Pi(),fNMassBins,fLowmasslimit,fUpmasslimit);
280 fOutput->Add(hMphiS);
281 TH2F* hMc2phiB=new TH2F(Form("hMc2phiB_pt%d%s",i,centrname.Data()),Form("Mass vs cos2#Delta#phi (p_{t} bin %d %s);cos2#Delta#phi;M (GeV/c^{2})",i,centrname.Data()),100,-1.,1.,fNMassBins,fLowmasslimit,fUpmasslimit);
282 fOutput->Add(hMc2phiB);
283 TH2F * hMphiB=new TH2F(Form("hMphiB_pt%d%s",i,centrname.Data()),Form("Mass vs #Delta#phi (p_{t} bin %d %s);#Delta#phi;M (GeV/c^{2})",i,centrname.Data()),96,0,2*TMath::Pi(),fNMassBins,fLowmasslimit,fUpmasslimit);
284 fOutput->Add(hMphiB);
285 if((fDecChannel != AliAnalysisTaskSEHFv2::kDplustoKpipi) &&(fDecChannel != AliAnalysisTaskSEHFv2::kDstartoKpipi)){
286 TH2F* hMc2phiR=new TH2F(Form("hMc2phiR_pt%d%s",i,centrname.Data()),Form("Mass vs cos2#Delta#phi (p_{t} bin %d %s);cos2#Delta#phi;M (GeV/c^{2})",i,centrname.Data()),100,-1.,1.,fNMassBins,fLowmasslimit,fUpmasslimit);
287 fOutput->Add(hMc2phiR);
288 TH2F* hMphiR=new TH2F(Form("hMphiR_pt%d%s",i,centrname.Data()),Form("Mass vs #Delta#phi (p_{t} bin %d %s);#Delta#phi;M (GeV/c^{2})",i,centrname.Data()),96,0,2*TMath::Pi(),fNMassBins,fLowmasslimit,fUpmasslimit);
289 fOutput->Add(hMphiR);
296 TH2F* hEvPlane=new TH2F(Form("hEvPlane%s",centrname.Data()),Form("VZERO/TPC Event plane angle %s;#phi Ev Plane (TPC);#phi Ev Plane (VZERO);Entries",centrname.Data()),200,0.,TMath::Pi(),200,0.,TMath::Pi());
297 fOutput->Add(hEvPlane);
299 TH1F* hEvPlaneneg=new TH1F(Form("hEvPlaneneg%s",centrname.Data()),Form("Event plane angle %s;#phi Ev Plane;Entries",centrname.Data()),200,0.,TMath::Pi());
300 fOutput->Add(hEvPlaneneg);
302 TH1F* hEvPlanepos=new TH1F(Form("hEvPlanepos%s",centrname.Data()),Form("Event plane angle %s;#phi Ev Plane;Entries",centrname.Data()),200,0.,TMath::Pi());
303 fOutput->Add(hEvPlanepos);
305 TH1F* hEvPlaneCand=new TH1F(Form("hEvPlaneCand%s",centrname.Data()),Form("Event plane angle - Event plane angle per candidate %s;#phi(Ev Plane Candidate);Entries",centrname.Data()),200,-TMath::Pi(),TMath::Pi());
306 fOutput->Add(hEvPlaneCand);
308 TH1F* hEvPlaneReso=new TH1F(Form("hEvPlaneReso%s",centrname.Data()),Form("Event plane angle Resolution %s;cos2(#psi_{A}-#psi_{B});Entries",centrname.Data()),220,-1.1,1.1);
309 fOutput->Add(hEvPlaneReso);
312 PostData(1,fhEventsInfo);
318 //________________________________________________________________________
319 void AliAnalysisTaskSEHFv2::UserExec(Option_t */*option*/)
321 // Execute analysis for current event:
322 // heavy flavor candidates association to MC truth
323 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
324 if(fDebug>2) printf("Analysing decay %d\n",fDecChannel);
325 // Post the data already here
326 PostData(1,fhEventsInfo);
329 TClonesArray *arrayProng =0;
331 if(!aod && AODEvent() && IsStandardAOD()) {
332 // In case there is an AOD handler writing a standard AOD, use the AOD
333 // event in memory rather than the input (ESD) event.
334 aod = dynamic_cast<AliAODEvent*> (AODEvent());
335 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
336 // have to taken from the AOD event hold by the AliAODExtension
337 AliAODHandler* aodHandler = (AliAODHandler*)
338 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
339 if(aodHandler->GetExtensions()) {
341 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
342 AliAODEvent *aodFromExt = ext->GetAOD();
347 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
351 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
355 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
361 arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
365 arrayProng=(TClonesArray*)aod->GetList()->FindObject("D0toKpi");
369 arrayProng=(TClonesArray*)aod->GetList()->FindObject("Dstar");
373 if(!aod || !arrayProng) {
374 AliError("AliAnalysisTaskSEHFv2::UserExec:Branch not found!\n");
378 // fix for temporary bug in ESDfilter
379 // the AODs with null vertex pointer didn't pass the PhysSel
380 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
382 TClonesArray *arrayMC=0;
383 AliAODMCHeader *mcHeader=0;
388 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
390 AliWarning("AliAnalysisTaskSEHFv2::UserExec:MC particles branch not found!\n");
395 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
397 AliError("AliAnalysisTaskSEHFv2::UserExec:MC header branch not found!\n");
402 fhEventsInfo->Fill(0); // count event
404 AliAODRecoDecayHF *d=0;
406 Int_t nCand = arrayProng->GetEntriesFast();
407 if(fDebug>2) printf("Number of D2H: %d\n",nCand);
409 Bool_t isEvSel=fRDCuts->IsEventSelected(aod);
411 if(!fRDCuts->IsEventRejectedDueToCentrality())fhEventsInfo->Fill(4);
415 fhEventsInfo->Fill(1);
416 AliEventplane *pl=aod->GetEventplane();
418 AliError("AliAnalysisTaskSEHFv2::UserExec:no eventplane! v2 analysis without eventplane not possible!\n");
423 Double_t eventplane=0;
424 Double_t rpangleTPC=0;
425 Double_t rpangleVZERO=0;
426 Double_t planereso=0;
428 Double_t rpangleeventneg=0;
429 Double_t rpangleeventpos=0;
431 //For candidate removal from TPC EP
436 //determine centrality bin
437 Float_t centr=fRDCuts->GetCentrality(aod);
439 for(Int_t ic=fMinCentr+5;ic<=fMaxCentr;ic=ic+5){
445 TString centrbinname=Form("centr%d_%d",icentr-5,icentr);
448 fEventPlaneMeth=kVZERO;
449 TRandom3 *g = new TRandom3(0);
450 rpangleVZERO=g->Rndm()*TMath::Pi();
452 eventplane=rpangleVZERO;
453 if(fUseAfterBurner)fAfterBurner->SetEventPlane((Double_t)eventplane);
455 if(fEventPlaneMeth!=kTPC){
456 //VZERO EP and resolution
457 rpangleVZERO=pl->GetEventplane("V0",aod,fV0EPorder);
458 if(fEventPlaneMeth!=kTPCVZERO){
459 //Using V0A/C to determine resolution
460 rpangleeventneg= pl->GetEventplane("V0A",aod,fV0EPorder);
461 rpangleeventpos= pl->GetEventplane("V0C",aod,fV0EPorder);
462 deltaPsi =rpangleeventneg-rpangleeventpos;
463 if(TMath::Abs(deltaPsi)>TMath::Pi()/2.){// difference of subevents reaction plane angle cannot be bigger than phi/2
464 if(deltaPsi>0.) deltaPsi-=TMath::Pi();
465 else deltaPsi +=TMath::Pi();
467 eventplane=rpangleVZERO;
470 if(fEventPlaneMeth!=kVZERO){
471 // TPC event plane and resolution
473 // extracting Q vectors and calculating v2 + resolution
475 qsub1 = pl->GetQsub1();
476 qsub2 = pl->GetQsub2();
477 rpangleeventpos = qsub1->Phi()/2.;
478 rpangleeventneg = qsub2->Phi()/2.;
481 q = pl->GetQVector();
482 rpangleTPC = pl->GetEventplane("Q");
484 if(fEventPlaneMeth!=kVZEROTPC){
485 deltaPsi = pl->GetQsubRes();
486 if(TMath::Abs(deltaPsi)>TMath::Pi()/2.){
487 if(deltaPsi>0.) deltaPsi-=TMath::Pi();
488 else deltaPsi +=TMath::Pi();
489 } // difference of subevents reaction plane angle cannot be bigger than phi/2
490 planereso = TMath::Cos(2.*deltaPsi); // reaction plane resolution
494 if(TMath::Abs(rpangleTPC-rpangleVZERO)>fEventPlanesComp)return;
495 //Filling EP-related histograms
496 planereso = TMath::Cos(2.*deltaPsi); // reaction plane resolution
497 ((TH2F*)fOutput->FindObject(Form("hEvPlane%s",centrbinname.Data())))->Fill(rpangleTPC,rpangleVZERO); // reaction plane angle without autocorrelations removal
498 ((TH1F*)fOutput->FindObject(Form("hEvPlaneReso%s",centrbinname.Data())))->Fill(planereso); //RP resolution
499 ((TH1F*)fOutput->FindObject(Form("hEvPlanepos%s",centrbinname.Data())))->Fill(rpangleeventpos); //Angle of first subevent
500 ((TH1F*)fOutput->FindObject(Form("hEvPlaneneg%s",centrbinname.Data())))->Fill(rpangleeventneg); //Angle of second subevent
502 //Loop on D candidates
503 for (Int_t iCand = 0; iCand < nCand; iCand++) {
504 d=(AliAODRecoDecayHF*)arrayProng->UncheckedAt(iCand);
505 Bool_t isSelBit=kTRUE;
506 if(fDecChannel==0) isSelBit=d->HasSelectionBit(AliRDHFCuts::kDplusCuts);
507 if(fDecChannel==1) isSelBit=d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts);
508 if(fDecChannel==2) isSelBit=d->HasSelectionBit(AliRDHFCuts::kD0fromDstarCuts);
509 if(!isSelBit)continue;
510 Int_t ptbin=fRDCuts->PtBin(d->Pt());
512 fhEventsInfo->Fill(3);
515 Bool_t isFidAcc = fRDCuts->IsInFiducialAcceptance(d->Pt(),d->Y(absPdgMom));
516 if(!isFidAcc)continue;
517 Int_t isSelected= fRDCuts->IsSelected(d,AliRDHFCuts::kCandidate,aod);
518 if(!isSelected)continue;
520 fhEventsInfo->Fill(2); // candidate selected
521 if(fDebug>3) printf("+++++++Is Selected\n");
523 Float_t* invMass=0x0;
525 CalculateInvMasses(d,invMass,nmasses);
527 if(fEventPlaneMeth%2==0){
528 eventplane = GetEventPlaneForCandidate(d,q,pl,qsub1,qsub2); // remove autocorrelations
529 ((TH1F*)fOutput->FindObject(Form("hEvPlaneCand%s",centrbinname.Data())))->Fill(rpangleTPC-eventplane);
532 Double_t phi=d->Phi();
533 if(fReadMC&&fUseAfterBurner)phi=fAfterBurner->GetNewAngle(d,arrayMC);
534 Float_t deltaphi=GetPhi0Pi(phi-eventplane);
536 //fill the histograms with the appropriate method
537 if(fDecChannel==0)FillDplus(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr);
538 else if(fDecChannel==1)FillD02p(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr);
539 else if(fDecChannel==2)FillDstar(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr);
544 PostData(1,fhEventsInfo);
550 //***************************************************************************
552 // Methods used in the UserExec
554 void AliAnalysisTaskSEHFv2::CalculateInvMasses(AliAODRecoDecayHF* d,Float_t*& masses,Int_t& nmasses){
555 //Calculates all the possible invariant masses for each candidate
556 //NB: the implementation for each candidate is responsibility of the corresponding developer
561 masses=new Float_t[nmasses];
562 Int_t pdgdaughters[3] = {211,321,211};
563 masses[0]=d->InvMass(3,(UInt_t*)pdgdaughters);
569 masses=new Float_t[nmasses];
570 Int_t pdgdaughtersD0[ndght]={211,321};//pi,K
571 masses[0]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0); //D0
572 Int_t pdgdaughtersD0bar[ndght]={321,211};//K,pi
573 masses[1]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0bar); //D0bar
576 //D* -- Robert,Yifei, Alessandro
578 masses=new Float_t[nmasses];
579 masses[0]=((AliAODRecoCascadeHF*)d)->DeltaInvMass();
583 //******************************************************************************
585 //Methods to fill the histograms, one for each channel
586 //NB: the implementation for each candidate is responsibility of the corresponding developer
588 //******************************************************************************
589 void AliAnalysisTaskSEHFv2::FillDplus(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr){
592 if(fDebug>3)AliWarning("Candidate not selected\n");
596 if(fDebug>3)AliWarning("Masses not calculated\n");
600 ((TH2F*)fOutput->FindObject(Form("hMc2phi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
601 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
602 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentr-5,icentr)))->Fill(d->Pt(),masses[0]);
603 Int_t pdgdaughters[3] = {211,321,211};
608 Bool_t isSignal=fAfterBurner->GetIsSignal();
611 lab = d->MatchToMC(411,arrayMC,3,pdgdaughters);
614 ((TH2F*)fOutput->FindObject(Form("hMc2phiS_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
615 ((TH2F*)fOutput->FindObject(Form("hMphiS_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
617 ((TH2F*)fOutput->FindObject(Form("hMc2phiB_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
618 ((TH2F*)fOutput->FindObject(Form("hMphiB_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
623 //******************************************************************************
624 void AliAnalysisTaskSEHFv2::FillD02p(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr){
630 if(fDebug>3)AliWarning("Masses not calculated\n");
633 if(isSel==1 || isSel==3) {
634 ((TH2F*)fOutput->FindObject(Form("hMc2phi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
635 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
636 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentr-5,icentr)))->Fill(d->Pt(),masses[0]);
639 ((TH2F*)fOutput->FindObject(Form("hMc2phi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
640 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[1]);
641 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentr-5,icentr)))->Fill(d->Pt(),masses[1]);
650 Int_t pdgdaughters[2];
651 pdgdaughters[0]=211;//pi
652 pdgdaughters[1]=321;//K
656 matchtoMC = d->MatchToMC(absPdgMom,arrayMC,nprongs,pdgdaughters);
658 Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421;
659 if((isSel==1 || isSel==3)){ //D0
661 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
662 Int_t pdgMC = dMC->GetPdgCode();
664 if(pdgMC==prongPdgPlus) {
665 ((TH2F*)fOutput->FindObject(Form("hMc2phiS_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
666 ((TH2F*)fOutput->FindObject(Form("hMphiS_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
669 ((TH2F*)fOutput->FindObject(Form("hMc2phiR_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
670 ((TH2F*)fOutput->FindObject(Form("hMphiR_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
673 ((TH2F*)fOutput->FindObject(Form("hMc2phiB_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
674 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
677 if(isSel>=2){ //D0bar
679 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
680 Int_t pdgMC = dMC->GetPdgCode();
682 if(pdgMC==prongPdgMinus) {
683 ((TH2F*)fOutput->FindObject(Form("hMc2phiS_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
684 ((TH2F*)fOutput->FindObject(Form("hMphiS_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[1]);
687 ((TH2F*)fOutput->FindObject(Form("hMc2phiR_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
688 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[1]);
691 ((TH2F*)fOutput->FindObject(Form("hMc2phiB_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
692 ((TH2F*)fOutput->FindObject(Form("hMphiB_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[1]);
697 //******************************************************************************
698 void AliAnalysisTaskSEHFv2::FillDstar(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr){
701 if(fDebug>3)AliWarning("Candidate not selected\n");
705 if(fDebug>3)AliWarning("Masses not calculated\n");
709 ((TH2F*)fOutput->FindObject(Form("hMc2phi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
710 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
711 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentr-5,icentr)))->Fill(d->Pt(),masses[0]);
712 Int_t pdgDgDStartoD0pi[2]={421,211};
713 Int_t pdgDgD0toKpi[2]={321,211};
717 lab = ((AliAODRecoCascadeHF*)d)->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,arrayMC);
719 ((TH2F*)fOutput->FindObject(Form("hMc2phiS_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
720 ((TH2F*)fOutput->FindObject(Form("hMphiS_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
722 ((TH2F*)fOutput->FindObject(Form("hMc2phiB_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
723 ((TH2F*)fOutput->FindObject(Form("hMphiB_pt%dcentr%d_%d",ptbin,icentr-5,icentr)))->Fill(deltaphi,masses[0]);
728 //________________________________________________________________________
729 void AliAnalysisTaskSEHFv2::SetEventPlaneMethod(Int_t method){
730 if(method>3||method<0){
731 AliWarning("No EP method associated to the selection, setting to TPC EP\n");
734 fEventPlaneMeth=method;
737 //________________________________________________________________________
738 Float_t AliAnalysisTaskSEHFv2::GetPhi0Pi(Float_t phi){
739 // Sets the phi angle in the range 0-pi
742 result=result+TMath::Pi();
744 while(result>TMath::Pi()){
745 result=result-TMath::Pi();
750 //________________________________________________________________________
751 Float_t AliAnalysisTaskSEHFv2::GetEventPlaneForCandidate(AliAODRecoDecayHF* d, const TVector2* q,AliEventplane *pl, const TVector2* qsub1, const TVector2* qsub2){
752 // remove autocorrelations
758 qx = pl->GetQContributionXArray();
759 qy = pl->GetQContributionYArray();
764 qx = pl->GetQContributionXArraysub1();
765 qy = pl->GetQContributionYArraysub1();
769 qx = pl->GetQContributionXArraysub2();
770 qy = pl->GetQContributionYArraysub2();
776 //D* -- Yifei, Alessandro,Robert
777 AliAODRecoDecayHF2Prong* theD0particle = ((AliAODRecoCascadeHF*)d)->Get2Prong();
778 AliAODTrack *track0 = (AliAODTrack*)theD0particle->GetDaughter(0);
779 AliAODTrack *track1 = (AliAODTrack*)theD0particle->GetDaughter(1);
780 AliAODTrack *track2 = ((AliAODRecoCascadeHF*)d)->GetBachelor();
781 // reduce global q vector
784 if((track0->GetID()) < qx->fN){
785 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
788 if((track1->GetID()) < qx->fN){
789 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
792 if((track2->GetID()) < qx->fN){
793 q2.Set(qx->At(track2->GetID()),qy->At(track2->GetID()));}
795 qcopy = qcopy -(q0+q1+q2);
799 // reduce Q vector for D+ and D0
803 AliAODTrack *track0 = (AliAODTrack*)d->GetDaughter(0);
804 AliAODTrack *track1 = (AliAODTrack*)d->GetDaughter(1);
807 if((track0->GetID()) < qx->fN){
808 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
811 if((track1->GetID()) < qx->fN){
812 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
814 qcopy = qcopy -(q0+q1);
819 AliAODTrack *track0 = (AliAODTrack*)d->GetDaughter(0);
820 AliAODTrack *track1 = (AliAODTrack*)d->GetDaughter(1);
821 AliAODTrack *track2 = (AliAODTrack*)d->GetDaughter(2);
824 if((track0->GetID()) < qx->fN){
825 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
828 if((track1->GetID()) < qx->fN){
829 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
832 if((track2->GetID()) < qx->fN){
833 q2.Set(qx->At(track2->GetID()),qy->At(track2->GetID()));}
835 qcopy = qcopy -(q0+q1+q2);
839 return qcopy.Phi()/2.;
842 // //________________________________________________________________________
843 // Float_t AliAnalysisTaskSEHFv2::GetEventPlaneFromV0(AliAODEvent *aodEvent){
844 // // Compute event plane for VZERO - Obsolete, used for 2010 data
846 // Int_t centr=fRDCuts->GetCentrality(aodEvent);
847 // centr=centr-centr%10;
849 // if(centr<20)centr=20;
850 // if(centr>70)centr=70;
851 // //end temporary fix
853 // Int_t iParHist=(centr-20)/10;
855 // TString name;name.Form("parhist%d_%d",centr,centr+10);
857 // if(fDebug>15)printf("EPfromV0 centr %d, iparhist %d (%p-%p)\n",centr,iParHist,fParHist->FindObject(name.Data()),fParHist->At(iParHist));
859 // Int_t runnumber=aodEvent->GetRunNumber();
860 // if(fParHist->At(iParHist)){
861 // for(Int_t i=1;i<=((TH2D*)fParHist->At(iParHist))->GetNbinsX()&&binx<=0;i++){
862 // Int_t run=atoi(((TH2D*)fParHist->At(iParHist))->GetXaxis()->GetBinLabel(i));
863 // if(run>=runnumber)binx=i;
866 // fhEventsInfo->Fill(7);
869 // AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts();
870 // cutsRP->SetEvent(aodEvent, MCEvent());//, 0x0);
871 // cutsRP->SetName( Form("rp_cuts") );
872 // AliFlowTrackCuts* dummy = new AliFlowTrackCuts("null_cuts");
873 // dummy->SetParamType(AliFlowTrackCuts::kGlobal);
874 // dummy->SetPtRange(+1,-1); // select nothing QUICK
875 // dummy->SetEtaRange(+1,-1); // select nothing VZERO
876 // dummy->SetEvent(aodEvent,MCEvent());
878 // //////////////// construct the flow event container ////////////
879 // AliFlowEvent flowEvent(cutsRP,dummy);
880 // flowEvent.SetReferenceMultiplicity( 64 );
881 // for(Int_t i=0;i<64&&binx>0;i++){
882 // AliFlowTrack *flowTrack=flowEvent.GetTrack(i);
883 // Double_t inte=((TH2D*)fParHist->At(iParHist))->Integral(binx,binx,i+1,i+1);
884 // if(inte>0)flowTrack->SetWeight(flowTrack->Weight()/inte);
886 // if(fDebug>15)printf("EPfromV0 flow tracks weights done\n");
888 // AliFlowVector qvec=flowEvent.GetQ(fV0EPorder);
889 // Double_t angleEP=(1./(Double_t)fV0EPorder)*qvec.Phi();
890 // if(fDebug>15)printf("EPfromV0 phi %f\n",angleEP);
893 //________________________________________________________________________
894 void AliAnalysisTaskSEHFv2::Terminate(Option_t */*option*/)
896 // Terminate analysis
898 if(fDebug > 1) printf("AnalysisTaskSEHFv2: Terminate() \n");