1 /**************************************************************************
2 * Copyright(c) 1998-2012, 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 **************************************************************************/
18 /////////////////////////////////////////////////////////////
20 // AliAnalysisTaskSE for D0 candidates (2Prongs)
21 // and hadrons correlations
23 // Authors: Chiara Bianchin, chiara.bianchin@pd.infn.it (invariant mass)
24 // Fabio Colamaria, fabio.colamaria@ba.infn.it (correlations)
25 /////////////////////////////////////////////////////////////
27 #include <Riostream.h>
28 #include <TClonesArray.h>
35 #include <THnSparse.h>
36 #include <TDatabasePDG.h>
38 #include <AliAnalysisDataSlot.h>
39 #include <AliAnalysisDataContainer.h>
40 #include "AliAnalysisManager.h"
41 #include "AliESDtrack.h"
42 #include "AliVertexerTracks.h"
43 #include "AliAODHandler.h"
44 #include "AliAODEvent.h"
45 #include "AliAODVertex.h"
46 #include "AliAODTrack.h"
47 #include "AliAODMCHeader.h"
48 #include "AliAODMCParticle.h"
49 #include "AliAODRecoDecayHF2Prong.h"
50 #include "AliAODRecoCascadeHF.h"
51 #include "AliAnalysisVertexingHF.h"
52 #include "AliAnalysisTaskSE.h"
53 #include "AliAnalysisTaskSED0Correlations.h"
54 #include "AliNormalizationCounter.h"
59 ClassImp(AliAnalysisTaskSED0Correlations)
62 //________________________________________________________________________
63 AliAnalysisTaskSED0Correlations::AliAnalysisTaskSED0Correlations():
70 fAlreadyFilled(kFALSE),
88 fIsSelectedCandidate(0),
91 fIsRejectSDDClusters(0),
94 // Default constructor
98 //________________________________________________________________________
99 AliAnalysisTaskSED0Correlations::AliAnalysisTaskSED0Correlations(const char *name,AliRDHFCutsD0toKpi* cutsD0, AliHFAssociatedTrackCuts* cutsTrk):
100 AliAnalysisTaskSE(name),
106 fAlreadyFilled(kFALSE),
112 fCutsTracks(cutsTrk),
124 fIsSelectedCandidate(0),
127 fIsRejectSDDClusters(0),
130 // Default constructor
132 fNPtBins=cutsD0->GetNPtBins();
136 // Output slot #1 writes into a TList container (mass with cuts)
137 DefineOutput(1,TList::Class()); //My private output
138 // Output slot #2 writes into a TH1F container (number of events)
139 DefineOutput(2,TH1F::Class()); //My private output
140 // Output slot #3 writes into a AliRDHFD0toKpi container (cuts)
141 DefineOutput(3,AliRDHFCutsD0toKpi::Class()); //My private output
142 // Output slot #4 writes Normalization Counter
143 DefineOutput(4,AliNormalizationCounter::Class());
144 // Output slot #5 writes into a TList container (correl output)
145 DefineOutput(5,TList::Class()); //My private output
146 // Output slot #6 writes into a TList container (correl advanced)
147 DefineOutput(6,TList::Class()); //My private output
148 // Output slot #7 writes into a AliHFAssociatedTrackCuts container (cuts)
149 DefineOutput(7,AliHFAssociatedTrackCuts::Class()); //My private output
152 //________________________________________________________________________
153 AliAnalysisTaskSED0Correlations::AliAnalysisTaskSED0Correlations(const AliAnalysisTaskSED0Correlations &source):
154 AliAnalysisTaskSE(source),
155 fNPtBinsCorr(source.fNPtBinsCorr),
156 fBinLimsCorr(source.fBinLimsCorr),
157 fPtThreshLow(source.fPtThreshLow),
158 fPtThreshUp(source.fPtThreshUp),
159 fEvents(source.fEvents),
160 fAlreadyFilled(source.fAlreadyFilled),
161 fOutputMass(source.fOutputMass),
162 fOutputCorr(source.fOutputCorr),
163 fOutputStudy(source.fOutputStudy),
164 fNentries(source.fNentries),
165 fCutsD0(source.fCutsD0),
166 fCutsTracks(source.fCutsTracks),
167 fCorrelatorTr(source.fCorrelatorTr),
168 fCorrelatorKc(source.fCorrelatorKc),
169 fCorrelatorK0(source.fCorrelatorK0),
170 fReadMC(source.fReadMC),
171 fRecoTr(source.fRecoTr),
172 fRecoD0(source.fRecoD0),
173 fSelEvType(source.fSelEvType),
174 fMixing(source.fMixing),
175 fCounter(source.fCounter),
176 fNPtBins(source.fNPtBins),
177 fFillOnlyD0D0bar(source.fFillOnlyD0D0bar),
178 fIsSelectedCandidate(source.fIsSelectedCandidate),
180 fEtaForCorrel(source.fEtaForCorrel),
181 fIsRejectSDDClusters(source.fIsRejectSDDClusters),
182 fFillGlobal(source.fFillGlobal)
187 //________________________________________________________________________
188 AliAnalysisTaskSED0Correlations::~AliAnalysisTaskSED0Correlations()
211 delete fCorrelatorTr;
215 delete fCorrelatorKc;
219 delete fCorrelatorK0;
228 //______________________________________________________________________________
229 AliAnalysisTaskSED0Correlations& AliAnalysisTaskSED0Correlations::operator=(const AliAnalysisTaskSED0Correlations& orig)
232 if (&orig == this) return *this; //if address is the same (same object), returns itself
234 AliAnalysisTaskSE::operator=(orig); //Uses the AliAnalysisTaskSE operator to assign the inherited part of the class
235 fNPtBinsCorr = orig.fNPtBinsCorr;
236 fBinLimsCorr = orig.fBinLimsCorr;
237 fPtThreshLow = orig.fPtThreshLow;
238 fPtThreshUp = orig.fPtThreshUp;
239 fEvents = orig.fEvents;
240 fAlreadyFilled = orig.fAlreadyFilled;
241 fOutputMass = orig.fOutputMass;
242 fOutputCorr = orig.fOutputCorr;
243 fOutputStudy = orig.fOutputStudy;
244 fNentries = orig.fNentries;
245 fCutsD0 = orig.fCutsD0;
246 fCutsTracks = orig.fCutsTracks;
247 fCorrelatorTr = orig.fCorrelatorTr;
248 fCorrelatorKc = orig.fCorrelatorKc;
249 fCorrelatorK0 = orig.fCorrelatorK0;
250 fReadMC = orig.fReadMC;
251 fRecoTr = orig.fRecoTr;
252 fRecoD0 = orig.fRecoD0;
253 fSelEvType = orig.fSelEvType;
254 fMixing = orig.fMixing;
255 fCounter = orig.fCounter;
256 fNPtBins = orig.fNPtBins;
257 fFillOnlyD0D0bar = orig.fFillOnlyD0D0bar;
258 fIsSelectedCandidate = orig.fIsSelectedCandidate;
260 fEtaForCorrel = orig.fEtaForCorrel;
261 fIsRejectSDDClusters = orig.fIsRejectSDDClusters;
262 fFillGlobal = orig.fFillGlobal;
264 return *this; //returns pointer of the class
267 //________________________________________________________________________
268 void AliAnalysisTaskSED0Correlations::Init()
272 if(fDebug > 1) printf("AnalysisTaskSED0Correlations::Init() \n");
274 //Copy of cuts objects
275 AliRDHFCutsD0toKpi* copyfCutsD0 = new AliRDHFCutsD0toKpi(*fCutsD0);
276 const char* nameoutput=GetOutputSlot(3)->GetContainer()->GetName();
277 copyfCutsD0->SetName(nameoutput);
279 //needer to clear completely the objects inside with Clear() method
281 PostData(3,copyfCutsD0);
282 PostData(7,fCutsTracks);
287 //________________________________________________________________________
288 void AliAnalysisTaskSED0Correlations::UserCreateOutputObjects()
291 // Create the output container
293 if(fDebug > 1) printf("AnalysisTaskSED0Correlations::UserCreateOutputObjects() \n");
295 //HFCorrelator creation and definition
296 fCorrelatorTr = new AliHFCorrelator("CorrelatorTr",fCutsTracks,fSys);
297 fCorrelatorKc = new AliHFCorrelator("CorrelatorKc",fCutsTracks,fSys);
298 fCorrelatorK0 = new AliHFCorrelator("CorrelatorK0",fCutsTracks,fSys);
299 fCorrelatorTr->SetDeltaPhiInterval(-TMath::Pi()/2,3*TMath::Pi()/2);// set the Delta Phi Interval you want (in this case -0.5Pi to 1.5 Pi)
300 fCorrelatorKc->SetDeltaPhiInterval(-TMath::Pi()/2,3*TMath::Pi()/2);
301 fCorrelatorK0->SetDeltaPhiInterval(-TMath::Pi()/2,3*TMath::Pi()/2);
302 fCorrelatorTr->SetEventMixing(fMixing);// sets the analysis on a single event (kFALSE) or mixed events (kTRUE)
303 fCorrelatorKc->SetEventMixing(fMixing);
304 fCorrelatorK0->SetEventMixing(fMixing);
305 fCorrelatorTr->SetAssociatedParticleType(1);// set 1 for correlations with hadrons, 2 with kaons, 3 with KZeros
306 fCorrelatorKc->SetAssociatedParticleType(2);// set 1 for correlations with hadrons, 2 with kaons, 3 with KZeros
307 fCorrelatorK0->SetAssociatedParticleType(3);// set 1 for correlations with hadrons, 2 with kaons, 3 with KZeros
308 fCorrelatorTr->SetApplyDisplacementCut(2); //0: don't calculate d0; 1: return d0; 2: return d0/d0err
309 fCorrelatorKc->SetApplyDisplacementCut(2);
310 fCorrelatorK0->SetApplyDisplacementCut(0);
311 fCorrelatorTr->SetUseMC(fReadMC);// sets Montecarlo flag
312 fCorrelatorKc->SetUseMC(fReadMC);
313 fCorrelatorK0->SetUseMC(fReadMC);
314 fCorrelatorTr->SetUseReco(fRecoTr);// sets (if MC analysis) wheter to analyze Reco or Kinem tracks
315 fCorrelatorKc->SetUseReco(fRecoTr);
316 fCorrelatorK0->SetUseReco(fRecoTr);
317 fCorrelatorKc->SetPIDmode(2); //switch for K+/- PID option
318 Bool_t pooldefTr = fCorrelatorTr->DefineEventPool();// method that defines the properties ot the event mixing (zVtx and Multipl. bins)
319 Bool_t pooldefKc = fCorrelatorKc->DefineEventPool();// method that defines the properties ot the event mixing (zVtx and Multipl. bins)
320 Bool_t pooldefK0 = fCorrelatorK0->DefineEventPool();// method that defines the properties ot the event mixing (zVtx and Multipl. bins)
321 if(!pooldefTr) AliInfo("Warning:: Event pool not defined properly");
322 if(!pooldefKc) AliInfo("Warning:: Event pool not defined properly");
323 if(!pooldefK0) AliInfo("Warning:: Event pool not defined properly");
325 // Several histograms are more conveniently managed in a TList
326 fOutputMass = new TList();
327 fOutputMass->SetOwner();
328 fOutputMass->SetName("listMass");
330 fOutputCorr = new TList();
331 fOutputCorr->SetOwner();
332 fOutputCorr->SetName("correlationslist");
334 fOutputStudy = new TList();
335 fOutputStudy->SetOwner();
336 fOutputStudy->SetName("MCstudyplots");
338 TString nameMass=" ",nameSgn=" ", nameBkg=" ", nameRfl=" ";
340 for(Int_t i=0;i<fCutsD0->GetNPtBins();i++){
342 nameMass="histMass_";
351 //histograms of invariant mass distributions
355 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",120,1.5648,2.1648);
358 //Reflection: histo filled with D0Mass which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
359 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",120,1.5648,2.1648);
360 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",120,1.5648,2.1648);
363 fOutputMass->Add(tmpSt);
364 fOutputMass->Add(tmpRt);
365 fOutputMass->Add(tmpBt);
369 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",120,1.5648,2.1648);
371 fOutputMass->Add(tmpMt);
374 const char* nameoutput=GetOutputSlot(2)->GetContainer()->GetName();
376 fNentries=new TH1F(nameoutput, "Integral(1,2) = number of AODs *** Integral(2,3) = number of candidates selected with cuts *** Integral(3,4) = number of D0 selected with cuts *** Integral(4,5) = events with good vertex *** Integral(5,6) = pt out of bounds", 20,-0.5,19.5);
378 fNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
379 fNentries->GetXaxis()->SetBinLabel(2,"nCandSel(Cuts)");
380 fReadMC ? fNentries->GetXaxis()->SetBinLabel(3,"nD0Selected") : fNentries->GetXaxis()->SetBinLabel(3,"Dstar<-D0");
381 fNentries->GetXaxis()->SetBinLabel(4,"nEventsGoodVtxS");
382 fNentries->GetXaxis()->SetBinLabel(5,"ptbin = -1");
383 fNentries->GetXaxis()->SetBinLabel(6,"no daughter");
384 if(fSys==0) fNentries->GetXaxis()->SetBinLabel(7,"nCandSel(Tr)");
385 if(fReadMC && fSys==0){
386 fNentries->GetXaxis()->SetBinLabel(12,"K");
387 fNentries->GetXaxis()->SetBinLabel(13,"Lambda");
389 fNentries->GetXaxis()->SetBinLabel(14,"Pile-up Rej");
390 fNentries->GetXaxis()->SetBinLabel(15,"N. of 0SMH");
391 if(fSys==1) fNentries->GetXaxis()->SetBinLabel(16,"Nev in centr");
392 if(fIsRejectSDDClusters) fNentries->GetXaxis()->SetBinLabel(17,"SDD-Cls Rej");
393 fNentries->GetXaxis()->SetBinLabel(18,"Phys.Sel.Rej");
394 fNentries->GetXaxis()->SetBinLabel(19,"nEventsSelected");
395 if(fReadMC) fNentries->GetXaxis()->SetBinLabel(20,"nEvsWithProdMech");
396 fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
398 fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(4)->GetContainer()->GetName()));
401 CreateCorrelationsObjs(); //creates histos for correlations analysis
404 PostData(1,fOutputMass);
405 PostData(2,fNentries);
406 PostData(4,fCounter);
407 PostData(5,fOutputCorr);
408 PostData(6,fOutputStudy);
413 //________________________________________________________________________
414 void AliAnalysisTaskSED0Correlations::UserExec(Option_t */*option*/)
416 // Execute analysis for current event:
417 // heavy flavor candidates association to MC truth
418 //cout<<"I'm in UserExec"<<endl;
422 // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
423 // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
424 // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
425 // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
426 // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
427 // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
428 // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
429 // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
430 // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
432 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
435 TString bname="D0toKpi";
437 TClonesArray *inputArray=0;
439 if(!aod && AODEvent() && IsStandardAOD()) {
440 // In case there is an AOD handler writing a standard AOD, use the AOD
441 // event in memory rather than the input (ESD) event.
442 aod = dynamic_cast<AliAODEvent*> (AODEvent());
443 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
444 // have to taken from the AOD event hold by the AliAODExtension
445 AliAODHandler* aodHandler = (AliAODHandler*)
446 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
448 if(aodHandler->GetExtensions()) {
449 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
450 AliAODEvent* aodFromExt = ext->GetAOD();
451 inputArray=(TClonesArray*)aodFromExt->GetList()->FindObject(bname.Data());
454 inputArray=(TClonesArray*)aod->GetList()->FindObject(bname.Data());
457 if(!inputArray || !aod) {
458 printf("AliAnalysisTaskSED0Correlations::UserExec: input branch not found!\n");
462 // fix for temporary bug in ESDfilter
463 // the AODs with null vertex pointer didn't pass the PhysSel
464 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
466 TClonesArray *mcArray = 0;
467 AliAODMCHeader *mcHeader = 0;
471 mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
473 printf("AliAnalysisTaskSED0Correlations::UserExec: MC particles branch not found!\n");
478 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
480 printf("AliAnalysisTaskSED0Correlations::UserExec: MC header branch not found!\n");
485 //histogram filled with 1 for every AOD
487 fCounter->StoreEvent(aod,fCutsD0,fReadMC);
489 // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
490 TString trigclass=aod->GetFiredTriggerClasses();
491 if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNentries->Fill(14);
493 if(!fCutsD0->IsEventSelected(aod)) {
494 if(fCutsD0->GetWhyRejection()==1) // rejected for pileup
496 if(fSys==1 && (fCutsD0->GetWhyRejection()==2 || fCutsD0->GetWhyRejection()==3)) fNentries->Fill(15);
497 if(fCutsD0->GetWhyRejection()==7) fNentries->Fill(17);
501 fNentries->Fill(18); //event selected after selection
503 //Setting PIDResponse for associated tracks
504 fCorrelatorTr->SetPidAssociated();
505 fCorrelatorKc->SetPidAssociated();
506 fCorrelatorK0->SetPidAssociated();
508 //Selection on production type (MC)
509 if(fReadMC && fSelEvType){
511 Bool_t isMCeventgood = kFALSE;
513 Int_t eventType = mcHeader->GetEventType();
514 Int_t NMCevents = fCutsTracks->GetNofMCEventType();
516 for(Int_t k=0; k<NMCevents; k++){
517 Int_t * MCEventType = fCutsTracks->GetMCEventType();
519 if(eventType == MCEventType[k]) isMCeventgood= kTRUE;
520 ((TH1D*)fOutputStudy->FindObject("EventTypeMC"))->Fill(eventType);
523 if(NMCevents && !isMCeventgood){
524 std::cout << "The MC event " << eventType << " not interesting for this analysis: skipping" << std::endl;
527 fNentries->Fill(19); //event with particular production type
532 // Check the Nb of SDD clusters
533 if (fIsRejectSDDClusters) {
534 Bool_t skipEvent = kFALSE;
536 if (aod) ntracks = aod->GetNTracks();
537 for(Int_t itrack=0; itrack<ntracks; itrack++) { // loop on tacks
539 AliAODTrack * track = aod->GetTrack(itrack);
540 if(TESTBIT(track->GetITSClusterMap(),2) || TESTBIT(track->GetITSClusterMap(),3) ){
546 if (skipEvent) return;
549 //HFCorrelators initialization (for this event)
550 fCorrelatorTr->SetAODEvent(aod); // set the AOD event from which you are processing
551 fCorrelatorKc->SetAODEvent(aod);
552 fCorrelatorK0->SetAODEvent(aod);
553 Bool_t correlatorONTr = fCorrelatorTr->Initialize(); // initialize the pool for event mixing
554 Bool_t correlatorONKc = fCorrelatorKc->Initialize();
555 Bool_t correlatorONK0 = fCorrelatorK0->Initialize();
556 if(!correlatorONTr) {AliInfo("AliHFCorrelator (tracks) didn't initialize the pool correctly or processed a bad event"); return;}
557 if(!correlatorONKc) {AliInfo("AliHFCorrelator (charged K) didn't initialize the pool correctly or processed a bad event"); return;}
558 if(!correlatorONK0) {AliInfo("AliHFCorrelator (K0) didn't initialize the pool correctly or processed a bad event"); return;}
561 fCorrelatorTr->SetMCArray(mcArray); // set the TClonesArray *fmcArray for analysis on monte carlo
562 fCorrelatorKc->SetMCArray(mcArray);
563 fCorrelatorK0->SetMCArray(mcArray);
566 // AOD primary vertex
567 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
570 TString primTitle = vtx1->GetTitle();
571 if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) {
575 //Reset flag for tracks distributions fill
576 fAlreadyFilled=kFALSE;
578 //***** Loop over D0 candidates *****
579 Int_t nInD0toKpi = inputArray->GetEntriesFast();
580 if(fDebug>2) printf("Number of D0->Kpi: %d\n",nInD0toKpi);
582 if(fFillGlobal) { //loop on V0 and tracks for each event, to fill Pt distr. and InvMass distr.
584 TClonesArray *v0array = (TClonesArray*)aod->GetList()->FindObject("v0s");
585 Int_t pdgCodes[2] = {211,211};
586 Int_t idArrayV0[v0array->GetEntriesFast()][2];
587 for(int iV0=0; iV0<v0array->GetEntriesFast(); iV0++) {
588 for(int j=0; j<2; j++) {idArrayV0[iV0][j]=-2;}
589 AliAODv0 *v0 = (AliAODv0*)v0array->UncheckedAt(iV0);
590 if(SelectV0(v0,vtx1,2,idArrayV0)) { //option 2 = for mass inv plots only
591 if(fReadMC && fRecoTr && (v0->MatchToMC(310,mcArray,2,pdgCodes)<0)) continue; //310 = K0s, 311 = K0 generico!!
592 ((TH2F*)fOutputStudy->FindObject("hK0MassInv"))->Fill(v0->MassK0Short(),v0->Pt()); //invariant mass plot
593 ((TH1F*)fOutputStudy->FindObject("hist_Pt_K0_AllEv"))->Fill(v0->Pt()); //pT distribution (in all events), K0 case
597 for(Int_t itrack=0; itrack<aod->GetNTracks(); itrack++) { // loop on tacks
598 AliAODTrack * track = aod->GetTrack(itrack);
599 //rejection of tracks
600 if(track->GetID() < 0) continue; //discard negative ID tracks
601 if(track->Pt() < fPtThreshLow.at(0) || track->Pt() > fPtThreshUp.at(0)) continue; //discard tracks outside pt range for hadrons/K
602 if(!fCutsTracks->IsHadronSelected(track) || !fCutsTracks->CheckHadronKinematic(track->Pt(),0.1)) continue; //0.1 = dummy (d0 value, no cut on it for me)
603 //pT distribution (in all events), charg and hadr cases
604 ((TH1F*)fOutputStudy->FindObject("hist_Pt_Charg_AllEv"))->Fill(track->Pt());
605 if(fCutsTracks->CheckKaonCompatibility(track,kFALSE,0,2)) ((TH1F*)fOutputStudy->FindObject("hist_Pt_Kcharg_AllEv"))->Fill(track->Pt());
608 } //end of loops for global plot fill
610 Int_t nSelectedloose=0,nSelectedtight=0;
612 //RecoD0 case ************************************************
615 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
616 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArray->UncheckedAt(iD0toKpi);
618 if(d->GetSelectionMap()) if(!d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)){
620 continue; //skip the D0 from Dstar
623 if (fCutsD0->IsInFiducialAcceptance(d->Pt(),d->Y(421)) ) {
627 if(fCutsD0->IsSelected(d,AliRDHFCuts::kTracks,aod))fNentries->Fill(6);
629 Int_t ptbin=fCutsD0->PtBin(d->Pt());
630 if(ptbin==-1) {fNentries->Fill(4); continue;} //out of bounds
632 fIsSelectedCandidate=fCutsD0->IsSelected(d,AliRDHFCuts::kAll,aod); //D0 selected
633 if(!fIsSelectedCandidate) continue;
636 Double_t phiD0 = fCorrelatorTr->SetCorrectPhiRange(d->Phi());
637 phiD0 = fCorrelatorKc->SetCorrectPhiRange(d->Phi()); //bad usage, but returns a Double_t...
638 phiD0 = fCorrelatorK0->SetCorrectPhiRange(d->Phi());
639 fCorrelatorTr->SetTriggerParticleProperties(d->Pt(),phiD0,d->Eta()); // sets the parameters of the trigger particles that are needed
640 fCorrelatorKc->SetTriggerParticleProperties(d->Pt(),phiD0,d->Eta());
641 fCorrelatorK0->SetTriggerParticleProperties(d->Pt(),phiD0,d->Eta());
642 fCorrelatorTr->SetD0Properties(d,fIsSelectedCandidate); //sets special properties for D0
643 fCorrelatorKc->SetD0Properties(d,fIsSelectedCandidate);
644 fCorrelatorK0->SetD0Properties(d,fIsSelectedCandidate);
647 if (TMath::Abs(d->Eta())<fEtaForCorrel) CalculateCorrelations(d); //correlations on real data
648 } else { //correlations on MC -> association of selected D0 to MCinfo with MCtruth
649 if (TMath::Abs(d->Eta())<fEtaForCorrel) {
650 Int_t pdgDgD0toKpi[2]={321,211};
651 Int_t labD0 = d->MatchToMC(421,mcArray,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not
652 if (labD0>-1) CalculateCorrelations(d,labD0,mcArray);
656 FillMassHists(d,mcArray,fCutsD0,fOutputMass);
660 //End RecoD0 case ************************************************
662 //MCKineD0 case ************************************************
663 if(fReadMC && !fRecoD0) {
665 for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) { //Loop over all the tracks of MCArray
666 AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
668 AliWarning("Particle not found in tree, skipping");
672 if(TMath::Abs(mcPart->GetPdgCode()) == 421){ // THIS IS A D0
673 if (fCutsD0->IsInFiducialAcceptance(mcPart->Pt(),mcPart->Y()) ) {
676 if(fSys==0) fNentries->Fill(6);
677 Int_t ptbin=fCutsD0->PtBin(mcPart->Pt());
678 if(ptbin==-1) {fNentries->Fill(4); continue;} //out of bounds
681 Double_t phiD0 = fCorrelatorTr->SetCorrectPhiRange(mcPart->Phi());
682 phiD0 = fCorrelatorKc->SetCorrectPhiRange(mcPart->Phi()); //bad usage, but returns a Double_t...
683 phiD0 = fCorrelatorK0->SetCorrectPhiRange(mcPart->Phi());
684 fCorrelatorTr->SetTriggerParticleProperties(mcPart->Pt(),phiD0,mcPart->Eta()); // sets the parameters of the trigger particles that are needed
685 fCorrelatorKc->SetTriggerParticleProperties(mcPart->Pt(),phiD0,mcPart->Eta());
686 fCorrelatorK0->SetTriggerParticleProperties(mcPart->Pt(),phiD0,mcPart->Eta());
687 //fCorrelatorTr->SetD0Properties(mcPart,fIsSelectedCandidate); //needed for D* soft pions rejection, useless in MCKine
688 //fCorrelatorKc->SetD0Properties(mcPart,fIsSelectedCandidate);
689 //fCorrelatorK0->SetD0Properties(mcPart,fIsSelectedCandidate);
691 if (TMath::Abs(mcPart->Eta())<fEtaForCorrel) {
693 //Removal of D0 from D* feeddown! This solves also the problem of soft pions, now excluded
694 /* Int_t mother = mcPart->GetMother();
695 AliAODMCParticle* mcMoth = dynamic_cast<AliAODMCParticle*>(mcArray->At(mother));
696 if(!mcMoth) continue;
697 if(TMath::Abs(mcMoth->GetPdgCode())==413) continue;
699 if (mcPart->GetPdgCode()==421) fIsSelectedCandidate = 1;
700 else fIsSelectedCandidate = 2;
702 TString fillthis="histSgn_"; fillthis+=ptbin;
703 ((TH1F*)(fOutputMass->FindObject(fillthis)))->Fill(1.864);
705 CalculateCorrelationsMCKine(mcPart,mcArray);
711 //End MCKineD0 case ************************************************
713 if(fMixing /* && fAlreadyFilled*/) { // update the pool for Event Mixing, if: enabled, event is ok, at least a SelD0 found! (fAlreadyFilled's role!)
714 Bool_t updatedTr = fCorrelatorTr->PoolUpdate();
715 Bool_t updatedKc = fCorrelatorKc->PoolUpdate();
716 Bool_t updatedK0 = fCorrelatorK0->PoolUpdate();
717 if(!updatedTr || !updatedKc || !updatedK0) AliInfo("Pool was not updated");
720 fCounter->StoreCandidates(aod,nSelectedloose,kTRUE);
721 fCounter->StoreCandidates(aod,nSelectedtight,kFALSE);
724 PostData(1,fOutputMass);
725 PostData(2,fNentries);
726 PostData(4,fCounter);
727 PostData(5,fOutputCorr);
728 PostData(6,fOutputStudy);
733 //____________________________________________________________________________
734 void AliAnalysisTaskSED0Correlations::FillMassHists(AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi* cuts, TList *listout){
736 // function used in UserExec to fill mass histograms:
738 if (!fIsSelectedCandidate) return;
740 if(fDebug>2) cout<<"Candidate selected"<<endl;
742 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
743 Int_t ptbin = cuts->PtBin(part->Pt());
746 Int_t pdgDgD0toKpi[2]={321,211};
748 if (fReadMC) labD0 = part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
750 //count candidates selected by cuts
752 //count true D0 selected by cuts
753 if (fReadMC && labD0>=0) fNentries->Fill(2);
755 if ((fIsSelectedCandidate==1 || fIsSelectedCandidate==3) && fFillOnlyD0D0bar<2) { //D0
759 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
760 Int_t pdgD0 = partD0->GetPdgCode();
761 if (pdgD0==421){ //D0
764 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
765 } else{ //it was a D0bar
768 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
773 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
776 fillthis="histMass_";
778 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
782 if (fIsSelectedCandidate>1 && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)) { //D0bar
786 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
787 Int_t pdgD0 = partD0->GetPdgCode();
789 if (pdgD0==-421){ //D0bar
792 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
796 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
798 } else {//background or LS
801 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
804 fillthis="histMass_";
806 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
813 //________________________________________________________________________
814 void AliAnalysisTaskSED0Correlations::Terminate(Option_t */*option*/)
816 // Terminate analysis
818 if(fDebug > 1) printf("AnalysisTaskSED0Correlations: Terminate() \n");
820 fOutputMass = dynamic_cast<TList*> (GetOutputData(1));
822 printf("ERROR: fOutputMass not available\n");
826 fNentries = dynamic_cast<TH1F*>(GetOutputData(2));
829 printf("ERROR: fNEntries not available\n");
833 fCutsD0 = dynamic_cast<AliRDHFCutsD0toKpi*>(GetOutputData(3));
835 printf("ERROR: fCuts not available\n");
839 fCounter = dynamic_cast<AliNormalizationCounter*>(GetOutputData(4));
841 printf("ERROR: fCounter not available\n");
844 fOutputCorr = dynamic_cast<TList*> (GetOutputData(5));
846 printf("ERROR: fOutputCorr not available\n");
849 fOutputStudy = dynamic_cast<TList*> (GetOutputData(6));
851 printf("ERROR: fOutputStudy not available\n");
854 fCutsTracks = dynamic_cast<AliHFAssociatedTrackCuts*>(GetOutputData(7));
856 printf("ERROR: fCutsTracks not available\n");
863 //_________________________________________________________________________________________________
864 Int_t AliAnalysisTaskSED0Correlations::CheckD0Origin(TClonesArray* arrayMC, AliAODMCParticle *mcPartCandidate) const {
866 // checking whether the mother of the particles come from a charm or a bottom quark
868 printf("AliAnalysisTaskSED0Correlations::CheckD0Origin() \n");
872 mother = mcPartCandidate->GetMother();
873 Int_t abspdgGranma =0;
874 Bool_t isFromB=kFALSE;
875 Bool_t isQuarkFound=kFALSE;
878 AliAODMCParticle* mcMoth = dynamic_cast<AliAODMCParticle*>(arrayMC->At(mother));
880 pdgGranma = mcMoth->GetPdgCode();
881 abspdgGranma = TMath::Abs(pdgGranma);
882 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)){
885 if(abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE;
886 mother = mcMoth->GetMother();
888 AliError("Failed casting the mother particle!");
894 if(isFromB) return 5;
900 //________________________________________________________________________
901 void AliAnalysisTaskSED0Correlations::CreateCorrelationsObjs() {
904 TString namePlot = "";
906 //These for limits in THnSparse (one per bin, same limits).
907 //Vars: DeltaPhi, InvMass, PtTrack, Displacement, DeltaEta
908 Int_t nBinsPhi[5] = {32,150,6,3,16};
909 Double_t binMinPhi[5] = {-TMath::Pi()/2,1.6,0.,0.,-1.6}; //is the minimum for all the bins
910 Double_t binMaxPhi[5] = {3*TMath::Pi()/2,2.2,3.0,3.,1.6}; //is the maximum for all the bins
912 //Vars: DeltaPhi, InvMass, DeltaEta
913 Int_t nBinsMix[3] = {32,150,16};
914 Double_t binMinMix[3] = {-TMath::Pi()/2,1.6,-1.6}; //is the minimum for all the bins
915 Double_t binMaxMix[3] = {3*TMath::Pi()/2,2.2,1.6}; //is the maximum for all the bins
917 for(Int_t i=0;i<fNPtBinsCorr;i++){
920 //THnSparse plots: correlations for various invariant mass (MC and data)
921 namePlot="hPhi_K0_Bin";
924 THnSparseF *hPhiK = new THnSparseF(namePlot.Data(), "Azimuthal correlation; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
926 fOutputCorr->Add(hPhiK);
928 namePlot="hPhi_Kcharg_Bin";
931 THnSparseF *hPhiH = new THnSparseF(namePlot.Data(), "Azimuthal correlation; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
933 fOutputCorr->Add(hPhiH);
935 namePlot="hPhi_Charg_Bin";
938 THnSparseF *hPhiC = new THnSparseF(namePlot.Data(), "Azimuthal correlation; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
940 fOutputCorr->Add(hPhiC);
942 //histos for c/b origin for D0 (MC only)
945 //generic origin for tracks
946 namePlot="hPhi_K0_From_c_Bin";
949 THnSparseF *hPhiK_c = new THnSparseF(namePlot.Data(), "Azimuthal correlation - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
951 fOutputCorr->Add(hPhiK_c);
953 namePlot="hPhi_Kcharg_From_c_Bin";
956 THnSparseF *hPhiH_c = new THnSparseF(namePlot.Data(), "Azimuthal correlation - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
958 fOutputCorr->Add(hPhiH_c);
960 namePlot="hPhi_Charg_From_c_Bin";
963 THnSparseF *hPhiC_c = new THnSparseF(namePlot.Data(), "Azimuthal correlation - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
965 fOutputCorr->Add(hPhiC_c);
967 namePlot="hPhi_K0_From_b_Bin";
970 THnSparseF *hPhiK_b = new THnSparseF(namePlot.Data(), "Azimuthal correlation - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
972 fOutputCorr->Add(hPhiK_b);
974 namePlot="hPhi_Kcharg_From_b_Bin";
977 THnSparseF *hPhiH_b = new THnSparseF(namePlot.Data(), "Azimuthal correlation - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
979 fOutputCorr->Add(hPhiH_b);
981 namePlot="hPhi_Charg_From_b_Bin";
984 THnSparseF *hPhiC_b = new THnSparseF(namePlot.Data(), "Azimuthal correlation - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
986 fOutputCorr->Add(hPhiC_b);
988 //HF-only tracks (c for c->D0, b for b->D0)
989 namePlot="hPhi_K0_HF_From_c_Bin";
992 THnSparseF *hPhiK_HF_c = new THnSparseF(namePlot.Data(), "Azimuthal correlation HF - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
994 fOutputCorr->Add(hPhiK_HF_c);
996 namePlot="hPhi_Kcharg_HF_From_c_Bin";
999 THnSparseF *hPhiH_HF_c = new THnSparseF(namePlot.Data(), "Azimuthal correlation HF - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
1000 hPhiH_HF_c->Sumw2();
1001 fOutputCorr->Add(hPhiH_HF_c);
1003 namePlot="hPhi_Charg_HF_From_c_Bin";
1006 THnSparseF *hPhiC_HF_c = new THnSparseF(namePlot.Data(), "Azimuthal correlation HF - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
1007 hPhiC_HF_c->Sumw2();
1008 fOutputCorr->Add(hPhiC_HF_c);
1010 namePlot="hPhi_K0_HF_From_b_Bin";
1013 THnSparseF *hPhiK_HF_b = new THnSparseF(namePlot.Data(), "Azimuthal correlation HF - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
1014 hPhiK_HF_b->Sumw2();
1015 fOutputCorr->Add(hPhiK_HF_b);
1017 namePlot="hPhi_Kcharg_HF_From_b_Bin";
1020 THnSparseF *hPhiH_HF_b = new THnSparseF(namePlot.Data(), "Azimuthal correlation HF - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
1021 hPhiH_HF_b->Sumw2();
1022 fOutputCorr->Add(hPhiH_HF_b);
1024 namePlot="hPhi_Charg_HF_From_b_Bin";
1027 THnSparseF *hPhiC_HF_b = new THnSparseF(namePlot.Data(), "Azimuthal correlation HF - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
1028 hPhiC_HF_b->Sumw2();
1029 fOutputCorr->Add(hPhiC_HF_b);
1031 namePlot="hPhi_K0_NonHF_Bin";
1034 THnSparseF *hPhiK_Non = new THnSparseF(namePlot.Data(), "Azimuthal correlation - Non HF; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
1036 fOutputCorr->Add(hPhiK_Non);
1038 namePlot="hPhi_Kcharg_NonHF_Bin";
1041 THnSparseF *hPhiH_Non = new THnSparseF(namePlot.Data(), "Azimuthal correlation - Non HF; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
1043 fOutputCorr->Add(hPhiH_Non);
1045 namePlot="hPhi_Charg_NonHF_Bin";
1048 THnSparseF *hPhiC_Non = new THnSparseF(namePlot.Data(), "Azimuthal correlation - Non HF; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",5,nBinsPhi,binMinPhi,binMaxPhi);
1050 fOutputCorr->Add(hPhiC_Non);
1053 //leading hadron correlations
1054 namePlot="hPhi_Lead_Bin";
1057 THnSparseF *hCorrLead = new THnSparseF(namePlot.Data(), "Leading particle correlations; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1059 fOutputCorr->Add(hCorrLead);
1062 namePlot="hPhi_Lead_From_c_Bin";
1065 THnSparseF *hCorrLead_c = new THnSparseF(namePlot.Data(), "Leading particle correlations - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1066 hCorrLead_c->Sumw2();
1067 fOutputCorr->Add(hCorrLead_c);
1069 namePlot="hPhi_Lead_From_b_Bin";
1072 THnSparseF *hCorrLead_b = new THnSparseF(namePlot.Data(), "Leading particle correlations - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1073 hCorrLead_b->Sumw2();
1074 fOutputCorr->Add(hCorrLead_b);
1076 namePlot="hPhi_Lead_HF_From_c_Bin";
1079 THnSparseF *hCorrLead_HF_c = new THnSparseF(namePlot.Data(), "Leading particle correlations HF - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1080 hCorrLead_HF_c->Sumw2();
1081 fOutputCorr->Add(hCorrLead_HF_c);
1083 namePlot="hPhi_Lead_HF_From_b_Bin";
1086 THnSparseF *hCorrLead_HF_b = new THnSparseF(namePlot.Data(), "Leading particle correlations HF - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1087 hCorrLead_HF_b->Sumw2();
1088 fOutputCorr->Add(hCorrLead_HF_b);
1090 namePlot="hPhi_Lead_NonHF_Bin";
1093 THnSparseF *hCorrLead_Non = new THnSparseF(namePlot.Data(), "Leading particle correlations - Non HF; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1094 hCorrLead_Non->Sumw2();
1095 fOutputCorr->Add(hCorrLead_Non);
1098 //pT weighted correlations
1099 namePlot="hPhi_Weig_Bin";
1102 THnSparseF *hCorrWeig = new THnSparseF(namePlot.Data(), "Charged particle correlations (pT weighted); #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1103 fOutputCorr->Add(hCorrWeig);
1106 namePlot="hPhi_Weig_From_c_Bin";
1109 THnSparseF *hCorrWeig_c = new THnSparseF(namePlot.Data(), "Charged particle correlations (pT weighted) - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1110 fOutputCorr->Add(hCorrWeig_c);
1112 namePlot="hPhi_Weig_From_b_Bin";
1115 THnSparseF *hCorrWeig_b = new THnSparseF(namePlot.Data(), "Charged particle correlations (pT weighted) - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1116 fOutputCorr->Add(hCorrWeig_b);
1118 namePlot="hPhi_Weig_HF_From_c_Bin";
1121 THnSparseF *hCorrWeig_HF_c = new THnSparseF(namePlot.Data(), "Charged particle correlations (pT weighted) HF - c origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1122 fOutputCorr->Add(hCorrWeig_HF_c);
1124 namePlot="hPhi_Weig_HF_From_b_Bin";
1127 THnSparseF *hCorrWeig_HF_b = new THnSparseF(namePlot.Data(), "Charged particle correlations (pT weighted) HF - b origin; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1128 fOutputCorr->Add(hCorrWeig_HF_b);
1130 namePlot="hPhi_Weig_NonHF_Bin";
1133 THnSparseF *hCorrWeig_Non = new THnSparseF(namePlot.Data(), "Charged particle correlations (pT weighted) - Non HF; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1134 fOutputCorr->Add(hCorrWeig_Non);
1137 //pT distribution histos
1138 namePlot = "hist_Pt_Charg_Bin"; namePlot+=i;
1139 TH1F *hPtC = new TH1F(namePlot.Data(), "Charged track pT (in D0 evs); p_{T} (GeV/c)",240,0.,12.);
1140 hPtC->SetMinimum(0);
1141 fOutputStudy->Add(hPtC);
1143 namePlot = "hist_Pt_Kcharg_Bin"; namePlot+=i;
1144 TH1F *hPtH = new TH1F(namePlot.Data(), "Hadrons pT (in D0 evs); p_{T} (GeV/c)",240,0.,12.);
1145 hPtH->SetMinimum(0);
1146 fOutputStudy->Add(hPtH);
1148 namePlot = "hist_Pt_K0_Bin"; namePlot+=i;
1149 TH1F *hPtK = new TH1F(namePlot.Data(), "Kaons pT (in D0 evs); p_{T} (GeV/c)",240,0.,12.);
1150 hPtK->SetMinimum(0);
1151 fOutputStudy->Add(hPtK);
1153 //D* feeddown pions rejection histos
1154 namePlot = "hDstarPions_Bin"; namePlot+=i;
1155 TH2F *hDstarPions = new TH2F(namePlot.Data(), "Tracks rejected for D* inv.mass cut; # Tracks",2,0.,2.,150,1.6,2.2);
1156 hDstarPions->GetXaxis()->SetBinLabel(1,"Not rejected");
1157 hDstarPions->GetXaxis()->SetBinLabel(2,"Rejected");
1158 hDstarPions->SetMinimum(0);
1159 fOutputStudy->Add(hDstarPions);
1164 //THnSparse plots for event mixing!
1165 namePlot="hPhi_K0_Bin";
1166 namePlot+=i;namePlot+="_EvMix";
1168 THnSparseF *hPhiK_EvMix = new THnSparseF(namePlot.Data(), "Az. corr. EvMix; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1169 hPhiK_EvMix->Sumw2();
1170 fOutputCorr->Add(hPhiK_EvMix);
1172 namePlot="hPhi_Kcharg_Bin";
1173 namePlot+=i;namePlot+="_EvMix";
1175 THnSparseF *hPhiH_EvMix = new THnSparseF(namePlot.Data(), "Az. corr. EvMix; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1176 hPhiH_EvMix->Sumw2();
1177 fOutputCorr->Add(hPhiH_EvMix);
1179 namePlot="hPhi_Charg_Bin";
1180 namePlot+=i;namePlot+="_EvMix";
1182 THnSparseF *hPhiC_EvMix = new THnSparseF(namePlot.Data(), "Az. corr. EvMix; #Delta#phi; Inv. Mass (GeV/c^{2}); p_{t} (GeV/c)",3,nBinsMix,binMinMix,binMaxMix);
1183 hPhiC_EvMix->Sumw2();
1184 fOutputCorr->Add(hPhiC_EvMix);
1190 TH1F *hCountC = new TH1F("hist_Count_Charg", "Charged track counter; # Tracks",100,0.,100.);
1191 hCountC->SetMinimum(0);
1192 fOutputStudy->Add(hCountC);
1194 TH1F *hCountH = new TH1F("hist_Count_Kcharg", "Hadrons counter; # Tracks",20,0.,20.);
1195 hCountH->SetMinimum(0);
1196 fOutputStudy->Add(hCountH);
1198 TH1F *hCountK = new TH1F("hist_Count_K0", "Kaons counter; # Tracks",20,0.,20.);
1199 hCountK->SetMinimum(0);
1200 fOutputStudy->Add(hCountK);
1204 TH1D *hEventTypeMC = new TH1D("EventTypeMC","EventTypeMC",100,-0.5,99.5);
1205 fOutputStudy->Add(hEventTypeMC);
1208 if (fFillGlobal) { //all-events plots
1210 TH1F *hPtCAll = new TH1F("hist_Pt_Charg_AllEv", "Charged track pT (All); p_{T} (GeV/c)",240,0.,12.);
1211 hPtCAll->SetMinimum(0);
1212 fOutputStudy->Add(hPtCAll);
1214 TH1F *hPtHAll = new TH1F("hist_Pt_Kcharg_AllEv", "Hadrons pT (All); p_{T} (GeV/c)",240,0.,12.);
1215 hPtHAll->SetMinimum(0);
1216 fOutputStudy->Add(hPtHAll);
1218 TH1F *hPtKAll = new TH1F("hist_Pt_K0_AllEv", "Kaons pT (All); p_{T} (GeV/c)",240,0.,12.);
1219 hPtKAll->SetMinimum(0);
1220 fOutputStudy->Add(hPtKAll);
1224 TH1F *hPhiDistCAll = new TH1F("hist_PhiDistr_Charg", "Charged track phi distr. (All); p_{T} (GeV/c)",64,0,6.283);
1225 hPhiDistCAll->SetMinimum(0);
1226 fOutputStudy->Add(hPhiDistCAll);
1228 TH1F *hPhiDistHAll = new TH1F("hist_PhiDistr_Kcharg", "Hadrons phi distr. (All); p_{T} (GeV/c)",64,0,6.283);
1229 hPhiDistHAll->SetMinimum(0);
1230 fOutputStudy->Add(hPhiDistHAll);
1232 TH1F *hPhiDistKAll = new TH1F("hist_PhiDistr_K0", "Kaons phi distr. (All); p_{T} (GeV/c)",64,0,6.283);
1233 hPhiDistKAll->SetMinimum(0);
1234 fOutputStudy->Add(hPhiDistKAll);
1236 TH1F *hPhiDistDAll = new TH1F("hist_PhiDistr_D0", "D^{0} phi distr. (All); p_{T} (GeV/c)",64,0,6.283);
1237 hPhiDistDAll->SetMinimum(0);
1238 fOutputStudy->Add(hPhiDistDAll);
1241 //K0 Invariant Mass plots
1242 TH2F *hK0MassInv = new TH2F("hK0MassInv", "K0 invariant mass; Invariant mass (MeV/c^{2}); pT (GeV/c)",200,0.4,0.6,100,0.,10.);
1243 hK0MassInv->SetMinimum(0);
1244 fOutputStudy->Add(hK0MassInv);
1247 //for MC analysis only
1248 for(Int_t i=0;i<fNPtBinsCorr;i++) {
1250 if (fReadMC && !fMixing) {
1252 //displacement histos
1253 namePlot="histDispl_K0_Bin"; namePlot+=i;
1254 TH1F *hDisplK = new TH1F(namePlot.Data(), "Kaons Displacement; DCA",150,0.,0.15);
1255 hDisplK->SetMinimum(0);
1256 fOutputStudy->Add(hDisplK);
1258 namePlot="histDispl_K0_HF_Bin"; namePlot+=i;
1259 TH1F *hDisplK_HF = new TH1F(namePlot.Data(), "Kaons Displacement (from HF decay only); DCA",150,0.,0.15);
1260 hDisplK_HF->SetMinimum(0);
1261 fOutputStudy->Add(hDisplK_HF);
1263 namePlot="histDispl_Kcharg_Bin"; namePlot+=i;
1264 TH1F *hDisplHadr = new TH1F(namePlot.Data(), "Hadrons Displacement; DCA",150,0.,0.15);
1265 hDisplHadr->SetMinimum(0);
1266 fOutputStudy->Add(hDisplHadr);
1268 namePlot="histDispl_Kcharg_HF_Bin"; namePlot+=i;
1269 TH1F *hDisplHadr_HF = new TH1F(namePlot.Data(), "Hadrons Displacement (from HF decay only); DCA",150,0.,0.15);
1270 hDisplHadr_HF->SetMinimum(0);
1271 fOutputStudy->Add(hDisplHadr_HF);
1273 namePlot="histDispl_Charg_Bin"; namePlot+=i;
1274 TH1F *hDisplCharg = new TH1F(namePlot.Data(), "Charged tracks Displacement; DCA",150,0.,0.15);
1275 hDisplCharg->SetMinimum(0);
1276 fOutputStudy->Add(hDisplCharg);
1278 namePlot="histDispl_Charg_HF_Bin"; namePlot+=i;
1279 TH1F *hDisplCharg_HF = new TH1F(namePlot.Data(), "Charged tracks Displacement (from HF decay only); DCA",150,0.,0.15);
1280 hDisplCharg_HF->SetMinimum(0);
1281 fOutputStudy->Add(hDisplCharg_HF);
1283 namePlot="histDispl_K0_From_c_Bin"; namePlot+=i;
1284 TH1F *hDisplK_c = new TH1F(namePlot.Data(), "Kaons Displacement - c origin; DCA",150,0.,0.15);
1285 hDisplK_c->SetMinimum(0);
1286 fOutputStudy->Add(hDisplK_c);
1288 namePlot="histDispl_K0_HF_From_c_Bin"; namePlot+=i;
1289 TH1F *hDisplK_HF_c = new TH1F(namePlot.Data(), "Kaons Displacement (from HF decay only) - c origin; DCA",150,0.,0.15);
1290 hDisplK_HF_c->SetMinimum(0);
1291 fOutputStudy->Add(hDisplK_HF_c);
1293 namePlot="histDispl_Kcharg_From_c_Bin"; namePlot+=i;
1294 TH1F *hDisplHadr_c = new TH1F(namePlot.Data(), "Hadrons Displacement - c origin; DCA",150,0.,0.15);
1295 hDisplHadr_c->SetMinimum(0);
1296 fOutputStudy->Add(hDisplHadr_c);
1298 namePlot="histDispl_Kcharg_HF_From_c_Bin"; namePlot+=i;
1299 TH1F *hDisplHadr_HF_c = new TH1F(namePlot.Data(), "Hadrons Displacement (from HF decay only) - c origin; DCA",150,0.,0.15);
1300 hDisplHadr_HF_c->SetMinimum(0);
1301 fOutputStudy->Add(hDisplHadr_HF_c);
1303 namePlot="histDispl_Charg_From_c_Bin"; namePlot+=i;
1304 TH1F *hDisplCharg_c = new TH1F(namePlot.Data(), "Charged tracks Displacement - c origin; DCA",150,0.,0.15);
1305 hDisplCharg_c->Sumw2();
1306 hDisplCharg_c->SetMinimum(0);
1307 fOutputStudy->Add(hDisplCharg_c);
1309 namePlot="histDispl_Charg_HF_From_c_Bin"; namePlot+=i;
1310 TH1F *hDisplCharg_HF_c = new TH1F(namePlot.Data(), "Charged tracks Displacement (from HF decay only) - c origin; DCA",150,0.,0.15);
1311 hDisplCharg_HF_c->SetMinimum(0);
1312 fOutputStudy->Add(hDisplCharg_HF_c);
1314 namePlot="histDispl_K0_From_b_Bin"; namePlot+=i;
1315 TH1F *hDisplK_b = new TH1F(namePlot.Data(), "Kaons Displacement - b origin; DCA",150,0.,0.15);
1316 hDisplK_b->SetMinimum(0);
1317 fOutputStudy->Add(hDisplK_b);
1319 namePlot="histDispl_K0_HF_From_b_Bin"; namePlot+=i;
1320 TH1F *hDisplK_HF_b = new TH1F(namePlot.Data(), "Kaons Displacement (from HF decay only) - b origin; DCA",150,0.,0.15);
1321 hDisplK_HF_b->SetMinimum(0);
1322 fOutputStudy->Add(hDisplK_HF_b);
1324 namePlot="histDispl_Kcharg_From_b_Bin"; namePlot+=i;
1325 TH1F *hDisplHadr_b = new TH1F(namePlot.Data(), "Hadrons Displacement - b origin; DCA",150,0.,0.15);
1326 hDisplHadr_b->SetMinimum(0);
1327 fOutputStudy->Add(hDisplHadr_b);
1329 namePlot="histDispl_Kcharg_HF_From_b_Bin"; namePlot+=i;
1330 TH1F *hDisplHadr_HF_b = new TH1F(namePlot.Data(), "Hadrons Displacement (from HF decay only) - b origin; DCA",150,0.,0.15);
1331 hDisplHadr_HF_b->SetMinimum(0);
1332 fOutputStudy->Add(hDisplHadr_HF_b);
1334 namePlot="histDispl_Charg_From_b_Bin"; namePlot+=i;
1335 TH1F *hDisplCharg_b = new TH1F(namePlot.Data(), "Charged tracks Displacement - b origin; DCA",150,0.,0.15);
1336 hDisplCharg_b->SetMinimum(0);
1337 fOutputStudy->Add(hDisplCharg_b);
1339 namePlot="histDispl_Charg_HF_From_b_Bin"; namePlot+=i;
1340 TH1F *hDisplCharg_HF_b = new TH1F(namePlot.Data(), "Charged tracks Displacement (from HF decay only) - b origin; DCA",150,0.,0.15);
1341 hDisplCharg_HF_b->SetMinimum(0);
1342 fOutputStudy->Add(hDisplCharg_HF_b);
1344 //origin of tracks histos
1345 namePlot="histOrig_Charg_Bin"; namePlot+=i;
1346 TH1F *hOrigin_Charm = new TH1F(namePlot.Data(), "Origin of charged tracks",9,0.,9.);
1347 hOrigin_Charm->SetMinimum(0);
1348 hOrigin_Charm->GetXaxis()->SetBinLabel(1,"Not HF");
1349 hOrigin_Charm->GetXaxis()->SetBinLabel(2,"D->#");
1350 hOrigin_Charm->GetXaxis()->SetBinLabel(3,"D->X->#");
1351 hOrigin_Charm->GetXaxis()->SetBinLabel(4,"c hadr.");
1352 hOrigin_Charm->GetXaxis()->SetBinLabel(5,"B->#");
1353 hOrigin_Charm->GetXaxis()->SetBinLabel(6,"B->X-># (X!=D)");
1354 hOrigin_Charm->GetXaxis()->SetBinLabel(7,"B->D->#");
1355 hOrigin_Charm->GetXaxis()->SetBinLabel(8,"B->D->X->#");
1356 hOrigin_Charm->GetXaxis()->SetBinLabel(9,"b hadr.");
1357 fOutputStudy->Add(hOrigin_Charm);
1359 namePlot="histOrig_Kcharg_Bin"; namePlot+=i;
1360 TH1F *hOrigin_Kcharg = new TH1F(namePlot.Data(), "Origin of hadrons",9,0.,9.);
1361 hOrigin_Kcharg->SetMinimum(0);
1362 hOrigin_Kcharg->GetXaxis()->SetBinLabel(1,"Not HF");
1363 hOrigin_Kcharg->GetXaxis()->SetBinLabel(2,"D->#");
1364 hOrigin_Kcharg->GetXaxis()->SetBinLabel(3,"D->X->#");
1365 hOrigin_Kcharg->GetXaxis()->SetBinLabel(4,"c hadr.");
1366 hOrigin_Kcharg->GetXaxis()->SetBinLabel(5,"B->#");
1367 hOrigin_Kcharg->GetXaxis()->SetBinLabel(6,"B->X-># (X!=D)");
1368 hOrigin_Kcharg->GetXaxis()->SetBinLabel(7,"B->D->#");
1369 hOrigin_Kcharg->GetXaxis()->SetBinLabel(8,"B->D->X->#");
1370 hOrigin_Kcharg->GetXaxis()->SetBinLabel(9,"b hadr.");
1371 fOutputStudy->Add(hOrigin_Kcharg);
1373 namePlot="histOrig_K0_Bin"; namePlot+=i;
1374 TH1F *hOrigin_K = new TH1F(namePlot.Data(), "Origin of kaons",9,0.,9.);
1375 hOrigin_K->SetMinimum(0);
1376 hOrigin_K->GetXaxis()->SetBinLabel(1,"Not HF");
1377 hOrigin_K->GetXaxis()->SetBinLabel(2,"D->#");
1378 hOrigin_K->GetXaxis()->SetBinLabel(3,"D->X->#");
1379 hOrigin_K->GetXaxis()->SetBinLabel(4,"c hadr.");
1380 hOrigin_K->GetXaxis()->SetBinLabel(5,"B->#");
1381 hOrigin_K->GetXaxis()->SetBinLabel(6,"B->X-># (X!=D)");
1382 hOrigin_K->GetXaxis()->SetBinLabel(7,"B->D->#");
1383 hOrigin_K->GetXaxis()->SetBinLabel(8,"B->D->X->#");
1384 hOrigin_K->GetXaxis()->SetBinLabel(9,"b hadr.");
1385 fOutputStudy->Add(hOrigin_K);
1389 //origin of D0 histos
1390 namePlot="histOrig_D0_Bin"; namePlot+=i;
1391 TH1F *hOrigin_D0 = new TH1F(namePlot.Data(), "Origin of D0",2,0.,2.);
1392 hOrigin_D0->SetMinimum(0);
1393 hOrigin_D0->GetXaxis()->SetBinLabel(1,"From c");
1394 hOrigin_D0->GetXaxis()->SetBinLabel(2,"From b");
1395 fOutputStudy->Add(hOrigin_D0);
1400 //________________________________________________________________________
1401 void AliAnalysisTaskSED0Correlations::CalculateCorrelations(AliAODRecoDecayHF2Prong* d, Int_t labD0, TClonesArray* mcArray) {
1403 // Method for correlations D0-hadrons study
1405 Int_t N_Charg = 0, N_KCharg = 0, N_Kaons = 0;
1406 Double_t mD0, mD0bar;
1407 Int_t origD0 = 0, PDGD0 = 0, ptbin = 0;
1408 d->InvMassD0(mD0,mD0bar);
1409 Double_t mInv[2] = {mD0, mD0bar};
1410 ptbin = PtBinCorr(d->Pt());
1412 if(ptbin < 0) return;
1414 //Fill of D0 phi distribution
1415 if (!fMixing) ((TH1F*)fOutputStudy->FindObject("hist_PhiDistr_D0"))->Fill(d->Phi());
1420 origD0=CheckD0Origin(mcArray,(AliAODMCParticle*)mcArray->At(labD0));
1421 PDGD0 = ((AliAODMCParticle*)mcArray->At(labD0))->GetPdgCode();
1422 switch (CheckD0Origin(mcArray,(AliAODMCParticle*)mcArray->At(labD0))) {
1425 ((TH1F*)fOutputStudy->FindObject(Form("histOrig_D0_Bin%d",ptbin)))->Fill(0.);
1429 ((TH1F*)fOutputStudy->FindObject(Form("histOrig_D0_Bin%d",ptbin)))->Fill(1.);
1436 Double_t highPt = 0; Double_t lead[4] = {0,0,0,1}; //infos for leading particle (pt,deltaphi)
1438 //loop over the tracks in the pool
1439 Bool_t execPoolTr = fCorrelatorTr->ProcessEventPool(); //pool is ready? (only in ME, in SE returns kFALSE)
1440 Bool_t execPoolKc = fCorrelatorKc->ProcessEventPool(); //pool is ready? (only in ME, in SE returns kFALSE)
1441 Bool_t execPoolK0 = fCorrelatorK0->ProcessEventPool(); //pool is ready? (only in ME, in SE returns kFALSE)
1443 Int_t NofEventsinPool = 1;
1445 NofEventsinPool = fCorrelatorTr->GetNofEventsInPool();
1447 AliInfo("Mixed event analysis: track pool is not ready");
1448 NofEventsinPool = 0;
1453 for (Int_t jMix =0; jMix < NofEventsinPool; jMix++) {// loop on events in the pool; if it is SE analysis, stops at one (index not needed there)
1454 Bool_t analyzetracksTr = fCorrelatorTr->ProcessAssociatedTracks(jMix);// process all the tracks in the aodEvent, by applying the selection cuts
1455 if(!analyzetracksTr) {
1456 AliInfo("AliHFCorrelator::Cannot process the track array");
1460 for(Int_t iTrack = 0; iTrack<fCorrelatorTr->GetNofTracks(); iTrack++){ // looping on track candidates
1462 Bool_t runcorrelation = fCorrelatorTr->Correlate(iTrack);
1463 if(!runcorrelation) continue;
1465 AliReducedParticle* track = fCorrelatorTr->GetAssociatedParticle();
1468 /*if(!track->CheckSoftPi()) { //removal of soft pions
1469 if (fIsSelectedCandidate == 1 || fIsSelectedCandidate == 3) ((TH2F*)fOutputStudy->FindObject(Form("hDstarPions_Bin%d",ptbin)))->Fill(1.,mD0);
1470 if (fIsSelectedCandidate >= 2) ((TH2F*)fOutputStudy->FindObject(Form("hDstarPions_Bin%d",ptbin)))->Fill(1.,mD0bar);
1472 } else { //not a soft pion
1473 if (fIsSelectedCandidate == 1 || fIsSelectedCandidate == 3) ((TH2F*)fOutputStudy->FindObject(Form("hDstarPions_Bin%d",ptbin)))->Fill(0.,mD0);
1474 if (fIsSelectedCandidate >= 2) ((TH2F*)fOutputStudy->FindObject(Form("hDstarPions_Bin%d",ptbin)))->Fill(0.,mD0bar);
1476 Int_t idDaughs[2] = {((AliVTrack*)d->GetDaughter(0))->GetID(),((AliVTrack*)d->GetDaughter(1))->GetID()}; //IDs of daughters to be skipped
1477 if(track->GetID() == idDaughs[0] || track->GetID() == idDaughs[1]) continue; //discards daughters of candidate
1479 if(track->Pt() < fPtThreshLow.at(ptbin) || track->Pt() > fPtThreshUp.at(ptbin)) continue; //discard tracks outside pt range for hadrons/K
1481 Double_t eff = track->GetWeight(); //extract track efficiency
1483 FillSparsePlots(mcArray,mInv,origD0,PDGD0,track,ptbin,kTrack,1./eff); //fills for charged tracks, weight = 1./eff
1485 if(!fMixing) N_Charg++;
1487 //retrieving leading info...
1488 if(track->Pt() > highPt) {
1489 if(fReadMC && track->GetLabel()<1) continue;
1490 if(fReadMC && !(AliAODMCParticle*)mcArray->At(track->GetLabel())) continue;
1491 lead[0] = fCorrelatorTr->GetDeltaPhi();
1492 lead[1] = fCorrelatorTr->GetDeltaEta();
1493 lead[2] = fReadMC ? CheckTrackOrigin(mcArray,(AliAODMCParticle*)mcArray->At(track->GetLabel())) : 0;
1494 lead[3] = 1./track->GetWeight(); //weight is 1./efficiency
1495 highPt = track->Pt();
1498 } // end of tracks loop
1499 } //end of event loop for fCorrelatorTr
1502 NofEventsinPool = fCorrelatorKc->GetNofEventsInPool();
1504 AliInfo("Mixed event analysis: K+/- pool is not ready");
1505 NofEventsinPool = 0;
1509 //Charged Kaons loop
1510 for (Int_t jMix = 0; jMix < NofEventsinPool; jMix++) {// loop on events in the pool; if it is SE analysis, stops at one (index not needed there)
1511 Bool_t analyzetracksKc = fCorrelatorKc->ProcessAssociatedTracks(jMix);
1512 if(!analyzetracksKc) {
1513 AliInfo("AliHFCorrelator::Cannot process the K+/- array");
1517 for(Int_t iTrack = 0; iTrack<fCorrelatorKc->GetNofTracks(); iTrack++){ // looping on charged kaons candidates
1519 Bool_t runcorrelation = fCorrelatorKc->Correlate(iTrack);
1520 if(!runcorrelation) continue;
1522 AliReducedParticle* kCharg = fCorrelatorKc->GetAssociatedParticle();
1525 if(!kCharg->CheckSoftPi()) { //removal of soft pions
1526 if (fIsSelectedCandidate == 1 || fIsSelectedCandidate == 3) ((TH2F*)fOutputStudy->FindObject(Form("hDstarPions_Bin%d",ptbin)))->Fill(1.,mD0);
1527 if (fIsSelectedCandidate >= 2) ((TH2F*)fOutputStudy->FindObject(Form("hDstarPions_Bin%d",ptbin)))->Fill(1.,mD0bar);
1530 if (fIsSelectedCandidate == 1 || fIsSelectedCandidate == 3) ((TH2F*)fOutputStudy->FindObject(Form("hDstarPions_Bin%d",ptbin)))->Fill(0.,mD0);
1531 if (fIsSelectedCandidate >= 2) ((TH2F*)fOutputStudy->FindObject(Form("hDstarPions_Bin%d",ptbin)))->Fill(0.,mD0bar);
1533 Int_t idDaughs[2] = {((AliVTrack*)d->GetDaughter(0))->GetID(),((AliVTrack*)d->GetDaughter(1))->GetID()}; //IDs of daughters to be skipped
1534 if(kCharg->GetID() == idDaughs[0] || kCharg->GetID() == idDaughs[1]) continue; //discards daughters of candidate
1536 if(kCharg->Pt() < fPtThreshLow.at(ptbin) || kCharg->Pt() > fPtThreshUp.at(ptbin)) continue; //discard tracks outside pt range for hadrons/K
1538 FillSparsePlots(mcArray,mInv,origD0,PDGD0,kCharg,ptbin,kKCharg); //fills for charged tracks
1540 if(!fMixing) N_KCharg++;
1542 } // end of charged kaons loop
1543 } //end of event loop for fCorrelatorKc
1546 NofEventsinPool = fCorrelatorK0->GetNofEventsInPool();
1548 AliInfo("Mixed event analysis: K0 pool is not ready");
1549 NofEventsinPool = 0;
1554 for (Int_t jMix =0; jMix < NofEventsinPool; jMix++) {// loop on events in the pool; if it is SE analysis, stops at one (index not needed there)
1555 Bool_t analyzetracksK0 = fCorrelatorK0->ProcessAssociatedTracks(jMix);
1556 if(!analyzetracksK0) {
1557 AliInfo("AliHFCorrelator::Cannot process the K0 array");
1561 for(Int_t iTrack = 0; iTrack<fCorrelatorK0->GetNofTracks(); iTrack++){ // looping on k0 candidates
1563 Bool_t runcorrelation = fCorrelatorK0->Correlate(iTrack);
1564 if(!runcorrelation) continue;
1566 AliReducedParticle* k0 = fCorrelatorK0->GetAssociatedParticle();
1568 if(k0->Pt() < fPtThreshLow.at(ptbin) || k0->Pt() > fPtThreshUp.at(ptbin)) continue; //discard tracks outside pt range for hadrons/K
1570 FillSparsePlots(mcArray,mInv,origD0,PDGD0,k0,ptbin,kK0); //fills for charged tracks
1572 if(!fMixing) N_Kaons++;
1574 } // end of charged kaons loop
1575 } //end of event loop for fCorrelatorK0
1577 Double_t fillSpLeadD0[3] = {lead[0],mD0,lead[1]};
1578 Double_t fillSpLeadD0bar[3] = {lead[0],mD0bar,lead[1]};
1580 //leading track correlations fill
1583 if(((AliAODMCParticle*)mcArray->At(labD0))->GetPdgCode()==421) { //D0
1584 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_Bin%d",ptbin)))->Fill(fillSpLeadD0,lead[3]); //c and b D0
1585 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadD0,lead[3]); //c or b D0
1586 if(origD0==4&&(int)lead[2]>=1&&(int)lead[2]<=3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadD0,lead[3]);
1587 if(origD0==5&&(int)lead[2]>=4&&(int)lead[2]<=8) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadD0,lead[3]);
1588 if((int)lead[2]==0) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_NonHF_Bin%d",ptbin)))->Fill(fillSpLeadD0,lead[3]); //non HF
1590 if(((AliAODMCParticle*)mcArray->At(labD0))->GetPdgCode()==-421) { //D0bar
1591 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_Bin%d",ptbin)))->Fill(fillSpLeadD0bar,lead[3]);
1592 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadD0bar,lead[3]); //c or b D0
1593 if(origD0==4&&(int)lead[2]>=1&&(int)lead[2]<=3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadD0bar,lead[3]);
1594 if(origD0==5&&(int)lead[2]>=4&&(int)lead[2]<=8) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadD0bar,lead[3]);
1595 if((int)lead[2]==0) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_NonHF_Bin%d",ptbin)))->Fill(fillSpLeadD0bar,lead[3]); //non HF
1598 if(fIsSelectedCandidate == 1 || fIsSelectedCandidate == 3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_Bin%d",ptbin)))->Fill(fillSpLeadD0,lead[3]);
1599 if(fIsSelectedCandidate == 2 || fIsSelectedCandidate == 3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_Bin%d",ptbin)))->Fill(fillSpLeadD0bar,lead[3]);
1602 //Fill of count histograms
1603 if (!fAlreadyFilled) {
1604 ((TH1F*)fOutputStudy->FindObject("hist_Count_Charg"))->Fill(N_Charg);
1605 ((TH1F*)fOutputStudy->FindObject("hist_Count_Kcharg"))->Fill(N_KCharg);
1606 ((TH1F*)fOutputStudy->FindObject("hist_Count_K0"))->Fill(N_Kaons);
1610 fAlreadyFilled=kTRUE; //at least a D0 analyzed in the event; distribution plots already filled
1614 //________________________________________________________________________
1615 void AliAnalysisTaskSED0Correlations::CalculateCorrelationsMCKine(AliAODMCParticle* d, TClonesArray* mcArray) {
1617 // Method for correlations D0-hadrons study
1619 Int_t N_Charg = 0, N_KCharg = 0, N_Kaons = 0;
1620 Double_t mD0 = 1.864, mD0bar = 1.864;
1621 Double_t mInv[2] = {mD0, mD0bar};
1622 Int_t origD0 = 0, PDGD0 = 0;
1623 Int_t ptbin = PtBinCorr(d->Pt());
1625 if(ptbin < 0) return;
1627 //Fill of D0 phi distribution
1628 if (!fMixing) ((TH1F*)fOutputStudy->FindObject("hist_PhiDistr_D0"))->Fill(d->Phi());
1632 origD0=CheckD0Origin(mcArray,d);
1633 PDGD0 = d->GetPdgCode();
1634 switch (CheckD0Origin(mcArray,d)) {
1637 ((TH1F*)fOutputStudy->FindObject(Form("histOrig_D0_Bin%d",ptbin)))->Fill(0.);
1641 ((TH1F*)fOutputStudy->FindObject(Form("histOrig_D0_Bin%d",ptbin)))->Fill(1.);
1647 Double_t highPt = 0; Double_t lead[3] = {0,0,0}; //infos for leading particle (pt,deltaphi)
1649 //loop over the tracks in the pool
1650 Bool_t execPoolTr = fCorrelatorTr->ProcessEventPool(); //pool is ready? (only in ME, in SE returns kFALSE)
1651 Bool_t execPoolKc = fCorrelatorKc->ProcessEventPool(); //pool is ready? (only in ME, in SE returns kFALSE)
1652 Bool_t execPoolK0 = fCorrelatorK0->ProcessEventPool(); //pool is ready? (only in ME, in SE returns kFALSE)
1654 Int_t NofEventsinPool = 1;
1656 NofEventsinPool = fCorrelatorTr->GetNofEventsInPool();
1658 AliInfo("Mixed event analysis: track pool is not ready");
1659 NofEventsinPool = 0;
1664 for (Int_t jMix =0; jMix < NofEventsinPool; jMix++) {// loop on events in the pool; if it is SE analysis, stops at one (index not needed there)
1666 Bool_t analyzetracksTr = fCorrelatorTr->ProcessAssociatedTracks(jMix);// process all the tracks in the aodEvent, by applying the selection cuts
1667 if(!analyzetracksTr) {
1668 AliInfo("AliHFCorrelator::Cannot process the track array");
1672 for(Int_t iTrack = 0; iTrack<fCorrelatorTr->GetNofTracks(); iTrack++){ // looping on track candidates
1674 Bool_t runcorrelation = fCorrelatorTr->Correlate(iTrack);
1675 if(!runcorrelation) continue;
1677 AliReducedParticle* track = fCorrelatorTr->GetAssociatedParticle();
1678 if(track->GetLabel()<0) continue;
1679 if(track->Pt() < fPtThreshLow.at(ptbin) || track->Pt() > fPtThreshUp.at(ptbin)) continue; //discard tracks outside pt range for hadrons/K
1680 if(track->Pt() < 0.3 || TMath::Abs(track->Eta())>0.8) continue; //discard tracks outside barrel (since it's kinematic MC and produces tracks all over rapidity region
1681 if(!fMixing) N_Charg++;
1683 AliAODMCParticle *trkMC = (AliAODMCParticle*)mcArray->At(track->GetLabel());
1684 if(!trkMC) continue;
1686 if (!trkMC->IsPhysicalPrimary()) continue; //reject material budget, or other fake tracks
1687 if (IsDDaughter(d,trkMC,mcArray)) continue;
1688 FillSparsePlots(mcArray,mInv,origD0,PDGD0,track,ptbin,kTrack); //fills for charged tracks
1690 //retrieving leading info...
1691 if(track->Pt() > highPt) {
1692 lead[0] = fCorrelatorTr->GetDeltaPhi();
1693 lead[1] = fCorrelatorTr->GetDeltaEta();
1694 lead[2] = fReadMC ? CheckTrackOrigin(mcArray,trkMC) : 0;
1695 highPt = track->Pt();
1698 } // end of tracks loop
1699 } //end of event loop for fCorrelatorTr
1702 NofEventsinPool = fCorrelatorKc->GetNofEventsInPool();
1704 AliInfo("Mixed event analysis: K+/- pool is not ready");
1705 NofEventsinPool = 0;
1709 //Charged Kaons loop
1710 for (Int_t jMix =0; jMix < NofEventsinPool; jMix++) {// loop on events in the pool; if it is SE analysis, stops at one (index not needed there)
1711 Bool_t analyzetracksKc = fCorrelatorKc->ProcessAssociatedTracks(jMix);
1712 if(!analyzetracksKc) {
1713 AliInfo("AliHFCorrelator::Cannot process the K+/- array");
1717 for(Int_t iTrack = 0; iTrack<fCorrelatorKc->GetNofTracks(); iTrack++){ // looping on charged kaons candidates
1719 Bool_t runcorrelation = fCorrelatorKc->Correlate(iTrack);
1720 if(!runcorrelation) continue;
1722 AliReducedParticle* kCharg = fCorrelatorKc->GetAssociatedParticle();
1723 if(kCharg->GetLabel()<1) continue;
1724 if(kCharg->Pt() < fPtThreshLow.at(ptbin) || kCharg->Pt() > fPtThreshUp.at(ptbin)) continue; //discard tracks outside pt range for hadrons/K
1725 if(TMath::Abs(kCharg->Eta())>0.8) continue; //discard tracks outside barrel (since it's kinematic MC and produces tracks all over rapidity region
1726 if(!fMixing) N_KCharg++;
1728 AliAODMCParticle *kChargMC = (AliAODMCParticle*)mcArray->At(kCharg->GetLabel());
1729 if(!kChargMC) continue;
1731 if (IsDDaughter(d,kChargMC,mcArray)) continue;
1732 FillSparsePlots(mcArray,mInv,origD0,PDGD0,kCharg,ptbin,kKCharg); //fills for charged tracks
1734 } // end of charged kaons loop
1735 } //end of event loop for fCorrelatorKc
1738 NofEventsinPool = fCorrelatorK0->GetNofEventsInPool();
1740 AliInfo("Mixed event analysis: K0 pool is not ready");
1741 NofEventsinPool = 0;
1746 for (Int_t jMix =0; jMix < NofEventsinPool; jMix++) {// loop on events in the pool; if it is SE analysis, stops at one (index not needed there)
1747 Bool_t analyzetracksK0 = fCorrelatorK0->ProcessAssociatedTracks(jMix);
1748 if(!analyzetracksK0) {
1749 AliInfo("AliHFCorrelator::Cannot process the K0 array");
1753 for(Int_t iTrack = 0; iTrack<fCorrelatorK0->GetNofTracks(); iTrack++){ // looping on k0 candidates
1755 Bool_t runcorrelation = fCorrelatorK0->Correlate(iTrack);
1756 if(!runcorrelation) continue;
1758 AliReducedParticle* k0 = fCorrelatorK0->GetAssociatedParticle();
1759 if(k0->GetLabel()<1) continue;
1760 if(k0->Pt() < fPtThreshLow.at(ptbin) || k0->Pt() > fPtThreshUp.at(ptbin)) continue; //discard tracks outside pt range for hadrons/K
1761 if(TMath::Abs(k0->Eta())>0.8) continue; //discard tracks outside barrel (since it's kinematic MC and produces tracks all over rapidity region
1763 AliAODMCParticle *k0MC = (AliAODMCParticle*)mcArray->At(k0->GetLabel());
1766 if (IsDDaughter(d,k0MC,mcArray)) continue;
1767 FillSparsePlots(mcArray,mInv,origD0,PDGD0,k0,ptbin,kK0); //fills for charged tracks
1769 if(!fMixing) N_Kaons++;
1771 } // end of charged kaons loop
1772 } //end of event loop for fCorrelatorK0
1774 Double_t fillSpLeadMC[3] = {lead[0],mD0,lead[1]}; //mD0 = mD0bar = 1.864
1776 //leading track correlations fill
1778 if(d->GetPdgCode()==421) { //D0
1779 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_Bin%d",ptbin)))->Fill(fillSpLeadMC); //c and b D0
1780 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadMC); //c or b D0
1781 if(origD0==4&&(int)lead[2]>=1&&(int)lead[2]<=3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadMC);
1782 if(origD0==5&&(int)lead[2]>=4&&(int)lead[2]<=8) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadMC);
1783 if((int)lead[2]==0) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_NonHF_Bin%d",ptbin)))->Fill(fillSpLeadMC); //non HF
1785 if(d->GetPdgCode()==-421) { //D0bar
1786 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_Bin%d",ptbin)))->Fill(fillSpLeadMC);
1787 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadMC); //c or b D0
1788 if(origD0==4&&(int)lead[2]>=1&&(int)lead[2]<=3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadMC);
1789 if(origD0==5&&(int)lead[2]>=4&&(int)lead[2]<=8) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpLeadMC);
1790 if((int)lead[2]==0) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Lead_NonHF_Bin%d",ptbin)))->Fill(fillSpLeadMC); //non HF
1793 //Fill of count histograms
1794 if (!fAlreadyFilled) {
1795 ((TH1F*)fOutputStudy->FindObject("hist_Count_Charg"))->Fill(N_Charg);
1796 ((TH1F*)fOutputStudy->FindObject("hist_Count_Kcharg"))->Fill(N_KCharg);
1797 ((TH1F*)fOutputStudy->FindObject("hist_Count_K0"))->Fill(N_Kaons);
1800 fAlreadyFilled=kTRUE; //at least a D0 analyzed in the event; distribution plots already filled
1805 //________________________________________________________________________
1806 void AliAnalysisTaskSED0Correlations::FillSparsePlots(TClonesArray* mcArray, Double_t mInv[], Int_t origD0, Int_t PdgD0, AliReducedParticle* track, Int_t ptbin, Int_t type, Double_t wg) {
1808 //fills the THnSparse for correlations, calculating the variables
1811 //Initialization of variables
1812 Double_t mD0, mD0bar, deltaphi = 0., deltaeta = 0.;
1816 if (fReadMC && track->GetLabel()<1) return;
1817 if (fReadMC && !(AliAODMCParticle*)mcArray->At(track->GetLabel())) return;
1818 Double_t ptTrack = track->Pt();
1819 Double_t d0Track = type!=kK0 ? track->GetImpPar() : 0.;
1820 Double_t phiTr = track->Phi();
1821 Double_t origTr = fReadMC ? CheckTrackOrigin(mcArray,(AliAODMCParticle*)mcArray->At(track->GetLabel())) : 0;
1823 TString part = "", orig = "";
1828 deltaphi = fCorrelatorTr->GetDeltaPhi();
1829 deltaeta = fCorrelatorTr->GetDeltaEta();
1834 deltaphi = fCorrelatorKc->GetDeltaPhi();
1835 deltaeta = fCorrelatorKc->GetDeltaEta();
1840 deltaphi = fCorrelatorK0->GetDeltaPhi();
1841 deltaeta = fCorrelatorK0->GetDeltaEta();
1846 if(fMixing == kSE) {
1848 //Fixes limits; needed to include overflow into THnSparse projections!
1849 Double_t pTorig = track->Pt();
1850 Double_t d0orig = track->GetImpPar();
1851 Double_t ptLim_Sparse = ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Charg_Bin%d",ptbin)))->GetAxis(2)->GetXmax(); //all plots have same axes...
1852 Double_t displLim_Sparse = ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Charg_Bin%d",ptbin)))->GetAxis(3)->GetXmax();
1853 Double_t EtaLim_Sparse = ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Charg_Bin%d",ptbin)))->GetAxis(4)->GetXmax();
1854 if(ptTrack > ptLim_Sparse) ptTrack = ptLim_Sparse-0.01;
1855 if(d0Track > displLim_Sparse) d0Track = (displLim_Sparse-0.001);
1856 if(deltaeta > EtaLim_Sparse) deltaeta = EtaLim_Sparse-0.01;
1857 if(deltaeta < -EtaLim_Sparse) deltaeta = -EtaLim_Sparse+0.01;
1859 //variables for filling histos
1860 Double_t fillSpPhiD0[5] = {deltaphi,mD0,ptTrack,d0Track,deltaeta};
1861 Double_t fillSpPhiD0bar[5] = {deltaphi,mD0bar,ptTrack,d0Track,deltaeta};
1862 Double_t fillSpWeigD0[3] = {deltaphi,mD0,deltaeta};
1863 Double_t fillSpWeigD0bar[3] = {deltaphi,mD0bar,deltaeta};
1866 //sparse fill for data (tracks, K+-, K0) + weighted
1867 if(fIsSelectedCandidate == 1 || fIsSelectedCandidate == 3) { //D0
1868 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_Bin%d",part.Data(),ptbin)))->Fill(fillSpPhiD0,wg);
1869 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_Bin%d",ptbin)))->Fill(fillSpWeigD0,pTorig*wg);
1871 if(fIsSelectedCandidate == 2 || fIsSelectedCandidate == 3) { //D0bar
1872 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_Bin%d",part.Data(),ptbin)))->Fill(fillSpPhiD0bar,wg);
1873 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_Bin%d",ptbin)))->Fill(fillSpWeigD0bar,pTorig*wg);
1875 if(!fAlreadyFilled) {
1876 ((TH1F*)fOutputStudy->FindObject(Form("hist_Pt_%s_Bin%d",part.Data(),ptbin)))->Fill(pTorig);
1877 ((TH1F*)fOutputStudy->FindObject(Form("hist_PhiDistr_%s",part.Data())))->Fill(phiTr);
1883 if(origD0==4) {orig = "_From_c";} else {orig = "_From_b";}
1885 //sparse fill for data (tracks, K+-, K0) + weighted
1886 if(PdgD0==421) { //D0 (from MCTruth)
1887 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_Bin%d",part.Data(),ptbin)))->Fill(fillSpPhiD0,wg);
1888 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s%s_Bin%d",part.Data(),orig.Data(),ptbin)))->Fill(fillSpPhiD0,wg);
1889 if(origD0==4&&origTr>=1&&origTr<=3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_HF%s_Bin%d",part.Data(),orig.Data(),ptbin)))->Fill(fillSpPhiD0,wg);
1890 if(origD0==5&&origTr>=4&&origTr<=8) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_HF%s_Bin%d",part.Data(),orig.Data(),ptbin)))->Fill(fillSpPhiD0,wg);
1891 if(origTr==0) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_NonHF_Bin%d",part.Data(),ptbin)))->Fill(fillSpPhiD0,wg);
1892 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_Bin%d",ptbin)))->Fill(fillSpWeigD0,pTorig*wg);
1893 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpWeigD0,pTorig*wg);
1894 if(origD0==4&&origTr>=1&&origTr<=3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpWeigD0,pTorig*wg);
1895 if(origD0==5&&origTr>=4&&origTr<=8) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpWeigD0,pTorig*wg);
1896 if(origTr==0) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_NonHF_Bin%d",ptbin)))->Fill(fillSpWeigD0,pTorig*wg);
1898 if(PdgD0==-421) { //D0bar
1899 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_Bin%d",part.Data(),ptbin)))->Fill(fillSpPhiD0bar,wg);
1900 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s%s_Bin%d",part.Data(),orig.Data(),ptbin)))->Fill(fillSpPhiD0bar,wg);
1901 if(origD0==4&&origTr>=1&&origTr<=3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_HF%s_Bin%d",part.Data(),orig.Data(),ptbin)))->Fill(fillSpPhiD0bar,wg);
1902 if(origD0==5&&origTr>=4&&origTr<=8) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_HF%s_Bin%d",part.Data(),orig.Data(),ptbin)))->Fill(fillSpPhiD0bar,wg);
1903 if(origTr==0) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_NonHF_Bin%d",part.Data(),ptbin)))->Fill(fillSpPhiD0bar,wg);
1904 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_Bin%d",ptbin)))->Fill(fillSpWeigD0bar,pTorig*wg);
1905 ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpWeigD0bar,pTorig*wg);
1906 if(origD0==4&&origTr>=1&&origTr<=3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpWeigD0bar,pTorig*wg);
1907 if(origD0==5&&origTr>=4&&origTr<=8) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_HF%s_Bin%d",orig.Data(),ptbin)))->Fill(fillSpWeigD0bar,pTorig*wg);
1908 if(origTr==0) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Weig_NonHF_Bin%d",ptbin)))->Fill(fillSpWeigD0bar,pTorig*wg);
1910 if(!fAlreadyFilled) {
1911 ((TH1F*)fOutputStudy->FindObject(Form("histDispl_%s_Bin%d",part.Data(),ptbin)))->Fill(d0orig); //Fills displacement histos
1912 if (origTr>=1&&origTr<=8) ((TH1F*)fOutputStudy->FindObject(Form("histDispl_%s_HF_Bin%d",part.Data(),ptbin)))->Fill(d0orig);
1913 if (origTr>=1&&origTr<=8) ((TH1F*)fOutputStudy->FindObject(Form("histDispl_%s_HF%s_Bin%d",part.Data(),orig.Data(),ptbin)))->Fill(d0orig);
1914 ((TH1F*)fOutputStudy->FindObject(Form("histDispl_%s%s_Bin%d",part.Data(),orig.Data(),ptbin)))->Fill(d0orig); //Fills displacement histos
1915 ((TH1F*)fOutputStudy->FindObject(Form("hist_Pt_%s_Bin%d",part.Data(),ptbin)))->Fill(pTorig);
1916 ((TH1F*)fOutputStudy->FindObject(Form("histOrig_%s_Bin%d",part.Data(),ptbin)))->Fill(origTr);
1917 ((TH1F*)fOutputStudy->FindObject(Form("hist_PhiDistr_%s",part.Data())))->Fill(phiTr);
1923 if(fMixing == kME) {
1925 //Fixes limits; needed to include overflow into THnSparse projections!
1926 Double_t EtaLim_Sparse = ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_Charg_Bin%d_EvMix",ptbin)))->GetAxis(2)->GetXmax();
1927 if(deltaeta > EtaLim_Sparse) deltaeta = EtaLim_Sparse-0.01;
1928 if(deltaeta < -EtaLim_Sparse) deltaeta = -EtaLim_Sparse+0.01;
1930 //variables for filling histos
1931 Double_t fillSpPhiD0[3] = {deltaphi,mD0,deltaeta};
1932 Double_t fillSpPhiD0bar[3] = {deltaphi,mD0bar,deltaeta};
1935 //sparse fill for data (tracks, K+-, K0)
1936 if(fIsSelectedCandidate == 1||fIsSelectedCandidate == 3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_Bin%d_EvMix",part.Data(),ptbin)))->Fill(fillSpPhiD0,wg);
1937 if(fIsSelectedCandidate == 2||fIsSelectedCandidate == 3) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_Bin%d_EvMix",part.Data(),ptbin)))->Fill(fillSpPhiD0bar,wg);
1940 //sparse fill for data (tracks, K+-, K0)
1941 if(PdgD0==421) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_Bin%d_EvMix",part.Data(),ptbin)))->Fill(fillSpPhiD0,wg);
1942 if(PdgD0==-421) ((THnSparseF*)fOutputCorr->FindObject(Form("hPhi_%s_Bin%d_EvMix",part.Data(),ptbin)))->Fill(fillSpPhiD0bar,wg);
1950 //_________________________________________________________________________________________________
1951 Int_t AliAnalysisTaskSED0Correlations::CheckTrackOrigin(TClonesArray* arrayMC, AliAODMCParticle *mcPartCandidate) const {
1953 // checks on particle (#) origin:
1957 // 3) c hadronization
1959 // 5) B->X-># (X!=D)
1962 // 8) b hadronization
1964 if(fDebug>2) printf("AliAnalysisTaskSED0Correlations::CheckTrkOrigin() \n");
1966 Int_t pdgGranma = 0;
1968 mother = mcPartCandidate->GetMother();
1970 Int_t abspdgGranma =0;
1971 Bool_t isFromB=kFALSE;
1972 Bool_t isDdaugh=kFALSE;
1973 Bool_t isDchaindaugh=kFALSE;
1974 Bool_t isBdaugh=kFALSE;
1975 Bool_t isBchaindaugh=kFALSE;
1976 Bool_t isQuarkFound=kFALSE;
1978 if (mother<0) return -1;
1979 while (mother >= 0){
1981 AliAODMCParticle* mcMoth = dynamic_cast<AliAODMCParticle*>(arrayMC->At(mother));
1983 pdgGranma = mcMoth->GetPdgCode();
1984 abspdgGranma = TMath::Abs(pdgGranma);
1985 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)){
1986 isBchaindaugh=kTRUE;
1987 if(istep==1) isBdaugh=kTRUE;
1989 if ((abspdgGranma > 400 && abspdgGranma < 500) || (abspdgGranma > 4000 && abspdgGranma < 5000)){
1990 isDchaindaugh=kTRUE;
1991 if(istep==1) isDdaugh=kTRUE;
1993 if(abspdgGranma==4 || abspdgGranma==5) {isQuarkFound=kTRUE; if(abspdgGranma==5) isFromB = kTRUE;}
1994 mother = mcMoth->GetMother();
1996 AliError("Failed casting the mother particle!");
2001 //decides what to return based on the flag status
2003 if(!isFromB) { //charm
2004 if(isDdaugh) return 1; //charm immediate
2005 else if(isDchaindaugh) return 2; //charm chain
2006 else return 3; //charm hadronization
2009 if(isBdaugh) return 4; //b immediate
2010 else if(isBchaindaugh) { //b chain
2012 if(isDdaugh) return 6; //d immediate
2015 else return 5; //b, not d
2017 else return 8; //b hadronization
2020 else if(!isDdaugh && !isDchaindaugh && !isBdaugh && !isBchaindaugh) return 0; //no HF decay
2021 //in this case, it's !isQuarkFound, but not in 100% cases it's a non HF particle!
2022 //rarely you can find a D/B meson which comes from a -1! It isn't a Non-HF, in that case! And I'll return -1...
2024 return -1; //some problem spotted
2026 //________________________________________________________________________
2027 Bool_t AliAnalysisTaskSED0Correlations::IsDDaughter(AliAODMCParticle* d, AliAODMCParticle* track, TClonesArray* mcArray) const {
2029 //Daughter removal in MCKine case
2030 Bool_t isDaughter = kFALSE;
2031 Int_t labelD0 = d->GetLabel();
2033 Int_t mother = track->GetMother();
2035 //Loop on the mothers to find the D0 label (it must be the trigger D0, not a generic D0!)
2037 AliAODMCParticle* mcMoth = dynamic_cast<AliAODMCParticle*>(mcArray->At(mother)); //it's the mother of the track!
2039 if (mcMoth->GetLabel() == labelD0) isDaughter = kTRUE;
2040 mother = mcMoth->GetMother(); //goes back by one
2042 AliError("Failed casting the mother particle!");
2050 //________________________________________________________________________
2051 Int_t AliAnalysisTaskSED0Correlations::PtBinCorr(Double_t pt) const {
2053 //give the pt bin where the pt lies.
2056 if(pt<fBinLimsCorr.at(0)) return ptbin; //out of bounds
2059 while(pt>fBinLimsCorr.at(i)) {ptbin=i; i++;}
2064 //---------------------------------------------------------------------------
2065 Bool_t AliAnalysisTaskSED0Correlations::SelectV0(AliAODv0* v0, AliAODVertex *vtx, Int_t opt, Int_t idArrayV0[][2]) const
2068 // Selection for K0 hypotheses
2069 // options: 1 = selects mass invariant about 3 sigma inside the peak + threshold of 0.3 GeV
2070 // 2 = no previous selections
2072 if(!fCutsTracks->IsKZeroSelected(v0,vtx)) return kFALSE;
2074 AliAODTrack *v0Daug1 = (AliAODTrack*)v0->GetDaughter(0);
2075 AliAODTrack *v0Daug2 = (AliAODTrack*)v0->GetDaughter(1);
2077 if(opt==1) { //additional cuts for correlations (V0 has to be closer than 3 sigma from K0 mass)
2078 if(TMath::Abs(v0->MassK0Short()-0.4976) > 3*0.004) return kFALSE;
2081 //This part removes double counting for swapped tracks!
2082 Int_t i = 0; //while loop (until the last-written entry pair of ID!
2083 while(idArrayV0[i][0]!=-2 && idArrayV0[i][1]!=-2) {
2084 if((v0Daug1->GetID()==idArrayV0[i][0] && v0Daug2->GetID()==idArrayV0[i][1])||
2085 (v0Daug1->GetID()==idArrayV0[i][1] && v0Daug2->GetID()==idArrayV0[i][0])) return kFALSE;
2088 idArrayV0[i][0]=v0Daug1->GetID();
2089 idArrayV0[i][1]=v0Daug2->GetID();
2094 //________________________________________________________________________
2095 void AliAnalysisTaskSED0Correlations::PrintBinsAndLimits() {
2097 cout << "--------------------------\n";
2098 cout << "PtBins = " << fNPtBinsCorr << "\n";
2099 cout << "PtBin limits--------------\n";
2100 for (int i=0; i<fNPtBinsCorr; i++) {
2101 cout << "Bin "<<i+1<<" = "<<fBinLimsCorr.at(i)<<" to "<<fBinLimsCorr.at(i+1)<<"\n";
2103 cout << "\n--------------------------\n";
2104 cout << "PtBin tresh. tracks low---\n";
2105 for (int i=0; i<fNPtBinsCorr; i++) {
2106 cout << fPtThreshLow.at(i) << "; ";
2108 cout << "PtBin tresh. tracks up----\n";
2109 for (int i=0; i<fNPtBinsCorr; i++) {
2110 cout << fPtThreshUp.at(i) << "; ";
2112 cout << "\n--------------------------\n";
2113 cout << "D0 Eta cut for Correl = "<<fEtaForCorrel<<"\n";
2114 cout << "--------------------------\n";
2115 cout << "MC Truth = "<<fReadMC<<" - MC Reco: Trk = "<<fRecoTr<<", D0 = "<<fRecoD0<<"\n";
2116 cout << "--------------------------\n";
2117 cout << "Sel of Event tpye (PP,GS,FE,...)= "<<fSelEvType<<"\n";
2118 cout << "--------------------------\n";
2119 cout << "Ev Mixing = "<<fMixing<<"\n";
2120 cout << "--------------------------\n";