Skip to content

Commit d559544

Browse files
fgrosaalibuildvkucera
authored
PWGHF: Add task to check gen pT and y distributions of HF hadrons in MC (#6259)
* PWGHF: Add task to check gen pT and y distributions of HF hadrons in MC * Please consider the following formatting changes * Update PWGHF/Tasks/taskMcGenPtRapShapes.cxx Co-authored-by: Vít Kučera <vit.kucera@cern.ch> * Update PWGHF/Tasks/taskMcGenPtRapShapes.cxx Co-authored-by: Vít Kučera <vit.kucera@cern.ch> * Update PWGHF/Tasks/taskMcGenPtRapShapes.cxx Co-authored-by: Vít Kučera <vit.kucera@cern.ch> --------- Co-authored-by: ALICE Action Bot <alibuild@cern.ch> Co-authored-by: Vít Kučera <vit.kucera@cern.ch>
1 parent 4807a37 commit d559544

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

PWGHF/Tasks/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ o2physics_add_dpl_workflow(task-sel-optimisation
3333
SOURCES taskSelOptimisation.cxx
3434
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
3535
COMPONENT_NAME Analysis)
36+
37+
o2physics_add_dpl_workflow(task-mc-gen-pt-rap-shapes
38+
SOURCES taskMcGenPtRapShapes.cxx
39+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
40+
COMPONENT_NAME Analysis)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file taskMcGenPtRapShapes.cxx
13+
/// \brief Task to check generated pt and y distributions of charm and beauty hadrons in MC productions
14+
15+
/// \author Fabrizio Grosa <fabrizio.grosa@cern.ch>, CERN
16+
17+
#include <array>
18+
19+
#include "Common/Core/RecoDecay.h"
20+
#include "CommonConstants/PhysicsConstants.h"
21+
#include "Framework/AnalysisTask.h"
22+
#include "Framework/AnalysisDataModel.h"
23+
#include "Framework/HistogramRegistry.h"
24+
#include "Framework/runDataProcessing.h"
25+
26+
using namespace o2;
27+
using namespace o2::aod;
28+
using namespace o2::framework;
29+
using namespace o2::framework::expressions;
30+
using namespace o2::constants::physics;
31+
32+
namespace
33+
{
34+
const int nCharmHadrons = 10;
35+
static constexpr std::array<int, nCharmHadrons> pdgCodesCharm = {Pdg::kD0, Pdg::kDPlus, Pdg::kDS, Pdg::kDStar, Pdg::kLambdaCPlus, Pdg::kSigmaC0, Pdg::kSigmaCPlusPlus, Pdg::kXiC0, Pdg::kXiCPlus, Pdg::kOmegaC0};
36+
37+
const int nBeautyHadrons = 4;
38+
static constexpr std::array<int, nBeautyHadrons> pdgCodesBeauty = {Pdg::kB0, Pdg::kBPlus, Pdg::kBS, Pdg::kLambdaB0};
39+
} // namespace
40+
41+
struct HfTaskMcGenPtRapShapes {
42+
43+
ConfigurableAxis axisPtCharm{"axisPtCharm", {1000, 0.f, 100.f}, "Binning for the pT axis of charm hadrons"};
44+
ConfigurableAxis axisPtBeauty{"axisPtBeauty", {3000, 0.f, 300.f}, "Binning for the pT axis of beauty hadrons"};
45+
ConfigurableAxis axisRapCharm{"axisRapCharm", {100, -1.f, 1.f}, "Binning for the y axis of charm hadrons"};
46+
ConfigurableAxis axisRapBeauty{"axisRapBeauty", {100, -1.f, 1.f}, "Binning for the y axis of beauty hadrons"};
47+
48+
std::array<std::shared_ptr<TH2>, nCharmHadrons> histRapVsPtCharmPrompt{};
49+
std::array<std::shared_ptr<TH2>, nCharmHadrons> histRapVsPtCharmNonPrompt{};
50+
std::array<std::shared_ptr<TH2>, nCharmHadrons> histPtCharmVsPtBeautyNonPrompt{};
51+
std::array<std::shared_ptr<TH2>, nBeautyHadrons> histRapVsPtBeauty{};
52+
53+
HistogramRegistry registry{};
54+
55+
void init(InitContext&)
56+
{
57+
58+
for (auto iCharmHad{0}; iCharmHad < nCharmHadrons; ++iCharmHad) {
59+
histRapVsPtCharmPrompt[iCharmHad] = registry.add<TH2>(Form("CharmHadrons/hRapVsPtPrompt%d", pdgCodesCharm[iCharmHad]), Form("Prompt %d;#it{p}_{T} (GeV/#it{c});#it{y}", pdgCodesCharm[iCharmHad]), {HistType::kTH2F, {axisPtCharm, axisRapCharm}});
60+
histRapVsPtCharmNonPrompt[iCharmHad] = registry.add<TH2>(Form("CharmHadrons/hRapVsPtNonPrompt%d", pdgCodesCharm[iCharmHad]), Form("Non-prompt %d;#it{p}_{T} (GeV/#it{c});#it{y}", pdgCodesCharm[iCharmHad]), {HistType::kTH2F, {axisPtCharm, axisRapCharm}});
61+
histPtCharmVsPtBeautyNonPrompt[iCharmHad] = registry.add<TH2>(Form("CharmHadrons/hPtCharmVsPtBeautyNonPrompt%d", pdgCodesCharm[iCharmHad]), Form("Non-prompt %d;#it{p}_{T}(b-had) (GeV/#it{c});#it{p}_{T}(c-had) (GeV/#it{c})", pdgCodesCharm[iCharmHad]), {HistType::kTH2F, {axisPtBeauty, axisPtCharm}});
62+
}
63+
64+
for (auto iBeautyHad{0}; iBeautyHad < nBeautyHadrons; ++iBeautyHad) {
65+
histRapVsPtBeauty[iBeautyHad] = registry.add<TH2>(Form("BeautyHadrons/hRapVsPt%d", pdgCodesBeauty[iBeautyHad]), Form("%d;#it{p}_{T} (GeV/#it{c});#it{y}", pdgCodesBeauty[iBeautyHad]), {HistType::kTH2F, {axisPtBeauty, axisRapBeauty}});
66+
}
67+
}
68+
69+
void process(aod::McParticles const& mcParticles)
70+
{
71+
for (auto const& mcParticle : mcParticles) {
72+
int absPdgCode = std::abs(mcParticle.pdgCode());
73+
float pt = mcParticle.pt();
74+
float rap = mcParticle.y();
75+
auto itCharm = std::find(pdgCodesCharm.begin(), pdgCodesCharm.end(), absPdgCode);
76+
auto itBeauty = std::find(pdgCodesBeauty.begin(), pdgCodesBeauty.end(), absPdgCode);
77+
if (itCharm != pdgCodesCharm.end()) {
78+
auto idxCharm = std::distance(pdgCodesCharm.begin(), itCharm);
79+
std::vector<int> idxBhadMothers{};
80+
auto origin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, false, &idxBhadMothers);
81+
if (origin == RecoDecay::OriginType::Prompt) {
82+
histRapVsPtCharmPrompt[idxCharm]->Fill(pt, rap);
83+
} else if (origin == RecoDecay::OriginType::NonPrompt) {
84+
histRapVsPtCharmNonPrompt[idxCharm]->Fill(pt, rap);
85+
if (std::abs(rap) < 0.5) {
86+
auto bMother = mcParticles.rawIteratorAt(idxBhadMothers[0]);
87+
histPtCharmVsPtBeautyNonPrompt[idxCharm]->Fill(bMother.pt(), pt);
88+
}
89+
}
90+
} else if (itBeauty != pdgCodesBeauty.end()) {
91+
auto idxBeauty = std::distance(pdgCodesBeauty.begin(), itBeauty);
92+
histRapVsPtBeauty[idxBeauty]->Fill(pt, rap);
93+
}
94+
}
95+
}
96+
};
97+
98+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
99+
{
100+
return WorkflowSpec{adaptAnalysisTask<HfTaskMcGenPtRapShapes>(cfgc)};
101+
}

0 commit comments

Comments
 (0)