From f0b2bef3376f3cc2a20460b17caeaf8e8eec7be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 24 Nov 2020 17:10:19 +0100 Subject: [PATCH] Add full table writing tasks for D0 and Lc - Add full table to be written to file - Add task dedicated to 2 prong tree writing - Add task dedicated to 3 prong tree writing - Use naming of tasks as in HFSecondaryVertex --- Analysis/Tasks/PWGHF/CMakeLists.txt | 10 + .../Tasks/PWGHF/HFCandidateCreator2Prong.cxx | 221 ++++++++++++++ .../Tasks/PWGHF/HFCandidateCreator3Prong.cxx | 246 +++++++++++++++ Analysis/Tasks/PWGHF/HFTreeCreatorD0ToKPi.cxx | 264 ++++++++++++++++ .../Tasks/PWGHF/HFTreeCreatorLcToPKPi.cxx | 287 ++++++++++++++++++ 5 files changed, 1028 insertions(+) create mode 100644 Analysis/Tasks/PWGHF/HFTreeCreatorD0ToKPi.cxx create mode 100644 Analysis/Tasks/PWGHF/HFTreeCreatorLcToPKPi.cxx diff --git a/Analysis/Tasks/PWGHF/CMakeLists.txt b/Analysis/Tasks/PWGHF/CMakeLists.txt index 16e4180937401..7f1b0a6d2dec8 100644 --- a/Analysis/Tasks/PWGHF/CMakeLists.txt +++ b/Analysis/Tasks/PWGHF/CMakeLists.txt @@ -23,11 +23,21 @@ o2_add_dpl_workflow(hf-candidate-creator-2prong PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing ROOT::EG COMPONENT_NAME Analysis) +o2_add_dpl_workflow(hf-tree-creator-d0-to-k-pi + SOURCES HFTreeCreatorD0ToKPi.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing ROOT::EG + COMPONENT_NAME Analysis) + o2_add_dpl_workflow(hf-candidate-creator-3prong SOURCES HFCandidateCreator3Prong.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing ROOT::EG COMPONENT_NAME Analysis) +o2_add_dpl_workflow(hf-tree-creator-lc-to-p-k-pi + SOURCES HFTreeCreatorLcToPKPi.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing ROOT::EG + COMPONENT_NAME Analysis) + o2_add_dpl_workflow(hf-d0-candidate-selector SOURCES HFD0CandidateSelector.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing diff --git a/Analysis/Tasks/PWGHF/HFCandidateCreator2Prong.cxx b/Analysis/Tasks/PWGHF/HFCandidateCreator2Prong.cxx index c4d1b5a3eb794..3ec2f3a917496 100644 --- a/Analysis/Tasks/PWGHF/HFCandidateCreator2Prong.cxx +++ b/Analysis/Tasks/PWGHF/HFCandidateCreator2Prong.cxx @@ -28,6 +28,8 @@ void customize(std::vector& workflowOptions) { ConfigParamSpec optionDoMC{"doMC", VariantType::Bool, false, {"Perform MC matching."}}; workflowOptions.push_back(optionDoMC); + ConfigParamSpec optionWriteTree{"writeTree", VariantType::Bool, false, {"Writing debug tree."}}; + workflowOptions.push_back(optionWriteTree); } #include "Framework/runDataProcessing.h" @@ -180,6 +182,221 @@ struct HFCandidateCreator2ProngMC { } }; +namespace o2::aod +{ +namespace full +{ +DECLARE_SOA_COLUMN(XSecondaryVertex, xSecondaryVertex, float); +DECLARE_SOA_COLUMN(RSecondaryVertex, rSecondaryVertex, float); +DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); +DECLARE_SOA_COLUMN(PProng0, pProng0, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised0, impactParameterNormalised0, float); +DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); +DECLARE_SOA_COLUMN(PProng1, pProng1, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised1, impactParameterNormalised1, float); +DECLARE_SOA_COLUMN(M, m, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(P, p, float); +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(NSigTPC_Pi_0, nsigTPC_Pi_0, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_0, nsigTPC_Ka_0, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_0, nsigTOF_Pi_0, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_0, nsigTOF_Ka_0, float); +DECLARE_SOA_COLUMN(NSigTPC_Pi_1, nsigTPC_Pi_1, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_1, nsigTPC_Ka_1, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_1, nsigTOF_Pi_1, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_1, nsigTOF_Ka_1, 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(Ct, ct, float); +DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); +DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float); +DECLARE_SOA_COLUMN(MCflag, mcflag, uint8_t); +// Events +DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); +} // namespace full + +DECLARE_SOA_TABLE(HfCandProng2Full, "AOD", "HFCANDP2Full", + collision::BCId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + hf_cand::XSecondaryVertex, + hf_cand::YSecondaryVertex, + hf_cand::ZSecondaryVertex, + hf_cand::ErrorDecayLength, + hf_cand::ErrorDecayLengthXY, + hf_cand::Chi2PCA, + full::RSecondaryVertex, + full::DecayLength, + full::DecayLengthXY, + full::DecayLengthNormalised, + full::DecayLengthXYNormalised, + full::ImpactParameterNormalised0, + full::PtProng0, + full::PProng0, + full::ImpactParameterNormalised1, + full::PtProng1, + full::PProng1, + hf_cand::PxProng0, + hf_cand::PyProng0, + hf_cand::PzProng0, + hf_cand::PxProng1, + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::ImpactParameter0, + hf_cand::ImpactParameter1, + hf_cand::ErrorImpactParameter0, + hf_cand::ErrorImpactParameter1, + full::NSigTPC_Pi_0, + full::NSigTPC_Ka_0, + full::NSigTOF_Pi_0, + full::NSigTOF_Ka_0, + full::NSigTPC_Pi_1, + full::NSigTPC_Ka_1, + full::NSigTOF_Pi_1, + full::NSigTOF_Ka_1, + full::M, + full::ImpactParameterProduct, + full::CosThetaStar, + full::Pt, + full::P, + full::CPA, + full::CPAXY, + full::Ct, + full::Eta, + full::Phi, + full::Y, + full::E, + full::MCflag); + +DECLARE_SOA_TABLE(HfCandProng2FullEvents, "AOD", "HFCANDP2FullE", + collision::BCId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + full::IsEventReject, + full::RunNumber); + +DECLARE_SOA_TABLE(HfCandProng2FullParticles, "AOD", "HFCANDP2FullP", + collision::BCId, + full::Pt, + full::Eta, + full::Phi, + full::Y, + full::MCflag); + +} // namespace o2::aod + +/// Writes a debug tree +struct CandidateTreeWriter { + Produces rowCandidateFull; + Produces rowCandidateFullEvents; + Produces rowCandidateFullParticles; + void init(InitContext const&) + { + } + void process(aod::Collisions const& collisions, + aod::McCollisions const& mccollisions, + soa::Join const& candidates, + soa::Join const& particles, + aod::BigTracksPID const& tracks) + { + rowCandidateFullEvents.reserve(collisions.size()); + for (auto& collision : collisions) { + rowCandidateFullEvents( + collision.bcId(), + collision.numContrib(), + collision.posX(), + collision.posY(), + collision.posZ(), + 0, + 1); + } + rowCandidateFull.reserve(candidates.size()); + for (auto& candidate : candidates) { + rowCandidateFull( + candidate.index0_as().collision().bcId(), + candidate.index0_as().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(), + TMath::Abs(candidate.ptProng0()), + TMath::Sqrt(RecoDecay::P(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0())), + candidate.impactParameterNormalised1(), + TMath::Abs(candidate.ptProng1()), + TMath::Sqrt(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.index0_as().tpcNSigmaPi(), + candidate.index0_as().tpcNSigmaKa(), + candidate.index0_as().tofNSigmaPi(), + candidate.index0_as().tofNSigmaKa(), + candidate.index1_as().tpcNSigmaPi(), + candidate.index1_as().tpcNSigmaKa(), + candidate.index1_as().tofNSigmaPi(), + candidate.index1_as().tofNSigmaKa(), + InvMassD0(candidate), + candidate.impactParameterProduct(), + CosThetaStarD0(candidate), + candidate.pt(), + candidate.p(), + candidate.cpa(), + candidate.cpaXY(), + CtD0(candidate), + candidate.eta(), + candidate.phi(), + YD0(candidate), + ED0(candidate), + candidate.flagMCMatchRec()); + } + + int npart = 0; + rowCandidateFullParticles.reserve(particles.size()); + for (auto& particle : particles) { + if (particle.flagMCMatchGen()) { + 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()); + } + } + } +}; + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ @@ -189,5 +406,9 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) if (doMC) { workflow.push_back(adaptAnalysisTask("hf-cand-creator-2prong-mc")); } + const bool writeTree = cfgc.options().get("writeTree"); + if (writeTree) { + workflow.push_back(adaptAnalysisTask("hf-cand-tree-2prong-writer")); + } return workflow; } diff --git a/Analysis/Tasks/PWGHF/HFCandidateCreator3Prong.cxx b/Analysis/Tasks/PWGHF/HFCandidateCreator3Prong.cxx index b56d8451fa0d8..ccb7c3e70141f 100644 --- a/Analysis/Tasks/PWGHF/HFCandidateCreator3Prong.cxx +++ b/Analysis/Tasks/PWGHF/HFCandidateCreator3Prong.cxx @@ -28,6 +28,8 @@ void customize(std::vector& workflowOptions) { ConfigParamSpec optionDoMC{"doMC", VariantType::Bool, false, {"Perform MC matching."}}; workflowOptions.push_back(optionDoMC); + ConfigParamSpec optionWriteTree{"writeTree", VariantType::Bool, false, {"Writing debug tree."}}; + workflowOptions.push_back(optionWriteTree); } #include "Framework/runDataProcessing.h" @@ -200,6 +202,246 @@ struct HFCandidateCreator3ProngMC { } }; +namespace o2::aod +{ +namespace full +{ +DECLARE_SOA_COLUMN(XSecondaryVertex, xSecondaryVertex, float); +DECLARE_SOA_COLUMN(RSecondaryVertex, rSecondaryVertex, float); +DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); +DECLARE_SOA_COLUMN(PProng0, pProng0, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised0, impactParameterNormalised0, float); +DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); +DECLARE_SOA_COLUMN(PProng1, pProng1, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised1, impactParameterNormalised1, float); +DECLARE_SOA_COLUMN(PtProng2, ptProng2, float); +DECLARE_SOA_COLUMN(PProng2, pProng2, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised2, impactParameterNormalised2, float); +DECLARE_SOA_COLUMN(M, m, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(P, p, float); +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(NSigTPC_Pi_0, nsigTPC_Pi_0, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_0, nsigTPC_Ka_0, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_0, nsigTOF_Pi_0, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_0, nsigTOF_Ka_0, float); +DECLARE_SOA_COLUMN(NSigTPC_Pi_1, nsigTPC_Pi_1, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_1, nsigTPC_Ka_1, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_1, nsigTOF_Pi_1, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_1, nsigTOF_Ka_1, float); +DECLARE_SOA_COLUMN(NSigTPC_Pi_2, nsigTPC_Pi_2, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_2, nsigTPC_Ka_2, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_2, nsigTOF_Pi_2, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_2, nsigTOF_Ka_2, 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(Ct, ct, float); +DECLARE_SOA_COLUMN(MCflag, mcflag, uint8_t); +// Events +DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); +} // namespace full + +DECLARE_SOA_TABLE(HfCandProng3Full, "AOD", "HFCANDP3Full", + collision::BCId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + hf_cand::XSecondaryVertex, + hf_cand::YSecondaryVertex, + hf_cand::ZSecondaryVertex, + hf_cand::ErrorDecayLength, + hf_cand::ErrorDecayLengthXY, + hf_cand::Chi2PCA, + full::RSecondaryVertex, + full::DecayLength, + full::DecayLengthXY, + full::DecayLengthNormalised, + full::DecayLengthXYNormalised, + full::ImpactParameterNormalised0, + full::PtProng0, + full::PProng0, + full::ImpactParameterNormalised1, + full::PtProng1, + full::PProng1, + full::ImpactParameterNormalised2, + full::PtProng2, + full::PProng2, + hf_cand::PxProng0, + hf_cand::PyProng0, + hf_cand::PzProng0, + hf_cand::PxProng1, + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::PxProng2, + hf_cand::PyProng2, + hf_cand::PzProng2, + hf_cand::ImpactParameter0, + hf_cand::ImpactParameter1, + hf_cand::ImpactParameter2, + hf_cand::ErrorImpactParameter0, + hf_cand::ErrorImpactParameter1, + hf_cand::ErrorImpactParameter2, + full::NSigTPC_Pi_0, + full::NSigTPC_Ka_0, + full::NSigTOF_Pi_0, + full::NSigTOF_Ka_0, + full::NSigTPC_Pi_1, + full::NSigTPC_Ka_1, + full::NSigTOF_Pi_1, + full::NSigTOF_Ka_1, + full::NSigTPC_Pi_2, + full::NSigTPC_Ka_2, + full::NSigTOF_Pi_2, + full::NSigTOF_Ka_2, + full::M, + full::Pt, + full::P, + full::CPA, + full::CPAXY, + full::Ct, + full::Eta, + full::Phi, + full::Y, + full::E, + full::MCflag); + +DECLARE_SOA_TABLE(HfCandProng3FullEvents, "AOD", "HFCANDP3FullE", + collision::BCId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + full::IsEventReject, + full::RunNumber); + +DECLARE_SOA_TABLE(HfCandProng3FullParticles, "AOD", "HFCANDP3FullP", + collision::BCId, + full::Pt, + full::Eta, + full::Phi, + full::Y, + full::MCflag); + +} // namespace o2::aod + +/// Writes a debug tree +struct CandidateTreeWriter { + Produces rowCandidateFull; + Produces rowCandidateFullEvents; + Produces rowCandidateFullParticles; + void init(InitContext const&) + { + } + void process(aod::Collisions const& collisions, + aod::McCollisions const& mccollisions, + soa::Join const& candidates, + soa::Join const& particles, + aod::BigTracksPID const& tracks) + { + rowCandidateFullEvents.reserve(collisions.size()); + for (auto& collision : collisions) { + rowCandidateFullEvents( + collision.bcId(), + collision.numContrib(), + collision.posX(), + collision.posY(), + collision.posZ(), + 0, + 1); + } + rowCandidateFull.reserve(candidates.size()); + for (auto& candidate : candidates) { + rowCandidateFull( + candidate.index0_as().collision().bcId(), + candidate.index0_as().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(), + TMath::Abs(candidate.ptProng0()), + TMath::Sqrt(RecoDecay::P(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0())), + candidate.impactParameterNormalised1(), + TMath::Abs(candidate.ptProng1()), + TMath::Sqrt(RecoDecay::P(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1())), + candidate.impactParameterNormalised2(), + TMath::Abs(candidate.ptProng2()), + TMath::Sqrt(RecoDecay::P(candidate.pxProng2(), candidate.pyProng2(), candidate.pzProng2())), + candidate.pxProng0(), + candidate.pyProng0(), + candidate.pzProng0(), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + candidate.pxProng2(), + candidate.pyProng2(), + candidate.pzProng2(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameter2(), + candidate.errorImpactParameter0(), + candidate.errorImpactParameter1(), + candidate.errorImpactParameter2(), + candidate.index0_as().tpcNSigmaPi(), + candidate.index0_as().tpcNSigmaKa(), + candidate.index0_as().tofNSigmaPi(), + candidate.index0_as().tofNSigmaKa(), + candidate.index1_as().tpcNSigmaPi(), + candidate.index1_as().tpcNSigmaKa(), + candidate.index1_as().tofNSigmaPi(), + candidate.index1_as().tofNSigmaKa(), + candidate.index2_as().tpcNSigmaPi(), + candidate.index2_as().tpcNSigmaKa(), + candidate.index2_as().tofNSigmaPi(), + candidate.index2_as().tofNSigmaKa(), + InvMassLcpKpi(candidate), + candidate.pt(), + candidate.p(), + candidate.cpa(), + candidate.cpaXY(), + CtLc(candidate), + candidate.eta(), + candidate.phi(), + YLc(candidate), + ELc(candidate), + candidate.flagMCMatchRec()); + } + + int npart = 0; + rowCandidateFullParticles.reserve(particles.size()); + for (auto& particle : particles) { + if (particle.flagMCMatchGen()) { + 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()); + } + } + } +}; + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ @@ -209,5 +451,9 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) if (doMC) { workflow.push_back(adaptAnalysisTask("hf-cand-creator-3prong-mc")); } + const bool writeTree = cfgc.options().get("writeTree"); + if (writeTree) { + workflow.push_back(adaptAnalysisTask("hf-cand-tree-3prong-writer")); + } return workflow; } diff --git a/Analysis/Tasks/PWGHF/HFTreeCreatorD0ToKPi.cxx b/Analysis/Tasks/PWGHF/HFTreeCreatorD0ToKPi.cxx new file mode 100644 index 0000000000000..8832c01888463 --- /dev/null +++ b/Analysis/Tasks/PWGHF/HFTreeCreatorD0ToKPi.cxx @@ -0,0 +1,264 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file HFTreeCreator2Prong.cxx +/// \brief Writer of the 2 prong candidates in the form of flat tables to be stored in TTrees. +/// Intended for debug or for the local optimization of analysis on small samples. +/// In this file are defined and filled the output tables +/// +/// \author Nicolo' Jacazio , CERN + +#include "Framework/AnalysisTask.h" +#include "DetectorsVertexing/DCAFitterN.h" +#include "AnalysisDataModel/HFSecondaryVertex.h" +#include "AnalysisDataModel/HFCandidateSelectionTables.h" +#include "AnalysisCore/trackUtilities.h" +#include "ReconstructionDataFormats/DCA.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod::hf_cand_prong2; + +void customize(std::vector& workflowOptions) +{ +} + +#include "Framework/runDataProcessing.h" + +namespace o2::aod +{ +namespace full +{ +DECLARE_SOA_COLUMN(RSecondaryVertex, rSecondaryVertex, float); +DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); +DECLARE_SOA_COLUMN(PProng0, pProng0, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised0, impactParameterNormalised0, float); +DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); +DECLARE_SOA_COLUMN(PProng1, pProng1, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised1, impactParameterNormalised1, float); +DECLARE_SOA_COLUMN(CandidateSelFlag, candidateSelFlag, int8_t); +DECLARE_SOA_COLUMN(M, m, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(P, p, float); +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(NSigTPC_Pi_0, nsigTPC_Pi_0, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_0, nsigTPC_Ka_0, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_0, nsigTOF_Pi_0, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_0, nsigTOF_Ka_0, float); +DECLARE_SOA_COLUMN(NSigTPC_Pi_1, nsigTPC_Pi_1, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_1, nsigTPC_Ka_1, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_1, nsigTOF_Pi_1, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_1, nsigTOF_Ka_1, 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(Ct, ct, float); +DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); +DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float); +DECLARE_SOA_COLUMN(MCflag, mcflag, uint8_t); +// Events +DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); +} // namespace full + +DECLARE_SOA_TABLE(HfCandProng2Full, "AOD", "HFCANDP2Full", + collision::BCId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + hf_cand::XSecondaryVertex, + hf_cand::YSecondaryVertex, + hf_cand::ZSecondaryVertex, + hf_cand::ErrorDecayLength, + hf_cand::ErrorDecayLengthXY, + hf_cand::Chi2PCA, + full::RSecondaryVertex, + full::DecayLength, + full::DecayLengthXY, + full::DecayLengthNormalised, + full::DecayLengthXYNormalised, + full::ImpactParameterNormalised0, + full::PtProng0, + full::PProng0, + full::ImpactParameterNormalised1, + full::PtProng1, + full::PProng1, + hf_cand::PxProng0, + hf_cand::PyProng0, + hf_cand::PzProng0, + hf_cand::PxProng1, + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::ImpactParameter0, + hf_cand::ImpactParameter1, + hf_cand::ErrorImpactParameter0, + hf_cand::ErrorImpactParameter1, + full::NSigTPC_Pi_0, + full::NSigTPC_Ka_0, + full::NSigTOF_Pi_0, + full::NSigTOF_Ka_0, + full::NSigTPC_Pi_1, + full::NSigTPC_Ka_1, + full::NSigTOF_Pi_1, + full::NSigTOF_Ka_1, + full::CandidateSelFlag, + full::M, + full::ImpactParameterProduct, + full::CosThetaStar, + full::Pt, + full::P, + full::CPA, + full::CPAXY, + full::Ct, + full::Eta, + full::Phi, + full::Y, + full::E, + full::MCflag); + +DECLARE_SOA_TABLE(HfCandProng2FullEvents, "AOD", "HFCANDP2FullE", + collision::BCId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + full::IsEventReject, + full::RunNumber); + +DECLARE_SOA_TABLE(HfCandProng2FullParticles, "AOD", "HFCANDP2FullP", + collision::BCId, + full::Pt, + full::Eta, + full::Phi, + full::Y, + full::MCflag); + +} // namespace o2::aod + +/// Writes the full information in an output TTree +struct CandidateTreeWriter { + Produces rowCandidateFull; + Produces rowCandidateFullEvents; + Produces rowCandidateFullParticles; + void init(InitContext const&) + { + } + void process(aod::Collisions const& collisions, + aod::McCollisions const& mccollisions, + soa::Join const& candidates, + soa::Join const& particles, + aod::BigTracksPID const& tracks) + { + rowCandidateFullEvents.reserve(collisions.size()); + for (auto& collision : collisions) { + rowCandidateFullEvents( + collision.bcId(), + collision.numContrib(), + collision.posX(), + collision.posY(), + collision.posZ(), + 0, + 1); + } + rowCandidateFull.reserve(candidates.size()); + for (auto& candidate : candidates) { + +#define FILL_TREE(CandFlag, FunctionSelection, FunctionInvMass, FunctionCosThetaStar, FunctionCt, FunctionY, FunctionE) \ + if (candidate.FunctionSelection() >= 1) { \ + rowCandidateFull( \ + candidate.index0_as().collision().bcId(), \ + candidate.index0_as().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(), \ + TMath::Abs(candidate.ptProng0()), \ + TMath::Sqrt(RecoDecay::P(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0())), \ + candidate.impactParameterNormalised1(), \ + TMath::Abs(candidate.ptProng1()), \ + TMath::Sqrt(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.index0_as().tpcNSigmaPi(), \ + candidate.index0_as().tpcNSigmaKa(), \ + candidate.index0_as().tofNSigmaPi(), \ + candidate.index0_as().tofNSigmaKa(), \ + candidate.index1_as().tpcNSigmaPi(), \ + candidate.index1_as().tpcNSigmaKa(), \ + candidate.index1_as().tofNSigmaPi(), \ + candidate.index1_as().tofNSigmaKa(), \ + 1 << CandFlag, \ + FunctionInvMass(candidate), \ + candidate.impactParameterProduct(), \ + FunctionCosThetaStar(candidate), \ + candidate.pt(), \ + candidate.p(), \ + candidate.cpa(), \ + candidate.cpaXY(), \ + FunctionCt(candidate), \ + candidate.eta(), \ + candidate.phi(), \ + FunctionY(candidate), \ + FunctionE(candidate), \ + candidate.flagMCMatchRec()); \ + } + + FILL_TREE(0, isSelD0, InvMassD0, CosThetaStarD0, CtD0, YD0, ED0); + FILL_TREE(1, isSelD0bar, InvMassD0bar, CosThetaStarD0bar, CtD0, YD0, ED0); + } + + int npart = 0; + rowCandidateFullParticles.reserve(particles.size()); + for (auto& particle : particles) { + if (particle.flagMCMatchGen()) { + 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()); + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow; + workflow.push_back(adaptAnalysisTask("hf-cand-tree-2prong-writer")); + return workflow; +} diff --git a/Analysis/Tasks/PWGHF/HFTreeCreatorLcToPKPi.cxx b/Analysis/Tasks/PWGHF/HFTreeCreatorLcToPKPi.cxx new file mode 100644 index 0000000000000..5e54d3f01139d --- /dev/null +++ b/Analysis/Tasks/PWGHF/HFTreeCreatorLcToPKPi.cxx @@ -0,0 +1,287 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file HFTreeCreator3Prong.cxx +/// \brief Writer of the 3 prong candidates in the form of flat tables to be stored in TTrees. +/// Intended for debug or for the local optimization of analysis on small samples. +/// In this file are defined and filled the output tables +/// +/// \author Nicolo' Jacazio , CERN + +#include "Framework/AnalysisTask.h" +#include "DetectorsVertexing/DCAFitterN.h" +#include "AnalysisDataModel/HFSecondaryVertex.h" +#include "AnalysisDataModel/HFCandidateSelectionTables.h" +#include "AnalysisCore/trackUtilities.h" +#include "ReconstructionDataFormats/DCA.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod::hf_cand_prong3; + +void customize(std::vector& workflowOptions) +{ +} + +#include "Framework/runDataProcessing.h" + +namespace o2::aod +{ +namespace full +{ +DECLARE_SOA_COLUMN(RSecondaryVertex, rSecondaryVertex, float); +DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); +DECLARE_SOA_COLUMN(PProng0, pProng0, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised0, impactParameterNormalised0, float); +DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); +DECLARE_SOA_COLUMN(PProng1, pProng1, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised1, impactParameterNormalised1, float); +DECLARE_SOA_COLUMN(PtProng2, ptProng2, float); +DECLARE_SOA_COLUMN(PProng2, pProng2, float); +DECLARE_SOA_COLUMN(ImpactParameterNormalised2, impactParameterNormalised2, float); +DECLARE_SOA_COLUMN(CandidateSelFlag, candidateSelFlag, int8_t); +DECLARE_SOA_COLUMN(M, m, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(P, p, float); +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(NSigTPC_Pi_0, nsigTPC_Pi_0, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_0, nsigTPC_Ka_0, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_0, nsigTOF_Pi_0, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_0, nsigTOF_Ka_0, float); +DECLARE_SOA_COLUMN(NSigTPC_Pi_1, nsigTPC_Pi_1, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_1, nsigTPC_Ka_1, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_1, nsigTOF_Pi_1, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_1, nsigTOF_Ka_1, float); +DECLARE_SOA_COLUMN(NSigTPC_Pi_2, nsigTPC_Pi_2, float); +DECLARE_SOA_COLUMN(NSigTPC_Ka_2, nsigTPC_Ka_2, float); +DECLARE_SOA_COLUMN(NSigTOF_Pi_2, nsigTOF_Pi_2, float); +DECLARE_SOA_COLUMN(NSigTOF_Ka_2, nsigTOF_Ka_2, 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(Ct, ct, float); +DECLARE_SOA_COLUMN(MCflag, mcflag, uint8_t); +// Events +DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); +} // namespace full + +DECLARE_SOA_TABLE(HfCandProng3Full, "AOD", "HFCANDP3Full", + collision::BCId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + hf_cand::XSecondaryVertex, + hf_cand::YSecondaryVertex, + hf_cand::ZSecondaryVertex, + hf_cand::ErrorDecayLength, + hf_cand::ErrorDecayLengthXY, + hf_cand::Chi2PCA, + full::RSecondaryVertex, + full::DecayLength, + full::DecayLengthXY, + full::DecayLengthNormalised, + full::DecayLengthXYNormalised, + full::ImpactParameterNormalised0, + full::PtProng0, + full::PProng0, + full::ImpactParameterNormalised1, + full::PtProng1, + full::PProng1, + full::ImpactParameterNormalised2, + full::PtProng2, + full::PProng2, + hf_cand::PxProng0, + hf_cand::PyProng0, + hf_cand::PzProng0, + hf_cand::PxProng1, + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::PxProng2, + hf_cand::PyProng2, + hf_cand::PzProng2, + hf_cand::ImpactParameter0, + hf_cand::ImpactParameter1, + hf_cand::ImpactParameter2, + hf_cand::ErrorImpactParameter0, + hf_cand::ErrorImpactParameter1, + hf_cand::ErrorImpactParameter2, + full::NSigTPC_Pi_0, + full::NSigTPC_Ka_0, + full::NSigTOF_Pi_0, + full::NSigTOF_Ka_0, + full::NSigTPC_Pi_1, + full::NSigTPC_Ka_1, + full::NSigTOF_Pi_1, + full::NSigTOF_Ka_1, + full::NSigTPC_Pi_2, + full::NSigTPC_Ka_2, + full::NSigTOF_Pi_2, + full::NSigTOF_Ka_2, + full::CandidateSelFlag, + full::M, + full::Pt, + full::P, + full::CPA, + full::CPAXY, + full::Ct, + full::Eta, + full::Phi, + full::Y, + full::E, + full::MCflag); + +DECLARE_SOA_TABLE(HfCandProng3FullEvents, "AOD", "HFCANDP3FullE", + collision::BCId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + full::IsEventReject, + full::RunNumber); + +DECLARE_SOA_TABLE(HfCandProng3FullParticles, "AOD", "HFCANDP3FullP", + collision::BCId, + full::Pt, + full::Eta, + full::Phi, + full::Y, + full::MCflag); + +} // namespace o2::aod + +/// Writes the full information in an output TTree +struct CandidateTreeWriter { + Produces rowCandidateFull; + Produces rowCandidateFullEvents; + Produces rowCandidateFullParticles; + void init(InitContext const&) + { + } + void process(aod::Collisions const& collisions, + aod::McCollisions const& mccollisions, + soa::Join const& candidates, + soa::Join const& particles, + aod::BigTracksPID const& tracks) + { + rowCandidateFullEvents.reserve(collisions.size()); + for (auto& collision : collisions) { + rowCandidateFullEvents( + collision.bcId(), + collision.numContrib(), + collision.posX(), + collision.posY(), + collision.posZ(), + 0, + 1); + } + rowCandidateFull.reserve(candidates.size()); + for (auto& candidate : candidates) { +#define FILL_TREE(CandFlag, FunctionSelection, FunctionInvMass, FunctionCt, FunctionY, FunctionE) \ + if (candidate.FunctionSelection() >= 1) { \ + rowCandidateFull( \ + candidate.index0_as().collision().bcId(), \ + candidate.index0_as().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(), \ + TMath::Abs(candidate.ptProng0()), \ + TMath::Sqrt(RecoDecay::P(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0())), \ + candidate.impactParameterNormalised1(), \ + TMath::Abs(candidate.ptProng1()), \ + TMath::Sqrt(RecoDecay::P(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1())), \ + candidate.impactParameterNormalised2(), \ + TMath::Abs(candidate.ptProng2()), \ + TMath::Sqrt(RecoDecay::P(candidate.pxProng2(), candidate.pyProng2(), candidate.pzProng2())), \ + candidate.pxProng0(), \ + candidate.pyProng0(), \ + candidate.pzProng0(), \ + candidate.pxProng1(), \ + candidate.pyProng1(), \ + candidate.pzProng1(), \ + candidate.pxProng2(), \ + candidate.pyProng2(), \ + candidate.pzProng2(), \ + candidate.impactParameter0(), \ + candidate.impactParameter1(), \ + candidate.impactParameter2(), \ + candidate.errorImpactParameter0(), \ + candidate.errorImpactParameter1(), \ + candidate.errorImpactParameter2(), \ + candidate.index0_as().tpcNSigmaPi(), \ + candidate.index0_as().tpcNSigmaKa(), \ + candidate.index0_as().tofNSigmaPi(), \ + candidate.index0_as().tofNSigmaKa(), \ + candidate.index1_as().tpcNSigmaPi(), \ + candidate.index1_as().tpcNSigmaKa(), \ + candidate.index1_as().tofNSigmaPi(), \ + candidate.index1_as().tofNSigmaKa(), \ + candidate.index2_as().tpcNSigmaPi(), \ + candidate.index2_as().tpcNSigmaKa(), \ + candidate.index2_as().tofNSigmaPi(), \ + candidate.index2_as().tofNSigmaKa(), \ + 1 << CandFlag, \ + FunctionInvMass(candidate), \ + candidate.pt(), \ + candidate.p(), \ + candidate.cpa(), \ + candidate.cpaXY(), \ + FunctionCt(candidate), \ + candidate.eta(), \ + candidate.phi(), \ + FunctionY(candidate), \ + FunctionE(candidate), \ + candidate.flagMCMatchRec()); \ + } + + FILL_TREE(0, isSelLcpKpi, InvMassLcpKpi, CtLc, YLc, ELc); + FILL_TREE(1, isSelLcpiKp, InvMassLcpiKp, CtLc, YLc, ELc); + } + int npart = 0; + rowCandidateFullParticles.reserve(particles.size()); + for (auto& particle : particles) { + if (particle.flagMCMatchGen()) { + 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()); + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow; + workflow.push_back(adaptAnalysisTask("hf-cand-tree-3prong-writer")); + return workflow; +}