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 // Analysis Taks for reconstructed particle correlation
18 // (first implementation done for D mesons) with jets
19 // (use the so called Emcal framework)
21 //-----------------------------------------------------------------------
23 // C. Bianchin (Utrecht University) chiara.bianchin@cern.ch
24 // A. Grelli (Utrecht University) a.grelli@uu.nl
25 // X. Zhang (LBNL) XMZhang@lbl.gov
26 //-----------------------------------------------------------------------
28 #include <TDatabasePDG.h>
29 #include <TParticle.h>
32 #include <THnSparse.h>
34 #include "AliAnalysisTaskFlavourJetCorrelations.h"
35 #include "AliAODMCHeader.h"
36 #include "AliAODHandler.h"
37 #include "AliAnalysisManager.h"
39 #include "AliEmcalJet.h"
40 #include "AliJetContainer.h"
41 #include "AliAODRecoDecay.h"
42 #include "AliAODRecoCascadeHF.h"
43 #include "AliAODRecoDecayHF2Prong.h"
44 #include "AliESDtrack.h"
45 #include "AliAODMCParticle.h"
46 #include "AliPicoTrack.h"
47 #include "AliRDHFCutsD0toKpi.h"
48 #include "AliRDHFCutsDStartoKpipi.h"
50 ClassImp(AliAnalysisTaskFlavourJetCorrelations)
53 //_______________________________________________________________________________
55 AliAnalysisTaskFlavourJetCorrelations::AliAnalysisTaskFlavourJetCorrelations() :
56 AliAnalysisTaskEmcalJet("",kTRUE),
69 fLeadingJetOnly(kFALSE),
83 //SetMakeGeneralHistograms(kTRUE);
87 //_______________________________________________________________________________
89 AliAnalysisTaskFlavourJetCorrelations::AliAnalysisTaskFlavourJetCorrelations(const Char_t* name, AliRDHFCuts* cuts,ECandidateType candtype, Bool_t jetOnly) :
90 AliAnalysisTaskEmcalJet(name,kTRUE),
103 fLeadingJetOnly(kFALSE),
107 fJetOnlyMode(jetOnly),
115 // Constructor. Initialization of Inputs and Outputs
118 Info("AliAnalysisTaskFlavourJetCorrelations","Calling Constructor");
120 fCandidateType=candtype;
121 const Int_t nptbins=fCuts->GetNPtBins();
122 Float_t defaultSigmaD013[13]={0.012, 0.012, 0.012, 0.015, 0.015,0.018,0.018,0.020,0.020,0.030,0.030,0.037,0.040};
124 switch(fCandidateType){
128 fPDGdaughters[0]=211;//pi
129 fPDGdaughters[1]=321;//K
130 fPDGdaughters[2]=0; //empty
131 fPDGdaughters[3]=0; //empty
132 fBranchName="D0toKpi";
138 fPDGdaughters[1]=211;//pi soft
139 fPDGdaughters[0]=421;//D0
140 fPDGdaughters[2]=211;//pi fromD0
141 fPDGdaughters[3]=321; // K from D0
143 fCandArrName="Dstar";
146 for(Int_t ipt=0;ipt<nptbins;ipt++) fSigmaD0[ipt]= defaultSigmaD013[ipt];
148 AliFatal(Form("Default sigma D0 not enough for %d pt bins, use SetSigmaD0ForDStar to set them",nptbins));
152 printf("%d not accepted!!\n",fCandidateType);
156 if(fCandidateType==kD0toKpi)SetMassLimits(0.15,fPDGmother);
157 if(fCandidateType==kDstartoKpipi) SetMassLimits(0.015, fPDGmother);
160 DefineOutput(1,TList::Class()); //histos with jet info
161 DefineOutput(2,AliRDHFCuts::Class()); // my cuts
164 DefineInput(1, TClonesArray::Class());
165 DefineInput(2, TClonesArray::Class());
167 DefineOutput(1,TList::Class()); // histos
168 DefineOutput(2,AliRDHFCuts::Class()); // my cuts
172 //_______________________________________________________________________________
174 AliAnalysisTaskFlavourJetCorrelations::~AliAnalysisTaskFlavourJetCorrelations() {
179 Info("~AliAnalysisTaskFlavourJetCorrelations","Calling Destructor");
185 //_______________________________________________________________________________
187 void AliAnalysisTaskFlavourJetCorrelations::Init(){
192 if(fDebug > 1) printf("AnalysisTaskRecoJetCorrelations::Init() \n");
194 switch(fCandidateType){
197 AliRDHFCutsD0toKpi* copyfCuts=new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fCuts)));
198 copyfCuts->SetName("AnalysisCutsDzero");
200 PostData(2,copyfCuts);
205 AliRDHFCutsDStartoKpipi* copyfCuts=new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
206 copyfCuts->SetName("AnalysisCutsDStar");
208 PostData(2,copyfCuts);
218 //_______________________________________________________________________________
220 void AliAnalysisTaskFlavourJetCorrelations::UserCreateOutputObjects() {
222 Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
223 AliAnalysisTaskEmcal::UserCreateOutputObjects();
225 // the TList fOutput is already defined in AliAnalysisTaskEmcal::UserCreateOutputObjects()
226 DefineHistoForAnalysis();
232 //_______________________________________________________________________________
234 Bool_t AliAnalysisTaskFlavourJetCorrelations::Run()
236 // user exec from AliAnalysisTaskEmcal is used
239 AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
241 TClonesArray *arrayDStartoD0pi=0;
243 if (!aodEvent && AODEvent() && IsStandardAOD()) {
245 // In case there is an AOD handler writing a standard AOD, use the AOD
246 // event in memory rather than the input (ESD) event.
247 aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
249 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
250 // have to taken from the AOD event hold by the AliAODExtension
251 AliAODHandler* aodHandler = (AliAODHandler*)
252 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
253 if(aodHandler->GetExtensions()) {
254 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
255 AliAODEvent *aodFromExt = ext->GetAOD();
256 arrayDStartoD0pi=(TClonesArray*)aodFromExt->GetList()->FindObject(fBranchName.Data());
259 arrayDStartoD0pi=(TClonesArray*)aodEvent->GetList()->FindObject(fBranchName.Data());
262 if (!arrayDStartoD0pi) {
263 AliInfo(Form("Could not find array %s, skipping the event",fBranchName.Data()));
265 } else AliDebug(2, Form("Found %d vertices",arrayDStartoD0pi->GetEntriesFast()));
267 TClonesArray* mcArray = 0x0;
269 mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
271 printf("AliAnalysisTaskSEDStarSpectra::UserExec: MC particles not found!\n");
277 fTrackArr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("PicoTracks"));
278 //clusArr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("CaloClustersCorr"));
279 //jetArr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fJetArrName));
280 fJetRadius=GetJetContainer(0)->GetJetRadius();
283 AliInfo(Form("Could not find the track array\n"));
288 fCandidateArray = dynamic_cast<TClonesArray*>(GetInputData(1));
289 if (!fCandidateArray) return kFALSE;
290 if (fCandidateType==1) {
291 fSideBandArray = dynamic_cast<TClonesArray*>(GetInputData(2));
292 if (!fSideBandArray) return kFALSE;
294 //Printf("ncandidates found %d",fCandidateArray->GetEntriesFast());
297 TH1I* hstat=(TH1I*)fOutput->FindObject("hstat");
298 TH1F* hPtJetTrks=(TH1F*)fOutput->FindObject("hPtJetTrks");
299 TH1F* hPhiJetTrks=(TH1F*)fOutput->FindObject("hPhiJetTrks");
300 TH1F* hEtaJetTrks=(TH1F*)fOutput->FindObject("hEtaJetTrks");
301 TH1F* hEjetTrks=(TH1F*)fOutput->FindObject("hEjetTrks");
302 TH1F* hPtJet=(TH1F*)fOutput->FindObject("hPtJet");
303 TH1F* hPhiJet=(TH1F*)fOutput->FindObject("hPhiJet");
304 TH1F* hEtaJet=(TH1F*)fOutput->FindObject("hEtaJet");
305 TH1F* hEjet=(TH1F*)fOutput->FindObject("hEjet");
306 TH1F* hNtrArr=(TH1F*)fOutput->FindObject("hNtrArr");
307 TH1F* hNJetPerEv=(TH1F*)fOutput->FindObject("hNJetPerEv");
308 TH1F* hdeltaRJetTracks=(TH1F*)fOutput->FindObject("hdeltaRJetTracks");
309 TH1F* hNDPerEvNoJet=(TH1F*)fOutput->FindObject("hNDPerEvNoJet");
310 TH1F* hptDPerEvNoJet=(TH1F*)fOutput->FindObject("hptDPerEvNoJet");
311 TH1F* hNJetPerEvNoD=(TH1F*)fOutput->FindObject("hNJetPerEvNoD");
312 TH1F* hPtJetPerEvNoD=(TH1F*)fOutput->FindObject("hPtJetPerEvNoD");
313 THnSparseF* hnspDstandalone=(THnSparseF*)fOutput->FindObject("hsDstandalone");
314 THnSparseF* hsJet=(THnSparseF*)fOutput->FindObject("hsJet");
316 TH1F* hztracksinjet=(TH1F*)fOutput->FindObject("hztracksinjet");
317 TH1F* hDiffPtTrPtJzNok=(TH1F*)fOutput->FindObject("hDiffPtTrPtJzNok");
318 TH1F* hDiffPtTrPtJzok=(TH1F*)fOutput->FindObject("hDiffPtTrPtJzok");
319 TH1F* hDiffPzTrPtJzok=(TH1F*)fOutput->FindObject("hDiffPzTrPtJzok");
320 TH1F* hDiffPzTrPtJzNok=(TH1F*)fOutput->FindObject("hDiffPzTrPtJzNok");
321 TH1I* hNtrkjzNok=(TH1I*)fOutput->FindObject("hNtrkjzNok");
322 TH1F* hztracksinjetT=(TH1F*)fOutput->FindObject("hztracksinjetT");
327 // fix for temporary bug in ESDfilter
328 // the AODs with null vertex pointer didn't pass the PhysSel
329 if(!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField())<0.001) return kFALSE;
332 Bool_t iseventselected=fCuts->IsEventSelected(aodEvent);
333 TString firedTriggerClasses=((AliAODEvent*)aodEvent)->GetFiredTriggerClasses();
334 if(!iseventselected) return kFALSE;
338 //retrieve charm candidates selected
339 Int_t candidates = 0;
340 Int_t njets=GetJetContainer()->GetNJets();
343 candidates = fCandidateArray->GetEntriesFast();
347 hstat->Fill(6, candidates);
348 hNDPerEvNoJet->Fill(candidates);
349 for(Int_t iD=0;iD<candidates;iD++){
350 AliVParticle* cand=(AliVParticle*)fCandidateArray->At(iD);
352 hptDPerEvNoJet->Fill(cand->Pt());
359 //loop on candidates standalone (checking the candidates are there and their phi-eta distributions)
361 for(Int_t ic = 0; ic < candidates; ic++) {
364 AliAODRecoDecayHF* charm=0x0;
365 AliAODRecoCascadeHF* dstar=0x0;
368 charm=(AliAODRecoDecayHF*)fCandidateArray->At(ic);
371 if(fCandidateType==kDstartoKpipi){
372 dstar=(AliAODRecoCascadeHF*)fCandidateArray->At(ic);
378 Double_t candsparse[4]={charm->Eta(), charm->Phi(), charm->Pt(), 0};
380 if(fCandidateType==kDstartoKpipi) {
382 Double_t deltamass= dstar->DeltaInvMass();
383 candsparse[3]=deltamass;
384 } else candsparse[3] = 0.145; //for generated
385 hnspDstandalone->Fill(candsparse);
387 if(fCandidateType==kD0toKpi){
389 AliAODRecoDecayHF* dzero=(AliAODRecoDecayHF*)charm;
390 Int_t isselected=fCuts->IsSelected(dzero,AliRDHFCuts::kAll,aodEvent);
391 //not a further selection,just to get the value of isselected for the D0
393 Int_t pdgdaughtersD0[2]={211,321};//pi,K
394 Int_t pdgdaughtersD0bar[2]={321,211};//K,pi
396 masses[0]=dzero->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0); //D0
397 masses[1]=dzero->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0bar); //D0bar
398 if(isselected==1 || isselected==3) {
399 candsparse[3]=masses[0];
400 hnspDstandalone->Fill(candsparse);
403 candsparse[3]=masses[1];
404 hnspDstandalone->Fill(candsparse);
408 Int_t pdg=((AliAODMCParticle*)charm)->GetPdgCode();
409 candsparse[3]=TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
410 hnspDstandalone->Fill(candsparse);
416 // we start with jets
421 Double_t leadingJet =0;
424 Int_t ntrarr=fTrackArr->GetEntriesFast();
425 hNtrArr->Fill(ntrarr);
427 for(Int_t i=0;i<ntrarr;i++){
428 AliVTrack *jtrack=static_cast<AliVTrack*>(fTrackArr->At(i));
430 hPtJetTrks->Fill(jtrack->Pt());
431 hPhiJetTrks->Fill(jtrack->Phi());
432 hEtaJetTrks->Fill(jtrack->Eta());
433 hEjetTrks->Fill(jtrack->E());
437 //option to use only the leading jet
439 for (Int_t iJetsL = 0; iJetsL<njets; iJetsL++) {
440 AliEmcalJet* jetL = (AliEmcalJet*)GetJetFromArray(iJetsL);
442 if(ptjet>leadingJet ) leadingJet = ptjet;
448 //loop over jets and consider only the leading jet in the event
449 for (Int_t iJets = 0; iJets<njets; iJets++) {
454 //Printf("Jet N %d",iJets);
455 AliEmcalJet* jet = (AliEmcalJet*)GetJetFromArray(iJets);
456 //Printf("Corr task Accept Jet");
457 if(!AcceptJet(jet)) {
467 Double_t origPtJet=fPtJet;
473 pointJ[4] = jet->GetNumberOfConstituents();
474 pointJ[5] = jet->Area();
476 // choose the leading jet
477 if(fLeadingJetOnly && (ejet<leadingJet)) continue;
478 //used for normalization
481 // fill energy, eta and phi of the jet
483 hPhiJet ->Fill(phiJet);
484 hEtaJet ->Fill(etaJet);
485 hPtJet ->Fill(fPtJet);
486 if(fJetOnlyMode) hsJet->Fill(pointJ,1);
487 //loop on jet particles
488 Int_t ntrjet= jet->GetNumberOfTracks();
489 Double_t sumPtTracks=0,sumPzTracks=0;
491 for(Int_t itrk=0;itrk<ntrjet;itrk++){
493 AliPicoTrack* jetTrk=(AliPicoTrack*)jet->TrackAt(itrk,fTrackArr);
494 hdeltaRJetTracks->Fill(DeltaR(jet,jetTrk));
495 Double_t ztrackj=Z(jetTrk,jet);
496 hztracksinjet->Fill(ztrackj);
497 sumPtTracks+=jetTrk->Pt();
498 sumPzTracks+=jetTrk->Pz();
503 Double_t ztrackjTr=Z(jetTrk,jet,kTRUE);
504 hztracksinjetT->Fill(ztrackjTr);
506 }//end loop on jet tracks
508 hNtrkjzNok->Fill(zg1jtrk);
509 Double_t diffpt=origPtJet-sumPtTracks;
510 Double_t diffpz=jet->Pz()-sumPzTracks;
512 hDiffPtTrPtJzNok->Fill(diffpt);
513 hDiffPzTrPtJzNok->Fill(diffpz);
516 hDiffPtTrPtJzok->Fill(diffpt);
517 hDiffPzTrPtJzok->Fill(diffpz);
522 hPtJetPerEvNoD->Fill(fPtJet);
525 //Printf("N candidates %d ", candidates);
526 for(Int_t ic = 0; ic < candidates; ic++) {
529 AliVParticle* charm=0x0;
530 charm=(AliVParticle*)fCandidateArray->At(ic);
532 AliAODRecoDecayHF *charmdecay=(AliAODRecoDecayHF*) charm;
533 fIsDInJet=IsDInJet(jet, charmdecay, kTRUE);
534 if (fIsDInJet) FlagFlavour(jet);
535 if (jet->TestFlavourTag(AliEmcalJet::kDStar)) hstat->Fill(4);
537 //Note: the z component of the jet momentum comes from the eta-phi direction of the jet particles, it is not calculated from the z component of the tracks since, as default, the scheme used for jet reco is the pt-scheme which sums the scalar component, not the vectors. Addind the D daughter momentum component by componet as done here is not 100% correct, but the difference is small, for fairly collimated particles.
541 RecalculateMomentum(pjet,fPmissing);
542 fPtJet=TMath::Sqrt(pjet[0]*pjet[0]+pjet[1]*pjet[1]);
545 //debugging histograms
546 Double_t pmissing=TMath::Sqrt(fPmissing[0]*fPmissing[0]+fPmissing[1]*fPmissing[1]+fPmissing[2]*fPmissing[2]);
547 for(Int_t k=0;k<3;k++) ((TH1F*)fOutput->FindObject(Form("hMissP%d",k)))->Fill(fPmissing[k]);
549 ((TH1F*)fOutput->FindObject("hmissingp"))->Fill(pmissing);
550 Double_t ptdiff=fPtJet-origPtJet;
551 ((TH1F*)fOutput->FindObject("hDeltaPtJet"))->Fill(ptdiff);
552 ((TH1F*)fOutput->FindObject("hRelDeltaPtJet"))->Fill(ptdiff/origPtJet);
554 FillHistogramsRecoJetCorr(charm, jet, aodEvent);
556 }//end loop on candidates
558 //retrieve side band background candidates for Dstar
559 Int_t nsbcand = 0; if(fSideBandArray) nsbcand=fSideBandArray->GetEntriesFast();
561 for(Int_t ib=0;ib<nsbcand;ib++){
562 if(fCandidateType==kDstartoKpipi && !fUseMCInfo){
563 AliAODRecoCascadeHF *sbcand=(AliAODRecoCascadeHF*)fSideBandArray->At(ib);
564 if(!sbcand) continue;
566 fIsDInJet=IsDInJet(jet, sbcand,kFALSE);
569 RecalculateMomentum(pjet,fPmissing);
570 fPtJet=TMath::Sqrt(pjet[0]*pjet[0]+pjet[1]*pjet[1]);
572 SideBandBackground(sbcand,jet);
576 AliAODRecoDecayHF* charmbg = 0x0;
577 charmbg=(AliAODRecoDecayHF*)fCandidateArray->At(ib);
578 if(!charmbg) continue;
579 fIsDInJet=IsDInJet(jet, charmbg,kFALSE);
583 RecalculateMomentum(pjet,fPmissing);
584 fPtJet=TMath::Sqrt(pjet[0]*pjet[0]+pjet[1]*pjet[1]);
586 MCBackground(charmbg);
592 hNJetPerEv->Fill(cntjet);
593 if(candidates==0) hNJetPerEvNoD->Fill(cntjet);
598 //_______________________________________________________________________________
600 void AliAnalysisTaskFlavourJetCorrelations::Terminate(Option_t*)
602 // The Terminate() function is the last function to be called during
603 // a query. It always runs on the client, it can be used to present
604 // the results graphically or save the results to file.
606 Info("Terminate"," terminate");
607 AliAnalysisTaskSE::Terminate();
609 fOutput = dynamic_cast<TList*> (GetOutputData(1));
611 printf("ERROR: fOutput not available\n");
616 //_______________________________________________________________________________
618 void AliAnalysisTaskFlavourJetCorrelations::SetMassLimits(Double_t range, Int_t pdg){
620 Int_t abspdg=TMath::Abs(pdg);
622 mass=TDatabasePDG::Instance()->GetParticle(abspdg)->Mass();
623 // compute the Delta mass for the D*
624 if(fCandidateType==kDstartoKpipi){
626 mass1=TDatabasePDG::Instance()->GetParticle(421)->Mass();
630 fMinMass = mass-range;
631 fMaxMass = mass+range;
633 AliInfo(Form("Setting mass limits to %f, %f",fMinMass,fMaxMass));
634 if (fMinMass<0 || fMaxMass<=0 || fMaxMass<fMinMass) AliFatal("Wrong mass limits!\n");
637 //_______________________________________________________________________________
639 void AliAnalysisTaskFlavourJetCorrelations::SetMassLimits(Double_t lowlimit, Double_t uplimit){
646 printf("Error! Lower limit larger than upper limit!\n");
647 fMinMass = uplimit - uplimit*0.2;
652 //_______________________________________________________________________________
654 Bool_t AliAnalysisTaskFlavourJetCorrelations::SetD0WidthForDStar(Int_t nptbins,Float_t *width){
656 AliInfo("Maximum number of bins allowed is 30!");
659 if(!width) return kFALSE;
660 for(Int_t ipt=0;ipt<nptbins;ipt++) fSigmaD0[ipt]=width[ipt];
664 //_______________________________________________________________________________
666 Double_t AliAnalysisTaskFlavourJetCorrelations::Z(AliVParticle* part,AliEmcalJet* jet, Bool_t transverse) const{
668 printf("Particle or jet do not exist!\n");
672 Bool_t okpp=part->PxPyPz(p);
673 Bool_t okpj=jet->PxPyPz(pj);
675 printf("Problems getting momenta\n");
679 RecalculateMomentum(pj, fPmissing);
680 if(transverse) return ZT(p,pj);
685 //_______________________________________________________________________________
686 Double_t AliAnalysisTaskFlavourJetCorrelations::Z(Double_t* p, Double_t *pj) const{
688 Double_t pjet2=pj[0]*pj[0]+pj[1]*pj[1]+pj[2]*pj[2];
689 Double_t z=(p[0]*pj[0]+p[1]*pj[1]+p[2]*pj[2])/(pjet2);
694 //_______________________________________________________________________________
695 Double_t AliAnalysisTaskFlavourJetCorrelations::ZT(Double_t* p, Double_t *pj) const{
697 Double_t pjet2=pj[0]*pj[0]+pj[1]*pj[1];
698 Double_t z=(p[0]*pj[0]+p[1]*pj[1])/(pjet2);
702 //_______________________________________________________________________________
704 void AliAnalysisTaskFlavourJetCorrelations::RecalculateMomentum(Double_t* pj, const Double_t* pmissing) const {
712 //_______________________________________________________________________________
714 Bool_t AliAnalysisTaskFlavourJetCorrelations::DefineHistoForAnalysis(){
717 TH1I* hstat=new TH1I("hstat","Statistics",8,-0.5,7.5);
718 hstat->GetXaxis()->SetBinLabel(1,"N ev anal");
719 hstat->GetXaxis()->SetBinLabel(2,"N ev sel");
720 hstat->GetXaxis()->SetBinLabel(3,"N cand sel & jet");
721 hstat->GetXaxis()->SetBinLabel(4,"N jets");
722 hstat->GetXaxis()->SetBinLabel(5,"N cand in jet");
723 hstat->GetXaxis()->SetBinLabel(6,"N jet rej");
724 hstat->GetXaxis()->SetBinLabel(7,"N cand sel & !jet");
725 hstat->GetXaxis()->SetBinLabel(8,"N jets & !D");
726 hstat->SetNdivisions(1);
729 const Int_t nbinsmass=200;
730 const Int_t nbinsptjet=500;
731 const Int_t nbinsptD=100;
732 const Int_t nbinsz=100;
733 const Int_t nbinsphi=200;
734 const Int_t nbinseta=100;
735 const Int_t nbinsContrib=100;
736 const Int_t nbinsA=100;
738 const Float_t ptjetlims[2]={0.,200.};
739 const Float_t ptDlims[2]={0.,50.};
740 const Float_t zlims[2]={0.,1.2};
741 const Float_t philims[2]={0.,6.3};
742 const Float_t etalims[2]={-1.5,1.5};
743 const Int_t nContriblims[2]={0,100};
744 const Float_t arealims[2]={0.,2};
746 // jet related fistograms
748 TH1F* hEjetTrks = new TH1F("hEjetTrks", "Jet tracks energy distribution;Energy (GeV)",500,0,200);
750 TH1F* hPhiJetTrks = new TH1F("hPhiJetTrks","Jet tracks #phi distribution; #phi (rad)", nbinsphi,philims[0],philims[1]);
751 hPhiJetTrks->Sumw2();
752 TH1F* hEtaJetTrks = new TH1F("hEtaJetTrks","Jet tracks #eta distribution; #eta", nbinseta,etalims[0],etalims[1]);
753 hEtaJetTrks->Sumw2();
754 TH1F* hPtJetTrks = new TH1F("hPtJetTrks", "Jet tracks Pt distribution; p_{T} (GeV/c)",nbinsptjet,ptjetlims[0],ptjetlims[1]);
757 TH1F* hEjet = new TH1F("hEjet", "Jet energy distribution;Energy (GeV)",500,0,200);
759 TH1F* hPhiJet = new TH1F("hPhiJet","Jet #phi distribution; #phi (rad)", nbinsphi,philims[0],philims[1]);
761 TH1F* hEtaJet = new TH1F("hEtaJet","Jet #eta distribution; #eta", nbinseta,etalims[0],etalims[1]);
763 TH1F* hPtJet = new TH1F("hPtJet", "Jet Pt distribution; p_{T} (GeV/c)",nbinsptjet,ptjetlims[0],ptjetlims[1]);
766 TH1F* hdeltaRJetTracks=new TH1F("hdeltaRJetTracks","Delta R of tracks in the jets",200, 0.,10.);
767 hdeltaRJetTracks->Sumw2();
769 TH1F* hNtrArr= new TH1F("hNtrArr", "Number of tracks in the array of jets; number of tracks",500,0,1000);
772 TH1F *hNJetPerEv=new TH1F("hNJetPerEv","Number of jets used per event; number of jets/ev",10,-0.5,9.5);
776 fOutput->Add(hEjetTrks);
777 fOutput->Add(hPhiJetTrks);
778 fOutput->Add(hEtaJetTrks);
779 fOutput->Add(hPtJetTrks);
781 fOutput->Add(hPhiJet);
782 fOutput->Add(hEtaJet);
783 fOutput->Add(hPtJet);
784 fOutput->Add(hdeltaRJetTracks);
785 fOutput->Add(hNtrArr);
786 fOutput->Add(hNJetPerEv);
791 const Int_t nbinsSparse[nAxis]={nbinsphi,nbinseta, nbinsptjet, nbinsptjet,nbinsContrib, nbinsA};
792 const Double_t minSparse[nAxis]={philims[0],etalims[0],ptjetlims[0],ptjetlims[0],static_cast<Double_t>(nContriblims[0]),arealims[0]};
794 maxSparse[nAxis]={philims[1],etalims[1],ptjetlims[1],ptjetlims[1],static_cast<Double_t>(nContriblims[1]),arealims[1]};
795 THnSparseF *hsJet=new THnSparseF("hsJet","#phi, #eta, p_{T}^{jet}, E^{jet}, N contrib, Area", nAxis, nbinsSparse, minSparse, maxSparse);
804 //debugging histograms
805 TH1I* hControlDInJ=new TH1I("hControlDInJ","Checks D in Jet",8, -0.5,7.5);
806 hControlDInJ->GetXaxis()->SetBinLabel(1,"DR In,1 daugh out");
807 hControlDInJ->GetXaxis()->SetBinLabel(2,"DR In,2 daugh out");
808 hControlDInJ->GetXaxis()->SetBinLabel(3,"DR In,3 daugh out");
809 hControlDInJ->GetXaxis()->SetBinLabel(4,"Tot tracks non matched");
810 hControlDInJ->GetXaxis()->SetBinLabel(5,"D0 daug missing");
811 hControlDInJ->GetXaxis()->SetBinLabel(6,"soft pi missing");
812 hControlDInJ->GetXaxis()->SetBinLabel(7,"IDprong diff GetDau");
813 hControlDInJ->GetXaxis()->SetBinLabel(8,"still z>1 (cand)");
815 hControlDInJ->SetNdivisions(1);
816 hControlDInJ->GetXaxis()->SetLabelSize(0.05);
817 fOutput->Add(hControlDInJ);
819 TH1F *hmissingp=new TH1F("hmissingp", "Distribution of missing momentum (modulo);|p_{missing}|", 200, 0.,20.);
820 fOutput->Add(hmissingp);
822 for(Int_t k=0;k<3;k++) {
823 TH1F *hMissPi=new TH1F(Form("hMissP%d",k), Form("Missing p component {%d};p_{%d}",k,k), 400, -10.,10.);
824 fOutput->Add(hMissPi);
826 TH1F *hDeltaPtJet=new TH1F("hDeltaPtJet", "Difference between the jet pt before and after correction;p_{T}^{jet,recalc}-p_{T}^{jet,orig}", 200, 0.,20.);
828 fOutput->Add(hDeltaPtJet);
829 TH1F *hRelDeltaPtJet=new TH1F("hRelDeltaPtJet", "Difference between the jet pt before and after correction/ original pt;(p_{T}^{jet,recalc}-p_{T}^{jet,orig})/p_{T}^{jet,orig}", 200, 0.,1.);
830 fOutput->Add(hRelDeltaPtJet);
832 TH1F* hzDinjet=new TH1F("hzDinjet","Z of candidates with daughters in jet;z",nbinsz,zlims[0],zlims[1]);
833 fOutput->Add(hzDinjet);
834 //frag func of tracks in the jet
835 TH1F* hztracksinjet=new TH1F("hztracksinjet","Z of tracks in jet;z",nbinsz,zlims[0],zlims[1]);
836 fOutput->Add(hztracksinjet);
838 //check jet and tracks
839 TH1F* hDiffPtTrPtJzok=new TH1F("hDiffPtTrPtJzok","Sum p_{T}^{trks} - p_{T}^{jet}, for z<1;(#Sigma p_{T}^{trks}) - p_{T}^{jet}", 100,-0.2,0.2);
840 fOutput->Add(hDiffPtTrPtJzok);
841 TH1F* hDiffPtTrPtJzNok=new TH1F("hDiffPtTrPtJzNok","Sum p_{T}^{trks} - p_{T}^{jet}, for z>1;(#Sigma p_{T}^{trks}) - p_{T}^{jet}", 100,-0.2,0.2);
842 fOutput->Add(hDiffPtTrPtJzNok);
843 TH1F* hDiffPzTrPtJzok=new TH1F("hDiffPzTrPtJzok","Sum p_{z}^{trks} - p_{z}^{jet}, for z<1;(#Sigma p_{z}^{trks}) - p_{z}^{jet}", 100,-0.2,0.2);
844 fOutput->Add(hDiffPzTrPtJzok);
845 TH1F* hDiffPzTrPtJzNok=new TH1F("hDiffPzTrPtJzNok","Sum p_{z}^{trks} - p_{z}^{jet}, for z>1;(#Sigma p_{z}^{trks}) - p_{z}^{jet}", 100,-0.2,0.2);
846 fOutput->Add(hDiffPzTrPtJzNok);
847 TH1I* hNtrkjzNok=new TH1I("hNtrkjzNok", "Number of tracks in a jet with z>1;N^{tracks} (z>1)",5,0,5);
848 fOutput->Add(hNtrkjzNok);
850 //calculate frag func with pt (simply ptD(or track)\cdot pt jet /ptjet^2)
851 TH1F* hzDT=new TH1F("hzDT", "Z of D in jet in transverse components;(p_{T}^{D} dot p_{T}^{jet})/p_{T}^{jet}^{2} ",nbinsz,zlims[0],zlims[1]);
853 TH1F* hztracksinjetT=new TH1F("hztracksinjetT", "Z of jet tracks in transverse components;(p_{T}^{trks} dot p_{T}^{jet})/p_{T}^{jet}^{2}",nbinsz,zlims[0],zlims[1]);
854 fOutput->Add(hztracksinjetT);
856 TH1I* hIDddaugh=new TH1I("hIDddaugh", "ID of daughters;ID", 2001,-1000,1000);
857 fOutput->Add(hIDddaugh);
858 TH1I* hIDddaughOut=new TH1I("hIDddaughOut", "ID of daughters not found in jet;ID", 2001,-1000,1000);
859 fOutput->Add(hIDddaughOut);
860 TH1I* hIDjetTracks=new TH1I("hIDjetTracks", "ID of jet tracks;ID", 2001,-1000,1000);
861 fOutput->Add(hIDjetTracks);
863 TH1F* hDRdaughOut=new TH1F("hDRdaughOut", "#Delta R of daughters not belonging to the jet tracks (D in jet);#Delta R",200, 0.,2.);
864 fOutput->Add(hDRdaughOut);
867 if(fCandidateType==kDstartoKpipi)
870 TH2F* hDiffSideBand = new TH2F("hDiffSideBand","M(kpipi)-M(kpi) Side Band Background",nbinsmass,fMinMass,fMaxMass,nbinsptD, ptDlims[0],ptDlims[1]);
871 hDiffSideBand->SetStats(kTRUE);
872 hDiffSideBand->GetXaxis()->SetTitle("M(kpipi)-M(Kpi) GeV");
873 hDiffSideBand->GetYaxis()->SetTitle("p_{t}^{D} (GeV/c)");
874 hDiffSideBand->Sumw2();
875 fOutput->Add(hDiffSideBand);
878 TH1F* hPtPion = new TH1F("hPtPion","Primary pions candidates pt ",500,0,10);
879 hPtPion->SetStats(kTRUE);
880 hPtPion->GetXaxis()->SetTitle("GeV/c");
881 hPtPion->GetYaxis()->SetTitle("Entries");
883 fOutput->Add(hPtPion);
886 // D related histograms
887 TH1F *hNDPerEvNoJet=new TH1F("hNDPerEvNoJet","Number of candidates per event with no jets; N candidate/ev with no jet", 20, 0., 20.);
888 hNDPerEvNoJet->Sumw2();
889 fOutput->Add(hNDPerEvNoJet);
891 TH1F *hptDPerEvNoJet=new TH1F("hptDPerEvNoJet","pt distribution of candidates per events with no jets; p_{t}^{D} (GeV/c)",nbinsptD, ptDlims[0],ptDlims[1]);
892 hptDPerEvNoJet->Sumw2();
893 fOutput->Add(hptDPerEvNoJet);
895 const Int_t nAxisD=4;
896 const Int_t nbinsSparseD[nAxisD]={nbinseta,nbinsphi,nbinsptD,nbinsmass};
897 const Double_t minSparseD[nAxisD] ={etalims[0],philims[0],ptDlims[0],fMinMass};
898 const Double_t maxSparseD[nAxisD] ={etalims[1],philims[1],ptDlims[1],fMaxMass};
899 THnSparseF *hsDstandalone=new THnSparseF("hsDstandalone","#phi, #eta, p_{T}^{D}, and mass", nAxisD, nbinsSparseD, minSparseD, maxSparseD);
900 hsDstandalone->Sumw2();
902 fOutput->Add(hsDstandalone);
904 TH3F* hPtJetWithD=new TH3F("hPtJetWithD","D-Jet Pt distribution; p_{T} (GeV/c);delta mass (GeV/c^{2})",nbinsptjet,ptjetlims[0],ptjetlims[1],nbinsmass,fMinMass,fMaxMass,nbinsptD, ptDlims[0],ptDlims[1]);
905 hPtJetWithD->Sumw2();
906 //for the MC this histogram is filled with the real background
907 TH3F* hPtJetWithDsb=new TH3F("hPtJetWithDsb","D(background)-Jet Pt distribution; p_{T} (GeV/c);delta mass (GeV/c^{2});p_{T}^{D} (GeV/c)",nbinsptjet,ptjetlims[0],ptjetlims[1],nbinsmass,fMinMass,fMaxMass,nbinsptD, ptDlims[0],ptDlims[1]);
908 hPtJetWithDsb->Sumw2();
910 TH1F *hNJetPerEvNoD=new TH1F("hNJetPerEvNoD","Number of jets per event with no D; number of jets/ev with no D",10,-0.5,9.5);
911 hNJetPerEvNoD->Sumw2();
913 TH1F *hPtJetPerEvNoD=new TH1F("hPtJetPerEvNoD","pt distribution of jets per event with no D; p_{T}^{jet} (GeV/c)",nbinsptjet,ptjetlims[0],ptjetlims[1]);
914 hPtJetPerEvNoD->Sumw2();
916 fOutput->Add(hPtJetWithD);
917 fOutput->Add(hPtJetWithDsb);
918 fOutput->Add(hNJetPerEvNoD);
919 fOutput->Add(hPtJetPerEvNoD);
921 TH1F* hDeltaRD=new TH1F("hDeltaRD","#Delta R distribution of D candidates selected;#Delta R",200, 0.,10.);
923 fOutput->Add(hDeltaRD);
925 //background (side bands for the Dstar and like sign for D0)
926 fJetRadius=GetJetContainer(0)->GetJetRadius();
927 TH2F* hInvMassptD = new TH2F("hInvMassptD",Form("D (Delta R < %.1f) invariant mass distribution p_{T}^{j} > threshold",fJetRadius),nbinsmass,fMinMass,fMaxMass,nbinsptD,ptDlims[0],ptDlims[1]);
928 hInvMassptD->SetStats(kTRUE);
929 hInvMassptD->GetXaxis()->SetTitle("mass (GeV)");
930 hInvMassptD->GetYaxis()->SetTitle("p_{t}^{D} (GeV/c)");
931 hInvMassptD->Sumw2();
933 fOutput->Add(hInvMassptD);
936 TH2F* hInvMassptDbg = new TH2F("hInvMassptDbg",Form("Background D (Delta R < %.1f) invariant mass distribution p_{T}^{j} > threshold",fJetRadius),nbinsmass,fMinMass,fMaxMass,nbinsptD,ptDlims[0],ptDlims[1]);
937 hInvMassptDbg->GetXaxis()->SetTitle(Form("%s (GeV)",(fCandidateType==kDstartoKpipi) ? "M(Kpipi)" : "M(Kpi)"));
938 hInvMassptDbg->GetYaxis()->SetTitle("p_{t}^{D} (GeV/c)");
939 hInvMassptDbg->Sumw2();
940 fOutput->Add(hInvMassptDbg);
943 Double_t pi=TMath::Pi(), philims2[2];
944 philims2[0]=-pi*1./2.;
945 philims2[1]=pi*3./2.;
947 const Int_t nbinsSparse[nAxis]={nbinsz,nbinsphi,nbinsptjet,nbinsptD,nbinsmass,2, 2, 2, 2};
948 const Double_t minSparse[nAxis]={zlims[0],philims2[0],ptjetlims[0],ptDlims[0],fMinMass,-0.5, -0.5,-0.5,-0.5};
949 const Double_t maxSparse[nAxis]={zlims[1],philims2[1],ptjetlims[1],ptDlims[1],fMaxMass, 1.5, 1.5, 1.5 , 1.5};
950 THnSparseF *hsDphiz=new THnSparseF("hsDphiz","Z and #Delta#phi vs p_{T}^{jet}, p_{T}^{D}, mass. SB? D within the jet cone?, D in EMCal acc?, jet in EMCal acc?", nAxis, nbinsSparse, minSparse, maxSparse);
953 fOutput->Add(hsDphiz);
955 PostData(1, fOutput);
960 //_______________________________________________________________________________
962 void AliAnalysisTaskFlavourJetCorrelations::FillHistogramsRecoJetCorr(AliVParticle* candidate, AliEmcalJet *jet, AliAODEvent* aodEvent){
964 Double_t ptD=candidate->Pt();
965 Double_t deltaR=DeltaR(candidate,jet);
966 Double_t phiD=candidate->Phi();
967 Double_t deltaphi = jet->Phi()-phiD;
968 if(deltaphi<=-(TMath::Pi())/2.) deltaphi = deltaphi+2.*(TMath::Pi());
969 if(deltaphi>(3.*(TMath::Pi()))/2.) deltaphi = deltaphi-2.*(TMath::Pi());
970 Double_t z=Z(candidate,jet);
973 ((TH1I*)fOutput->FindObject("hControlDInJ"))->Fill(7);
974 Double_t pmissing=TMath::Sqrt(fPmissing[0]*fPmissing[0]+fPmissing[1]*fPmissing[1]+fPmissing[2]*fPmissing[2]);
976 for(Int_t k=0;k<3;k++) ((TH1F*)fOutput->FindObject(Form("hMissP%d",k)))->Fill(fPmissing[k]);
978 ((TH1F*)fOutput->FindObject("hmissingp"))->Fill(pmissing);
979 Double_t ptdiff=fPtJet-jet->Pt();
980 ((TH1F*)fOutput->FindObject("hDeltaPtJet"))->Fill(ptdiff);
981 ((TH1F*)fOutput->FindObject("hRelDeltaPtJet"))->Fill(ptdiff/jet->Pt());
986 if(fIsDInJet)((TH1F*)fOutput->FindObject("hzDT"))->Fill(Z(candidate,jet,kTRUE));
988 TH1F* hDeltaRD=(TH1F*)fOutput->FindObject("hDeltaRD");
989 hDeltaRD->Fill(deltaR);
990 Bool_t bDInEMCalAcc=InEMCalAcceptance(candidate);
991 Bool_t bJetInEMCalAcc=InEMCalAcceptance(jet);
993 if(fCandidateType==kD0toKpi) {
994 AliAODRecoDecayHF* dzero=(AliAODRecoDecayHF*)candidate;
996 FillHistogramsD0JetCorr(dzero,deltaphi,phiD,z,ptD,fPtJet,bDInEMCalAcc,bJetInEMCalAcc, aodEvent);
1000 if(fCandidateType==kDstartoKpipi) {
1001 AliAODRecoCascadeHF* dstar = (AliAODRecoCascadeHF*)candidate;
1002 FillHistogramsDstarJetCorr(dstar,deltaphi,phiD,z,ptD,fPtJet,bDInEMCalAcc,bJetInEMCalAcc);
1005 } else{ //generated level
1006 //AliInfo("Non reco");
1007 FillHistogramsMCGenDJetCorr(deltaphi,phiD,z,ptD,fPtJet,bDInEMCalAcc,bJetInEMCalAcc);
1011 //_______________________________________________________________________________
1013 void AliAnalysisTaskFlavourJetCorrelations::FillHistogramsD0JetCorr(AliAODRecoDecayHF* candidate, Double_t dPhi, Double_t phiD, Double_t z, Double_t ptD, Double_t ptj, Bool_t bDInEMCalAcc, Bool_t bJetInEMCalAcc, AliAODEvent* aodEvent){
1016 Double_t masses[2]={0.,0.};
1017 Int_t pdgdaughtersD0[2]={211,321};//pi,K
1018 Int_t pdgdaughtersD0bar[2]={321,211};//K,pi
1020 masses[0]=candidate->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0); //D0
1021 masses[1]=candidate->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0bar); //D0bar
1023 TH3F* hPtJetWithD=(TH3F*)fOutput->FindObject("hPtJetWithD");
1024 THnSparseF* hsDphiz=(THnSparseF*)fOutput->FindObject("hsDphiz");
1026 Double_t point[9]={z,dPhi,ptj,ptD,masses[0],0, static_cast<Double_t>(fIsDInJet ? 1 : 0),bDInEMCalAcc,bJetInEMCalAcc};
1027 Printf("Candidate in FillHistogramsD0JetCorr IsA %s", (candidate->IsA())->GetName());
1028 Int_t isselected=fCuts->IsSelected(candidate,AliRDHFCuts::kAll,aodEvent);
1029 if(isselected==1 || isselected==3) {
1031 if(fIsDInJet) hPtJetWithD->Fill(ptj,masses[0],ptD);
1033 FillMassHistograms(masses[0], ptD);
1034 hsDphiz->Fill(point,1.);
1037 if(fIsDInJet) hPtJetWithD->Fill(ptj,masses[1],ptD);
1039 FillMassHistograms(masses[1], ptD);
1041 hsDphiz->Fill(point,1.);
1046 //_______________________________________________________________________________
1048 void AliAnalysisTaskFlavourJetCorrelations::FillHistogramsDstarJetCorr(AliAODRecoCascadeHF* dstar, Double_t dPhi, Double_t phiD, Double_t z, Double_t ptD, Double_t ptj, Bool_t bDInEMCalAcc, Bool_t bJetInEMCalAcc){
1049 //dPhi and z not used at the moment,but will be (re)added
1051 AliAODTrack *softpi = (AliAODTrack*)dstar->GetBachelor();
1052 Double_t deltamass= dstar->DeltaInvMass();
1053 //Double_t massD0= dstar->InvMassD0();
1056 TH1F* hPtPion=(TH1F*)fOutput->FindObject("hPtPion");
1057 hPtPion->Fill(softpi->Pt());
1059 TH3F* hPtJetWithD=(TH3F*)fOutput->FindObject("hPtJetWithD");
1060 THnSparseF* hsDphiz=(THnSparseF*)fOutput->FindObject("hsDphiz");
1061 Int_t isSB=0;//IsDzeroSideBand(dstar);
1063 Double_t point[]={z,dPhi,ptj,ptD,deltamass,static_cast<Double_t>(isSB), static_cast<Double_t>(fIsDInJet ? 1 : 0),bDInEMCalAcc,bJetInEMCalAcc};
1065 if(fIsDInJet) hPtJetWithD->Fill(ptj,deltamass,ptD);
1067 FillMassHistograms(deltamass, ptD);
1068 hsDphiz->Fill(point,1.);
1072 //_______________________________________________________________________________
1074 void AliAnalysisTaskFlavourJetCorrelations::FillHistogramsMCGenDJetCorr(Double_t dPhi,Double_t phiD,Double_t z,Double_t ptD,Double_t ptjet, Bool_t bDInEMCalAcc, Bool_t bJetInEMCalAcc){
1077 TH3F* hPtJetWithD=(TH3F*)fOutput->FindObject("hPtJetWithD");
1078 THnSparseF* hsDphiz=(THnSparseF*)fOutput->FindObject("hsDphiz");
1079 Double_t point[9]={z,dPhi,ptjet,ptD,pdgmass,0, static_cast<Double_t>(fIsDInJet ? 1 : 0),bDInEMCalAcc,bJetInEMCalAcc};
1081 if(fCandidateType==kD0toKpi) pdgmass=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1082 if(fCandidateType==kDstartoKpipi) pdgmass=TDatabasePDG::Instance()->GetParticle(413)->Mass()-TDatabasePDG::Instance()->GetParticle(421)->Mass();
1084 hsDphiz->Fill(point,1.);
1086 hPtJetWithD->Fill(ptjet,pdgmass,ptD); // candidates within a jet
1091 //_______________________________________________________________________________
1093 void AliAnalysisTaskFlavourJetCorrelations::FillMassHistograms(Double_t mass,Double_t ptD){
1096 TH2F* hInvMassptD=(TH2F*)fOutput->FindObject("hInvMassptD");
1097 hInvMassptD->Fill(mass,ptD);
1101 //________________________________________________________________________________
1103 void AliAnalysisTaskFlavourJetCorrelations::FlagFlavour(AliEmcalJet *jet){
1105 AliEmcalJet::EFlavourTag tag=AliEmcalJet::kDStar;
1106 if (fCandidateType==kD0toKpi) tag=AliEmcalJet::kD0;
1107 if (fIsDInJet) jet->AddFlavourTag(tag);
1113 //_______________________________________________________________________________
1115 void AliAnalysisTaskFlavourJetCorrelations::SideBandBackground(AliAODRecoCascadeHF *candDstar, AliEmcalJet *jet){
1117 // D* side band background method. Two side bands, in M(Kpi) are taken at ~6 sigmas
1118 // (expected detector resolution) on the left and right frm the D0 mass. Each band
1119 // has a width of ~5 sigmas. Two band needed for opening angle considerations
1120 TH2F* hDiffSideBand=(TH2F*)fOutput->FindObject("hDiffSideBand");
1121 TH3F* hPtJetWithDsb=(TH3F*)fOutput->FindObject("hPtJetWithDsb");
1122 THnSparseF* hsDphiz=(THnSparseF*)fOutput->FindObject("hsDphiz");
1124 Bool_t bDInEMCalAcc=InEMCalAcceptance(candDstar);
1125 Bool_t bJetInEMCalAcc=InEMCalAcceptance(jet);
1127 Double_t deltaM=candDstar->DeltaInvMass();
1128 //Printf("Inv mass = %f between %f and %f or %f and %f?",invM, sixSigmal,fourSigmal,fourSigmar,sixSigmar);
1129 Double_t z=Z(candDstar,jet);
1130 Double_t ptD=candDstar->Pt();
1132 Double_t dPhi=jet->Phi()-candDstar->Phi();
1134 if(dPhi<=-(TMath::Pi())/2) dPhi = dPhi+2*(TMath::Pi());
1135 if(dPhi>(3*(TMath::Pi()))/2) dPhi = dPhi-2*(TMath::Pi());
1137 Int_t isSideBand=1;//IsDzeroSideBand(candDstar);
1138 Double_t point[9]={z,dPhi,fPtJet,ptD,deltaM,static_cast<Double_t>(isSideBand), static_cast<Double_t>(fIsDInJet ? 1 : 0),bDInEMCalAcc,bJetInEMCalAcc};
1139 //fill the background histogram with the side bands or when looking at MC with the real background
1141 hDiffSideBand->Fill(deltaM,ptD); // M(Kpipi)-M(Kpi) side band background
1142 //hdeltaPhiDjaB->Fill(deltaM,ptD,dPhi);
1143 hsDphiz->Fill(point,1.);
1144 if(fIsDInJet){ // evaluate in the near side
1145 hPtJetWithDsb->Fill(fPtJet,deltaM,ptD);
1150 //_______________________________________________________________________________
1152 void AliAnalysisTaskFlavourJetCorrelations::MCBackground(AliAODRecoDecayHF *candbg){
1154 //need mass, deltaR, pt jet, ptD
1155 //two cases: D0 and Dstar
1157 Int_t isselected=fCuts->IsSelected(candbg,AliRDHFCuts::kAll, AODEvent());
1158 if(!isselected) return;
1160 Double_t ptD=candbg->Pt();
1162 TH2F* hInvMassptDbg=(TH2F*)fOutput->FindObject("hInvMassptDbg");
1163 TH3F* hPtJetWithDsb=(TH3F*)fOutput->FindObject("hPtJetWithDsb");
1166 if(fCandidateType==kDstartoKpipi){
1167 AliAODRecoCascadeHF* dstarbg = (AliAODRecoCascadeHF*)candbg;
1168 Double_t deltaM=dstarbg->DeltaInvMass();
1169 hInvMassptDbg->Fill(deltaM,ptD);
1170 if(fIsDInJet) hPtJetWithDsb->Fill(fPtJet,deltaM,ptD);
1173 if(fCandidateType==kD0toKpi){
1174 Double_t masses[2]={0.,0.};
1175 Int_t pdgdaughtersD0[2]={211,321};//pi,K
1176 Int_t pdgdaughtersD0bar[2]={321,211};//K,pi
1178 masses[0]=candbg->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0); //D0
1179 masses[1]=candbg->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0bar); //D0bar
1182 if(isselected==1 || isselected==3) {
1183 if(fIsDInJet) hPtJetWithDsb->Fill(fPtJet,masses[0],ptD);
1184 hInvMassptDbg->Fill(masses[0],ptD);
1187 if(fIsDInJet) hPtJetWithDsb->Fill(fPtJet,masses[1],ptD);
1188 hInvMassptDbg->Fill(masses[1],ptD);
1195 //_______________________________________________________________________________
1197 Float_t AliAnalysisTaskFlavourJetCorrelations::DeltaR(AliVParticle *p1, AliVParticle *p2) const {
1198 //Calculate DeltaR between p1 and p2: DeltaR=sqrt(Delataphi^2+DeltaEta^2)
1200 if(!p1 || !p2) return -1;
1201 Double_t phi1=p1->Phi(),eta1=p1->Eta();
1202 Double_t phi2 = p2->Phi(),eta2 = p2->Eta() ;
1204 Double_t dPhi=phi1-phi2;
1205 if(dPhi<=-(TMath::Pi())/2) dPhi = dPhi+2*(TMath::Pi());
1206 if(dPhi>(3*(TMath::Pi()))/2) dPhi = dPhi-2*(TMath::Pi());
1208 Double_t dEta=eta1-eta2;
1209 Double_t deltaR=TMath::Sqrt(dEta*dEta + dPhi*dPhi );
1214 //_______________________________________________________________________________
1216 Int_t AliAnalysisTaskFlavourJetCorrelations::IsDzeroSideBand(AliAODRecoCascadeHF *candDstar){
1218 Double_t ptD=candDstar->Pt();
1219 Int_t bin = fCuts->PtBin(ptD);
1221 // /PWGHF/vertexingHF/AliRDHFCuts::PtBin(Double_t) const may return values below zero depending on config.
1222 bin = 9999; // void result code for coverity (bin later in the code non-zero) - will coverity pick up on this?
1223 return -1; // out of bounds
1226 Double_t invM=candDstar->InvMassD0();
1227 Double_t mPDGD0=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1229 Float_t fourSigmal= mPDGD0-4.*fSigmaD0[bin] , sixSigmal= mPDGD0-8.*fSigmaD0[bin];
1230 Float_t fourSigmar= mPDGD0+4.*fSigmaD0[bin] , sixSigmar= mPDGD0+8.*fSigmaD0[bin];
1232 if((invM>=sixSigmal && invM<fourSigmal) || (invM>fourSigmar && invM<=sixSigmar)) return 1;
1237 //_______________________________________________________________________________
1239 Bool_t AliAnalysisTaskFlavourJetCorrelations::AreDaughtersInJet(AliEmcalJet *thejet, AliAODRecoDecayHF* charm, Int_t*& daughOutOfJetID, AliAODTrack**& dtrks, Bool_t fillH){
1240 //returns true/false and the array of particles not found among jet constituents
1242 TH1I* hControlDInJ=(TH1I*)fOutput->FindObject("hControlDInJ");
1243 TH1I* hIDddaugh =(TH1I*)fOutput->FindObject("hIDddaugh");
1244 TH1I* hIDddaughOut=(TH1I*)fOutput->FindObject("hIDddaughOut");
1245 TH1I* hIDjetTracks=(TH1I*)fOutput->FindObject("hIDjetTracks");
1247 Int_t daughtersID[3];
1249 Int_t dmatchedID[3]={0,0,0};
1250 Int_t countmatches=0;
1251 if (fCandidateType==kDstartoKpipi){
1252 AliAODRecoCascadeHF* dstar = (AliAODRecoCascadeHF*)charm;
1253 AliAODRecoDecayHF2Prong* dzero=dstar->Get2Prong();
1254 daughtersID[0]=dzero->GetProngID(0);
1255 daughtersID[1]=dzero->GetProngID(1);
1256 daughtersID[2]=dstar->GetBachelor()->GetID();
1259 dtrks=new AliAODTrack*[3];
1260 dtrks[0]=(AliAODTrack*)dzero->GetDaughter(0);
1261 dtrks[1]=(AliAODTrack*)dzero->GetDaughter(1);
1262 dtrks[2]=(AliAODTrack*)dstar->GetBachelor();
1266 if(daughtersID[0]!=((AliAODTrack*)dtrks[0])->GetID() || daughtersID[1]!=((AliAODTrack*)dtrks[1])->GetID()) hControlDInJ->Fill(6);
1268 hIDddaugh->Fill(daughtersID[0]);
1269 hIDddaugh->Fill(daughtersID[1]);
1270 hIDddaugh->Fill(daughtersID[2]);
1273 //Printf("ID daughters %d, %d, %d",daughtersID[0], daughtersID[1], daughtersID[2]);
1276 if (fCandidateType==kD0toKpi){
1277 daughtersID[0]=charm->GetProngID(0);
1278 daughtersID[1]=charm->GetProngID(1);
1281 hIDddaugh->Fill(daughtersID[0]);
1282 hIDddaugh->Fill(daughtersID[1]);
1284 dtrks=new AliAODTrack*[2];
1285 dtrks[0]=(AliAODTrack*)charm->GetDaughter(0);
1286 dtrks[1]=(AliAODTrack*)charm->GetDaughter(1);
1290 const Int_t cndaugh=ndaugh;
1291 daughOutOfJetID=new Int_t[cndaugh];
1293 Int_t nchtrk=thejet->GetNumberOfTracks();
1294 for(Int_t itk=0;itk<nchtrk;itk++){
1295 AliVTrack* tkjet=((AliPicoTrack*)thejet->TrackAt(itk,fTrackArr))->GetTrack();
1296 Int_t idtkjet=tkjet->GetID();
1297 if(fillH) hIDjetTracks->Fill(idtkjet);
1298 for(Int_t id=0;id<ndaugh;id++){
1299 if(idtkjet==daughtersID[id]) {
1300 dmatchedID[id]=daughtersID[id]; //daughter which matches a track in the jet
1305 if(countmatches==ndaugh) break;
1308 //reverse: include in the array the ID of daughters not matching
1310 for(Int_t id=0;id<ndaugh;id++){
1311 if(dmatchedID[id]==0) {
1312 daughOutOfJetID[id]=daughtersID[id];
1313 if(fillH) hIDddaughOut->Fill(daughOutOfJetID[id]);
1315 else daughOutOfJetID[id]=0;
1318 if((ndaugh-countmatches) == 1) hControlDInJ->Fill(0);
1319 if((ndaugh-countmatches) == 2) hControlDInJ->Fill(1);
1320 if((ndaugh-countmatches) == 3) hControlDInJ->Fill(2);
1322 if(ndaugh!=countmatches){
1329 //_______________________________________________________________________________
1331 Bool_t AliAnalysisTaskFlavourJetCorrelations::IsDInJet(AliEmcalJet *thejet, AliAODRecoDecayHF* charm, Bool_t fillH){
1333 //check the conditions type:
1334 //type 0 : DeltaR < jet radius, don't check daughters (and don't correct pt jet)
1335 //type 1 : DeltaR < jet radius and check for all daughters among jet tracks, don't correct ptjet
1336 //type 2 (default) : DeltaR < jet radius and check for all daughters among jet tracks, if not present, correct the ptjet
1338 TH1I* hControlDInJ=(TH1I*)fOutput->FindObject("hControlDInJ");
1339 TH1F* hDRdaughOut=(TH1F*)fOutput->FindObject("hDRdaughOut");
1345 Bool_t testDeltaR=kFALSE;
1346 if(DeltaR(thejet,charm)<fJetRadius) testDeltaR=kTRUE;
1348 Int_t* daughOutOfJet;
1349 AliAODTrack** charmDaugh;
1350 Bool_t testDaugh=AreDaughtersInJet(thejet, charm, daughOutOfJet,charmDaugh,fillH);
1351 if(testDaugh && testDeltaR) {
1352 //Z of candidates with daughters in the jet
1353 ((TH1F*)fOutput->FindObject("hzDinjet"))->Fill(Z(charm,thejet));
1356 if(!testDaugh && testDeltaR && fTypeDInJet==2){
1359 if(fCandidateType==kD0toKpi) ndaugh=2;
1362 for(Int_t id=0;id<ndaugh;id++){
1363 if(daughOutOfJet[id]!=0){ //non-matched daughter
1364 //get track and its momentum
1367 hControlDInJ->Fill(3);
1368 if(id<2) hControlDInJ->Fill(4);
1369 if(id==2)hControlDInJ->Fill(5);
1370 hDRdaughOut->Fill(DeltaR(thejet, charmDaugh[id]));
1372 fPmissing[0]+=charmDaugh[id]->Px();
1373 fPmissing[1]+=charmDaugh[id]->Py();
1374 fPmissing[2]+=charmDaugh[id]->Pz();
1379 //now the D in within the jet
1384 delete[] charmDaugh;
1387 switch(fTypeDInJet){
1392 result=testDeltaR && testDaugh;
1395 result=testDeltaR && testDaugh;
1398 AliInfo("Selection type not specified, use 1");
1399 result=testDeltaR && testDaugh;
1405 Bool_t AliAnalysisTaskFlavourJetCorrelations::InEMCalAcceptance(AliVParticle *vpart){
1406 //check eta phi of a VParticle: return true if it is in the EMCal acceptance, false otherwise
1408 Double_t phiEMCal[2]={1.405,3.135},etaEMCal[2]={-0.7,0.7};
1409 Bool_t binEMCal=kTRUE;
1410 Double_t phi=vpart->Phi(), eta=vpart->Eta();
1411 if(phi<phiEMCal[0] || phi>phiEMCal[1]) binEMCal=kFALSE;
1412 if(eta<etaEMCal[0] || eta>etaEMCal[1]) binEMCal=kFALSE;