Skip to content

Commit

Permalink
PWGHF: Developments for D-resonances workflow (#7596)
Browse files Browse the repository at this point in the history
* developements for Resonance workflow

* modified data creator to build V0s on the fly

* minor change

* first attempt at ev. mixing for D resonances task

* updated mixed event

* changes in candidate creator and Task

* changed variables to naming convention

* revereted changes to  CMakeLists.txt

* Update CMakeLists.txt

* Please consider the following formatting changes

* implemented suggested changes

* Please consider the following formatting changes

* fixed header file

* Update SelectorCutsRedDataFormat.h

* Update PWGHF/D2H/Tasks/taskCharmResoReduced.cxx

Co-authored-by: Vít Kučera <[email protected]>

---------

Co-authored-by: ALICE Action Bot <[email protected]>
Co-authored-by: Vít Kučera <[email protected]>
  • Loading branch information
3 people authored Sep 10, 2024
1 parent c381a0f commit 6689279
Show file tree
Hide file tree
Showing 5 changed files with 405 additions and 34 deletions.
81 changes: 81 additions & 0 deletions PWGHF/D2H/Core/SelectorCutsRedDataFormat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// 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 SelectorCutsRedDataFormat.h
/// \brief Default pT bins and cut arrays for heavy-flavour selectors and analysis tasks
///
/// \author Luca Aglietta <[email protected]>, Università degli Studi di Torino

// namespace with D selections for reduced charmed-resonances analysis

#ifndef PWGHF_D2H_CORE_SELECTORCUTSREDDATAFORMAT_H_
#define PWGHF_D2H_CORE_SELECTORCUTSREDDATAFORMAT_H_

#include <string> // std::string
#include <vector> // std::vector

namespace hf_cuts_d_daughter
{
const int nBinsPt = 7;
static constexpr int nCutVars = 6;
constexpr double binsPt[nBinsPt + 1] = {
1.,
2.,
4.,
6.,
8.,
12.,
24.,
1000.};
auto vecBinsPt = std::vector<double>{binsPt, binsPt + nBinsPt + 1};
// default values for the cuts
constexpr double cuts[nBinsPt][nCutVars] = {{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 1 < pt < 2 */
{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 2 < pt < 4 */
{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 4 < pt < 6 */
{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 6 < pt < 8 */
{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 8 < pt < 12 */
{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 12 < pt < 24 */
{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}}; /* 24 < pt < 1000 */
// row labels
static const std::vector<std::string> labelsPt{};
// column labels
static const std::vector<std::string> labelsCutVar = {"invMassSignalLow", "invMassSignalHigh", "invMassLeftSBLow", "invMassLeftSBHigh", "invMassRightSBLow", "invMassRightSBHigh"};
} // namespace hf_cuts_d_daughter

// namespace with v0 selections for reduced charmed-resonances analysis
namespace hf_cuts_v0_daughter
{
const int nBinsPt = 7;
static constexpr int nCutVars = 5;
constexpr double binsPt[nBinsPt + 1] = {
0.,
1.,
2.,
4.,
8.,
12.,
24.,
1000.};
auto vecBinsPt = std::vector<double>{binsPt, binsPt + nBinsPt + 1};
// default values for the cuts
constexpr double cuts[nBinsPt][nCutVars] = {{0.48, 0.52, 0.99, 1., 0.9}, /* 1 < pt < 2 */
{0.48, 0.52, 0.99, 1., 0.9}, /* 2 < pt < 4 */
{0.48, 0.52, 0.99, 1., 0.9}, /* 4 < pt < 6 */
{0.48, 0.52, 0.99, 1., 0.9}, /* 6 < pt < 8 */
{0.48, 0.52, 0.99, 1., 0.9}, /* 8 < pt < 12 */
{0.48, 0.52, 0.99, 1., 0.9}, /* 12 < pt < 24 */
{0.48, 0.52, 0.99, 1., 0.9}}; /* 24 < pt < 1000 */
// row labels
static const std::vector<std::string> labelsPt{};
// column labels
static const std::vector<std::string> labelsCutVar = {"invMassLow", "invMassHigh", "cpaMin", "dcaMax", "radiusMin"};
} // namespace hf_cuts_v0_daughter
#endif // PWGHF_D2H_CORE_SELECTORCUTSREDDATAFORMAT_H_
38 changes: 29 additions & 9 deletions PWGHF/D2H/DataModel/ReducedDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,25 @@ DECLARE_SOA_TABLE(HfCandBpConfigs, "AOD", "HFCANDBPCONFIG", //! Table with confi
// Charm resonances analysis
namespace hf_reso_cand_reduced
{
DECLARE_SOA_COLUMN(InvMass, invMass, float); //! Invariant mass in GeV/c2
DECLARE_SOA_COLUMN(Pt, pt, float); //! Pt of Resonance candidate in GeV/c
DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); //! Pt of D daughter in GeV/c
DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); //! Pt of V0 daughter in GeV/c
DECLARE_SOA_COLUMN(InvMass, invMass, float); //! Invariant mass in GeV/c2
DECLARE_SOA_COLUMN(InvMassProng0, invMassProng0, float); //! Invariant Mass of D daughter in GeV/c
DECLARE_SOA_COLUMN(InvMassProng1, invMassProng1, float); //! Invariant Mass of V0 daughter in GeV/c
DECLARE_SOA_COLUMN(MlScoreBkgProng0, mlScoreBkgProng0, float); //! Bkg ML score of the D daughter
DECLARE_SOA_COLUMN(MlScorePromptProng0, mlScorePromptProng0, float); //! Prompt ML score of the D daughter
DECLARE_SOA_COLUMN(MlScoreNonpromptProng0, mlScoreNonpromptProng0, float); //! Nonprompt ML score of the D daughter

DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //!
[](float pxProng0, float pxProng1, float pyProng0, float pyProng1) -> float { return RecoDecay::pt((1.f * pxProng0 + 1.f * pxProng1), (1.f * pyProng0 + 1.f * pyProng1)); });
DECLARE_SOA_DYNAMIC_COLUMN(PtProng0, ptProng0, //!
[](float pxProng0, float pyProng0) -> float { return RecoDecay::pt(pxProng0, pyProng0); });
DECLARE_SOA_DYNAMIC_COLUMN(PtProng1, ptProng1, //!
[](float pxProng1, float pyProng1) -> float { return RecoDecay::pt(pxProng1, pyProng1); });
DECLARE_SOA_DYNAMIC_COLUMN(CosThetaStarDs1, cosThetaStarDs1, //! costhetastar under Ds1 hypothesis
[](float px0, float py0, float pz0, float px1, float py1, float pz1, float invMass) -> float { return RecoDecay::cosThetaStar(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, std::array{o2::constants::physics::MassDStar, o2::constants::physics::MassK0}, invMass, 1); });
DECLARE_SOA_DYNAMIC_COLUMN(CosThetaStarDs2Star, cosThetaStarDs2Star, //! costhetastar under Ds2Star hypothesis
[](float px0, float py0, float pz0, float px1, float py1, float pz1, float invMass) -> float { return RecoDecay::cosThetaStar(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, std::array{o2::constants::physics::MassDPlus, o2::constants::physics::MassK0}, invMass, 1); });
DECLARE_SOA_DYNAMIC_COLUMN(CosThetaStarXiC3055, cosThetaStarXiC3055, //! costhetastar under XiC3055 hypothesis
[](float px0, float py0, float pz0, float px1, float py1, float pz1, float invMass) -> float { return RecoDecay::cosThetaStar(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, std::array{o2::constants::physics::MassDPlus, o2::constants::physics::MassLambda0}, invMass, 1); });
} // namespace hf_reso_cand_reduced

namespace hf_reso_3_prong
Expand Down Expand Up @@ -474,7 +484,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //!
[](float pzProng0, float pzProng1) -> float { return 1.f * pzProng0 + 1.f * pzProng1; });
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //!
[](float pxProng0, float pxProng1, float pyProng0, float pyProng1) -> float { return RecoDecay::pt((1.f * pxProng0 + 1.f * pxProng1), (1.f * pyProng0 + 1.f * pyProng1)); });
DECLARE_SOA_DYNAMIC_COLUMN(V0Radius, v0radius, //! V0 decay radius (2D, centered at zero)
DECLARE_SOA_DYNAMIC_COLUMN(V0Radius, v0Radius, //! V0 decay radius (2D, centered at zero)
[](float x, float y) -> float { return RecoDecay::sqrtSumOfSquares(x, y); });
DECLARE_SOA_DYNAMIC_COLUMN(InvMassLambda, invMassLambda, //! mass under lambda hypothesis
[](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> float { return RecoDecay::m(std::array{std::array{pxpos, pypos, pzpos}, std::array{pxneg, pyneg, pzneg}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); });
Expand Down Expand Up @@ -571,16 +581,26 @@ DECLARE_SOA_TABLE(HfRed3PrNoTrks, "AOD", "HFRED3PRNOTRK", //! Table with 3 prong

DECLARE_SOA_TABLE(HfCandCharmReso, "AOD", "HFCANDCHARMRESO", //! Table with Resonance candidate information for resonances reduced workflow
o2::soa::Index<>,
// Indices
hf_track_index_reduced::HfRedCollisionId,
// Static
hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0,
hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1,
hf_reso_cand_reduced::InvMass,
hf_reso_cand_reduced::Pt,
hf_reso_cand_reduced::InvMassProng0,
hf_reso_cand_reduced::PtProng0,
hf_reso_cand_reduced::InvMassProng1,
hf_reso_cand_reduced::PtProng1,
hf_reso_v0::Cpa,
hf_reso_v0::Dca,
hf_reso_v0::Radius);
hf_reso_v0::Radius,
// Dynamic
hf_reso_cand_reduced::Pt<hf_cand::PxProng0, hf_cand::PxProng1, hf_cand::PyProng0, hf_cand::PyProng1>,
hf_reso_cand_reduced::PtProng0<hf_cand::PxProng0, hf_cand::PyProng0>,
hf_reso_cand_reduced::PtProng1<hf_cand::PxProng1, hf_cand::PyProng1>,
hf_cand::PVectorProng0<hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0>,
hf_cand::PVectorProng1<hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1>,
hf_reso_cand_reduced::CosThetaStarDs1<hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, hf_reso_cand_reduced::InvMass>,
hf_reso_cand_reduced::CosThetaStarDs2Star<hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, hf_reso_cand_reduced::InvMass>,
hf_reso_cand_reduced::CosThetaStarXiC3055<hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, hf_reso_cand_reduced::InvMass>);

DECLARE_SOA_TABLE(HfCharmResoMLs, "AOD", "HFCHARMRESOML", //! Table with ML scores for the D daughter
hf_reso_cand_reduced::MlScoreBkgProng0,
Expand Down
77 changes: 52 additions & 25 deletions PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@

#include "Common/Core/trackUtilities.h"
#include "Common/DataModel/CollisionAssociationTables.h"
#include "EventFiltering/PWGHF/HFFilterHelpers.h"

#include "PWGHF/D2H/DataModel/ReducedDataModel.h"
#include "PWGHF/D2H/Core/SelectorCutsRedDataFormat.h"
#include "PWGHF/Utils/utilsAnalysis.h"

using namespace o2;
using namespace o2::aod;
using namespace o2::analysis;
using namespace o2::framework;
using namespace o2::framework::expressions;

Expand All @@ -47,32 +51,36 @@ enum V0Type : uint8_t {
Lambda,
AntiLambda
};
const int nBins = 7;
constexpr double binsPt[nBins + 1] = {

const int nBinsPt = 7;
constexpr double binsPt[nBinsPt + 1] = {
1.,
2.,
4.,
6.,
8.,
12.,
24.,
50.};
auto vecBins = std::vector<double>{binsPt, binsPt + nBins + 1};
1000.};
auto vecBinsPt = std::vector<double>{binsPt, binsPt + nBinsPt + 1};

struct HfCandidateCreatorCharmResoReduced {
// Produces: Tables with resonance info
Produces<aod::HfCandCharmReso> rowCandidateReso;
// Optional D daughter ML scores table
// Optional daughter ML scores table
Produces<aod::HfCharmResoMLs> mlScores;

// Configurables
Configurable<double> invMassWindowD{"invMassWindowD", 0.5, "invariant-mass window for D candidates (GeV/c2)"};
Configurable<double> invMassWindowV0{"invMassWindowV0", 0.5, "invariant-mass window for V0 candidates (GeV/c2)"};
Configurable<bool> rejectDV0PairsWithCommonDaughter{"rejectDV0PairsWithCommonDaughter", true, "flag to reject the pairs that share a daughter track if not done in the derived data creation"};
Configurable<bool> keepSideBands{"keepSideBands", false, "flag to keep events from D meson sidebands for backgorund estimation"};
// QA switch
Configurable<bool> activateQA{"activateQA", false, "Flag to enable QA histogram"};
// Hist Axis
Configurable<std::vector<double>> binsPt{"binsPt", std::vector<double>{vecBins}, "pT bin limits"};
Configurable<std::vector<double>> binsPt{"binsPt", std::vector<double>{vecBinsPt}, "Histogram pT bin limits"};
// Daughters selection cuts
Configurable<LabeledArray<double>> cutsD{"cutsDdaughter", {hf_cuts_d_daughter::cuts[0], hf_cuts_d_daughter::nBinsPt, hf_cuts_d_daughter::nCutVars, hf_cuts_d_daughter::labelsPt, hf_cuts_d_daughter::labelsCutVar}, "D daughter selections"};
Configurable<std::vector<double>> binsPtD{"binsPtD", std::vector<double>{hf_cuts_d_daughter::vecBinsPt}, "pT bin limits for D daughter cuts"};
Configurable<LabeledArray<double>> cutsV0{"cutsV0daughter", {hf_cuts_v0_daughter::cuts[0], hf_cuts_v0_daughter::nBinsPt, hf_cuts_v0_daughter::nCutVars, hf_cuts_v0_daughter::labelsPt, hf_cuts_v0_daughter::labelsCutVar}, "V0 daughter selections"};
Configurable<std::vector<double>> binsPtV0{"binsPtV0", std::vector<double>{hf_cuts_v0_daughter::vecBinsPt}, "pT bin limits for V0 daughter cuts"};

using reducedDWithMl = soa::Join<aod::HfRed3PrNoTrks, aod::HfRed3ProngsMl>;

Expand All @@ -82,15 +90,14 @@ struct HfCandidateCreatorCharmResoReduced {

Preslice<aod::HfRedVzeros> candsV0PerCollision = aod::hf_track_index_reduced::hfRedCollisionId;
Preslice<aod::HfRed3PrNoTrks> candsDPerCollision = hf_track_index_reduced::hfRedCollisionId;
// aod::HfRedVzeros

// Useful constants
double massK0{0.};
double massLambda{0.};
double massDplus{0.};
double massDstar{0.};
double massD0{0.};

// Histogram registry: if task make it with a THNsparse with all variables you want to save
HistogramRegistry registry{"registry"};

void init(InitContext const&)
Expand All @@ -101,7 +108,7 @@ struct HfCandidateCreatorCharmResoReduced {
LOGP(fatal, "Only one process function should be enabled! Please check your configuration!");
}
// histograms
const AxisSpec axisPt{(std::vector<double>)vecBins, "#it{p}_{T} (GeV/#it{c})"};
const AxisSpec axisPt{(std::vector<double>)vecBinsPt, "#it{p}_{T} (GeV/#it{c})"};
registry.add("hMassDs1", "Ds1 candidates;m_{Ds1} (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{100, 2.4, 2.7}, {(std::vector<double>)binsPt, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hMassDs2Star", "Ds^{*}2 candidates; m_Ds^{*}2 (GeV/#it{c}^{2}) ;entries", {HistType::kTH2F, {{100, 2.4, 2.7}, {(std::vector<double>)binsPt, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hMassXcRes", "XcRes candidates; m_XcRes (GeV/#it{c}^{2}) ;entries", {HistType::kTH2F, {{100, 2.9, 3.3}, {(std::vector<double>)binsPt, "#it{p}_{T} (GeV/#it{c})"}}});
Expand Down Expand Up @@ -131,21 +138,33 @@ struct HfCandidateCreatorCharmResoReduced {
template <DecayChannel channel, typename DRedTable>
bool isDSelected(DRedTable const& candD)
{
float massD{0.};
float invMassD{0.};
float ptD = candD.pt();
int ptBin = findBin(binsPtD, ptD);
if (ptBin == -1) {
return false;
}
// slection on D candidate mass
if (channel == DecayChannel::Ds2StarToDplusK0s || channel == DecayChannel::XcToDplusLambda || channel == DecayChannel::LambdaDminus) {
massD = massDplus;
invMassD = candD.invMassDplus();
} else if (channel == DecayChannel::Ds1ToDstarK0s) {
massD = massDstar - massD0;
if (candD.dType() > 0)
invMassD = candD.invMassDstar();
else
invMassD = candD.invMassAntiDstar();
}
if (std::fabs(invMassD - massD) > invMassWindowD) {
return false;
// invariant mass selection
if (!keepSideBands) {
if (invMassD < cutsD->get(ptBin, "invMassSignalLow") || invMassD > cutsD->get(ptBin, "invMassSignalHigh")) {
return false;
}
} else {
if ((invMassD < cutsD->get(ptBin, "invMassLeftSBLow")) ||
(invMassD > cutsD->get(ptBin, "invMassLeftSBHigh") && invMassD < cutsD->get(ptBin, "invMassSignalLow")) ||
(invMassD > cutsD->get(ptBin, "invMassSignalHigh") && invMassD < cutsD->get(ptBin, "invMassRightSBLow")) ||
(invMassD > cutsD->get(ptBin, "invMassRightSBHigh"))) {
return false;
}
}
return true;
}
Expand All @@ -159,6 +178,11 @@ struct HfCandidateCreatorCharmResoReduced {
{
float massV0{0.};
float invMassV0{0.};
float ptV0 = candV0.pt();
int ptBin = findBin(binsPtV0, ptV0);
if (ptBin == -1) {
return false;
}
if (channel == DecayChannel::Ds2StarToDplusK0s || channel == DecayChannel::Ds1ToDstarK0s) {
massV0 = massK0;
invMassV0 = candV0.invMassK0s();
Expand All @@ -175,12 +199,17 @@ struct HfCandidateCreatorCharmResoReduced {
invMassV0 = candV0.invMassAntiLambda();
targetV0Type = V0Type::AntiLambda;
}
// check skimming cuts
if (!TESTBIT(candV0.v0Type(), targetV0Type)) {
return false;
}
}
// slection on V0 candidate mass
if (std::fabs(invMassV0 - massV0) > invMassWindowV0) {
// selection on V0 candidate mass
if ((invMassV0 - massV0) > cutsV0->get(ptBin, "invMassLow") && (massV0 - invMassV0) < cutsV0->get(ptBin, "invMassLow")) {
return false;
}
// selection on kinematics and topology
if (candV0.dca() > cutsV0->get(ptBin, "dcaMax") || candV0.cpa() < cutsV0->get(ptBin, "cpaMin") || candV0.v0Radius() < cutsV0->get(ptBin, "radiusMin")) {
return false;
}
return true;
Expand Down Expand Up @@ -211,7 +240,7 @@ struct HfCandidateCreatorCharmResoReduced {
if (candD.dType() == -2)
invMassD = candD.invMassAntiDstar();
std::array<float, 3> pVecD = {candD.px(), candD.py(), candD.pz()};
float ptD = RecoDecay::pt(pVecD);
std::array<int, 3> dDaughtersIds = {candD.prong0Id(), candD.prong1Id(), candD.prong2Id()};
;
// loop on V0 candidates
bool alreadyCounted{false};
Expand All @@ -233,7 +262,6 @@ struct HfCandidateCreatorCharmResoReduced {
float invMassReso{0.};
float invMassV0{0.};
std::array<float, 3> pVecV0 = {candV0.px(), candV0.py(), candV0.pz()};
float ptV0 = RecoDecay::pt(pVecV0);
float ptReso = RecoDecay::pt(RecoDecay::sumOfVec(pVecV0, pVecD));
switch (channel) {
case DecayChannel::Ds1ToDstarK0s:
Expand Down Expand Up @@ -269,15 +297,14 @@ struct HfCandidateCreatorCharmResoReduced {
}
// Filling Output table
rowCandidateReso(collision.globalIndex(),
pVecD[0], pVecD[1], pVecD[2],
pVecV0[0], pVecV0[1], pVecV0[2],
invMassReso,
ptReso,
invMassD,
ptD,
invMassV0,
ptV0,
candV0.cpa(),
candV0.dca(),
candV0.v0radius());
candV0.v0Radius());
if constexpr (fillMl) {
mlScores(candD.mlScoreBkgMassHypo0(), candD.mlScorePromptMassHypo0(), candD.mlScoreNonpromptMassHypo0());
}
Expand Down
5 changes: 5 additions & 0 deletions PWGHF/D2H/Tasks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ o2physics_add_dpl_workflow(task-charm-polarisation
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(task-charm-reso-reduced
SOURCES taskCharmResoReduced.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(task-d0
SOURCES taskD0.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
Expand Down
Loading

0 comments on commit 6689279

Please sign in to comment.