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
275 for(Int_t i=0;i<fNPtBins;i++){
277 // Delta Phi histograms
278 Double_t maxphi = TMath::Pi();
279 if (fDecChannel == 2) maxphi = TMath::PiOver2();
280 TH2F* hMdeltaphi=new TH2F(Form("hMdeltaphi_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(hMdeltaphi);//for phi bins analysis
282 TH2F* hMc2deltaphi=new TH2F(Form("hMc2deltaphi_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);
283 fOutput->Add(hMc2deltaphi);
284 TH2F* hMs2deltaphi=new TH2F(Form("hMs2deltaphi_pt%d%s",i,centrname.Data()),Form("Mass vs sin2#Delta#phi (p_{t} bin %d %s);sin2#Delta#phi;M (GeV/c^{2})",i,centrname.Data()),100,-1.,1.,fNMassBins,fLowmasslimit,fUpmasslimit);
285 fOutput->Add(hMs2deltaphi);
287 // phi histograms (for systematics)
288 TH2F* hCos2PhiMass=new TH2F(Form("hCos2phiMass_pt%d%s",i,centrname.Data()),Form("Mass vs cos(2#phi) %s;cos(2#phi);M (GeV/c^{2})",centrname.Data()),100,-1.,1.,fNMassBins,fLowmasslimit,fUpmasslimit);
289 fOutput->Add(hCos2PhiMass);
290 TH2F* hSin2PhiMass=new TH2F(Form("hSin2phiMass_pt%d%s",i,centrname.Data()),Form("Mass vs sin(2#phi) %s;sin(2#phi);M (GeV/c^{2})",centrname.Data()),100,-1.,1.,fNMassBins,fLowmasslimit,fUpmasslimit);
291 fOutput->Add(hSin2PhiMass);
293 // Histos using MC truth
295 TH2F* hMc2deltaphiS=new TH2F(Form("hMc2deltaphiS_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);
296 fOutput->Add(hMc2deltaphiS);
297 TH2F * hMdeltaphiS=new TH2F(Form("hMdeltaphiS_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);
298 fOutput->Add(hMdeltaphiS);
299 TH2F* hMc2deltaphiB=new TH2F(Form("hMc2deltaphiB_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);
300 fOutput->Add(hMc2deltaphiB);
301 TH2F * hMdeltaphiB=new TH2F(Form("hMdeltaphiB_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);
302 fOutput->Add(hMdeltaphiB);
303 if((fDecChannel != AliAnalysisTaskSEHFv2::kDplustoKpipi) &&(fDecChannel != AliAnalysisTaskSEHFv2::kDstartoKpipi)){
304 TH2F* hMc2deltaphiR=new TH2F(Form("hMc2deltaphiR_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);
305 fOutput->Add(hMc2deltaphiR);
306 TH2F* hMdeltaphiR=new TH2F(Form("hMdeltaphiR_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);
307 fOutput->Add(hMdeltaphiR);
314 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());
315 fOutput->Add(hEvPlane);
316 TH1F* hEvPlaneA=new TH1F(Form("hEvPlaneA%s",centrname.Data()),Form("Event plane angle %s;#phi Ev Plane;Entries",centrname.Data()),200,0.,TMath::Pi());
317 fOutput->Add(hEvPlaneA);
318 TH1F* hEvPlaneB=new TH1F(Form("hEvPlaneB%s",centrname.Data()),Form("Event plane angle %s;#phi Ev Plane;Entries",centrname.Data()),200,0.,TMath::Pi());
319 fOutput->Add(hEvPlaneB);
320 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());
321 fOutput->Add(hEvPlaneCand);
323 // histos for EP resolution
324 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);
325 fOutput->Add(hEvPlaneReso);
326 if(fEventPlaneMeth>=kTPCVZERO){
327 TH1F* hEvPlaneReso2=new TH1F(Form("hEvPlaneReso2%s",centrname.Data()),Form("Event plane angle Resolution %s;cos2(#psi_{A}-#psi_{C});Entries",centrname.Data()),220,-1.1,1.1);
328 fOutput->Add(hEvPlaneReso2);
329 TH1F* hEvPlaneReso3=new TH1F(Form("hEvPlaneReso3%s",centrname.Data()),Form("Event plane angle Resolution %s;cos2(#psi_{B}-#psi_{C});Entries",centrname.Data()),220,-1.1,1.1);
330 fOutput->Add(hEvPlaneReso3);
333 // histos for EPsystematics
334 TH1F *hCos2EP=new TH1F(Form("hCos2EP%s",centrname.Data()),Form("cos(2PsiEP) %s;cos2(#psi_{EP});Entries",centrname.Data()),100,-1.,1.);
335 fOutput->Add(hCos2EP);
336 TH1F *hSin2EP=new TH1F(Form("hSin2EP%s",centrname.Data()),Form("sin(2PsiEP) %s;sin2(#psi_{EP});Entries",centrname.Data()),100,-1.,1.);
337 fOutput->Add(hSin2EP);
340 PostData(1,fhEventsInfo);
346 //________________________________________________________________________
347 void AliAnalysisTaskSEHFv2::UserExec(Option_t */*option*/)
349 // Execute analysis for current event:
350 // heavy flavor candidates association to MC truth
351 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
352 if(fDebug>2) printf("Analysing decay %d\n",fDecChannel);
353 // Post the data already here
354 PostData(1,fhEventsInfo);
357 TClonesArray *arrayProng =0;
359 if(!aod && AODEvent() && IsStandardAOD()) {
360 // In case there is an AOD handler writing a standard AOD, use the AOD
361 // event in memory rather than the input (ESD) event.
362 aod = dynamic_cast<AliAODEvent*> (AODEvent());
363 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
364 // have to taken from the AOD event hold by the AliAODExtension
365 AliAODHandler* aodHandler = (AliAODHandler*)
366 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
367 if(aodHandler->GetExtensions()) {
369 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
370 AliAODEvent *aodFromExt = ext->GetAOD();
375 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
379 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
383 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
389 arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
393 arrayProng=(TClonesArray*)aod->GetList()->FindObject("D0toKpi");
397 arrayProng=(TClonesArray*)aod->GetList()->FindObject("Dstar");
401 if(!aod || !arrayProng) {
402 AliError("AliAnalysisTaskSEHFv2::UserExec:Branch not found!\n");
406 // fix for temporary bug in ESDfilter
407 // the AODs with null vertex pointer didn't pass the PhysSel
408 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
410 TClonesArray *arrayMC=0;
411 AliAODMCHeader *mcHeader=0;
416 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
418 AliWarning("AliAnalysisTaskSEHFv2::UserExec:MC particles branch not found!\n");
423 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
425 AliError("AliAnalysisTaskSEHFv2::UserExec:MC header branch not found!\n");
430 fhEventsInfo->Fill(0); // count event
432 AliAODRecoDecayHF *d=0;
434 Int_t nCand = arrayProng->GetEntriesFast();
435 if(fDebug>2) printf("Number of D2H: %d\n",nCand);
437 Bool_t isEvSel=fRDCuts->IsEventSelected(aod);
439 if(!fRDCuts->IsEventRejectedDueToCentrality())fhEventsInfo->Fill(4);
443 fhEventsInfo->Fill(1);
444 fhEventsInfo->Fill(4);
446 AliEventplane *pl=aod->GetEventplane();
448 AliError("AliAnalysisTaskSEHFv2::UserExec:no eventplane! v2 analysis without eventplane not possible!\n");
449 fhEventsInfo->Fill(6);
454 Double_t eventplane=0;
455 Double_t rpangleTPC=0;
456 Double_t rpangleVZERO=0;
457 Double_t planereso=0;
459 Double_t rpangleeventC=0;
460 Double_t rpangleeventB=0;
461 Double_t rpangleeventA=0;
463 //For candidate removal from TPC EP
468 //determine centrality bin
469 Float_t centr=fRDCuts->GetCentrality(aod);
470 Float_t centrPerMil=centr*10.;
472 for(Int_t ic=fMinCentr*10+fCentBinSizePerMil;ic<=fMaxCentr*10;ic=ic+fCentBinSizePerMil){
478 if(icentr==-1) return;
480 TString centrbinname=Form("centr%d_%d",icentr-fCentBinSizePerMil,icentr);
483 TRandom3 *g = new TRandom3(0);
484 eventplane=g->Rndm()*TMath::Pi();
486 if(fUseAfterBurner)fAfterBurner->SetEventPlane((Double_t)eventplane);
489 rpangleTPC = pl->GetEventplane("Q");
491 fhEventsInfo->Fill(6);
494 rpangleeventA = rpangleTPC;
495 if(fSubEvents==2||fEventPlaneMeth==kVZERO){
496 qsub1 = pl->GetQsub1();
497 qsub2 = pl->GetQsub2();
498 if(!qsub1 || !qsub2){
499 fhEventsInfo->Fill(6);
502 rpangleeventA = qsub1->Phi()/2.;
503 rpangleeventB = qsub2->Phi()/2.;
505 if(fEventPlaneMeth!=kTPC){
506 //VZERO EP and resolution
507 rpangleVZERO=GetPhi0Pi(pl->GetEventplane("V0",aod,fV0EPorder));
508 rpangleeventC=rpangleVZERO;
509 if(fEventPlaneMeth==kVZEROA||fEventPlaneMeth==kVZEROC||(fEventPlaneMeth==kTPCVZERO&&fSubEvents==3)){
510 rpangleeventB=GetPhi0Pi(pl->GetEventplane("V0A",aod,fV0EPorder));
511 rpangleeventC=GetPhi0Pi(pl->GetEventplane("V0C",aod,fV0EPorder));
512 if(fEventPlaneMeth==kVZEROA)rpangleVZERO=rpangleeventB;
513 else if(fEventPlaneMeth==kVZEROC)rpangleVZERO=rpangleeventC;
518 if(fEventPlaneMeth>kTPCVZERO)eventplane=rpangleVZERO;
520 q = pl->GetQVector();
521 eventplane=rpangleTPC;
523 deltaPsi =rpangleeventA-rpangleeventB;
526 if(TMath::Abs(deltaPsi)>TMath::Pi()/2.){
527 if(deltaPsi>0.) deltaPsi-=TMath::Pi();
528 else deltaPsi +=TMath::Pi();
529 } // difference of subevents reaction plane angle cannot be bigger than phi/2
530 planereso = TMath::Cos(2.*deltaPsi); // reaction plane resolution
531 if(TMath::Abs(rpangleTPC-rpangleVZERO)>fEventPlanesComp)return;
533 if(fDebug>2)printf("Filling EP-related histograms\n");
534 //Filling EP-related histograms
535 ((TH2F*)fOutput->FindObject(Form("hEvPlane%s",centrbinname.Data())))->Fill(rpangleTPC,rpangleVZERO); // reaction plane angle without autocorrelations removal
536 ((TH1F*)fOutput->FindObject(Form("hEvPlaneReso%s",centrbinname.Data())))->Fill(planereso); //RP resolution
537 ((TH1F*)fOutput->FindObject(Form("hCos2EP%s",centrbinname.Data())))->Fill(TMath::Cos(2*eventplane)); // syst check
538 ((TH1F*)fOutput->FindObject(Form("hSin2EP%s",centrbinname.Data())))->Fill(TMath::Sin(2*eventplane)); // syst check
540 if(fEventPlaneMeth>kTPCVZERO||fEtaGap){
541 ((TH1F*)fOutput->FindObject(Form("hEvPlaneA%s",centrbinname.Data())))->Fill(rpangleeventA); //Angle of first subevent
542 ((TH1F*)fOutput->FindObject(Form("hEvPlaneB%s",centrbinname.Data())))->Fill(rpangleeventB); //Angle of second subevent
544 if(fEventPlaneMeth>kTPCVZERO||fSubEvents==3){
545 Double_t deltaSub=rpangleeventA-rpangleeventC;
546 if(TMath::Abs(deltaSub)>TMath::Pi()/2.){// difference of subevents reaction plane angle cannot be bigger than phi/2
547 if(deltaSub>0.) deltaSub-=TMath::Pi();
548 else deltaSub +=TMath::Pi();
550 TH1F* htmp1=(TH1F*)fOutput->FindObject(Form("hEvPlaneReso2%s",centrbinname.Data()));
551 if(htmp1) htmp1->Fill(TMath::Cos(2.*deltaSub)); //RP resolution
552 deltaSub =rpangleeventB-rpangleeventC;
553 if(TMath::Abs(deltaSub)>TMath::Pi()/2.){// difference of subevents reaction plane angle cannot be bigger than phi/2
554 if(deltaSub>0.) deltaSub-=TMath::Pi();
555 else deltaSub +=TMath::Pi();
557 TH1F* htmp2=(TH1F*)fOutput->FindObject(Form("hEvPlaneReso3%s",centrbinname.Data()));
558 if(htmp2) htmp2->Fill(TMath::Cos(2.*deltaSub)); //RP resolution
561 if(fDebug>2)printf("Loop on D candidates\n");
562 //Loop on D candidates
563 for (Int_t iCand = 0; iCand < nCand; iCand++) {
564 d=(AliAODRecoDecayHF*)arrayProng->UncheckedAt(iCand);
565 Bool_t isSelBit=kTRUE;
566 if(fDecChannel==0) isSelBit=d->HasSelectionBit(AliRDHFCuts::kDplusCuts);
567 if(fDecChannel==1) isSelBit=d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts);
568 if(fDecChannel==2) isSelBit=kTRUE;
569 if(!isSelBit)continue;
570 Int_t ptbin=fRDCuts->PtBin(d->Pt());
572 fhEventsInfo->Fill(3);
575 Bool_t isFidAcc = fRDCuts->IsInFiducialAcceptance(d->Pt(),d->Y(absPdgMom));
576 if(!isFidAcc)continue;
577 Int_t isSelected= fRDCuts->IsSelected(d,AliRDHFCuts::kAll,aod);
578 if(!isSelected)continue;
580 fhEventsInfo->Fill(2); // candidate selected
581 if(fDebug>3) printf("+++++++Is Selected\n");
583 Float_t* invMass=0x0;
585 CalculateInvMasses(d,invMass,nmasses);
587 if(fEventPlaneMeth<=kTPCVZERO){
588 eventplane = GetEventPlaneForCandidate(d,q,pl,qsub1,qsub2); // remove autocorrelations
589 ((TH1F*)fOutput->FindObject(Form("hEvPlaneCand%s",centrbinname.Data())))->Fill(rpangleTPC-eventplane);
592 Double_t phi=d->Phi();
593 if(fReadMC&&fUseAfterBurner)phi=fAfterBurner->GetNewAngle(d,arrayMC);
594 Float_t deltaphi=GetPhi0Pi(phi-eventplane);
596 //fill the histograms with the appropriate method
597 if(fDecChannel==0)FillDplus(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr,phi);
598 else if(fDecChannel==1)FillD02p(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr,phi);
599 else if(fDecChannel==2)FillDstar(d,arrayMC,ptbin,deltaphi,invMass,isSelected,icentr,phi);
604 PostData(1,fhEventsInfo);
610 //***************************************************************************
612 // Methods used in the UserExec
614 void AliAnalysisTaskSEHFv2::CalculateInvMasses(AliAODRecoDecayHF* d,Float_t*& masses,Int_t& nmasses){
615 //Calculates all the possible invariant masses for each candidate
616 //NB: the implementation for each candidate is responsibility of the corresponding developer
621 masses=new Float_t[nmasses];
622 Int_t pdgdaughters[3] = {211,321,211};
623 masses[0]=d->InvMass(3,(UInt_t*)pdgdaughters);
629 masses=new Float_t[nmasses];
630 Int_t pdgdaughtersD0[ndght]={211,321};//pi,K
631 masses[0]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0); //D0
632 Int_t pdgdaughtersD0bar[ndght]={321,211};//K,pi
633 masses[1]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0bar); //D0bar
636 //D* -- Robert,Yifei, Alessandro
638 masses=new Float_t[nmasses];
639 masses[0]=((AliAODRecoCascadeHF*)d)->DeltaInvMass();
643 //******************************************************************************
645 //Methods to fill the histograms, one for each channel
646 //NB: the implementation for each candidate is responsibility of the corresponding developer
648 //******************************************************************************
649 void AliAnalysisTaskSEHFv2::FillDplus(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr, Double_t phiD){
652 if(fDebug>3)AliWarning("Candidate not selected\n");
656 if(fDebug>3)AliWarning("Masses not calculated\n");
659 Int_t icentrmin=icentr-fCentBinSizePerMil;
660 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
661 ((TH2F*)fOutput->FindObject(Form("hMs2deltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Sin(2*deltaphi),masses[0]);
662 ((TH2F*)fOutput->FindObject(Form("hMdeltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
663 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentrmin,icentr)))->Fill(d->Pt(),masses[0]);
664 ((TH2F*)fOutput->FindObject(Form("hCos2phiMass_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*phiD),masses[0]);
665 ((TH2F*)fOutput->FindObject(Form("hSin2phiMass_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Sin(2*phiD),masses[0]);
668 Int_t pdgdaughters[3] = {211,321,211};
673 Bool_t isSignal=fAfterBurner->GetIsSignal();
676 lab = d->MatchToMC(411,arrayMC,3,pdgdaughters);
679 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
680 ((TH2F*)fOutput->FindObject(Form("hMdeltaphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
682 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
683 ((TH2F*)fOutput->FindObject(Form("hMdeltaphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
688 //******************************************************************************
689 void AliAnalysisTaskSEHFv2::FillD02p(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr,Double_t phiD){
695 if(fDebug>3)AliWarning("Masses not calculated\n");
698 Int_t icentrmin=icentr-fCentBinSizePerMil;
699 if(isSel==1 || isSel==3) {
700 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
701 ((TH2F*)fOutput->FindObject(Form("hMs2deltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Sin(2*deltaphi),masses[0]);
702 ((TH2F*)fOutput->FindObject(Form("hMdeltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
703 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentrmin,icentr)))->Fill(d->Pt(),masses[0]);
704 ((TH2F*)fOutput->FindObject(Form("hCos2phiMass_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*phiD),masses[0]);
705 ((TH2F*)fOutput->FindObject(Form("hSin2phiMass_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Sin(2*phiD),masses[0]);
708 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
709 ((TH2F*)fOutput->FindObject(Form("hMs2deltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Sin(2*deltaphi),masses[1]);
710 ((TH2F*)fOutput->FindObject(Form("hMdeltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[1]);
711 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentrmin,icentr)))->Fill(d->Pt(),masses[1]);
712 ((TH2F*)fOutput->FindObject(Form("hCos2phiMass_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*phiD),masses[1]);
713 ((TH2F*)fOutput->FindObject(Form("hSin2phiMass_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Sin(2*phiD),masses[1]);
722 Int_t pdgdaughters[2];
723 pdgdaughters[0]=211;//pi
724 pdgdaughters[1]=321;//K
728 matchtoMC = d->MatchToMC(absPdgMom,arrayMC,nprongs,pdgdaughters);
730 Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421;
731 if((isSel==1 || isSel==3)){ //D0
733 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
734 Int_t pdgMC = dMC->GetPdgCode();
736 if(pdgMC==prongPdgPlus) {
737 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
738 ((TH2F*)fOutput->FindObject(Form("hMdeltaphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
741 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiR_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
742 ((TH2F*)fOutput->FindObject(Form("hMdeltaphiR_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
745 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
746 ((TH2F*)fOutput->FindObject(Form("hMdeltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
749 if(isSel>=2){ //D0bar
751 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
752 Int_t pdgMC = dMC->GetPdgCode();
754 if(pdgMC==prongPdgMinus) {
755 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
756 ((TH2F*)fOutput->FindObject(Form("hMdeltaphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[1]);
759 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiR_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
760 ((TH2F*)fOutput->FindObject(Form("hMdeltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[1]);
763 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[1]);
764 ((TH2F*)fOutput->FindObject(Form("hMdeltaphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[1]);
769 //******************************************************************************
770 void AliAnalysisTaskSEHFv2::FillDstar(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t ptbin,Float_t deltaphi, const Float_t* masses,Int_t isSel,Int_t icentr, Double_t phiD){
773 if(fDebug>3)AliWarning("Candidate not selected\n");
777 if(fDebug>3)AliWarning("Masses not calculated\n");
781 Float_t deltaphi1 = deltaphi;
782 if(deltaphi1 > TMath::PiOver2()) deltaphi1 = TMath::Pi() - deltaphi1;
783 Int_t icentrmin=icentr-fCentBinSizePerMil;
784 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
785 ((TH2F*)fOutput->FindObject(Form("hMs2deltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Sin(2*deltaphi),masses[0]);
786 ((TH2F*)fOutput->FindObject(Form("hMdeltaphi_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi1,masses[0]);
787 ((TH2F*)fOutput->FindObject(Form("hMPtCandcentr%d_%d",icentrmin,icentr)))->Fill(d->Pt(),masses[0]);
788 ((TH2F*)fOutput->FindObject(Form("hCos2phiMass_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*phiD),masses[0]);
789 ((TH2F*)fOutput->FindObject(Form("hSin2phiMass_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Sin(2*phiD),masses[0]);
790 Int_t pdgDgDStartoD0pi[2]={421,211};
791 Int_t pdgDgD0toKpi[2]={321,211};
795 lab = ((AliAODRecoCascadeHF*)d)->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,arrayMC);
797 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
798 ((TH2F*)fOutput->FindObject(Form("hMdeltaphiS_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
800 ((TH2F*)fOutput->FindObject(Form("hMc2deltaphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(TMath::Cos(2*deltaphi),masses[0]);
801 ((TH2F*)fOutput->FindObject(Form("hMdeltaphiB_pt%dcentr%d_%d",ptbin,icentrmin,icentr)))->Fill(deltaphi,masses[0]);
806 //________________________________________________________________________
807 void AliAnalysisTaskSEHFv2::SetEventPlaneMethod(Int_t method){
808 if(method>kVZEROC||method<0){
809 AliWarning("No EP method associated to the selection, setting to TPC EP\n");
812 fEventPlaneMeth=method;
814 //________________________________________________________________________
815 void AliAnalysisTaskSEHFv2::SetNTPCSubEvents(Int_t nsub){
817 AliWarning("Only 2 or 3 subevents implemented. Setting 2 subevents\n");
820 if(fEventPlaneMeth==kTPC&&nsub==3){
821 AliWarning("V0 must be enabled to run 3 TPC subevents. Enabling...\n");
822 fEventPlaneMeth=kTPCVZERO;
826 //________________________________________________________________________
827 Float_t AliAnalysisTaskSEHFv2::GetPhi0Pi(Float_t phi){
828 // Sets the phi angle in the range 0-pi
831 result=result+TMath::Pi();
833 while(result>TMath::Pi()){
834 result=result-TMath::Pi();
839 //________________________________________________________________________
840 Float_t AliAnalysisTaskSEHFv2::GetEventPlaneForCandidate(AliAODRecoDecayHF* d, const TVector2* q,AliEventplane *pl, const TVector2* qsub1, const TVector2* qsub2){
841 // remove autocorrelations
847 qx = pl->GetQContributionXArray();
848 qy = pl->GetQContributionYArray();
852 qx = pl->GetQContributionXArraysub1();
853 qy = pl->GetQContributionYArraysub1();
856 qx = pl->GetQContributionXArraysub2();
857 qy = pl->GetQContributionYArraysub2();
863 //D* -- Yifei, Alessandro,Robert
864 AliAODRecoDecayHF2Prong* theD0particle = ((AliAODRecoCascadeHF*)d)->Get2Prong();
865 AliAODTrack *track0 = (AliAODTrack*)theD0particle->GetDaughter(0);
866 AliAODTrack *track1 = (AliAODTrack*)theD0particle->GetDaughter(1);
867 AliAODTrack *track2 = ((AliAODRecoCascadeHF*)d)->GetBachelor();
868 // reduce global q vector
871 if((track0->GetID()) < qx->fN){
872 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
875 if((track1->GetID()) < qx->fN){
876 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
879 if((track2->GetID()) < qx->fN){
880 q2.Set(qx->At(track2->GetID()),qy->At(track2->GetID()));}
882 qcopy = qcopy -(q0+q1+q2);
886 // reduce Q vector for D+ and D0
890 AliAODTrack *track0 = (AliAODTrack*)d->GetDaughter(0);
891 AliAODTrack *track1 = (AliAODTrack*)d->GetDaughter(1);
894 if((track0->GetID()) < qx->fN){
895 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
898 if((track1->GetID()) < qx->fN){
899 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
901 qcopy = qcopy -(q0+q1);
906 AliAODTrack *track0 = (AliAODTrack*)d->GetDaughter(0);
907 AliAODTrack *track1 = (AliAODTrack*)d->GetDaughter(1);
908 AliAODTrack *track2 = (AliAODTrack*)d->GetDaughter(2);
911 if((track0->GetID()) < qx->fN){
912 q0.Set(qx->At(track0->GetID()),qy->At(track0->GetID()));}
915 if((track1->GetID()) < qx->fN){
916 q1.Set(qx->At(track1->GetID()),qy->At(track1->GetID()));}
919 if((track2->GetID()) < qx->fN){
920 q2.Set(qx->At(track2->GetID()),qy->At(track2->GetID()));}
922 qcopy = qcopy -(q0+q1+q2);
926 return qcopy.Phi()/2.;
929 // //________________________________________________________________________
930 // Float_t AliAnalysisTaskSEHFv2::GetEventPlaneFromV0(AliAODEvent *aodEvent){
931 // // Compute event plane for VZERO - Obsolete, used for 2010 data
933 // Int_t centr=fRDCuts->GetCentrality(aodEvent);
934 // centr=centr-centr%10;
936 // if(centr<20)centr=20;
937 // if(centr>70)centr=70;
938 // //end temporary fix
940 // Int_t iParHist=(centr-20)/10;
942 // TString name;name.Form("parhist%d_%d",centr,centr+10);
944 // if(fDebug>15)printf("EPfromV0 centr %d, iparhist %d (%p-%p)\n",centr,iParHist,fParHist->FindObject(name.Data()),fParHist->At(iParHist));
946 // Int_t runnumber=aodEvent->GetRunNumber();
947 // if(fParHist->At(iParHist)){
948 // for(Int_t i=1;i<=((TH2D*)fParHist->At(iParHist))->GetNbinsX()&&binx<=0;i++){
949 // Int_t run=atoi(((TH2D*)fParHist->At(iParHist))->GetXaxis()->GetBinLabel(i));
950 // if(run>=runnumber)binx=i;
953 // fhEventsInfo->Fill(7);
956 // AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts();
957 // cutsRP->SetEvent(aodEvent, MCEvent());//, 0x0);
958 // cutsRP->SetName( Form("rp_cuts") );
959 // AliFlowTrackCuts* dummy = new AliFlowTrackCuts("null_cuts");
960 // dummy->SetParamType(AliFlowTrackCuts::kGlobal);
961 // dummy->SetPtRange(+1,-1); // select nothing QUICK
962 // dummy->SetEtaRange(+1,-1); // select nothing VZERO
963 // dummy->SetEvent(aodEvent,MCEvent());
965 // //////////////// construct the flow event container ////////////
966 // AliFlowEvent flowEvent(cutsRP,dummy);
967 // flowEvent.SetReferenceMultiplicity( 64 );
968 // for(Int_t i=0;i<64&&binx>0;i++){
969 // AliFlowTrack *flowTrack=flowEvent.GetTrack(i);
970 // Double_t inte=((TH2D*)fParHist->At(iParHist))->Integral(binx,binx,i+1,i+1);
971 // if(inte>0)flowTrack->SetWeight(flowTrack->Weight()/inte);
973 // if(fDebug>15)printf("EPfromV0 flow tracks weights done\n");
975 // AliFlowVector qvec=flowEvent.GetQ(fV0EPorder);
976 // Double_t angleEP=(1./(Double_t)fV0EPorder)*qvec.Phi();
977 // if(fDebug>15)printf("EPfromV0 phi %f\n",angleEP);
980 //________________________________________________________________________
981 void AliAnalysisTaskSEHFv2::Terminate(Option_t */*option*/)
983 // Terminate analysis
985 if(fDebug > 1) printf("AnalysisTaskSEHFv2: Terminate() \n");