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 **************************************************************************/
18 /////////////////////////////////////////////////////////////
20 // AliAnalysisTaskSE for D0 candidates invariant mass histogram
21 // and comparison with the MC truth and cut variables distributions.
23 // Authors: A.Dainese, andrea.dainese@lnl.infn.it
24 // Chiara Bianchin, chiara.bianchin@pd.infn.it (invariant mass)
25 // Carmelo Di Giglio, carmelo.digiglio@ba.infn.it (like sign)
26 // Jeremy Wilkinson, jwilkinson@physi.uni-heidelberg.de (weighted Bayesian)
27 /////////////////////////////////////////////////////////////
29 #include <Riostream.h>
30 #include <TClonesArray.h>
37 #include <TDatabasePDG.h>
39 #include <AliAnalysisDataSlot.h>
40 #include <AliAnalysisDataContainer.h>
41 #include "AliAnalysisManager.h"
42 #include "AliESDtrack.h"
43 #include "AliVertexerTracks.h"
44 #include "AliAODHandler.h"
45 #include "AliAODEvent.h"
46 #include "AliAODVertex.h"
47 #include "AliAODTrack.h"
48 #include "AliAODMCHeader.h"
49 #include "AliAODMCParticle.h"
50 #include "AliAODRecoDecayHF2Prong.h"
51 #include "AliAODRecoCascadeHF.h"
52 #include "AliAnalysisVertexingHF.h"
53 #include "AliAnalysisTaskSE.h"
54 #include "AliAnalysisTaskSED0Mass.h"
55 #include "AliNormalizationCounter.h"
60 ClassImp(AliAnalysisTaskSED0Mass)
63 //________________________________________________________________________
64 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass():
80 fIsSelectedCandidate(0),
83 fIsRejectSDDClusters(0),
85 fFillImpParHist(kFALSE),
86 fUseSelectionBit(kTRUE),
87 fWriteVariableTree(kFALSE),
89 fCandidateVariables(),
91 fDrawDetSignal(kFALSE),
94 // Default constructor
95 for(Int_t ih=0; ih<5; ih++) fHistMassPtImpParTC[ih]=0x0;
99 //________________________________________________________________________
100 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name,AliRDHFCutsD0toKpi* cuts):
101 AliAnalysisTaskSE(name),
113 fLsNormalization(1.),
116 fIsSelectedCandidate(0),
117 fFillVarHists(kTRUE),
119 fIsRejectSDDClusters(0),
121 fFillImpParHist(kFALSE),
122 fUseSelectionBit(kTRUE),
123 fWriteVariableTree(kFALSE),
125 fCandidateVariables(),
127 fDrawDetSignal(kFALSE),
130 // Default constructor
132 fNPtBins=cuts->GetNPtBins();
135 for(Int_t ih=0; ih<5; ih++) fHistMassPtImpParTC[ih]=0x0;
137 // Output slot #1 writes into a TList container (mass with cuts)
138 DefineOutput(1,TList::Class()); //My private output
139 // Output slot #2 writes into a TList container (distributions)
140 DefineOutput(2,TList::Class()); //My private output
141 // Output slot #3 writes into a TH1F container (number of events)
142 DefineOutput(3,TH1F::Class()); //My private output
143 // Output slot #4 writes into a TList container (cuts)
144 DefineOutput(4,AliRDHFCutsD0toKpi::Class()); //My private output
145 // Output slot #5 writes Normalization Counter
146 DefineOutput(5,AliNormalizationCounter::Class());
147 // Output slot #6 stores the mass vs pt and impact parameter distributions
148 DefineOutput(6,TList::Class()); //My private output
149 // Output slot #7 keeps a tree of the candidate variables after track selection
150 DefineOutput(7,TTree::Class()); //My private outpu
151 // Output slot #8 writes into a TList container (Detector signals)
152 DefineOutput(8, TList::Class()); //My private output
155 //________________________________________________________________________
156 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
163 delete fOutputMassPt;
174 for(Int_t i=0; i<5; i++){
175 if(fHistMassPtImpParTC[i]) delete fHistMassPtImpParTC[i];
186 delete fVariablesTree;
196 //________________________________________________________________________
197 void AliAnalysisTaskSED0Mass::Init()
201 if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
204 AliRDHFCutsD0toKpi* copyfCuts=new AliRDHFCutsD0toKpi(*fCuts);
205 const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
206 copyfCuts->SetName(nameoutput);
208 PostData(4,copyfCuts);
214 //________________________________________________________________________
215 void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
218 // Create the output container
220 if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
222 // Several histograms are more conveniently managed in a TList
223 fOutputMass = new TList();
224 fOutputMass->SetOwner();
225 fOutputMass->SetName("listMass");
227 fOutputMassPt = new TList();
228 fOutputMassPt->SetOwner();
229 fOutputMassPt->SetName("listMassPt");
231 fDistr = new TList();
233 fDistr->SetName("distributionslist");
235 fDetSignal = new TList();
236 fDetSignal->SetOwner();
237 fDetSignal->SetName("detectorsignals");
239 TString nameMass=" ",nameSgn27=" ",nameSgn=" ", nameBkg=" ", nameRfl=" ",nameMassNocutsS =" ",nameMassNocutsB =" ", namedistr=" ";
240 TString nameMassPt="", nameSgnPt="", nameBkgPt="", nameRflPt="";
241 Int_t nbins2dPt=60; Float_t binInPt=0., binFinPt=30.;
243 for(Int_t i=0;i<fCuts->GetNPtBins();i++){
245 nameMass="histMass_";
247 nameSgn27="histSgn27_";
255 nameMassNocutsS="hMassS_";
257 nameMassNocutsB="hMassB_";
260 //histograms of cut variable distributions
266 TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
270 TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
274 TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
277 TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
282 TH1F *hdeclengthS = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm]",200,0,0.015);
284 namedistr="hnormdeclS_";
286 TH1F *hnormdeclengthS = new TH1F(namedistr.Data(), "Normalized Decay Length^{2} distribution;(Decay Length/Err)^{2} ",200,0,12.);
288 namedistr="hdeclxyS_";
290 TH1F* hdeclxyS=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);
291 namedistr="hnormdeclxyS_";
293 TH1F* hnormdeclxyS=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6.);
295 namedistr="hdeclxyd0d0S_";
297 TH2F* hdeclxyd0d0S=new TH2F(namedistr.Data(),"Correlation decay Length XY - d_{0}#times d_{0};Decay Length XY [cm];d_{0}#times d_{0}[cm^{2}]",200,0,0.15,200,-0.001,0.001);
299 namedistr="hnormdeclxyd0d0S_";
301 TH2F* hnormdeclxyd0d0S=new TH2F(namedistr.Data(),"Correlation normalized decay Length XY - d_{0}#times d_{0};Decay Length XY/Err;d_{0}#times d_{0}[cm^{2}]",200,0,6,200,-0.001,0.001);
304 namedistr="hcosthetapointS_";
306 TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
308 namedistr="hcosthetapointxyS_";
310 TH1F *hcosthetapointxyS = new TH1F(namedistr.Data(), "cos#theta_{Point} XYdistribution;cos#theta_{Point}",300,0.,1.);
312 TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
323 fDistr->Add(hcosthetapointS);
325 fDistr->Add(hcosthetapointxyS);
327 fDistr->Add(hdeclengthS);
329 fDistr->Add(hnormdeclengthS);
331 fDistr->Add(hdeclxyS);
333 fDistr->Add(hnormdeclxyS);
335 fDistr->Add(hdeclxyd0d0S);
336 fDistr->Add(hnormdeclxyd0d0S);
344 TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
349 TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
353 TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
358 TH1F *hdeclengthB = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm^{2}]",200,0,0.015);
360 namedistr="hnormdeclB_";
362 TH1F *hnormdeclengthB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;(Decay Length/Err)^{2} ",200,0,12.);
364 namedistr="hdeclxyB_";
366 TH1F* hdeclxyB=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);
367 namedistr="hnormdeclxyB_";
369 TH1F* hnormdeclxyB=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6.);
371 namedistr="hdeclxyd0d0B_";
373 TH2F* hdeclxyd0d0B=new TH2F(namedistr.Data(),"Correlation decay Length XY - d_{0}#times d_{0};Decay Length XY [cm];d_{0}#times d_{0}[cm^{2}]",200,0,0.15,200,-0.001,0.001);
375 namedistr="hnormdeclxyd0d0B_";
377 TH2F* hnormdeclxyd0d0B=new TH2F(namedistr.Data(),"Correlation normalized decay Length XY - d_{0}#times d_{0};Decay Length XY/Err;d_{0}#times d_{0}[cm^{2}]",200,0,6,200,-0.001,0.001);
380 namedistr="hcosthetapointB_";
382 TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
384 namedistr="hcosthetapointxyB_";
386 TH1F *hcosthetapointxyB = new TH1F(namedistr.Data(), "cos#theta_{Point} XY distribution;cos#theta_{Point} XY",300,0.,1.);
388 TH1F* tmpMB = new TH1F(nameMassNocutsB.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
399 fDistr->Add(hcosthetapointB);
401 fDistr->Add(hcosthetapointxyB);
403 fDistr->Add(hdeclengthB);
405 fDistr->Add(hnormdeclengthB);
407 fDistr->Add(hdeclxyB);
409 fDistr->Add(hnormdeclxyB);
411 fDistr->Add(hdeclxyd0d0B);
412 fDistr->Add(hnormdeclxyd0d0B);
416 //histograms filled only when the secondary vertex is recalculated w/o the daughter tracks (as requested in the cut object)
418 if(fCuts->GetIsPrimaryWithoutDaughters()){
420 namedistr="hd0vpiS_";
422 TH1F *hd0vpiS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions)(vtx w/o these tracks);d0(#pi) [cm]",200,-0.1,0.1);
426 TH1F *hd0vKS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons) (vtx w/o these tracks);d0(K) [cm]",200,-0.1,0.1);
428 namedistr="hd0d0vS_";
430 TH1F *hd0d0vS = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (vtx w/o these tracks);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
432 namedistr="hdeclvS_";
434 TH1F *hdeclengthvS = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
436 namedistr="hnormdeclvS_";
438 TH1F *hnormdeclengthvS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
440 fDistr->Add(hd0vpiS);
442 fDistr->Add(hd0d0vS);
443 fDistr->Add(hdeclengthvS);
444 fDistr->Add(hnormdeclengthvS);
448 namedistr="hd0vmoresB_";
450 TH1F *hd0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
452 namedistr="hd0d0vmoresB_";
454 TH1F *hd0d0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
459 TH1F *hd0vB = new TH1F(namedistr.Data(), "Impact parameter distribution (vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
461 namedistr="hd0vp0B_";
463 TH1F *hd0vp0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong + ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
465 namedistr="hd0vp1B_";
467 TH1F *hd0vp1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong - ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
469 namedistr="hd0d0vB_";
471 TH1F *hd0d0vB = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (vtx w/o these tracks);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
473 namedistr="hdeclvB_";
475 TH1F *hdeclengthvB = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
477 namedistr="hnormdeclvB_";
479 TH1F *hnormdeclengthvB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
482 fDistr->Add(hd0vp0B);
483 fDistr->Add(hd0vp1B);
484 fDistr->Add(hd0vmoresB);
486 fDistr->Add(hd0d0vB);
487 fDistr->Add(hd0d0vmoresB);
489 fDistr->Add(hdeclengthvB);
491 fDistr->Add(hnormdeclengthvB);
496 //histograms of invariant mass distributions
501 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
503 TH1F *tmpSl=(TH1F*)tmpSt->Clone();
507 //Reflection: histo filled with D0Mass which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
508 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
509 //TH1F *tmpRl=(TH1F*)tmpRt->Clone();
510 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
511 //TH1F *tmpBl=(TH1F*)tmpBt->Clone();
517 fOutputMass->Add(tmpSt);
518 fOutputMass->Add(tmpRt);
519 fOutputMass->Add(tmpBt);
524 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.5648,2.1648);
525 //TH1F *tmpMl=(TH1F*)tmpMt->Clone();
528 //distribution w/o cuts large range
529 // TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,0.7,3.);
531 fOutputMass->Add(tmpMt);
533 if(fSys==0){ //histograms filled only in pp to save time in PbPb
540 TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
544 TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
547 namedistr="hcosthetastarS_";
549 TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
553 namedistr="hptpiSnoMcut_";
555 TH1F *hptpiSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
557 namedistr="hptKSnoMcut_";
559 TH1F *hptKSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
563 fDistr->Add(hcosthetastarS);
565 fDistr->Add(hptpiSnoMcut);
566 fDistr->Add(hptKSnoMcut);
568 // costhetapoint vs d0 or d0d0
569 namedistr="hcosthpointd0S_";
571 TH2F *hcosthpointd0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0};cos#theta_{Point};d_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
572 namedistr="hcosthpointd0d0S_";
574 TH2F *hcosthpointd0d0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
576 fDistr->Add(hcosthpointd0S);
577 fDistr->Add(hcosthpointd0d0S);
579 //to compare with AliAnalysisTaskCharmFraction
580 TH1F* tmpS27t = new TH1F(nameSgn27.Data(),"D^{0} invariant mass in M(D^{0}) +/- 27 MeV - MC; M [GeV]; Entries",200,1.5648,2.1648);
581 TH1F *tmpS27l=(TH1F*)tmpS27t->Clone();
585 fOutputMass->Add(tmpS27t);
586 fOutputMass->Add(tmpS27l);
593 TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
596 namedistr="hcosthetastarB_";
598 TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
601 namedistr="hptB1prongnoMcut_";
603 TH1F *hptB1pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
605 namedistr="hptB2prongsnoMcut_";
607 TH1F *hptB2pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
610 fDistr->Add(hcosthetastarB);
612 fDistr->Add(hptB1pnoMcut);
613 fDistr->Add(hptB2pnoMcut);
615 //impact parameter of negative/positive track
618 TH1F *hd0p0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.1,0.1);
622 TH1F *hd0p1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong -);d0 [cm]",200,-0.1,0.1);
624 //impact parameter corrected for strangeness
625 namedistr="hd0moresB_";
627 TH1F *hd0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
629 namedistr="hd0d0moresB_";
631 TH1F *hd0d0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
634 namedistr="hcosthetapointmoresB_";
636 TH1F *hcosthetapointmoresB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
638 // costhetapoint vs d0 or d0d0
639 namedistr="hcosthpointd0B_";
641 TH2F *hcosthpointd0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0};cos#theta_{Point};d_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
643 namedistr="hcosthpointd0d0B_";
645 TH2F *hcosthpointd0d0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
650 fDistr->Add(hd0moresB);
651 fDistr->Add(hd0d0moresB);
652 fDistr->Add(hcosthetapointmoresB);
655 fDistr->Add(hcosthpointd0B);
658 fDistr->Add(hcosthpointd0d0B);
665 //for Like sign analysis
668 namedistr="hpospair";
669 TH1F* hpospair=new TH1F(namedistr.Data(),"Number of positive pairs",fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
670 namedistr="hnegpair";
671 TH1F* hnegpair=new TH1F(namedistr.Data(),"Number of negative pairs",fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
672 fOutputMass->Add(hpospair);
673 fOutputMass->Add(hnegpair);
677 // 2D Pt distributions and impact parameter histograms
680 nameMassPt="histMassPt";
681 nameSgnPt="histSgnPt";
682 nameBkgPt="histBkgPt";
683 nameRflPt="histRflPt";
687 TH2F* tmpStPt = new TH2F(nameSgnPt.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries; Pt[GeV/c]",200,1.5648,2.16484,nbins2dPt,binInPt,binFinPt);
688 TH2F *tmpSlPt=(TH2F*)tmpStPt->Clone();
692 //Reflection: histo filled with D0MassV1 which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
693 TH2F* tmpRtPt = new TH2F(nameRflPt.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries; Pt[GeV/c]",200,1.5648,2.1648,nbins2dPt,binInPt,binFinPt);
694 TH2F* tmpBtPt = new TH2F(nameBkgPt.Data(), "Background invariant mass - MC; M [GeV]; Entries; Pt[GeV/c]",200,1.5648,2.1648,nbins2dPt,binInPt,binFinPt);
698 fOutputMassPt->Add(tmpStPt);
699 fOutputMassPt->Add(tmpRtPt);
700 fOutputMassPt->Add(tmpBtPt);
702 // cout<<endl<<endl<<"***************************************"<<endl;
703 // cout << " created and added to the list "<< nameSgnPt.Data() <<" "<< tmpStPt <<
704 // ", "<<nameRflPt.Data() <<" " << tmpRtPt<<", "<<nameBkgPt.Data()<< " " << tmpBtPt <<endl;
705 // cout<<"***************************************"<<endl<<endl;
708 TH2F* tmpMtPt = new TH2F(nameMassPt.Data(),"D^{0} invariant mass; M [GeV]; Entries; Pt[GeV/c]",200,1.5648,2.1648,nbins2dPt,binInPt,binFinPt);
711 fOutputMassPt->Add(tmpMtPt);
714 if(fFillImpParHist) CreateImpactParameterHistos();
716 const char* nameoutput=GetOutputSlot(3)->GetContainer()->GetName();
718 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", 18,-0.5,17.5);
720 fNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
721 fNentries->GetXaxis()->SetBinLabel(2,"nCandSel(Cuts)");
722 if(fReadMC) fNentries->GetXaxis()->SetBinLabel(3,"nD0Selected");
723 else fNentries->GetXaxis()->SetBinLabel(3,"Dstar<-D0");
724 fNentries->GetXaxis()->SetBinLabel(4,"nEventsGoodVtxS");
725 fNentries->GetXaxis()->SetBinLabel(5,"ptbin = -1");
726 fNentries->GetXaxis()->SetBinLabel(6,"no daughter");
727 if(fSys==0) fNentries->GetXaxis()->SetBinLabel(7,"nCandSel(Tr)");
728 if(fFillVarHists || fPIDCheck){
729 fNentries->GetXaxis()->SetBinLabel(8,"PID=0");
730 fNentries->GetXaxis()->SetBinLabel(9,"PID=1");
731 fNentries->GetXaxis()->SetBinLabel(10,"PID=2");
732 fNentries->GetXaxis()->SetBinLabel(11,"PID=3");
734 if(fReadMC && fSys==0){
735 fNentries->GetXaxis()->SetBinLabel(12,"K");
736 fNentries->GetXaxis()->SetBinLabel(13,"Lambda");
738 fNentries->GetXaxis()->SetBinLabel(14,"Pile-up Rej");
739 fNentries->GetXaxis()->SetBinLabel(15,"N. of 0SMH");
740 if(fSys==1) fNentries->GetXaxis()->SetBinLabel(16,"Nev in centr");
741 if(fIsRejectSDDClusters) fNentries->GetXaxis()->SetBinLabel(17,"SDD-Cls Rej");
742 fNentries->GetXaxis()->SetBinLabel(18,"Phys.Sel.Rej");
743 fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
745 fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(5)->GetContainer()->GetName()));
749 // Output slot 7 : tree of the candidate variables after track selection
751 nameoutput = GetOutputSlot(7)->GetContainer()->GetName();
752 fVariablesTree = new TTree(nameoutput,"Candidates variables tree");
754 fCandidateVariables = new Double_t [nVar];
755 TString * fCandidateVariableNames = new TString[nVar];
756 fCandidateVariableNames[0] = "massD0";
757 fCandidateVariableNames[1] = "massD0bar";
758 fCandidateVariableNames[2] = "pt";
759 fCandidateVariableNames[3] = "dca";
760 fCandidateVariableNames[4] = "costhsD0";
761 fCandidateVariableNames[5] = "costhsD0bar";
762 fCandidateVariableNames[6] = "ptk";
763 fCandidateVariableNames[7] = "ptpi";
764 fCandidateVariableNames[8] = "d0k";
765 fCandidateVariableNames[9] = "d0pi";
766 fCandidateVariableNames[10] = "d0xd0";
767 fCandidateVariableNames[11] = "costhp";
768 fCandidateVariableNames[12] = "costhpxy";
769 fCandidateVariableNames[13] = "lxy";
770 fCandidateVariableNames[14] = "specialcuts";
771 for(Int_t ivar=0; ivar<nVar; ivar++){
772 fVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/d",fCandidateVariableNames[ivar].Data()));
776 // Output slot 8 : List for detector response histograms
778 if (fDrawDetSignal) {
779 TH2F *TOFSigBefPID = new TH2F("TOFSigBefPID", "TOF signal of daughters before PID;p(daught)(GeV/c);Signal", 500, 0, 10, 5000, 0, 50e3);
780 TH2F *TOFSigAftPID = new TH2F("TOFSigAftPID", "TOF signal after PID;p(daught)(GeV/c);Signal", 500, 0, 10, 5000, 0, 50e3);
782 TH2F *TPCSigBefPID = new TH2F("TPCSigBefPID", "TPC dE/dx before PID;p(daught)(GeV/c);dE/dx (arb. units)", 1000, 0, 10, 1000, 0, 500);
783 TH2F *TPCSigAftPID = new TH2F("TPCSigAftPID", "TPC dE/dx after PID;p(daught)(GeV/c);dE/dx (arb. units)", 1000, 0, 10, 1000, 0, 500);
785 fDetSignal->Add(TOFSigBefPID);
786 fDetSignal->Add(TOFSigAftPID);
787 fDetSignal->Add(TPCSigBefPID);
788 fDetSignal->Add(TPCSigAftPID);
792 PostData(1,fOutputMass);
794 PostData(3,fNentries);
795 PostData(5,fCounter);
796 PostData(6,fOutputMassPt);
797 PostData(7,fVariablesTree);
798 PostData(8, fDetSignal);
803 //________________________________________________________________________
804 void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
806 // Execute analysis for current event:
807 // heavy flavor candidates association to MC truth
808 //cout<<"I'm in UserExec"<<endl;
812 // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
813 // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
814 // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
815 // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
816 // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
817 // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
818 // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
819 // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
820 // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
823 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
826 if(fArray==0){ //D0 candidates
827 // load D0->Kpi candidates
828 //cout<<"D0 candidates"<<endl;
830 } else { //LikeSign candidates
831 // load like sign candidates
832 //cout<<"LS candidates"<<endl;
833 bname="LikeSign2Prong";
836 TClonesArray *inputArray=0;
838 if(!aod && AODEvent() && IsStandardAOD()) {
839 // In case there is an AOD handler writing a standard AOD, use the AOD
840 // event in memory rather than the input (ESD) event.
841 aod = dynamic_cast<AliAODEvent*> (AODEvent());
842 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
843 // have to taken from the AOD event hold by the AliAODExtension
844 AliAODHandler* aodHandler = (AliAODHandler*)
845 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
847 if(aodHandler->GetExtensions()) {
848 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
849 AliAODEvent* aodFromExt = ext->GetAOD();
850 inputArray=(TClonesArray*)aodFromExt->GetList()->FindObject(bname.Data());
853 inputArray=(TClonesArray*)aod->GetList()->FindObject(bname.Data());
857 if(!inputArray || !aod) {
858 printf("AliAnalysisTaskSED0Mass::UserExec: input branch not found!\n");
862 // fix for temporary bug in ESDfilter
863 // the AODs with null vertex pointer didn't pass the PhysSel
864 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
867 TClonesArray *mcArray = 0;
868 AliAODMCHeader *mcHeader = 0;
872 mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
874 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
879 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
881 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
886 //printf("VERTEX Z %f %f\n",vtx1->GetZ(),mcHeader->GetVtxZ());
888 //histogram filled with 1 for every AOD
890 fCounter->StoreEvent(aod,fCuts,fReadMC);
891 //fCounter->StoreEvent(aod,fReadMC);
893 // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
894 TString trigclass=aod->GetFiredTriggerClasses();
895 if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNentries->Fill(14);
897 if(!fCuts->IsEventSelected(aod)) {
898 if(fCuts->GetWhyRejection()==1) // rejected for pileup
900 if(fSys==1 && (fCuts->GetWhyRejection()==2 || fCuts->GetWhyRejection()==3)) fNentries->Fill(15);
901 if(fCuts->GetWhyRejection()==7) fNentries->Fill(17);
905 // Check the Nb of SDD clusters
906 if (fIsRejectSDDClusters) {
907 Bool_t skipEvent = kFALSE;
909 if (aod) ntracks = aod->GetNTracks();
910 for(Int_t itrack=0; itrack<ntracks; itrack++) { // loop on tacks
912 AliAODTrack * track = aod->GetTrack(itrack);
913 if(TESTBIT(track->GetITSClusterMap(),2) || TESTBIT(track->GetITSClusterMap(),3) ){
919 if (skipEvent) return;
922 // AOD primary vertex
923 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
925 Bool_t isGoodVtx=kFALSE;
928 TString primTitle = vtx1->GetTitle();
929 if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) {
934 // loop over candidates
935 Int_t nInD0toKpi = inputArray->GetEntriesFast();
936 if(fDebug>2) printf("Number of D0->Kpi: %d\n",nInD0toKpi);
938 // FILE *f=fopen("4display.txt","a");
939 // fprintf(f,"Number of D0->Kpi: %d\n",nInD0toKpi);
940 Int_t nSelectedloose=0,nSelectedtight=0;
941 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
942 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArray->UncheckedAt(iD0toKpi);
944 if(fUseSelectionBit && d->GetSelectionMap()) if(!d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)){
946 continue; //skip the D0 from Dstar
949 // Bool_t unsetvtx=kFALSE;
950 // if(!d->GetOwnPrimaryVtx()) {
951 // d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
956 if ( fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(421)) ) {
960 if(fCuts->IsSelected(d,AliRDHFCuts::kTracks,aod))fNentries->Fill(6);
962 Int_t ptbin=fCuts->PtBin(d->Pt());
963 if(ptbin==-1) {fNentries->Fill(4); continue;} //out of bounds
964 fIsSelectedCandidate=fCuts->IsSelected(d,AliRDHFCuts::kAll,aod); //selected
966 //if(!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate)) {
967 fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(0),0);
968 fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(1),1);
970 if(!fDaughterTracks.UncheckedAt(0) || !fDaughterTracks.UncheckedAt(1)) {
971 AliDebug(1,"at least one daughter not found!");
973 fDaughterTracks.Clear();
977 FillVarHists(aod,d,mcArray,fCuts,fDistr);
980 if (fDrawDetSignal) {
981 DrawDetSignal(d, fDetSignal);
984 FillMassHists(d,mcArray,mcHeader,fCuts,fOutputMass);
986 Int_t isSelectedPIDfill = 3;
987 if (!fReadMC || (fReadMC && fUsePid4Distr)) isSelectedPIDfill = fCuts->IsSelectedPID(d); //0 rejected,1 D0,2 Dobar, 3 both
989 if (isSelectedPIDfill == 0)fNentries->Fill(7);
990 if (isSelectedPIDfill == 1)fNentries->Fill(8);
991 if (isSelectedPIDfill == 2)fNentries->Fill(9);
992 if (isSelectedPIDfill == 3)fNentries->Fill(10);
997 fDaughterTracks.Clear();
998 //if(unsetvtx) d->UnsetOwnPrimaryVtx();
1000 fCounter->StoreCandidates(aod,nSelectedloose,kTRUE);
1001 fCounter->StoreCandidates(aod,nSelectedtight,kFALSE);
1003 PostData(1,fOutputMass);
1005 PostData(3,fNentries);
1006 PostData(5,fCounter);
1007 PostData(6,fOutputMassPt);
1008 PostData(7,fVariablesTree);
1009 PostData(8, fDetSignal);
1014 //____________________________________________________________________________
1015 void AliAnalysisTaskSED0Mass::DrawDetSignal(AliAODRecoDecayHF2Prong *part, TList *ListDetSignal)
1018 // Function called in UserExec for drawing detector signal histograms:
1020 fDaughterTracks.AddAt((AliAODTrack*)part->GetDaughter(0), 0);
1021 fDaughterTracks.AddAt((AliAODTrack*)part->GetDaughter(1), 1);
1023 AliESDtrack *esdtrack1 = new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(0));
1024 AliESDtrack *esdtrack2 = new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(1));
1027 //For filling detector histograms
1028 Int_t isSelectedPIDfill = 3;
1029 if (!fReadMC || (fReadMC && fUsePid4Distr)) isSelectedPIDfill = fCuts->IsSelectedPID(part); //0 rejected,1 D0,2 Dobar, 3 both
1032 //fill "before PID" histos with every daughter
1033 ((TH2F*)ListDetSignal->FindObject("TOFSigBefPID"))->Fill(esdtrack1->P(), esdtrack1->GetTOFsignal());
1034 ((TH2F*)ListDetSignal->FindObject("TOFSigBefPID"))->Fill(esdtrack2->P(), esdtrack2->GetTOFsignal());
1035 ((TH2F*)ListDetSignal->FindObject("TPCSigBefPID"))->Fill(esdtrack1->P(), esdtrack1->GetTPCsignal());
1036 ((TH2F*)ListDetSignal->FindObject("TPCSigBefPID"))->Fill(esdtrack2->P(), esdtrack2->GetTPCsignal());
1038 if (isSelectedPIDfill != 0) { //fill "After PID" with everything that's not rejected
1039 ((TH2F*)ListDetSignal->FindObject("TOFSigAftPID"))->Fill(esdtrack1->P(), esdtrack1->GetTOFsignal());
1040 ((TH2F*)ListDetSignal->FindObject("TOFSigAftPID"))->Fill(esdtrack2->P(), esdtrack2->GetTOFsignal());
1041 ((TH2F*)ListDetSignal->FindObject("TPCSigAftPID"))->Fill(esdtrack1->P(), esdtrack1->GetTPCsignal());
1042 ((TH2F*)ListDetSignal->FindObject("TPCSigAftPID"))->Fill(esdtrack2->P(), esdtrack2->GetTPCsignal());
1052 //____________________________________________________________________________
1053 void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi *cuts, TList *listout){
1055 // function used in UserExec to fill variable histograms:
1059 Int_t pdgDgD0toKpi[2]={321,211};
1061 if(fReadMC) lab=part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
1062 //Double_t pt = d->Pt(); //mother pt
1063 Int_t isSelectedPID=3;
1064 if(!fReadMC || (fReadMC && fUsePid4Distr)) isSelectedPID=cuts->IsSelectedPID(part); //0 rejected,1 D0,2 Dobar, 3 both
1065 if (!fPIDCheck) { //if fPIDCheck, this is already filled elsewhere
1066 if (isSelectedPID==0)fNentries->Fill(7);
1067 if (isSelectedPID==1)fNentries->Fill(8);
1068 if (isSelectedPID==2)fNentries->Fill(9);
1069 if (isSelectedPID==3)fNentries->Fill(10);
1070 //fNentries->Fill(8+isSelectedPID);
1073 if(fCutOnDistr && !fIsSelectedCandidate) return;
1074 //printf("\nif no cuts or cuts passed\n");
1080 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1083 Double_t minvD0 = part->InvMassD0();
1086 Double_t minvD0bar = part->InvMassD0bar();
1087 //cout<<"inside mass cut"<<endl;
1089 Double_t invmasscut=0.03;
1091 TString fillthispi="",fillthisK="",fillthis="", fillthispt="";
1093 Int_t ptbin=cuts->PtBin(part->Pt());
1094 Double_t pt = part->Pt();
1096 Double_t dz1[2],dz2[2],covar1[3],covar2[3];//,d0xd0proper,errd0xd0proper;
1097 dz1[0]=-99; dz2[0]=-99;
1099 Double_t decl[2]={-99,-99};
1100 Bool_t recalcvtx=kFALSE;
1104 if(fCuts->GetIsPrimaryWithoutDaughters()){
1106 //recalculate vertex
1107 AliAODVertex *vtxProp=0x0;
1108 vtxProp=GetPrimaryVtxSkipped(aod);
1110 part->SetOwnPrimaryVtx(vtxProp);
1111 //Bool_t unsetvtx=kTRUE;
1112 //Calculate d0 for daughter tracks with Vtx Skipped
1113 AliESDtrack *esdtrack1=new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(0));
1114 AliESDtrack *esdtrack2=new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(1));
1115 esdtrack1->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz1,covar1);
1116 esdtrack2->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz2,covar2);
1117 delete vtxProp; vtxProp=NULL;
1125 decl[0]=part->DecayLength2();
1126 decl[1]=part->NormalizedDecayLength2();
1127 part->UnsetOwnPrimaryVtx();
1131 Double_t cosThetaStarD0 = 99;
1132 Double_t cosThetaStarD0bar = 99;
1133 Double_t cosPointingAngle = 99;
1134 Double_t normalizedDecayLength2 = -1, normalizedDecayLengthxy=-1;
1135 Double_t decayLength2 = -1, decayLengthxy=-1;
1136 Double_t ptProng[2]={-99,-99};
1137 Double_t d0Prong[2]={-99,-99};
1141 if(!fUsePid4Distr) isSelectedPID=0;
1142 if((lab>=0 && fReadMC) || (!fReadMC && isSelectedPID)){ //signal (from MC or PID)
1144 //check pdg of the prongs
1145 AliAODTrack *prong0=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1146 AliAODTrack *prong1=(AliAODTrack*)fDaughterTracks.UncheckedAt(1);
1148 if(!prong0 || !prong1) {
1153 labprong[0]=prong0->GetLabel();
1154 labprong[1]=prong1->GetLabel();
1156 AliAODMCParticle *mcprong=0;
1157 Int_t pdgProng[2]={0,0};
1159 for (Int_t iprong=0;iprong<2;iprong++){
1160 if(fReadMC && labprong[iprong]>=0) {
1161 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
1162 pdgProng[iprong]=mcprong->GetPdgCode();
1167 //no mass cut ditributions: ptbis
1169 fillthispi="hptpiSnoMcut_";
1172 fillthisK="hptKSnoMcut_";
1175 if ((TMath::Abs(pdgProng[0]) == 211 && TMath::Abs(pdgProng[1]) == 321)
1176 || (isSelectedPID==1 || isSelectedPID==3)){
1177 ((TH1F*)listout->FindObject(fillthispi))->Fill(prong0->Pt());
1178 ((TH1F*)listout->FindObject(fillthisK))->Fill(prong1->Pt());
1181 if ((TMath::Abs(pdgProng[0]) == 321 && TMath::Abs(pdgProng[1]) == 211)
1182 || (isSelectedPID==2 || isSelectedPID==3)){
1183 ((TH1F*)listout->FindObject(fillthisK))->Fill(prong0->Pt());
1184 ((TH1F*)listout->FindObject(fillthispi))->Fill(prong1->Pt());
1188 //no mass cut ditributions: mass
1191 fillthispt="histSgnPt";
1193 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)
1194 || (!fReadMC && (isSelectedPID==1 || isSelectedPID==3))){//D0
1195 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
1196 if(fFillPtHist && fReadMC) ((TH2F*)fOutputMassPt->FindObject(fillthispt))->Fill(minvD0,pt);
1199 if(fReadMC || (!fReadMC && isSelectedPID > 1)){
1200 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
1201 if(fFillPtHist && fReadMC) ((TH2F*)fOutputMassPt->FindObject(fillthispt))->Fill(minvD0bar,pt);
1205 //apply cut on invariant mass on the pair
1206 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
1208 cosThetaStarD0 = part->CosThetaStarD0();
1209 cosThetaStarD0bar = part->CosThetaStarD0bar();
1210 cosPointingAngle = part->CosPointingAngle();
1211 normalizedDecayLength2 = part->NormalizedDecayLength2();
1212 decayLength2 = part->DecayLength2();
1213 decayLengthxy = part->DecayLengthXY();
1214 normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
1216 ptProng[0]=prong0->Pt(); ptProng[1]=prong1->Pt();
1217 d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
1219 if(fArray==1) cout<<"LS signal: ERROR"<<endl;
1220 for (Int_t iprong=0; iprong<2; iprong++){
1221 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
1222 if (fReadMC) labprong[iprong]=prong->GetLabel();
1224 //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
1226 if(fReadMC && labprong[iprong]>=0) {
1227 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
1228 pdgprong=mcprong->GetPdgCode();
1231 Bool_t isPionHere[2]={(isSelectedPID==1 || isSelectedPID==3) ? kTRUE : kFALSE,(isSelectedPID==2 || isSelectedPID==3) ? kTRUE : kFALSE};
1233 if(TMath::Abs(pdgprong)==211 || isPionHere[iprong]) {
1237 fillthispi="hptpiS_";
1239 ((TH1F*)listout->FindObject(fillthispi))->Fill(ptProng[iprong]);
1241 fillthispi="hd0piS_";
1243 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0Prong[iprong]);
1246 fillthispi="hd0vpiS_";
1248 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0[iprong]);
1253 if(TMath::Abs(pdgprong)==321 || !isPionHere[iprong]) {
1254 //cout<<"kappa"<<endl;
1258 ((TH1F*)listout->FindObject(fillthisK))->Fill(ptProng[iprong]);
1262 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0Prong[iprong]);
1264 fillthisK="hd0vKS_";
1266 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0[iprong]);
1271 fillthis="hcosthpointd0S_";
1273 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[iprong]);
1275 } //end loop on prongs
1279 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
1281 fillthis="hcosthetapointS_";
1283 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
1285 fillthis="hcosthetapointxyS_";
1287 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngleXY());
1292 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0());
1296 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
1298 fillthis="hnormdeclS_";
1300 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
1302 fillthis="hdeclxyS_";
1304 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
1306 fillthis="hnormdeclxyS_";
1308 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
1310 fillthis="hdeclxyd0d0S_";
1312 ((TH2F*)listout->FindObject(fillthis))->Fill(decayLengthxy,d0Prong[0]*d0Prong[1]);
1314 fillthis="hnormdeclxyd0d0S_";
1316 ((TH2F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy,d0Prong[0]*d0Prong[1]);
1319 fillthis="hdeclvS_";
1321 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1323 fillthis="hnormdeclvS_";
1325 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1327 fillthis="hd0d0vS_";
1329 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1333 fillthis="hcosthetastarS_";
1335 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)) ((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1337 if (fReadMC || isSelectedPID>1)((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0bar);
1338 if(isSelectedPID==1 || isSelectedPID==3)((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1341 fillthis="hcosthpointd0d0S_";
1343 ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
1348 } else{ //Background or LS
1350 //cout<<"is background"<<endl;
1352 //no mass cut distributions: mass, ptbis
1355 fillthispt="histBkgPt";
1357 if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3))) {
1358 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
1359 if(fFillPtHist && fReadMC) ((TH2F*)fOutputMassPt->FindObject(fillthispt))->Fill(minvD0,pt);
1361 if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1)) {
1362 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
1363 if(fFillPtHist && fReadMC) ((TH2F*)fOutputMassPt->FindObject(fillthispt))->Fill(minvD0bar,pt);
1366 fillthis="hptB1prongnoMcut_";
1369 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1371 fillthis="hptB2prongsnoMcut_";
1373 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1374 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1376 //apply cut on invariant mass on the pair
1377 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
1379 ptProng[0]=((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt(); ptProng[1]=((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt();
1380 cosThetaStarD0 = part->CosThetaStarD0();
1381 cosThetaStarD0bar = part->CosThetaStarD0bar();
1384 cosPointingAngle = part->CosPointingAngle();
1385 normalizedDecayLength2 = part->NormalizedDecayLength2();
1386 decayLength2 = part->DecayLength2();
1387 decayLengthxy = part->DecayLengthXY();
1388 normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
1389 d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
1392 AliAODTrack *prongg=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1394 if(fDebug>2) cout<<"No daughter found";
1399 if(prongg->Charge()==1) {
1400 //fTotPosPairs[ptbin]++;
1401 ((TH1F*)fOutputMass->FindObject("hpospair"))->Fill(ptbin);
1403 //fTotNegPairs[ptbin]++;
1404 ((TH1F*)fOutputMass->FindObject("hnegpair"))->Fill(ptbin);
1411 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
1412 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
1415 Int_t pdgMother[2]={0,0};
1416 Double_t factor[2]={1,1};
1418 for(Int_t iprong=0;iprong<2;iprong++){
1419 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
1420 lab=prong->GetLabel();
1422 AliAODMCParticle* mcprong=(AliAODMCParticle*)arrMC->At(lab);
1424 Int_t labmom=mcprong->GetMother();
1426 AliAODMCParticle* mcmother=(AliAODMCParticle*)arrMC->At(labmom);
1427 if(mcmother) pdgMother[iprong]=mcmother->GetPdgCode();
1434 fillthis="hd0moresB_";
1437 if(TMath::Abs(pdgMother[iprong])==310 || TMath::Abs(pdgMother[iprong])==130 || TMath::Abs(pdgMother[iprong])==321){ //K^0_S, K^0_L, K^+-
1438 if(ptProng[iprong]<=1)factor[iprong]=1./.7;
1439 else factor[iprong]=1./.6;
1440 fNentries->Fill(11);
1443 if(TMath::Abs(pdgMother[iprong])==3122) { //Lambda
1444 factor[iprong]=1./0.25;
1445 fNentries->Fill(12);
1447 fillthis="hd0moresB_";
1450 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[iprong],factor[iprong]);
1453 fillthis="hd0vmoresB_";
1455 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[iprong],factor[iprong]);
1461 fillthis="hd0d0moresB_";
1463 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0(),factor[0]*factor[1]);
1465 fillthis="hcosthetapointmoresB_";
1467 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,factor[0]*factor[1]);
1470 fillthis="hd0d0vmoresB_";
1472 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1],factor[0]*factor[1]);
1478 //normalise pt distr to half afterwards
1481 ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[0]);
1482 ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[1]);
1484 fillthis="hcosthetastarB_";
1486 if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3)))((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1487 if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1))((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0bar);
1492 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
1495 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
1497 fillthis="hcosthpointd0d0B_";
1499 ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
1501 fillthis="hcosthpointd0B_";
1503 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[0]);
1504 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[1]);
1509 fillthis="hd0vp0B_";
1511 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1512 fillthis="hd0vp1B_";
1514 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1518 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1519 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1527 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
1531 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]*d0Prong[1]);
1534 fillthis="hd0d0vB_";
1536 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1539 fillthis="hcosthetapointB_";
1541 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
1543 fillthis="hcosthetapointxyB_";
1545 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngleXY());
1549 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
1551 fillthis="hnormdeclB_";
1553 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
1555 fillthis="hdeclxyB_";
1557 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
1559 fillthis="hnormdeclxyB_";
1561 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
1563 fillthis="hdeclxyd0d0B_";
1565 ((TH2F*)listout->FindObject(fillthis))->Fill(decayLengthxy,d0Prong[0]*d0Prong[1]);
1567 fillthis="hnormdeclxyd0d0B_";
1569 ((TH2F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy,d0Prong[0]*d0Prong[1]);
1573 fillthis="hdeclvB_";
1575 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1577 fillthis="hnormdeclvB_";
1579 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1584 }//else (background)
1589 //____________________________________________________________________________
1590 void AliAnalysisTaskSED0Mass::FillMassHists(AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliAODMCHeader *mcHeader, AliRDHFCutsD0toKpi* cuts, TList *listout){
1592 // function used in UserExec to fill mass histograms:
1596 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1598 //cout<<"is selected = "<<fIsSelectedCandidate<<endl;
1600 // Fill candidate variable Tree (track selection, no candidate selection)
1601 if( fWriteVariableTree && !part->HasBadDaughters()
1602 && fCuts->AreDaughtersSelected(part) && fCuts->IsSelectedPID(part) ){
1603 fCandidateVariables[0] = part->InvMassD0();
1604 fCandidateVariables[1] = part->InvMassD0bar();
1605 fCandidateVariables[2] = part->Pt();
1606 fCandidateVariables[3] = part->GetDCA();
1607 Double_t ctsD0=0. ,ctsD0bar=0.; part->CosThetaStarD0(ctsD0,ctsD0bar);
1608 fCandidateVariables[4] = ctsD0;
1609 fCandidateVariables[5] = ctsD0bar;
1610 fCandidateVariables[6] = part->Pt2Prong(0);
1611 fCandidateVariables[7] = part->Pt2Prong(1);
1612 fCandidateVariables[8] = part->Getd0Prong(0);
1613 fCandidateVariables[9] = part->Getd0Prong(1);
1614 fCandidateVariables[10] = part->Prodd0d0();
1615 fCandidateVariables[11] = part->CosPointingAngle();
1616 fCandidateVariables[12] = part->CosPointingAngleXY();
1617 fCandidateVariables[13] = part->NormalizedDecayLengthXY();
1618 fCandidateVariables[14] = fCuts->IsSelectedSpecialCuts(part);
1619 fVariablesTree->Fill();
1622 //cout<<"check cuts = "<<endl;
1624 if (!fIsSelectedCandidate){
1625 //cout<<"Not Selected"<<endl;
1626 //cout<<"Rejected because "<<cuts->GetWhy()<<endl;
1631 if(fDebug>2) cout<<"Candidate selected"<<endl;
1633 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
1634 //printf("SELECTED\n");
1635 Int_t ptbin=cuts->PtBin(part->Pt());
1636 Double_t pt = part->Pt();
1638 Double_t impparXY=part->ImpParXY()*10000.;
1639 Double_t trueImpParXY=0.;
1640 Double_t arrayForSparse[3]={invmassD0,pt,impparXY};
1641 Double_t arrayForSparseTrue[3]={invmassD0,pt,trueImpParXY};
1644 // AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1646 // AliDebug(2,"No daughter found");
1650 // if(prong->Charge()==1) {
1651 // ((TH1F*)fDistr->FindObject("hpospair"))->Fill(fCuts->GetNPtBins()+ptbin);
1652 // //fTotPosPairs[ptbin]++;
1654 // ((TH1F*)fDistr->FindObject("hnegpair"))->Fill(fCuts->GetNPtBins()+ptbin);
1655 // //fTotNegPairs[ptbin]++;
1659 // for(Int_t it=0;it<2;it++){
1661 // //request on spd points to be addes
1662 // if(/*nSPD==2 && */part->Pt() > 5. && (TMath::Abs(invmassD0-mPDG)<0.01 || TMath::Abs(invmassD0bar-mPDG)<0.01)){
1663 // FILE *f=fopen("4display.txt","a");
1664 // fprintf(f,"pt: %f \n Rapidity: %f \t Period Number: %x \t Run Number: %d \t BunchCrossNumb: %d \t OrbitNumber: %d\n",part->Pt(),part->Y(421),aod->GetPeriodNumber(),aod->GetRunNumber(),aod->GetBunchCrossNumber(),aod->GetOrbitNumber());
1666 // //printf("PrimVtx NContributors: %d \n Prongs Rel Angle: %f \n \n",ncont,relangle);
1670 TString fillthis="", fillthispt="", fillthismasspt="";
1671 Int_t pdgDgD0toKpi[2]={321,211};
1673 Bool_t isPrimary=kTRUE;
1674 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)
1676 //Define weights for Bayesian (if appropriate)
1679 Double_t weigD0bar=1.;
1680 if (fCuts->GetCombPID() && (fCuts->GetBayesianStrategy() == AliRDHFCutsD0toKpi::kBayesWeight || fCuts->GetBayesianStrategy() == AliRDHFCutsD0toKpi::kBayesWeightNoFilter)) {
1681 weigD0=fCuts->GetWeightsNegative()[AliPID::kKaon] * fCuts->GetWeightsPositive()[AliPID::kPion];
1682 weigD0bar=fCuts->GetWeightsPositive()[AliPID::kKaon] * fCuts->GetWeightsNegative()[AliPID::kPion];
1683 if (weigD0 > 1.0 || weigD0 < 0.) {weigD0 = 0.;}
1684 if (weigD0bar > 1.0 || weigD0bar < 0.) {weigD0bar = 0.;} //Prevents filling with weight > 1, or < 0
1687 //count candidates selected by cuts
1689 //count true D0 selected by cuts
1690 if (fReadMC && labD0>=0) fNentries->Fill(2);
1692 if ((fIsSelectedCandidate==1 || fIsSelectedCandidate==3) && fFillOnlyD0D0bar<2) { //D0
1694 arrayForSparse[0]=invmassD0; arrayForSparse[2]=impparXY;
1698 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1700 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1701 Int_t pdgD0 = partD0->GetPdgCode();
1702 // cout<<"pdg = "<<pdgD0<<endl;
1704 if(CheckOrigin(arrMC,partD0)==5) isPrimary=kFALSE;
1706 trueImpParXY=GetTrueImpactParameter(mcHeader,arrMC,partD0)*10000.;
1707 arrayForSparseTrue[0]=invmassD0; arrayForSparseTrue[2]=trueImpParXY;
1709 if (pdgD0==421){ //D0
1710 // cout<<"Fill S with D0"<<endl;
1711 fillthis="histSgn_";
1713 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0,weigD0);
1716 fillthismasspt="histSgnPt";
1717 ((TH2F*)(fOutputMassPt->FindObject(fillthismasspt)))->Fill(invmassD0,pt,weigD0);
1719 if(fFillImpParHist){
1720 if(isPrimary) fHistMassPtImpParTC[1]->Fill(arrayForSparse,weigD0);
1722 fHistMassPtImpParTC[2]->Fill(arrayForSparse,weigD0);
1723 fHistMassPtImpParTC[3]->Fill(arrayForSparseTrue,weigD0);
1728 if(TMath::Abs(invmassD0 - mPDG) < 0.027 && fFillVarHists){
1729 fillthis="histSgn27_";
1731 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0,weigD0);
1734 } else{ //it was a D0bar
1735 fillthis="histRfl_";
1737 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0,weigD0);
1740 fillthismasspt="histRflPt";
1741 // cout << " Filling "<<fillthismasspt<<" D0bar"<<endl;
1742 ((TH2F*)(fOutputMassPt->FindObject(fillthismasspt)))->Fill(invmassD0,pt,weigD0);
1746 } else {//background
1747 fillthis="histBkg_";
1749 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0,weigD0);
1752 fillthismasspt="histBkgPt";
1753 // cout << " Filling "<<fillthismasspt<<" D0bar"<<endl;
1754 ((TH2F*)(fOutputMassPt->FindObject(fillthismasspt)))->Fill(invmassD0,pt,weigD0);
1756 if(fFillImpParHist) fHistMassPtImpParTC[4]->Fill(arrayForSparse,weigD0);
1761 fillthis="histMass_";
1763 // cout<<"Filling "<<fillthis<<endl;
1765 // printf("Fill mass with D0");
1766 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0,weigD0);
1770 fillthismasspt="histMassPt";
1771 // cout<<"Filling "<<fillthismasspt<<endl;
1772 ((TH2F*)(fOutputMassPt->FindObject(fillthismasspt)))->Fill(invmassD0,pt,weigD0);
1774 if(fFillImpParHist) {
1775 // cout << "Filling fHistMassPtImpParTC[0]"<<endl;
1776 fHistMassPtImpParTC[0]->Fill(arrayForSparse,weigD0);
1782 if (fIsSelectedCandidate>1 && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)) { //D0bar
1784 arrayForSparse[0]=invmassD0bar; arrayForSparse[2]=impparXY;
1788 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1789 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1790 Int_t pdgD0 = partD0->GetPdgCode();
1791 // cout<<" pdg = "<<pdgD0<<endl;
1793 if(CheckOrigin(arrMC,partD0)==5) isPrimary=kFALSE;
1795 trueImpParXY=GetTrueImpactParameter(mcHeader,arrMC,partD0)*10000.;
1796 arrayForSparseTrue[0]=invmassD0bar; arrayForSparseTrue[2]=trueImpParXY;
1798 if (pdgD0==-421){ //D0bar
1799 fillthis="histSgn_";
1801 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar,weigD0bar);
1802 // if (TMath::Abs(invmassD0bar - mPDG) < 0.027){
1803 // fillthis="histSgn27_";
1805 // ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1809 fillthismasspt="histSgnPt";
1810 // cout<<" Filling "<< fillthismasspt << endl;
1811 ((TH2F*)(fOutputMassPt->FindObject(fillthismasspt)))->Fill(invmassD0bar,pt,weigD0bar);
1813 if(fFillImpParHist){
1814 // cout << " Filling impact parameter thnsparse"<<endl;
1815 if(isPrimary) fHistMassPtImpParTC[1]->Fill(arrayForSparse,weigD0bar);
1817 fHistMassPtImpParTC[2]->Fill(arrayForSparse,weigD0bar);
1818 fHistMassPtImpParTC[3]->Fill(arrayForSparseTrue,weigD0bar);
1823 fillthis="histRfl_";
1825 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar,weigD0bar);
1827 fillthismasspt="histRflPt";
1828 // cout << " Filling "<<fillthismasspt<<endl;
1829 ((TH2F*)(fOutputMassPt->FindObject(fillthismasspt)))->Fill(invmassD0bar,pt,weigD0bar);
1832 } else {//background or LS
1833 fillthis="histBkg_";
1835 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar,weigD0bar);
1838 fillthismasspt="histBkgPt";
1839 // cout<<" Filling "<< fillthismasspt << endl;
1840 ((TH2F*)(fOutputMassPt->FindObject(fillthismasspt)))->Fill(invmassD0bar,pt,weigD0bar);
1842 if(fFillImpParHist) fHistMassPtImpParTC[4]->Fill(arrayForSparse,weigD0bar);
1846 fillthis="histMass_";
1848 // printf("Fill mass with D0bar");
1850 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar,weigD0bar);
1854 fillthismasspt="histMassPt";
1855 // cout<<" Filling "<< fillthismasspt << endl;
1856 ((TH2F*)(fOutputMassPt->FindObject(fillthismasspt)))->Fill(invmassD0bar,pt,weigD0bar);
1858 if(fFillImpParHist) fHistMassPtImpParTC[0]->Fill(arrayForSparse,weigD0bar);
1866 //__________________________________________________________________________
1867 AliAODVertex* AliAnalysisTaskSED0Mass::GetPrimaryVtxSkipped(AliAODEvent *aodev){
1868 //Calculate the primary vertex w/o the daughter tracks of the candidate
1871 Int_t nTrksToSkip=2;
1872 AliAODTrack *dgTrack = (AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1874 AliDebug(2,"no daughter found!");
1877 skipped[0]=dgTrack->GetID();
1878 dgTrack = (AliAODTrack*)fDaughterTracks.UncheckedAt(1);
1880 AliDebug(2,"no daughter found!");
1883 skipped[1]=dgTrack->GetID();
1885 AliESDVertex *vertexESD=0x0;
1886 AliAODVertex *vertexAOD=0x0;
1887 AliVertexerTracks *vertexer = new AliVertexerTracks(aodev->GetMagneticField());
1890 vertexer->SetSkipTracks(nTrksToSkip,skipped);
1891 vertexer->SetMinClusters(4);
1892 vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(aodev);
1893 if(!vertexESD) return vertexAOD;
1894 if(vertexESD->GetNContributors()<=0) {
1895 AliDebug(2,"vertexing failed");
1896 delete vertexESD; vertexESD=NULL;
1900 delete vertexer; vertexer=NULL;
1903 // convert to AliAODVertex
1904 Double_t pos[3],cov[6],chi2perNDF;
1905 vertexESD->GetXYZ(pos); // position
1906 vertexESD->GetCovMatrix(cov); //covariance matrix
1907 chi2perNDF = vertexESD->GetChi2toNDF();
1908 delete vertexESD; vertexESD=NULL;
1910 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
1916 //________________________________________________________________________
1917 void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
1919 // Terminate analysis
1921 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
1924 fOutputMass = dynamic_cast<TList*> (GetOutputData(1));
1926 printf("ERROR: fOutputMass not available\n");
1929 fOutputMassPt = dynamic_cast<TList*> (GetOutputData(6));
1930 if ((fFillPtHist || fFillImpParHist) && !fOutputMassPt) {
1931 printf("ERROR: fOutputMass not available\n");
1936 fDistr = dynamic_cast<TList*> (GetOutputData(2));
1938 printf("ERROR: fDistr not available\n");
1943 fNentries = dynamic_cast<TH1F*>(GetOutputData(3));
1946 printf("ERROR: fNEntries not available\n");
1949 fCuts = dynamic_cast<AliRDHFCutsD0toKpi*>(GetOutputData(4));
1951 printf("ERROR: fCuts not available\n");
1954 fCounter = dynamic_cast<AliNormalizationCounter*>(GetOutputData(5));
1956 printf("ERROR: fCounter not available\n");
1959 if (fDrawDetSignal) {
1960 fDetSignal = dynamic_cast<TList*>(GetOutputData(8));
1962 printf("ERROR: fDetSignal not available\n");
1966 Int_t nptbins=fCuts->GetNPtBins();
1967 for(Int_t ipt=0;ipt<nptbins;ipt++){
1969 if(fArray==1 && fFillVarHists){
1970 fLsNormalization = 2.*TMath::Sqrt(((TH1F*)fOutputMass->FindObject("hpospair"))->Integral(nptbins+ipt+1,nptbins+ipt+2)*((TH1F*)fOutputMass->FindObject("hnegpair"))->Integral(nptbins+ipt+1,nptbins+ipt+2)); //after cuts
1973 if(fLsNormalization>1e-6) {
1975 TString massName="histMass_";
1977 ((TH1F*)fOutputMass->FindObject(massName))->Scale((1/fLsNormalization)*((TH1F*)fOutputMass->FindObject(massName))->GetEntries());
1982 fLsNormalization = 2.*TMath::Sqrt(((TH1F*)fOutputMass->FindObject("hpospair"))->Integral(ipt+1,ipt+2)*((TH1F*)fOutputMass->FindObject("hnegpair"))->Integral(ipt+1,ipt+2));
1983 //fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs[4]*fTotNegPairs[4]);
1985 if(fLsNormalization>1e-6) {
1987 TString nameDistr="hptB_";
1989 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1992 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1993 nameDistr="hcosthetastarB_";
1995 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1998 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1999 nameDistr="hd0d0B_";
2001 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
2002 nameDistr="hcosthetapointB_";
2004 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
2006 nameDistr="hcosthpointd0d0B_";
2008 ((TH2F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH2F*)fDistr->FindObject(nameDistr))->GetEntries());
2013 TString cvname,cstname;
2023 TCanvas *cMass=new TCanvas(cvname,cvname);
2025 ((TH1F*)fOutputMass->FindObject("histMass_3"))->Draw();
2027 TCanvas* cStat=new TCanvas(cstname,Form("Stat%s",fArray ? "LS" : "D0"));
2030 fNentries->Draw("htext0");
2032 // TCanvas *ccheck=new TCanvas(Form("cc%d",fArray),Form("cc%d",fArray));
2039 //________________________________________________________________________
2040 void AliAnalysisTaskSED0Mass::CreateImpactParameterHistos(){
2041 // Histos for impact paramter study
2043 Int_t nmassbins=200;
2044 Double_t fLowmasslimit=1.5648, fUpmasslimit=2.1648;
2045 Int_t fNImpParBins=400;
2046 Double_t fLowerImpPar=-2000., fHigherImpPar=2000.;
2047 Int_t nbins[3]={nmassbins,200,fNImpParBins};
2048 Double_t xmin[3]={fLowmasslimit,0.,fLowerImpPar};
2049 Double_t xmax[3]={fUpmasslimit,20.,fHigherImpPar};
2052 fHistMassPtImpParTC[0]=new THnSparseF("hMassPtImpParAll",
2053 "Mass vs. pt vs.imppar - All",
2055 fHistMassPtImpParTC[1]=new THnSparseF("hMassPtImpParPrompt",
2056 "Mass vs. pt vs.imppar - promptD",
2058 fHistMassPtImpParTC[2]=new THnSparseF("hMassPtImpParBfeed",
2059 "Mass vs. pt vs.imppar - DfromB",
2061 fHistMassPtImpParTC[3]=new THnSparseF("hMassPtImpParTrueBfeed",
2062 "Mass vs. pt vs.true imppar -DfromB",
2064 fHistMassPtImpParTC[4]=new THnSparseF("hMassPtImpParBkg",
2065 "Mass vs. pt vs.imppar - backgr.",
2068 for(Int_t i=0; i<5;i++){
2069 fOutputMassPt->Add(fHistMassPtImpParTC[i]);
2073 //_________________________________________________________________________________________________
2074 Float_t AliAnalysisTaskSED0Mass::GetTrueImpactParameter(AliAODMCHeader *mcHeader, TClonesArray* arrayMC, AliAODMCParticle *partD0) const {
2075 // true impact parameter calculation
2077 printf(" AliAnalysisTaskSED0MassV1::GetTrueImpactParameter() \n");
2079 Double_t vtxTrue[3];
2080 mcHeader->GetVertex(vtxTrue);
2082 partD0->XvYvZv(origD);
2083 Short_t charge=partD0->Charge();
2084 Double_t pXdauTrue[2],pYdauTrue[2],pZdauTrue[2];
2085 for(Int_t iDau=0; iDau<2; iDau++){
2091 // Int_t nDau=partD0->GetNDaughters();
2092 Int_t labelFirstDau = partD0->GetDaughter(0);
2094 for(Int_t iDau=0; iDau<2; iDau++){
2095 Int_t ind = labelFirstDau+iDau;
2096 AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(arrayMC->At(ind));
2098 Int_t pdgCode = TMath::Abs( part->GetPdgCode() );
2100 AliError("Daughter particle not found in MC array");
2103 if(pdgCode==211 || pdgCode==321){
2104 pXdauTrue[iDau]=part->Px();
2105 pYdauTrue[iDau]=part->Py();
2106 pZdauTrue[iDau]=part->Pz();
2110 Double_t d0dummy[2]={0.,0.};
2111 AliAODRecoDecayHF aodDzeroMC(vtxTrue,origD,2,charge,pXdauTrue,pYdauTrue,pZdauTrue,d0dummy);
2112 return aodDzeroMC.ImpParXY();
2116 //_________________________________________________________________________________________________
2117 Int_t AliAnalysisTaskSED0Mass::CheckOrigin(TClonesArray* arrayMC, AliAODMCParticle *mcPartCandidate) const {
2119 // checking whether the mother of the particles come from a charm or a bottom quark
2121 printf(" AliAnalysisTaskSED0MassV1::CheckOrigin() \n");
2123 Int_t pdgGranma = 0;
2125 mother = mcPartCandidate->GetMother();
2127 Int_t abspdgGranma =0;
2128 Bool_t isFromB=kFALSE;
2129 Bool_t isQuarkFound=kFALSE;
2132 AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(arrayMC->At(mother));
2134 pdgGranma = mcGranma->GetPdgCode();
2135 abspdgGranma = TMath::Abs(pdgGranma);
2136 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)){
2139 if(abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE;
2140 mother = mcGranma->GetMother();
2142 AliError("Failed casting the mother particle!");
2147 if(isFromB) return 5;