Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255 changes: 148 additions & 107 deletions PWGHF/TableProducer/treeCreatorD0ToKPi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/// In this file are defined and filled the output tables
///
/// \author Nicolo' Jacazio <nicolo.jacazio@cern.ch>, CERN
/// \author Andrea Tavira García <tavira-garcia@ijclab.in2p3.fr>, IJCLab

#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
Expand Down Expand Up @@ -46,27 +47,29 @@ DECLARE_SOA_COLUMN(Eta, eta, float);
DECLARE_SOA_COLUMN(Phi, phi, float);
DECLARE_SOA_COLUMN(Y, y, float);
DECLARE_SOA_COLUMN(E, e, float);
DECLARE_SOA_COLUMN(NSigTPCPi0, nsigTPCPi0, float);
DECLARE_SOA_COLUMN(NSigTPCKa0, nsigTPCKa0, float);
DECLARE_SOA_COLUMN(NSigTOFPi0, nsigTOFPi0, float);
DECLARE_SOA_COLUMN(NSigTOFKa0, nsigTOFKa0, float);
DECLARE_SOA_COLUMN(NSigTPCPi1, nsigTPCPi1, float);
DECLARE_SOA_COLUMN(NSigTPCKa1, nsigTPCKa1, float);
DECLARE_SOA_COLUMN(NSigTOFPi1, nsigTOFPi1, float);
DECLARE_SOA_COLUMN(NSigTOFKa1, nsigTOFKa1, float);
DECLARE_SOA_COLUMN(NSigTpcPi0, nSigTpcPi0, float);
DECLARE_SOA_COLUMN(NSigTpcKa0, nSigTpcKa0, float);
DECLARE_SOA_COLUMN(NSigTofPi0, nSigTofPi0, float);
DECLARE_SOA_COLUMN(NSigTofKa0, nSigTofKa0, float);
DECLARE_SOA_COLUMN(NSigTpcPi1, nSigTpcPi1, float);
DECLARE_SOA_COLUMN(NSigTpcKa1, nSigTpcKa1, float);
DECLARE_SOA_COLUMN(NSigTofPi1, nSigTofPi1, float);
DECLARE_SOA_COLUMN(NSigTofKa1, nSigTofKa1, float);
DECLARE_SOA_COLUMN(DecayLength, decayLength, float);
DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float);
DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float);
DECLARE_SOA_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, float);
DECLARE_SOA_COLUMN(CPA, cpa, float);
DECLARE_SOA_COLUMN(CPAXY, cpaXY, float);
DECLARE_SOA_COLUMN(Cpa, cpa, float);
DECLARE_SOA_COLUMN(CpaXY, cpaXY, float);
DECLARE_SOA_COLUMN(Ct, ct, float);
DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float);
DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float);
DECLARE_SOA_COLUMN(MCflag, mcflag, int8_t);
DECLARE_SOA_COLUMN(FlagMc, flagMc, int8_t);
// Events
DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int);
DECLARE_SOA_COLUMN(RunNumber, runNumber, int);
DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // is prompt or non-prompt, reco level
DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // is prompt or non-prompt, Gen level
} // namespace full

DECLARE_SOA_TABLE(HfCand2ProngFull, "AOD", "HFCAND2PFull",
Expand Down Expand Up @@ -102,28 +105,29 @@ DECLARE_SOA_TABLE(HfCand2ProngFull, "AOD", "HFCAND2PFull",
hf_cand::ImpactParameter1,
hf_cand::ErrorImpactParameter0,
hf_cand::ErrorImpactParameter1,
full::NSigTPCPi0,
full::NSigTPCKa0,
full::NSigTOFPi0,
full::NSigTOFKa0,
full::NSigTPCPi1,
full::NSigTPCKa1,
full::NSigTOFPi1,
full::NSigTOFKa1,
full::NSigTpcPi0,
full::NSigTpcKa0,
full::NSigTofPi0,
full::NSigTofKa0,
full::NSigTpcPi1,
full::NSigTpcKa1,
full::NSigTofPi1,
full::NSigTofKa1,
full::CandidateSelFlag,
full::M,
full::ImpactParameterProduct,
full::CosThetaStar,
full::Pt,
full::P,
full::CPA,
full::CPAXY,
full::Cpa,
full::CpaXY,
full::Ct,
full::Eta,
full::Phi,
full::Y,
full::E,
full::MCflag);
full::FlagMc,
full::OriginMcRec);

DECLARE_SOA_TABLE(HfCand2ProngFullEvents, "AOD", "HFCAND2PFullE",
collision::BCId,
Expand All @@ -140,7 +144,8 @@ DECLARE_SOA_TABLE(HfCand2ProngFullParticles, "AOD", "HFCAND2PFullP",
full::Eta,
full::Phi,
full::Y,
full::MCflag);
full::FlagMc,
full::OriginMcGen);

} // namespace o2::aod

Expand All @@ -154,113 +159,149 @@ struct HfTreeCreatorD0ToKPi {
{
}

void process(aod::Collisions const& collisions,
aod::McCollisions const& mccollisions,
soa::Join<aod::HfCand2Prong, aod::HfCand2ProngMcRec, aod::HfSelD0> const& candidates,
soa::Join<aod::McParticles, aod::HfCand2ProngMcGen> const& particles,
aod::BigTracksPID const& tracks)
template <typename T>
void fillEvent(const T& collision, int isEventReject, int runNumber)
{
rowCandidateFullEvents(
collision.bcId(),
collision.numContrib(),
collision.posX(),
collision.posY(),
collision.posZ(),
isEventReject,
runNumber);
}

template <typename T, typename U>
auto fillTable(const T& candidate, const U& prong0, const U& prong1, int candFlag, int selection, double invMass, double cosThetaStar,
double ct, double y, double e, int8_t flagMc, int8_t origin)
{
if (selection >= 1) {
rowCandidateFull(
prong0.collision().bcId(),
prong0.collision().numContrib(),
candidate.posX(),
candidate.posY(),
candidate.posZ(),
candidate.xSecondaryVertex(),
candidate.ySecondaryVertex(),
candidate.zSecondaryVertex(),
candidate.errorDecayLength(),
candidate.errorDecayLengthXY(),
candidate.chi2PCA(),
candidate.rSecondaryVertex(),
candidate.decayLength(),
candidate.decayLengthXY(),
candidate.decayLengthNormalised(),
candidate.decayLengthXYNormalised(),
candidate.impactParameterNormalised0(),
candidate.ptProng0(),
RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()),
candidate.impactParameterNormalised1(),
candidate.ptProng1(),
RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()),
candidate.pxProng0(),
candidate.pyProng0(),
candidate.pzProng0(),
candidate.pxProng1(),
candidate.pyProng1(),
candidate.pzProng1(),
candidate.impactParameter0(),
candidate.impactParameter1(),
candidate.errorImpactParameter0(),
candidate.errorImpactParameter1(),
prong0.tpcNSigmaPi(),
prong0.tpcNSigmaKa(),
prong0.tofNSigmaPi(),
prong0.tofNSigmaKa(),
prong1.tpcNSigmaPi(),
prong1.tpcNSigmaKa(),
prong1.tofNSigmaPi(),
prong1.tofNSigmaKa(),
1 << candFlag,
invMass,
candidate.impactParameterProduct(),
cosThetaStar,
candidate.pt(),
candidate.p(),
candidate.cpa(),
candidate.cpaXY(),
ct,
candidate.eta(),
candidate.phi(),
y,
e,
flagMc,
origin);
}
}

void processData(aod::Collisions const& collisions,
soa::Join<aod::HfCand2Prong, aod::HfSelD0> const& candidates,
aod::BigTracksPID const&)
{
// Filling event properties
rowCandidateFullEvents.reserve(collisions.size());
for (auto& collision : collisions) {
rowCandidateFullEvents(
collision.bcId(),
collision.numContrib(),
collision.posX(),
collision.posY(),
collision.posZ(),
0,
1);
for (auto const& collision : collisions) {
fillEvent(collision, 0, 1);
}

// Filling candidate properties
rowCandidateFull.reserve(candidates.size());
for (auto& candidate : candidates) {
auto fillTable = [&](int CandFlag,
int FunctionSelection,
double FunctionInvMass,
double FunctionCosThetaStar,
double FunctionCt,
double FunctionY,
double FunctionE) {
if (FunctionSelection >= 1) {
rowCandidateFull(
candidate.prong0_as<aod::BigTracksPID>().collision().bcId(),
candidate.prong0_as<aod::BigTracksPID>().collision().numContrib(),
candidate.posX(),
candidate.posY(),
candidate.posZ(),
candidate.xSecondaryVertex(),
candidate.ySecondaryVertex(),
candidate.zSecondaryVertex(),
candidate.errorDecayLength(),
candidate.errorDecayLengthXY(),
candidate.chi2PCA(),
candidate.rSecondaryVertex(),
candidate.decayLength(),
candidate.decayLengthXY(),
candidate.decayLengthNormalised(),
candidate.decayLengthXYNormalised(),
candidate.impactParameterNormalised0(),
candidate.ptProng0(),
RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()),
candidate.impactParameterNormalised1(),
candidate.ptProng1(),
RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()),
candidate.pxProng0(),
candidate.pyProng0(),
candidate.pzProng0(),
candidate.pxProng1(),
candidate.pyProng1(),
candidate.pzProng1(),
candidate.impactParameter0(),
candidate.impactParameter1(),
candidate.errorImpactParameter0(),
candidate.errorImpactParameter1(),
candidate.prong0_as<aod::BigTracksPID>().tpcNSigmaPi(),
candidate.prong0_as<aod::BigTracksPID>().tpcNSigmaKa(),
candidate.prong0_as<aod::BigTracksPID>().tofNSigmaPi(),
candidate.prong0_as<aod::BigTracksPID>().tofNSigmaKa(),
candidate.prong1_as<aod::BigTracksPID>().tpcNSigmaPi(),
candidate.prong1_as<aod::BigTracksPID>().tpcNSigmaKa(),
candidate.prong1_as<aod::BigTracksPID>().tofNSigmaPi(),
candidate.prong1_as<aod::BigTracksPID>().tofNSigmaKa(),
1 << CandFlag,
FunctionInvMass,
candidate.impactParameterProduct(),
FunctionCosThetaStar,
candidate.pt(),
candidate.p(),
candidate.cpa(),
candidate.cpaXY(),
FunctionCt,
candidate.eta(),
candidate.phi(),
FunctionY,
FunctionE,
candidate.flagMcMatchRec());
}
};
for (auto const& candidate : candidates) {
auto prong0 = candidate.prong0_as<aod::BigTracksPID>();
auto prong1 = candidate.prong1_as<aod::BigTracksPID>();
double yD = yD0(candidate);
double eD = eD0(candidate);
double ctD = ctD0(candidate);
fillTable(candidate, prong0, prong1, 0, candidate.isSelD0(), invMassD0ToPiK(candidate), cosThetaStarD0(candidate), ctD, yD, eD, 0, 0);
fillTable(candidate, prong0, prong1, 1, candidate.isSelD0bar(), invMassD0barToKPi(candidate), cosThetaStarD0bar(candidate), ctD, yD, eD, 0, 0);
}
}

PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processData, "Process data", true);

fillTable(0, candidate.isSelD0(), invMassD0ToPiK(candidate), cosThetaStarD0(candidate), ctD0(candidate), yD0(candidate), eD0(candidate));
fillTable(1, candidate.isSelD0bar(), invMassD0barToKPi(candidate), cosThetaStarD0bar(candidate), ctD0(candidate), yD0(candidate), eD0(candidate));
void processMc(aod::Collisions const& collisions,
aod::McCollisions const&,
soa::Join<aod::HfCand2Prong, aod::HfCand2ProngMcRec, aod::HfSelD0> const& candidates,
soa::Join<aod::McParticles, aod::HfCand2ProngMcGen> const& particles,
aod::BigTracksPID const&)
{
// Filling event properties
rowCandidateFullEvents.reserve(collisions.size());
for (auto const& collision : collisions) {
fillEvent(collision, 0, 1);
}

// Filling candidate properties
rowCandidateFull.reserve(candidates.size());
for (auto const& candidate : candidates) {
auto prong0 = candidate.prong0_as<aod::BigTracksPID>();
auto prong1 = candidate.prong0_as<aod::BigTracksPID>();
double yD = yD0(candidate);
double eD = eD0(candidate);
double ctD = ctD0(candidate);
fillTable(candidate, prong0, prong1, 0, candidate.isSelD0(), invMassD0ToPiK(candidate), cosThetaStarD0(candidate), ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec());
fillTable(candidate, prong0, prong1, 1, candidate.isSelD0bar(), invMassD0barToKPi(candidate), cosThetaStarD0bar(candidate), ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec());
}

// Filling particle properties
rowCandidateFullParticles.reserve(particles.size());
for (auto& particle : particles) {
for (auto const& particle : particles) {
if (std::abs(particle.flagMcMatchGen()) == 1 << DecayType::D0ToPiK) {
rowCandidateFullParticles(
particle.mcCollision().bcId(),
particle.pt(),
particle.eta(),
particle.phi(),
RecoDecay::y(array{particle.px(), particle.py(), particle.pz()}, RecoDecay::getMassPDG(particle.pdgCode())),
particle.flagMcMatchGen());
particle.flagMcMatchGen(),
particle.originMcGen());
}
}
}

PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMc, "Process MC", false);
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
Expand Down