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 fCentBinSizePerMil(25)
103 // Default constructor
106 //________________________________________________________________________
107 AliAnalysisTaskSEHFv2::AliAnalysisTaskSEHFv2(const char *name,AliRDHFCuts *rdCuts,Int_t decaychannel):
108 AliAnalysisTaskSE(name),
117 fUseAfterBurner(kFALSE),
118 fDecChannel(decaychannel),
120 fEventPlaneMeth(kTPCVZERO),
121 fEventPlanesComp(10),
127 fCentBinSizePerMil(25)
129 // standard constructor
151 fAfterBurner = new AliHFAfterBurner(fDecChannel);
152 if(pdg==413) SetMassLimits((Float_t)0.1,(Float_t)0.2);
153 else SetMassLimits((Float_t)0.2,pdg); //check range
154 fNPtBins=fRDCuts->GetNPtBins();
156 if(fDebug>1)fRDCuts->PrintAll();
157 // Output slot #1 writes into a TH1F container
158 DefineOutput(1,TH1F::Class()); //Info on the number of events etc.
159 // Output slot #2 writes into a TList container
160 DefineOutput(2,TList::Class()); //Main output
161 // Output slot #3 writes into a AliRDHFCuts container (cuts)
164 DefineOutput(3,AliRDHFCutsDplustoKpipi::Class()); //Cut object for Dplus
167 DefineOutput(3,AliRDHFCutsD0toKpi::Class()); //Cut object for D0
170 DefineOutput(3,AliRDHFCutsDStartoKpipi::Class()); //Cut object for D*
173 //DefineOutput(4,AliFlowEventSimple::Class());
174 //DefineOutput(4,TList::Class());
177 //________________________________________________________________________
178 AliAnalysisTaskSEHFv2::~AliAnalysisTaskSEHFv2()
186 //_________________________________________________________________
187 void AliAnalysisTaskSEHFv2::SetMassLimits(Float_t range, Int_t pdg){
188 // Set limits for mass spectra plots
190 Int_t abspdg=TMath::Abs(pdg);
191 mass=TDatabasePDG::Instance()->GetParticle(abspdg)->Mass();
192 fUpmasslimit = mass+range;
193 fLowmasslimit = mass-range;
195 //_________________________________________________________________
196 void AliAnalysisTaskSEHFv2::SetMassLimits(Float_t lowlimit, Float_t uplimit){
197 // Set limits for mass spectra plots
200 fUpmasslimit = uplimit;
201 fLowmasslimit = lowlimit;
206 //________________________________________________________________________
207 void AliAnalysisTaskSEHFv2::LocalInit()
211 if(fDebug > 1) printf("AnalysisTaskSEHFv2::Init() \n");
213 fRDCuts->SetMinCentrality(fMinCentr);
214 fRDCuts->SetMaxCentrality(fMaxCentr);
219 AliRDHFCutsDplustoKpipi* copycut=new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fRDCuts)));
226 AliRDHFCutsD0toKpi* copycut=new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fRDCuts)));
233 AliRDHFCutsDStartoKpipi* copycut=new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fRDCuts)));
243 //________________________________________________________________________
244 void AliAnalysisTaskSEHFv2::UserCreateOutputObjects()
246 // Create the output container
248 if(fDebug > 1) printf("AnalysisTaskSEHFv2::UserCreateOutputObjects() \n");
250 fhEventsInfo=new TH1F(GetOutputSlot(1)->GetContainer()->GetName(), "Number of AODs scanned",7,-0.5,6.5);
251 fhEventsInfo->GetXaxis()->SetBinLabel(1,"nEventsAnal");
252 fhEventsInfo->GetXaxis()->SetBinLabel(2,"nEvSelected");
253 fhEventsInfo->GetXaxis()->SetBinLabel(3,"nCandidatesSelected");
254 fhEventsInfo->GetXaxis()->SetBinLabel(4,"out of pt bounds");
255 fhEventsInfo->GetXaxis()->SetBinLabel(5,Form("Ev Sel in Centr %.0f-%.0f%s",fRDCuts->GetMinCentrality(),fRDCuts->GetMaxCentrality(),"%"));
256 fhEventsInfo->GetXaxis()->SetBinLabel(6,"mismatch lab");
257 fhEventsInfo->GetXaxis()->SetBinLabel(7,"non valid TPC EP");
258 fhEventsInfo->GetXaxis()->SetNdivisions(1,kFALSE);
261 // Several histograms are more conveniently managed in a TList
262 fOutput = new TList();
264 fOutput->SetName("MainOutput");
266 for(Int_t icentr=fMinCentr*10+fCentBinSizePerMil;icentr<=fMaxCentr*10;icentr=icentr+fCentBinSizePerMil){
267 TString centrname;centrname.Form("centr%d_%d",icentr-fCentBinSizePerMil,icentr);
269 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);
270 fOutput->Add(hMPtCand);//For <pt> calculation
273 //Candidate distributions
274 for(Int_t i=0;i<fNPtBins;i++){
275 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);
276 fOutput->Add(hMc2phi);//for 2D analysis
278 Double_t maxphi = TMath::Pi();
279 if (fDecChannel == 2) maxphi = TMath::PiOver2();
280 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,maxphi,fNMassBins,fLowmasslimit,fUpmasslimit);
281 fOutput->Add(hMphi);//for phi bins analysis
284 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);
285 fOutput->Add(hMc2phiS);
286 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);
287 fOutput->Add(hMphiS);
288 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);
289 fOutput->Add(hMc2phiB);
290 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);
291 fOutput->Add(hMphiB);
292 if((fDecChannel != AliAnalysisTaskSEHFv2::kDplustoKpipi) &&(fDecChannel != AliAnalysisTaskSEHFv2::kDstartoKpipi)){
293 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);
294 fOutput->Add(hMc2phiR);
295 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);
296 fOutput->Add(hMphiR);
303 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());
304 fOutput->Add(hEvPlane);
306 TH1F* hEvPlaneA=new TH1F(Form("hEvPlaneA%s",centrname.Data()),Form("Event plane angle %s;#phi Ev Plane;Entries",centrname.Data()),200,0.,TMath::Pi());
307 fOutput->Add(hEvPlaneA);
309 TH1F* hEvPlaneB=new TH1F(Form("hEvPlaneB%s",centrname.Data()),Form("Event plane angle %s;#phi Ev Plane;Entries",centrname.Data()),200,0.,TMath::Pi());
310 fOutput->Add(hEvPlaneB);
312 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());
313 fOutput->Add(hEvPlaneCand);
315 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);
316 fOutput->Add(hEvPlaneReso);
317 if(fEventPlaneMeth>kTPCVZERO){
318 TH1F* hEvPlaneReso2=new TH1F(Form("hEvPlaneReso2%s",centrname.Data()),Form("Event plane angle Resolution %s;cos2(#psi_{A}-#psi_{B});Entries",centrname.Data()),220,-1.1,1.1);
319 fOutput->Add(hEvPlaneReso2);
320 TH1F* hEvPlaneReso3=new TH1F(Form("hEvPlaneReso3%s",centrname.Data()),Form("Event plane angle Resolution %s;cos2(#psi_{A}-#psi_{B});Entries",centrname.Data()),220,-1.1,1.1);
321 fOutput->Add(hEvPlaneReso3);
325 PostData(1,fhEventsInfo);
331 //________________________________________________________________________
332 void AliAnalysisTaskSEHFv2::UserExec(Option_t */*option*/)
334 // Execute analysis for current event:
335 // heavy flavor candidates association to MC truth
336 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
337 if(fDebug>2) printf("Analysing decay %d\n",fDecChannel);
338 // Post the data already here
339 PostData(1,fhEventsInfo);
342 TClonesArray *arrayProng =0;
344 if(!aod && AODEvent() && IsStandardAOD()) {
345 // In case there is an AOD handler writing a standard AOD, use the AOD
346 // event in memory rather than the input (ESD) event.
347 aod = dynamic_cast<AliAODEvent*> (AODEvent());
348 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
349 // have to taken from the AOD event hold by the AliAODExtension
350 AliAODHandler* aodHandler = (AliAODHandler*)
351 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
352 if(aodHandler->GetExtensions()) {
354 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
355 AliAODEvent *aodFromExt = ext->GetAOD();
360 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
364 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
368 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
374 arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
378 arrayProng=(TClonesArray*)aod->GetList()->FindObject("D0toKpi");
382 arrayProng=(TClonesArray*)aod->GetList()->FindObject("Dstar");
386 if(!aod || !arrayProng) {
387 AliError("AliAnalysisTaskSEHFv2::UserExec:Branch not found!\n");
391 // fix for temporary bug in ESDfilter
392 // the AODs with null vertex pointer didn't pass the PhysSel
393 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
395 TClonesArray *arrayMC=0;
396 AliAODMCHeader *mcHeader=0;
401 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
403 AliWarning("AliAnalysisTaskSEHFv2::UserExec:MC particles branch not found!\n");
408 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
410 AliError("AliAnalysisTaskSEHFv2::UserExec:MC header branch not found!\n");
415 fhEventsInfo->Fill(0); // count event
417 AliAODRecoDecayHF *d=0;
419 Int_t nCand = arrayProng->GetEntriesFast();
420 if(fDebug>2) printf("Number of D2H: %d\n",nCand);
422 Bool_t isEvSel=fRDCuts->IsEventSelected(aod);
424 if(!fRDCuts->IsEventRejectedDueToCentrality())fhEventsInfo->Fill(4);
428 fhEventsInfo->Fill(1);
429 fhEventsInfo->Fill(4);
431 AliEventplane *pl=aod->GetEventplane();
433 AliError("AliAnalysisTaskSEHFv2::UserExec:no eventplane! v2 analysis without eventplane not possible!\n");
434 fhEventsInfo->Fill(6);
439 Double_t eventplane=0;
440 Double_t rpangleTPC=0;
441 Double_t rpangleVZERO=0;
442 Double_t planereso=0;
444 Double_t rpangleeventC=0;
445 Double_t rpangleeventB=0;
446 Double_t rpangleeventA=0;
448 //For candidate removal from TPC EP
453 //determine centrality bin
454 Float_t centr=fRDCuts->GetCentrality(aod);
455 Float_t centrPerMil=centr*10.;
457 for(Int_t ic=fMinCentr*10+fCentBinSizePerMil;ic<=fMaxCentr*10;ic=ic+fCentBinSizePerMil){
463 if(icentr==-1) return;
465 TString centrbinname=Form("centr%d_%d",icentr-fCentBinSizePerMil,icentr);
468 TRandom3 *g = new TRandom3(0);
469 eventplane=g->Rndm()*TMath::Pi();
471 if(fUseAfterBurner)fAfterBurner->SetEventPlane((Double_t)eventplane);
474 rpangleTPC = pl->GetEventplane("Q");
476 fhEventsInfo->Fill(6);
479 rpangleeventA = rpangleTPC;
480 if(fSubEvents==2||fEventPlaneMeth==kVZERO){
481 qsub1 = pl->GetQsub1();
482 qsub2 = pl->GetQsub2();
483 if(!qsub1 || !qsub2){
484 fhEventsInfo->Fill(6);
487 rpangleeventA = qsub1->Phi()/2.;
488 rpangleeventB = qsub2->Phi()/2.;
490 if(fEventPlaneMeth!=kTPC){
491 //VZERO EP and resolution
492 rpangleVZERO=GetPhi0Pi(pl->GetEventplane("V0",aod,fV0EPorder));
493 rpangleeventC=rpangleVZERO;
494 if(fEventPlaneMeth==kVZEROA||fEventPlaneMeth==kVZEROC||(fEventPlaneMeth==kTPCVZERO&&fSubEvents==3)){
495 rpangleeventB=GetPhi0Pi(pl->GetEventplane("V0A",aod,fV0EPorder));
496 rpangleeventC=GetPhi0Pi(pl->GetEventplane("V0C",aod,fV0EPorder));
497 if(fEventPlaneMeth==kVZEROA)rpangleVZERO=rpangleeventB;
498 else if(fEventPlaneMeth==kVZEROC)rpangleVZERO=rpangleeventC;
503 if(fEventPlaneMeth>kTPCVZERO)eventplane=rpangleVZERO;
505 q = pl->GetQVector();
506 eventplane=rpangleTPC;
508 deltaPsi =rpangleeventA-rpangleeventB;
511 if(TMath::Abs(deltaPsi)>TMath::Pi()/2.){
512 if(deltaPsi>0.) deltaPsi-=TMath::Pi();
513 else deltaPsi +=TMath::Pi();
514 } // difference of subevents reaction plane angle cannot be bigger than phi/2
515 planereso = TMath::Cos(2.*deltaPsi); // reaction plane resolution
516 if(TMath::Abs(rpangleTPC-rpangleVZERO)>fEventPlanesComp)return;
518 if(fDebug>2)printf("Filling EP-related histograms\n");
519 //Filling EP-related histograms
520 ((TH2F*)fOutput->FindObject(Form("hEvPlane%s",centrbinname.Data())))->Fill(rpangleTPC,rpangleVZERO); // reaction plane angle without autocorrelations removal
521 ((TH1F*)fOutput->FindObject(Form("hEvPlaneReso%s",centrbinname.Data())))->Fill(planereso); //RP resolution
522 if(fEventPlaneMeth>kTPCVZERO||fEtaGap){
523 ((TH1F*)fOutput->FindObject(Form("hEvPlaneA%s",centrbinname.Data())))->Fill(rpangleeventA); //Angle of first subevent
524 ((TH1F*)fOutput->FindObject(Form("hEvPlaneB%s",centrbinname.Data())))->Fill(rpangleeventB); //Angle of second subevent
526 if(fEventPlaneMeth>kTPCVZERO||fSubEvents==3){
527 Double_t deltaSub=rpangleeventA-rpangleeventC;
528 if(TMath::Abs(deltaSub)>TMath::Pi()/2.){// difference of subevents reaction plane angle cannot be bigger than phi/2
529 if(deltaSub>0.) deltaSub-=TMath::Pi();
530 else deltaSub +=TMath::Pi();
532 TH1F* htmp1=(TH1F*)fOutput->FindObject(Form("hEvPlaneReso2%s",centrbinname.Data()));
533 if(htmp1) htmp1->Fill(TMath::Cos(2.*deltaSub)); //RP resolution
534 deltaSub =rpangleeventB-rpangleeventC;
535 if(TMath::Abs(deltaSub)>TMath::Pi()/2.){// difference of subevents reaction plane angle cannot be bigger than phi/2
536 if(deltaSub>0.) deltaSub-=TMath::Pi();
537 else deltaSub +=TMath::Pi();
539 TH1F* htmp2=(TH1F*)fOutput->FindObject(Form("hEvPlaneReso3%s",centrbinname.Data()));
540 if(htmp2) htmp2->Fill(TMath::Cos(2.*deltaSub)); //RP resolution
543 if(fDebug>2)printf("Loop on D candidates\n");
544 //Loop on D candidates
545 for (Int_t iCand = 0; iCand < nCand; iCand++) {
546 d=(AliAODRecoDecayHF*)arrayProng->UncheckedAt(iCand);
547 Bool_t isSelBit=kTRUE;
548 if(fDecChannel==0) isSelBit=d->HasSelectionBit(AliRDHFCuts::kDplusCuts);
549 if(fDecChannel==1) isSelBit=d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts);
550 if(fDecChannel==2) isSelBit=kTRUE;
551 if(!isSelBit)continue;
552 Int_t ptbin=fRDCuts->PtBin(d->Pt());
554 fhEventsInfo->Fill(3);
557 Bool_t isFidAcc = fRDCuts->IsInFiducialAcceptance(d->Pt(),d->Y(absPdgMom));
558 if(!isFidAcc)continue;
559 Int_t isSelected= fRDCuts->IsSelected(d,AliRDHFCuts::kAll,aod);
560 if(!isSelected)continue;
562 fhEventsInfo->Fill(2); // candidate selected
563 if(fDebug>3) printf("+++++++Is Selected\n");
565 Float_t* invMass=0x0;
567 CalculateInvMasses(d,invMass,nmasses);
569 if(fEventPlaneMeth<=kTPCVZERO){
570 eventplane = GetEventPlaneForCandidate(d,q,pl,qsub1,qsub2); // remove autocorrelations
571 ((TH1F*)fOutput->FindObject(Form("hEvPlaneCand%s",centrbinname.Data())))->Fill(rpangleTPC-eventplane);
574 Double_t phi=d->Phi();
575 if(fReadMC&&fUseAfterBurner)phi=fAfterBurner->GetNewAngle(d,arrayMC);
576 Float_t deltaphi=GetPhi0Pi(phi-eventplane);
578 //fill the histograms with the appropriate method
579 if(fDecChannel==0)FillDplus(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr);
580 else if(fDecChannel==1)FillD02p(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr);
581 else if(fDecChannel==2)FillDstar(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr);
586 PostData(1,fhEventsInfo);
592 //***************************************************************************
594 // Methods used in the UserExec
596 void AliAnalysisTaskSEHFv2::CalculateInvMasses(AliAODRecoDecayHF* d,Float_t*& masses,Int_t& nmasses){
597 //Calculates all the possible invariant masses for each candidate
598 //NB: the implementation for each candidate is responsibility of the corresponding developer
603 masses=new Float_t[nmasses];
604 Int_t pdgdaughters[3] = {211,321,211};
605 masses[0]=d->InvMass(3,(UInt_t*)pdgdaughters);
611 masses=new Float_t[nmasses];
612 Int_t pdgdaughtersD0[ndght]={211,321};//pi,K
613 masses[0]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0); //D0
614 Int_t pdgdaughtersD0bar[ndght]={321,211};//K,pi
615 masses[1]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0bar); //D0bar
618 //D* -- Robert,Yifei, Alessandro
620 masses=new Float_t[nmasses];
621 masses[0]=((AliAODRecoCascadeHF*)d)->DeltaInvMass();
625 //******************************************************************************
627 //Methods to fill the histograms, one for each channel
628 //NB: the implementation for each candidate is responsibility of the corresponding developer
630 //******************************************************************************
631 void AliAnalysisTaskSEHFv2::FillDplus(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr){
634 if(fDebug>3)AliWarning("Candidate not selected\n");
638 if(fDebug>3)AliWarning("Masses not calculated\n");
641 Int_t icentrmin=icentr-fCentBinSizePerMil;
642 ((TH2F*)fOutput->FindObject(Form("hMc2phi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
643 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
644 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentrmin,icentr)))->Fill(d->Pt(),masses[0]);
645 Int_t pdgdaughters[3] = {211,321,211};
650 Bool_t isSignal=fAfterBurner->GetIsSignal();
653 lab = d->MatchToMC(411,arrayMC,3,pdgdaughters);
656 ((TH2F*)fOutput->FindObject(Form("hMc2phiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
657 ((TH2F*)fOutput->FindObject(Form("hMphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
659 ((TH2F*)fOutput->FindObject(Form("hMc2phiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
660 ((TH2F*)fOutput->FindObject(Form("hMphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
665 //******************************************************************************
666 void AliAnalysisTaskSEHFv2::FillD02p(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr){
672 if(fDebug>3)AliWarning("Masses not calculated\n");
675 Int_t icentrmin=icentr-fCentBinSizePerMil;
676 if(isSel==1 || isSel==3) {
677 ((TH2F*)fOutput->FindObject(Form("hMc2phi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
678 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
679 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentrmin,icentr)))->Fill(d->Pt(),masses[0]);
682 ((TH2F*)fOutput->FindObject(Form("hMc2phi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
683 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[1]);
684 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentrmin,icentr)))->Fill(d->Pt(),masses[1]);
693 Int_t pdgdaughters[2];
694 pdgdaughters[0]=211;//pi
695 pdgdaughters[1]=321;//K
699 matchtoMC = d->MatchToMC(absPdgMom,arrayMC,nprongs,pdgdaughters);
701 Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421;
702 if((isSel==1 || isSel==3)){ //D0
704 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
705 Int_t pdgMC = dMC->GetPdgCode();
707 if(pdgMC==prongPdgPlus) {
708 ((TH2F*)fOutput->FindObject(Form("hMc2phiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
709 ((TH2F*)fOutput->FindObject(Form("hMphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
712 ((TH2F*)fOutput->FindObject(Form("hMc2phiR_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
713 ((TH2F*)fOutput->FindObject(Form("hMphiR_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
716 ((TH2F*)fOutput->FindObject(Form("hMc2phiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
717 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
720 if(isSel>=2){ //D0bar
722 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
723 Int_t pdgMC = dMC->GetPdgCode();
725 if(pdgMC==prongPdgMinus) {
726 ((TH2F*)fOutput->FindObject(Form("hMc2phiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
727 ((TH2F*)fOutput->FindObject(Form("hMphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[1]);
730 ((TH2F*)fOutput->FindObject(Form("hMc2phiR_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
731 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[1]);
734 ((TH2F*)fOutput->FindObject(Form("hMc2phiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
735 ((TH2F*)fOutput->FindObject(Form("hMphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[1]);
740 //******************************************************************************
741 void AliAnalysisTaskSEHFv2::FillDstar(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr){
744 if(fDebug>3)AliWarning("Candidate not selected\n");
748 if(fDebug>3)AliWarning("Masses not calculated\n");
752 Float_t deltaphi1 = deltaphi;
753 if(deltaphi1 > TMath::PiOver2()) deltaphi1 = TMath::Pi() - deltaphi1;
754 Int_t icentrmin=icentr-fCentBinSizePerMil;
755 ((TH2F*)fOutput->FindObject(Form("hMc2phi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
756 ((TH2F*)fOutput->FindObject(Form("hMphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi1,masses[0]);
757 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentrmin,icentr)))->Fill(d->Pt(),masses[0]);
758 Int_t pdgDgDStartoD0pi[2]={421,211};
759 Int_t pdgDgD0toKpi[2]={321,211};
763 lab = ((AliAODRecoCascadeHF*)d)->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,arrayMC);
765 ((TH2F*)fOutput->FindObject(Form("hMc2phiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
766 ((TH2F*)fOutput->FindObject(Form("hMphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
768 ((TH2F*)fOutput->FindObject(Form("hMc2phiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
769 ((TH2F*)fOutput->FindObject(Form("hMphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
774 //________________________________________________________________________
775 void AliAnalysisTaskSEHFv2::SetEventPlaneMethod(Int_t method){
776 if(method>kVZEROC||method<0){
777 AliWarning("No EP method associated to the selection, setting to TPC EP\n");
780 fEventPlaneMeth=method;
782 //________________________________________________________________________
783 void AliAnalysisTaskSEHFv2::SetNTPCSubEvents(Int_t nsub){
785 AliWarning("Only 2 or 3 subevents implemented. Setting 2 subevents\n");
788 if(fEventPlaneMeth==kTPC&&nsub==3){
789 AliWarning("V0 must be enabled to run 3 TPC subevents. Enabling...\n");
790 fEventPlaneMeth=kTPCVZERO;
794 //________________________________________________________________________
795 Float_t AliAnalysisTaskSEHFv2::GetPhi0Pi(Float_t phi){
796 // Sets the phi angle in the range 0-pi
799 result=result+TMath::Pi();
801 while(result>TMath::Pi()){
802 result=result-TMath::Pi();
807 //________________________________________________________________________
808 Float_t AliAnalysisTaskSEHFv2::GetEventPlaneForCandidate(AliAODRecoDecayHF* d, const TVector2* q,AliEventplane *pl, const TVector2* qsub1, const TVector2* qsub2){
809 // remove autocorrelations
815 qx = pl->GetQContributionXArray();
816 qy = pl->GetQContributionYArray();
821 qx = pl->GetQContributionXArraysub1();
822 qy = pl->GetQContributionYArraysub1();
826 qx = pl->GetQContributionXArraysub2();
827 qy = pl->GetQContributionYArraysub2();
833 //D* -- Yifei, Alessandro,Robert
834 AliAODRecoDecayHF2Prong* theD0particle = ((AliAODRecoCascadeHF*)d)->Get2Prong();
835 AliAODTrack *track0 = (AliAODTrack*)theD0particle->GetDaughter(0);
836 AliAODTrack *track1 = (AliAODTrack*)theD0particle->GetDaughter(1);
837 AliAODTrack *track2 = ((AliAODRecoCascadeHF*)d)->GetBachelor();
838 // reduce global q vector
841 if((track0->GetID()) < qx->fN){
842 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
845 if((track1->GetID()) < qx->fN){
846 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
849 if((track2->GetID()) < qx->fN){
850 q2.Set(qx->At(track2->GetID()),qy->At(track2->GetID()));}
852 qcopy = qcopy -(q0+q1+q2);
856 // reduce Q vector for D+ and D0
860 AliAODTrack *track0 = (AliAODTrack*)d->GetDaughter(0);
861 AliAODTrack *track1 = (AliAODTrack*)d->GetDaughter(1);
864 if((track0->GetID()) < qx->fN){
865 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
868 if((track1->GetID()) < qx->fN){
869 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
871 qcopy = qcopy -(q0+q1);
876 AliAODTrack *track0 = (AliAODTrack*)d->GetDaughter(0);
877 AliAODTrack *track1 = (AliAODTrack*)d->GetDaughter(1);
878 AliAODTrack *track2 = (AliAODTrack*)d->GetDaughter(2);
881 if((track0->GetID()) < qx->fN){
882 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
885 if((track1->GetID()) < qx->fN){
886 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
889 if((track2->GetID()) < qx->fN){
890 q2.Set(qx->At(track2->GetID()),qy->At(track2->GetID()));}
892 qcopy = qcopy -(q0+q1+q2);
896 return qcopy.Phi()/2.;
899 // //________________________________________________________________________
900 // Float_t AliAnalysisTaskSEHFv2::GetEventPlaneFromV0(AliAODEvent *aodEvent){
901 // // Compute event plane for VZERO - Obsolete, used for 2010 data
903 // Int_t centr=fRDCuts->GetCentrality(aodEvent);
904 // centr=centr-centr%10;
906 // if(centr<20)centr=20;
907 // if(centr>70)centr=70;
908 // //end temporary fix
910 // Int_t iParHist=(centr-20)/10;
912 // TString name;name.Form("parhist%d_%d",centr,centr+10);
914 // if(fDebug>15)printf("EPfromV0 centr %d, iparhist %d (%p-%p)\n",centr,iParHist,fParHist->FindObject(name.Data()),fParHist->At(iParHist));
916 // Int_t runnumber=aodEvent->GetRunNumber();
917 // if(fParHist->At(iParHist)){
918 // for(Int_t i=1;i<=((TH2D*)fParHist->At(iParHist))->GetNbinsX()&&binx<=0;i++){
919 // Int_t run=atoi(((TH2D*)fParHist->At(iParHist))->GetXaxis()->GetBinLabel(i));
920 // if(run>=runnumber)binx=i;
923 // fhEventsInfo->Fill(7);
926 // AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts();
927 // cutsRP->SetEvent(aodEvent, MCEvent());//, 0x0);
928 // cutsRP->SetName( Form("rp_cuts") );
929 // AliFlowTrackCuts* dummy = new AliFlowTrackCuts("null_cuts");
930 // dummy->SetParamType(AliFlowTrackCuts::kGlobal);
931 // dummy->SetPtRange(+1,-1); // select nothing QUICK
932 // dummy->SetEtaRange(+1,-1); // select nothing VZERO
933 // dummy->SetEvent(aodEvent,MCEvent());
935 // //////////////// construct the flow event container ////////////
936 // AliFlowEvent flowEvent(cutsRP,dummy);
937 // flowEvent.SetReferenceMultiplicity( 64 );
938 // for(Int_t i=0;i<64&&binx>0;i++){
939 // AliFlowTrack *flowTrack=flowEvent.GetTrack(i);
940 // Double_t inte=((TH2D*)fParHist->At(iParHist))->Integral(binx,binx,i+1,i+1);
941 // if(inte>0)flowTrack->SetWeight(flowTrack->Weight()/inte);
943 // if(fDebug>15)printf("EPfromV0 flow tracks weights done\n");
945 // AliFlowVector qvec=flowEvent.GetQ(fV0EPorder);
946 // Double_t angleEP=(1./(Double_t)fV0EPorder)*qvec.Phi();
947 // if(fDebug>15)printf("EPfromV0 phi %f\n",angleEP);
950 //________________________________________________________________________
951 void AliAnalysisTaskSEHFv2::Terminate(Option_t */*option*/)
953 // Terminate analysis
955 if(fDebug > 1) printf("AnalysisTaskSEHFv2: Terminate() \n");