1 /**************************************************************************
2 * Copyright(c) 1998-2009, 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 **************************************************************************/
17 // Base class for DStar - Hadron Correlations Analysis
19 //-----------------------------------------------------------------------
22 // Author S.Bjelogrlic
24 // sandro.bjelogrlic@cern.ch
26 //-----------------------------------------------------------------------
30 //#include <TDatabasePDG.h>
31 #include <TParticle.h>
36 #include "AliAnalysisTaskDStarCorrelations.h"
37 #include "AliRDHFCutsDStartoKpipi.h"
38 #include "AliHFAssociatedTrackCuts.h"
39 #include "AliAODRecoDecay.h"
40 #include "AliAODRecoCascadeHF.h"
41 #include "AliAODRecoDecayHF2Prong.h"
42 #include "AliAODPidHF.h"
43 #include "AliVParticle.h"
44 #include "AliAnalysisManager.h"
45 #include "AliAODInputHandler.h"
46 #include "AliAODHandler.h"
47 #include "AliESDtrack.h"
48 #include "AliAODMCParticle.h"
49 #include "AliNormalizationCounter.h"
50 #include "AliReducedParticle.h"
51 #include "AliHFCorrelator.h"
52 #include "AliAODMCHeader.h"
53 #include "AliEventPoolManager.h"
59 ClassImp(AliAnalysisTaskDStarCorrelations)
62 //__________________________________________________________________________
63 AliAnalysisTaskDStarCorrelations::AliAnalysisTaskDStarCorrelations() :
83 // default constructor
86 //__________________________________________________________________________
87 AliAnalysisTaskDStarCorrelations::AliAnalysisTaskDStarCorrelations(const Char_t* name,AliRDHFCutsDStartoKpipi* cuts, AliHFAssociatedTrackCuts *AsscCuts) :
88 AliAnalysisTaskSE(name),
109 Info("AliAnalysisTaskDStarCorrelations","Calling Constructor");
110 DefineInput(0, TChain::Class());
112 DefineOutput(1,TList::Class()); // histos from data and MC
113 DefineOutput(2,TList::Class()); // histos from MC
114 DefineOutput(3,AliRDHFCutsDStartoKpipi::Class()); // my D meson cuts
115 DefineOutput(4,AliHFAssociatedTrackCuts::Class()); // my associated tracks cuts
116 DefineOutput(5,AliNormalizationCounter::Class()); // normalization
119 //__________________________________________________________________________
121 AliAnalysisTaskDStarCorrelations::~AliAnalysisTaskDStarCorrelations() {
126 Info("AliAnalysisTaskDStarCorrelations","Calling Destructor");
128 if(fhandler) {delete fhandler; fhandler = 0;}
129 //if(fPoolMgr) {delete fPoolMgr; fPoolMgr = 0;}
130 if(fmcArray) {delete fmcArray; fmcArray = 0;}
131 if(fCounter) {delete fCounter; fCounter = 0;}
132 if(fCorrelator) {delete fCorrelator; fCorrelator = 0;}
133 if(fOutput) {delete fOutput; fOutput = 0;}
134 if(fOutputMC) {delete fOutputMC; fOutputMC = 0;}
135 if(fCuts) {delete fCuts; fCuts = 0;}
136 if(fCuts2) {delete fCuts2; fCuts2=0;}
140 //___________________________________________________________
141 void AliAnalysisTaskDStarCorrelations::Init(){
145 if(fDebugLevel > 1) printf("AliAnalysisTaskDStarCorrelations::Init() \n");
147 AliRDHFCutsDStartoKpipi* copyfCuts=new AliRDHFCutsDStartoKpipi(*fCuts);
153 PostData(3,copyfCuts);
155 // Post the hadron cuts
164 //_________________________________________________
165 void AliAnalysisTaskDStarCorrelations::UserCreateOutputObjects(){
166 Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
170 fOutput = new TList();
173 fOutputMC = new TList();
174 fOutputMC->SetOwner();
177 DefineHistoForAnalysis();
178 fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(5)->GetContainer()->GetName()));
181 Double_t Pi = TMath::Pi();
182 fCorrelator = new AliHFCorrelator("Correlator",fCuts2,fSystem); // fCuts2 is the hadron cut object, fSystem to switch between pp or PbPb
183 fCorrelator->SetDeltaPhiInterval((-0.5-1./32)*Pi,(1.5-1./32)*Pi); // set correct phi interval
184 fCorrelator->SetEventMixing(fmixing); //set kFALSE/kTRUE for mixing Off/On
185 fCorrelator->SetAssociatedParticleType(fselect); // set 1/2/3 for hadron/kaons/kzeros
186 fCorrelator->SetApplyDisplacementCut(fDisplacement); //set kFALSE/kTRUE for using the displacement cut
187 fCorrelator->SetUseMC(fmontecarlo);
188 fCorrelator->SetUseReco(fReco);
189 Bool_t pooldef = fCorrelator->DefineEventPool();
191 if(!pooldef) AliInfo("Warning:: Event pool not defined properly");
195 PostData(1,fOutput); // set the outputs
196 PostData(2,fOutputMC); // set the outputs
197 PostData(5,fCounter); // set the outputs
199 //_________________________________________________
200 void AliAnalysisTaskDStarCorrelations::UserExec(Option_t *){
205 if(fReco) std::cout << "USING RECONSTRUCTION" << std::endl;
206 if(!fReco) std::cout << "USING MC TRUTH" << std::endl;
207 std::cout << " " << std::endl;
208 std::cout << "=================================================================================" << std::endl;
210 if(fselect==1) std::cout << "TASK::Correlation with hadrons on SE "<< std::endl;
211 if(fselect==2) std::cout << "TASK::Correlation with kaons on SE "<< std::endl;
212 if(fselect==3) std::cout << "TASK::Correlation with kzeros on SE "<< std::endl;
215 if(fselect==1) std::cout << "TASK::Correlation with hadrons on ME "<< std::endl;
216 if(fselect==2) std::cout << "TASK::Correlation with kaons on ME "<< std::endl;
217 if(fselect==3) std::cout << "TASK::Correlation with kzeros on ME "<< std::endl;
223 Error("UserExec","NO EVENT FOUND!");
227 AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
229 AliError("AOD event not found!");
235 fEvents++; // event counter
236 ((TH1D*)fOutput->FindObject("NofEvents"))->Fill(0);
237 fCounter->StoreEvent(aodEvent,fCuts,fmontecarlo);
240 fmcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
241 if(fmontecarlo && !fmcArray){
242 AliError("Array of MC particles not found");
249 Bool_t isEvSel=fCuts->IsEventSelected(aodEvent);
252 fCorrelator->SetAODEvent(aodEvent); // set the event to be processed
254 ((TH1D*)fOutput->FindObject("NofEvents"))->Fill(1);
256 Bool_t correlatorON = fCorrelator->Initialize(); //define the pool for mixing
258 AliInfo("AliHFCorrelator didn't initialize the pool correctly or processed a bad event");
261 ((TH1D*)fOutput->FindObject("NofEvents"))->Fill(2);
263 if(fmontecarlo) fCorrelator->SetMCArray(fmcArray);
266 // check the event type
270 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
271 if (fmontecarlo && !mcHeader) {
272 AliError("Could not find MC Header in AOD");
276 Bool_t isMCeventgood = kFALSE;
279 Int_t eventType = mcHeader->GetEventType();
280 Int_t NMCevents = fCuts2->GetNofMCEventType();
282 for(Int_t k=0; k<NMCevents; k++){
283 Int_t * MCEventType = fCuts2->GetMCEventType();
285 if(eventType == MCEventType[k]) isMCeventgood= kTRUE;
286 ((TH1D*)fOutputMC->FindObject("EventTypeMC"))->Fill(eventType);
289 if(NMCevents && !isMCeventgood){
290 if(fDebugLevel) std::cout << "The MC event " << eventType << " not interesting for this analysis: skipping" << std::endl;
294 } // end if montecarlo
297 TClonesArray *arrayDStartoD0pi=0;
298 if(!aodEvent && AODEvent() && IsStandardAOD()) {
299 // In case there is an AOD handler writing a standard AOD, use the AOD
300 // event in memory rather than the input (ESD) event.
301 aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
302 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
303 // have to taken from the AOD event hold by the AliAODExtension
304 AliAODHandler* aodHandler = (AliAODHandler*)
305 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
306 if(aodHandler->GetExtensions()) {
307 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
308 AliAODEvent *aodFromExt = ext->GetAOD();
309 arrayDStartoD0pi=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
312 arrayDStartoD0pi=(TClonesArray*)aodEvent->GetList()->FindObject("Dstar");
315 if(!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField())<0.001) return;
317 // initialize variables you will need for the D*
322 Bool_t isInPeak, isInSideBand, isDStarMCtag;
323 Double_t invMassDZero;
324 Double_t deltainvMDStar;
327 Double_t mPDGD0=1.8648;//TDatabasePDG::Instance()->GetParticle(421)->Mass();
328 Double_t mPDGDstar=2.01022;//TDatabasePDG::Instance()->GetParticle(413)->Mass();
331 //MC tagging for DStar
332 //D* and D0 prongs needed to MatchToMC method
333 Int_t pdgDgDStartoD0pi[2]={421,211};
334 Int_t pdgDgD0toKpi[2]={321,211};
336 Bool_t isDStarCand = kFALSE;
337 //loop on D* candidates
338 for (Int_t iDStartoD0pi = 0; iDStartoD0pi<arrayDStartoD0pi->GetEntriesFast(); iDStartoD0pi++) {
340 isInSideBand = kFALSE;
341 isDStarMCtag = kFALSE;
345 invMassDZero = - 999;
346 deltainvMDStar = -998;
348 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)arrayDStartoD0pi->At(iDStartoD0pi);
349 if(!dstarD0pi->GetSecondaryVtx()) continue;
350 AliAODRecoDecayHF2Prong* theD0particle = (AliAODRecoDecayHF2Prong*)dstarD0pi->Get2Prong();
351 if (!theD0particle) continue;
354 // track quality cuts
355 Int_t isTkSelected = fCuts->IsSelected(dstarD0pi,AliRDHFCuts::kTracks); // quality cuts on tracks
356 // region of interest + topological cuts + PID
357 Int_t isSelected=fCuts->IsSelected(dstarD0pi,AliRDHFCuts::kCandidate); //selected
359 if(!isTkSelected) continue;
360 if(!isSelected) continue;
361 if(!fCuts->IsInFiducialAcceptance(dstarD0pi->Pt(),dstarD0pi->YDstar())) continue;
362 Int_t mcLabelDStar = -999;
364 // find associated MC particle for D* ->D0toKpi
365 mcLabelDStar = dstarD0pi->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,fmcArray,kFALSE);
366 if(mcLabelDStar>=0) isDStarMCtag = kTRUE;
369 ptDStar = dstarD0pi->Pt();
370 phiDStar = dstarD0pi->Phi();
371 etaDStar = dstarD0pi->Eta();
373 phiDStar = fCorrelator->SetCorrectPhiRange(phiDStar); // set the phi of the D meson in the correct range
375 Int_t ptbin=fCuts->PtBin(dstarD0pi->Pt());
377 Double_t dmDStarWindow =0.0019;// 0.0019 = 3 sigma
378 Double_t mD0Window=0.074;
381 if (ptbin==1) mD0Window = 0.026; //0.5-1
382 if (ptbin==2) mD0Window = 0.022; //1-2
383 if (ptbin==3) mD0Window = 0.024; //2-3
384 if (ptbin==4) mD0Window = 0.032;
385 if (ptbin==5) mD0Window = 0.032;
386 if (ptbin==6) mD0Window = 0.036;
387 if (ptbin==7) mD0Window = 0.036;
388 if (ptbin==8) mD0Window = 0.036;
389 if (ptbin==9) mD0Window = 0.058;
390 if (ptbin==10) mD0Window = 0.058;
391 if (ptbin>10) mD0Window = 0.074;
394 if (ptbin==0) mD0Window = 0.032; //1-1
395 if (ptbin==1) mD0Window = 0.032; //2-3
396 if (ptbin==2) mD0Window = 0.032; //3-4
397 if (ptbin==3) mD0Window = 0.032; //4-5
398 if (ptbin==4) mD0Window = 0.036; //5-6
399 if (ptbin==5) mD0Window = 0.036; //6-8
400 if (ptbin==6) mD0Window = 0.055; //8-12
401 if (ptbin==7) mD0Window = 0.074; //12-16
402 if (ptbin==8) mD0Window = 0.074; //16-24
403 if (ptbin==9) mD0Window = 0.074; //24-35
406 invMassDZero = dstarD0pi->InvMassD0();
407 ((TH2F*)fOutput->FindObject("D0InvMass"))->Fill(ptDStar,invMassDZero);
409 deltainvMDStar = dstarD0pi->DeltaInvMass();
413 if (TMath::Abs(invMassDZero-mPDGD0)<mD0Window){
415 ((TH2F*)fOutput->FindObject("DeltaInvMass"))->Fill(ptDStar,deltainvMDStar);
416 if(TMath::Abs(deltainvMDStar-(mPDGDstar-mPDGD0))<dmDStarWindow){ // is in DStar peak region?
418 ((TH1F*)fOutput->FindObject("RecoPtDStar"))->Fill(ptDStar);
420 ((TH2F*)fOutput->FindObject("PhiEtaTrigger"))->Fill(phiDStar,etaDStar);
422 }// end if good candidates
425 if (TMath::Abs(invMassDZero-mPDGD0)>1.3*mD0Window && TMath::Abs(invMassDZero-mPDGD0)<4.*mD0Window ){
426 ((TH2F*)fOutput->FindObject("bkgDeltaInvMass"))->Fill(ptDStar,deltainvMDStar);
427 ((TH2F*)fOutput->FindObject("D0InvMassinSB"))->Fill(ptDStar,invMassDZero);
429 if(TMath::Abs(deltainvMDStar-(mPDGDstar-mPDGD0))<dmDStarWindow){ // is in DStar peak region?
430 ((TH1F*)fOutput->FindObject("RecoPtBkg"))->Fill(ptDStar);
431 isInSideBand = kTRUE;
432 ((TH2F*)fOutput->FindObject("PhiEtaSideBand"))->Fill(phiDStar,etaDStar);
436 // getting the number of triggers in the MCtag D* case
439 if(fmontecarlo && isDStarMCtag) ((TH1F*)fOutput->FindObject("MCtagPtDStar"))->Fill(ptDStar);
442 if(!isInPeak && !isInSideBand) continue; // skip if it is not side band or peak event - SAVE CPU TIME
446 fCorrelator->SetTriggerParticleProperties(ptDStar,phiDStar,etaDStar); // pass to the object the necessary trigger part parameters
448 Short_t daughtercharge = ((AliAODTrack*)theD0particle->GetDaughter(0))->Charge();
449 fCorrelator->SetTriggerParticleDaughterCharge(daughtercharge);
452 Int_t trackiddaugh0 = ((AliAODTrack*)theD0particle->GetDaughter(0))->GetID();
453 Int_t trackiddaugh1 = ((AliAODTrack*)theD0particle->GetDaughter(1))->GetID();
454 Int_t trackidsoftPi = ((AliAODTrack*)dstarD0pi->GetBachelor())->GetID();
456 Bool_t execPool = fCorrelator->ProcessEventPool();
457 if(fmixing && !execPool) {
458 AliInfo("Mixed event analysis: pool is not ready");
462 Int_t NofEventsinPool = 1;
463 if(fmixing) NofEventsinPool = fCorrelator->GetNofEventsInPool();
465 for (Int_t jMix =0; jMix < NofEventsinPool; jMix++){// loop on events in the pool; if it is SE analysis, stops at one
467 Bool_t analyzetracks = fCorrelator->ProcessAssociatedTracks(jMix);
470 AliInfo("AliHFCorrelator::Cannot process the track array");
474 //initialization of variables for correlations with leading particles
475 Double_t DeltaPhiLeading = -999.;
476 Double_t DeltaEtaLeading = -999.;
477 //Double_t ptleading = -999.;
478 Int_t labelleading = -999;
480 Int_t NofTracks = fCorrelator->GetNofTracks();
482 for(Int_t iTrack = 0; iTrack<NofTracks; iTrack++){ // looping on track candidates
484 Bool_t runcorrelation = fCorrelator->Correlate(iTrack);
485 if(!runcorrelation) continue;
487 Double_t DeltaPhi = fCorrelator->GetDeltaPhi();
488 Double_t DeltaEta = fCorrelator->GetDeltaEta();
490 AliReducedParticle * hadron = fCorrelator->GetAssociatedParticle();
492 Double_t ptHad = hadron->Pt();
493 Double_t phiHad = hadron->Phi();
494 Double_t etaHad = hadron->Eta();
495 Double_t label = hadron->GetLabel();
496 Int_t trackid = hadron->GetID();
498 phiHad = fCorrelator->SetCorrectPhiRange(phiHad);
500 if(!fmixing){ // skip D* Daughetrs
501 if(trackid == trackiddaugh0) continue;
502 if(trackid == trackiddaugh1) continue;
503 if(trackid == trackidsoftPi) continue;
506 // from here on it is up to the user to decide what object to fill
508 if(fmontecarlo && isDStarMCtag){ // check correlations of MC tagged DStars in MonteCarlo
510 Bool_t* PartSource = fCuts2->IsMCpartFromHF(label,fmcArray); // check source of associated particle (hadron/kaon/K0)
511 FillMCTagCorrelations(ptDStar,DeltaPhi,DeltaEta,ptHad,PartSource);
514 ((TH3F*)fOutputMC->FindObject("MCPhiEtaPart"))->Fill(phiHad,etaHad,0);
515 if(PartSource[0]) ((TH3F*)fOutputMC->FindObject("MCPhiEtaPart"))->Fill(phiHad,etaHad,1);
516 if(PartSource[1]) ((TH3F*)fOutputMC->FindObject("MCPhiEtaPart"))->Fill(phiHad,etaHad,2);
517 if(PartSource[2]&&PartSource[0]) ((TH3F*)fOutputMC->FindObject("MCPhiEtaPart"))->Fill(phiHad,etaHad,3);
518 if(PartSource[2]&&PartSource[1]) ((TH3F*)fOutputMC->FindObject("MCPhiEtaPart"))->Fill(phiHad,etaHad,4);
519 if(PartSource[3]) ((TH3F*)fOutputMC->FindObject("MCPhiEtaPart"))->Fill(phiHad,etaHad,5);
526 if(fselect==1) ((TH3D*)fOutput->FindObject("DPhiDStarHadron"))->Fill(DeltaPhi,ptDStar,DeltaEta);
527 if(fselect==2) ((TH3D*)fOutput->FindObject("DPhiDStarKaon"))->Fill(DeltaPhi,ptDStar,DeltaEta);
528 if(fselect==3) ((TH3D*)fOutput->FindObject("DPhiDStarKZero"))->Fill(DeltaPhi,ptDStar,DeltaEta);
529 ((TH2F*)fOutput->FindObject("PhiEtaPart"))->Fill(phiHad,etaHad);
530 //counterPeak++; // count tracks per peak per event
536 if(fselect==1) ((TH3D*)fOutput->FindObject("bkgDPhiDStarHadron"))->Fill(DeltaPhi,ptDStar,DeltaEta);
537 if(fselect==2) ((TH3D*)fOutput->FindObject("bkgDPhiDStarKaon"))->Fill(DeltaPhi,ptDStar,DeltaEta);
538 if(fselect==3) ((TH3D*)fOutput->FindObject("bkgDPhiDStarKZero"))->Fill(DeltaPhi,ptDStar,DeltaEta);
546 } // end loop on track candidates
548 // fill the leading particle histograms
550 if(isInPeak) ((TH3D*)fOutput->FindObject("LeadingCand"))->Fill(DeltaPhiLeading,ptDStar,DeltaEtaLeading);
551 if(isInSideBand) ((TH3D*)fOutput->FindObject("LeadingSB"))->Fill(DeltaPhiLeading,ptDStar,DeltaEtaLeading);
553 if(fmontecarlo && isDStarMCtag){
554 Bool_t* LeadPartSource = fCuts2->IsMCpartFromHF(labelleading,fmcArray);
555 FillMCTagLeadingCorrelations(ptDStar,DeltaPhiLeading,DeltaEtaLeading,LeadPartSource);
559 } // end loop on events in the pool
561 }// end loop on D* candidates
564 Bool_t updated = fCorrelator->PoolUpdate();
566 if(updated) EventMixingChecks(aodEvent);
567 if(!updated) AliInfo("Pool was not updated");
574 //________________________________________ terminate ___________________________
575 void AliAnalysisTaskDStarCorrelations::Terminate(Option_t*)
577 // The Terminate() function is the last function to be called during
578 // a query. It always runs on the client, it can be used to present
579 // the results graphically or save the results to file.
581 AliAnalysisTaskSE::Terminate();
583 fOutput = dynamic_cast<TList*> (GetOutputData(1));
585 printf("ERROR: fOutput not available\n");
593 //_____________________________________________________
594 void AliAnalysisTaskDStarCorrelations::DefineHistoForAnalysis(){
596 Double_t Pi = TMath::Pi();
597 Int_t nbinscorr = 32;
598 Double_t lowcorrbin = -0.5*Pi - Pi/32; // shift the bin by half the width so that at 0 is it the bin center
599 Double_t upcorrbin = 1.5*Pi - Pi/32;
601 // ========================= histograms for both Data and MonteCarlo
604 TH1D * NofEvents = new TH1D("NofEvents","NofEvents",11,0,11);
605 fOutput->Add(NofEvents);
611 TH2F *D0InvMass = new TH2F("D0InvMass","K#pi invariant mass distribution",300,0,30,1500,0.5,3.5);
612 fOutput->Add(D0InvMass);
614 TH2F *D0InvMassinSB = new TH2F("D0InvMassinSB","K#pi invariant mass distribution in sb",300,0,30,1500,0.5,3.5);
615 fOutput->Add(D0InvMassinSB);
617 TH2F *DeltaInvMass = new TH2F("DeltaInvMass","K#pi#pi - K#pi invariant mass distribution",300,0,30,750,0.1,0.2);
618 fOutput->Add(DeltaInvMass);
620 TH2F *bkgDeltaInvMass = new TH2F("bkgDeltaInvMass","K#pi#pi - K#pi invariant mass distribution",300,0,30,750,0.1,0.2);
621 fOutput->Add(bkgDeltaInvMass);
623 TH1F *RecoPtDStar = new TH1F("RecoPtDStar","RECO DStar pt distribution",50,0,50);
624 fOutput->Add(RecoPtDStar);
626 TH1F *RecoPtBkg = new TH1F("RecoPtBkg","RECO pt distribution side bands",50,0,50);
627 fOutput->Add(RecoPtBkg);
629 TH1F *MCtagPtDStar = new TH1F("MCtagPtDStar","RECO pt of MCtagged DStars side bands",50,0,50);
630 fOutput->Add(MCtagPtDStar);
632 TH2F *KZeroSpectra = new TH2F("KZeroSpectra","Spectra of K0s",500,0.3,0.8,250,0,25);
633 if(fselect==3) fOutput->Add(KZeroSpectra);
635 TH2F *KZeroSpectraifHF = new TH2F("KZeroSpectraifHF","Spectra of K0s in association with a D*",500,0.3,0.8,250,0,25);
636 if(fselect==3) fOutput->Add(KZeroSpectraifHF);
638 TH1D * NofTracksInPeak = new TH1D("NofTracksInPeak","NofTracksInPeak",500,0.5,500.5);
639 fOutput->Add(NofTracksInPeak);
641 TH1D * NofTracksInSB = new TH1D("NofTracksInSB","NofTracksInSB",500,0.5,500.5);
642 fOutput->Add(NofTracksInSB);
644 TH2I * EventMixingCheck = new TH2I("EventMixingCheck","EventMixingCheck",5,-0.5,4.5,7,-0.5,6.5);
645 if(fmixing) fOutput->Add(EventMixingCheck);
651 TH2F * PhiEtaTrigger = new TH2F("PhiEtaTrigger","#phi distribution of the trigger particle",36,-0.5*Pi,1.5*Pi,18,-0.9,0.9);
652 fOutput->Add(PhiEtaTrigger);
654 TH2F * PhiEtaSideBand = new TH2F("PhiEtaSideBand","#phi distribution of the sideband particle",36,-0.5*Pi,1.5*Pi,18,-0.9,0.9);
655 fOutput->Add(PhiEtaSideBand);
657 TH2F * PhiEtaPart = new TH2F("PhiEtaPart","#phi distribution of the associated particle",36,-0.5*Pi,1.5*Pi,18,-0.9,0.9);
658 fOutput->Add(PhiEtaPart);
661 //correlations histograms
662 TString histoname1 = "DPhiDStar";
663 if(fselect==1) histoname1 += "Hadron";
664 if(fselect==2) histoname1 += "Kaon";
665 if(fselect==3) histoname1 += "KZero";
668 TH3D * DPhiDStar = new TH3D(histoname1.Data(),histoname1.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
670 TH3D * DPhiDStarKZero1 = new TH3D("DPhiDStarKZero1","DPhiDStarKZero1",nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
672 //side band background histograms
673 TString histoname2 = "bkg";
674 histoname2 += histoname1;
675 TH3D * bkgDPhiDStar = new TH3D(histoname2.Data(),histoname2.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
676 TH3D * bkgDPhiDStarKZero1 = new TH3D("bkgDPhiDStarKZero1","bkgDPhiDStarKZero1",nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
679 fOutput->Add(DPhiDStar);
681 if(fselect==3){fOutput->Add(DPhiDStarKZero1);}
683 fOutput->Add(bkgDPhiDStar);
685 if(fselect==3){fOutput->Add(bkgDPhiDStarKZero1);}
689 TH3D * leadingcand = new TH3D("LeadingCand","LeadingCand",nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
690 TH3D * leadingsidebands = new TH3D("LeadingSB","LeadingSB",nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
692 fOutput->Add(leadingcand);
693 fOutput->Add(leadingsidebands);
695 // ========================= histos for analysis on MC only
697 TH1D * EventTypeMC = new TH1D("EventTypeMC","EventTypeMC",100,-0.5,99.5);
698 if(fmontecarlo) fOutputMC->Add(EventTypeMC);
700 TH1F * MCSources = new TH1F("MCSources","Origin of associated particles in MC", 10, -0.5, 9.5);
701 MCSources->GetXaxis()->SetBinLabel(1,"All ");
702 MCSources->GetXaxis()->SetBinLabel(2," from hadron Heavy flavour");
703 MCSources->GetXaxis()->SetBinLabel(3," from c->D");
704 MCSources->GetXaxis()->SetBinLabel(4," from b->D");
705 MCSources->GetXaxis()->SetBinLabel(5," from b->B");
706 MCSources->GetXaxis()->SetBinLabel(6," from quark Heavy flavour");
707 MCSources->GetXaxis()->SetBinLabel(7," from c");
708 MCSources->GetXaxis()->SetBinLabel(8," from b");
710 if(fmontecarlo) fOutputMC->Add(MCSources);
712 // leading particle from mc source
713 TH1F * LeadingMCSources = new TH1F("LeadingMCSources","Origin of associated leading particles in MC", 10, -0.5, 9.5);
714 LeadingMCSources->GetXaxis()->SetBinLabel(1,"All ");
715 LeadingMCSources->GetXaxis()->SetBinLabel(2," from hadron Heavy flavour");
716 LeadingMCSources->GetXaxis()->SetBinLabel(3," from c->D");
717 LeadingMCSources->GetXaxis()->SetBinLabel(4," from b->D");
718 LeadingMCSources->GetXaxis()->SetBinLabel(5," from b->B");
719 LeadingMCSources->GetXaxis()->SetBinLabel(6," from quark Heavy flavour");
720 LeadingMCSources->GetXaxis()->SetBinLabel(7," from c");
721 LeadingMCSources->GetXaxis()->SetBinLabel(8," from b");
723 if(fmontecarlo) fOutputMC->Add(LeadingMCSources);
726 TString histoname3 = "MCTag";
727 histoname3 += histoname1;
728 TH3D * MCTagDPhiDStar = new TH3D(histoname3.Data(),histoname3.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
730 TString histoname44 = "CharmDOrigin";
731 histoname44 += histoname1;
734 TH3D * CharmDOriginDPhiDStar = new TH3D(histoname44.Data(),histoname44.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
737 TString histoname54 = "BeautyDOrigin";
738 histoname54 += histoname1;
740 TH3D * BeautyDOriginDPhiDStar = new TH3D(histoname54.Data(),histoname54.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
742 TString histoname55 = "BeautyBOrigin";
743 histoname55 += histoname1;
745 TH3D * BeautyBOriginDPhiDStar = new TH3D(histoname55.Data(),histoname55.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
747 TString histoname4 = "CharmQuarkOrigin";
748 histoname4 += histoname1;
750 TH3D * CharmQuarkOriginDPhiDStar = new TH3D(histoname4.Data(),histoname4.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
752 TString histoname5 = "BeautyQuarkOrigin";
753 histoname5 += histoname1;
755 TH3D * BeautyQuarkOriginDPhiDStar = new TH3D(histoname5.Data(),histoname5.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
759 fOutputMC->Add(MCTagDPhiDStar);
760 fOutputMC->Add(CharmDOriginDPhiDStar);
761 fOutputMC->Add(BeautyDOriginDPhiDStar);
762 fOutputMC->Add(BeautyBOriginDPhiDStar);
763 fOutputMC->Add(CharmQuarkOriginDPhiDStar);
764 fOutputMC->Add(BeautyQuarkOriginDPhiDStar);
768 // ========================= histos for analysis on MC
769 // all leading hadron
770 TString Leadinghistoname3 = "LeadingMCTag";
771 Leadinghistoname3 += histoname1;
772 TH3D * LeadingMCTagDPhiDStar = new TH3D(Leadinghistoname3.Data(),Leadinghistoname3.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
774 TString Leadinghistoname44 = "LeadingCharmDOrigin";
775 Leadinghistoname44 += histoname1;
776 Leadinghistoname44 += "MC";
778 TH3D * LeadingCharmDOriginDPhiDStar = new TH3D(Leadinghistoname44.Data(),Leadinghistoname44.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
781 TString Leadinghistoname54 = "LeadingBeautyDOrigin";
782 Leadinghistoname54 += histoname1;
783 Leadinghistoname54 += "MC";
784 TH3D * LeadingBeautyDOriginDPhiDStar = new TH3D(Leadinghistoname54.Data(),Leadinghistoname54.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
786 TString Leadinghistoname55 = "LeadingBeautyBOrigin";
787 Leadinghistoname55 += histoname1;
788 Leadinghistoname55 += "MC";
789 TH3D * LeadingBeautyBOriginDPhiDStar = new TH3D(Leadinghistoname55.Data(),Leadinghistoname55.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
791 TString Leadinghistoname4 = "LeadingCharmQuarkOrigin";
792 Leadinghistoname4 += histoname1;
793 Leadinghistoname4 += "MC";
794 TH3D * LeadingCharmQuarkOriginDPhiDStar = new TH3D(Leadinghistoname4.Data(),Leadinghistoname4.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
796 TString Leadinghistoname5 = "LeadingBeautyQuarkOrigin";
797 Leadinghistoname5 += histoname1;
798 Leadinghistoname5 += "MC";
799 TH3D * LeadingBeautyQuarkOriginDPhiDStar = new TH3D(Leadinghistoname5.Data(),Leadinghistoname5.Data(),nbinscorr,lowcorrbin,upcorrbin,50,0,50,39,-1.95,1.95);
806 fOutputMC->Add(LeadingMCTagDPhiDStar);
807 fOutputMC->Add(LeadingCharmDOriginDPhiDStar);
808 fOutputMC->Add(LeadingBeautyDOriginDPhiDStar);
809 fOutputMC->Add(LeadingBeautyBOriginDPhiDStar);
810 fOutputMC->Add(LeadingCharmQuarkOriginDPhiDStar);
811 fOutputMC->Add(LeadingBeautyQuarkOriginDPhiDStar);
815 TH3F * MCPhiEtaPart = new TH3F("MCPhiEtaPart","#phi distribution of the associated particle",36,-0.5*Pi,1.5*Pi,50,-2.5,2.5,6,-0.5,6.5);
816 MCPhiEtaPart->GetZaxis()->SetBinLabel(1,"All particles");
817 MCPhiEtaPart->GetZaxis()->SetBinLabel(2,"from c quark");
818 MCPhiEtaPart->GetZaxis()->SetBinLabel(3,"from b quark");
819 MCPhiEtaPart->GetZaxis()->SetBinLabel(4,"from D from c");
820 MCPhiEtaPart->GetZaxis()->SetBinLabel(5,"from D from b");
821 MCPhiEtaPart->GetZaxis()->SetBinLabel(6,"from B from b");
822 if(fmontecarlo) fOutputMC->Add(MCPhiEtaPart);
824 // ============================= EVENT MIXING CHECKS ======================================
826 Int_t MaxNofEvents = fCuts2->GetMaxNEventsInPool();
827 Int_t MinNofTracks = fCuts2->GetMinNTracksInPool();
828 Int_t NofCentBins = fCuts2->GetNCentPoolBins();
829 Double_t * CentBins = fCuts2->GetCentPoolBins();
830 Int_t NofZVrtxBins = fCuts2->GetNZvtxPoolBins();
831 Double_t *ZVrtxBins = fCuts2->GetZvtxPoolBins();
835 if(fSystem) k = 100; // PbPb centrality
836 if(!fSystem) k = NofCentBins; // pp multiplicity
839 Double_t minvalue = CentBins[0];
840 Double_t maxvalue = CentBins[NofCentBins+1];
841 Double_t Zminvalue = ZVrtxBins[0];
842 Double_t Zmaxvalue = ZVrtxBins[NofCentBins+1];
846 Double_t Nevents[]={0,2*MaxNofEvents/10,4*MaxNofEvents/10,6*MaxNofEvents/10,8*MaxNofEvents/10,MaxNofEvents};
847 Double_t * events = Nevents;
849 TH3D * EventsPerPoolBin = new TH3D("EventsPerPoolBin","Number of events in bin pool",NofCentBins,CentBins,NofZVrtxBins,ZVrtxBins,5,events);
850 EventsPerPoolBin->GetXaxis()->SetTitle("Centrality/multiplicity ");
851 EventsPerPoolBin->GetYaxis()->SetTitle("Z vertex [cm]");
852 EventsPerPoolBin->GetZaxis()->SetTitle("Number of events in pool bin");
853 if(fmixing) fOutput->Add(EventsPerPoolBin);
855 Int_t MaxNofTracks = (MaxNofEvents+1)*MinNofTracks;
856 Int_t Diff = MaxNofTracks-MinNofTracks;
858 Double_t Ntracks[]={MinNofTracks,MinNofTracks+Diff/5,MinNofTracks+2*Diff/5,MinNofTracks+3*Diff/5,MinNofTracks+4*Diff/5,MaxNofTracks};
859 Double_t * trackN = Ntracks;
861 TH3D * NofTracksPerPoolBin = new TH3D("NofTracksPerPoolBin","Number of tracks in bin pool",NofCentBins,CentBins,NofZVrtxBins,ZVrtxBins,5,trackN);
862 NofTracksPerPoolBin->GetXaxis()->SetTitle("Centrality/multiplicity ");
863 NofTracksPerPoolBin->GetYaxis()->SetTitle("Z vertex [cm]");
864 NofTracksPerPoolBin->GetZaxis()->SetTitle("Number of tracks per bin");
866 if(fmixing) fOutput->Add(NofTracksPerPoolBin);
868 TH2D * NofPoolBinCalls = new TH2D("NofPoolBinCalls","Number of tracks in bin pool",NofCentBins,CentBins,NofZVrtxBins,ZVrtxBins);
869 NofPoolBinCalls->GetXaxis()->SetTitle("Centrality/multiplicity ");
870 NofPoolBinCalls->GetYaxis()->SetTitle("Z vertex [cm]");
871 if(fmixing) fOutput->Add(NofPoolBinCalls);
875 TH2D * EventProps = new TH2D("EventProps","Number of tracks in bin pool",k,minvalue,maxvalue,100,Zminvalue,Zmaxvalue);
876 EventProps->GetXaxis()->SetTitle("Centrality/multiplicity ");
877 EventProps->GetYaxis()->SetTitle("Z vertex [cm]");
878 if(fmixing) fOutput->Add(EventProps);
884 //____________________________ Function for MC correlations ___________________________________________________
885 void AliAnalysisTaskDStarCorrelations::FillMCTagCorrelations(Double_t ptTrig, Double_t DelPhi, Double_t DelEta, Double_t ptTrack, Bool_t *mcSource){
891 if(fselect==1) ((TH3D*)fOutputMC->FindObject("MCTagDPhiDStarHadron"))->Fill(DelPhi,ptTrig,DelEta);
892 if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutputMC->FindObject("MCTagDPhiDStarKaon"))->Fill(DelPhi,ptTrig,DelEta);
893 if(fselect==3) ((TH3D*)fOutputMC->FindObject("MCTagDPhiDStarKZero"))->Fill(DelPhi,ptTrig,DelEta);
897 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(0);
900 std::cout << "MC source " << mcSource[0] << " " << mcSource[1] << " " << mcSource[2] << " " << mcSource[3] << std::endl;
902 if(mcSource[0]) std::cout << "mcSource 0 " << std::endl;
903 if(mcSource[1]) std::cout << "mcSource 1 " << std::endl;
904 if(mcSource[2]) std::cout << "mcSource 2 " << std::endl;
905 if(mcSource[3]) std::cout << "mcSource 3 " << std::endl;
908 if(mcSource[0]){ // is from charm quark
909 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(5); // all HF quarks
910 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(6); // charm quarks
911 if(fselect==1) ((TH3D*)fOutputMC->FindObject("CharmQuarkOriginDPhiDStarHadronMC"))->Fill(DelPhi,ptTrig,DelEta);
912 if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutputMC->FindObject("CharmQuarkOriginDPhiDStarKaonMC"))->Fill(DelPhi,ptTrig,DelEta);
913 if(fselect==3) ((TH3D*)fOutputMC->FindObject("CharmQuarkOriginDPhiDStarKZeroMC"))->Fill(DelPhi,ptTrig,DelEta);
916 if(mcSource[1]){ // is from b quark
917 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(5); // all HF quarks
918 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(7); // beauty quarks
919 if(fselect==1) ((TH3D*)fOutputMC->FindObject("BeautyQuarkOriginDPhiDStarHadronMC"))->Fill(DelPhi,ptTrig,DelEta);
920 if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutputMC->FindObject("BeautyQuarkOriginDPhiDStarKaonMC"))->Fill(DelPhi,ptTrig,DelEta);
921 if(fselect==3) ((TH3D*)fOutputMC->FindObject("BeautyQuarkOriginDPhiDStarKZeroMC"))->Fill(DelPhi,ptTrig,DelEta);
925 if(mcSource[2]&&mcSource[0]){ // is from D meson and charm quark
926 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(1); // all HF mesons
927 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(2); // charm + D
928 if(fselect==1) ((TH3D*)fOutputMC->FindObject("CharmDOriginDPhiDStarHadronMC"))->Fill(DelPhi,ptTrig,DelEta);
929 if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutputMC->FindObject("CharmDOriginDPhiDStarKaonMC"))->Fill(DelPhi,ptTrig,DelEta);
930 if(fselect==3) ((TH3D*)fOutputMC->FindObject("CharmDOriginDPhiDStarKZeroMC"))->Fill(DelPhi,ptTrig,DelEta);
933 if(mcSource[2]&&mcSource[1]){ // is from D meson and b quark
934 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(1); // all HF mesons
935 ((TH1F*)fOutputMC->FindObject("MCSources"))->Fill(3); // beauty + D
936 if(fselect==1) ((TH3D*)fOutputMC->FindObject("BeautyDOriginDPhiDStarHadronMC"))->Fill(DelPhi,ptTrig,DelEta);
937 if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutputMC->FindObject("BeautyDOriginDPhiDStarKaonMC"))->Fill(DelPhi,ptTrig,DelEta);
938 if(fselect==3) ((TH3D*)fOutputMC->FindObject("BeautyDOriginDPhiDStarKZeroMC"))->Fill(DelPhi,ptTrig,DelEta);
944 //____________________________ Function for MC leading part correlations ___________________________________________________
945 void AliAnalysisTaskDStarCorrelations::FillMCTagLeadingCorrelations(Double_t ptTrig, Double_t DelPhi, Double_t DelEta, Bool_t *mcSource){
946 // correlations with leading hadron on MC
948 if(fselect==1) ((TH3D*)fOutputMC->FindObject("LeadingMCTagDPhiDStarHadron"))->Fill(DelPhi,ptTrig,DelEta);
952 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(0);
954 if(fDebugLevel){ std::cout << "MC source " << mcSource[0] << " " << mcSource[1] << " " << mcSource[2] << " " << mcSource[3] << std::endl;
956 if(mcSource[0]) std::cout << "mcSource 0 " << std::endl;
957 if(mcSource[1]) std::cout << "mcSource 1 " << std::endl;
958 if(mcSource[2]) std::cout << "mcSource 2 " << std::endl;
959 if(mcSource[3]) std::cout << "mcSource 3 " << std::endl;
962 if(mcSource[0]){ // is from charm quark
963 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(5); // all HF quarks
964 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(6); // charm quarks
965 if(fselect==1) ((TH3D*)fOutputMC->FindObject("LeadingCharmQuarkOriginDPhiDStarHadronMC"))->Fill(DelPhi,ptTrig,DelEta);
969 if(mcSource[1]){ // is from b quaLeadingrk
970 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(5); // all HF quarks
971 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(7); // beauty quarks
972 if(fselect==1) ((TH3D*)fOutputMC->FindObject("LeadingBeautyQuarkOriginDPhiDStarHadronMC"))->Fill(DelPhi,ptTrig,DelEta);
977 if(mcSource[2]&&mcSource[0]){ // is from D meson and charm quark
978 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(1); // all HF mesons
979 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(2); // charm + D
980 if(fselect==1) ((TH3D*)fOutputMC->FindObject("LeadingCharmDOriginDPhiDStarHadronMC"))->Fill(DelPhi,ptTrig,DelEta);
984 if(mcSource[2]&&mcSource[1]){ // is from D meson and b quark
985 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(1); // all HF mesons
986 ((TH1F*)fOutputMC->FindObject("LeadingMCSources"))->Fill(3); // beauty + D
987 if(fselect==1) ((TH3D*)fOutputMC->FindObject("LeadingBeautyDOriginDPhiDStarHadronMC"))->Fill(DelPhi,ptTrig,DelEta);
996 //____________________________ Run checks on event mixing ___________________________________________________
997 void AliAnalysisTaskDStarCorrelations::EventMixingChecks(AliAODEvent* AOD){
999 AliCentrality *centralityObj = 0;
1000 Int_t multiplicity = -1;
1001 Double_t MultipOrCent = -1;
1003 // get the pool for event mixing
1005 multiplicity = AOD->GetNTracks();
1006 MultipOrCent = multiplicity; // convert from Int_t to Double_t
1008 if(fSystem){ // PbPb
1010 centralityObj = AOD->GetHeader()->GetCentralityP();
1011 MultipOrCent = centralityObj->GetCentralityPercentileUnchecked("V0M");
1012 AliInfo(Form("Centrality is %f", MultipOrCent));
1015 AliAODVertex *vtx = AOD->GetPrimaryVertex();
1016 Double_t zvertex = vtx->GetZ(); // zvertex
1021 AliEventPool * pool = fCorrelator->GetPool();
1026 ((TH2D*)fOutput->FindObject("NofPoolBinCalls"))->Fill(MultipOrCent,zvertex); // number of calls of pool
1027 ((TH2D*)fOutput->FindObject("EventProps"))->Fill(MultipOrCent,zvertex); // event properties
1029 ((TH3D*)fOutput->FindObject("EventsPerPoolBin"))->Fill(MultipOrCent,zvertex,pool->NTracksInPool()); // number of events in the pool
1030 ((TH3D*)fOutput->FindObject("NofTracksPerPoolBin"))->Fill(MultipOrCent,zvertex,pool->GetCurrentNEvents()); // number of calls of pool