Skip to content

Commit edf22a0

Browse files
authored
[PWGHF] added basic hfl electron derived data task (AliceO2Group#9338)
1 parent 7a20d21 commit edf22a0

File tree

2 files changed

+146
-0
lines changed

2 files changed

+146
-0
lines changed

PWGHF/HFL/TableProducer/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ o2physics_add_dpl_workflow(electron-selection-with-tpc-emcal
1414
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
1515
COMPONENT_NAME Analysis)
1616

17+
o2physics_add_dpl_workflow(tree-creator-electron-d-c-a
18+
SOURCES treeCreatorElectronDCA.cxx
19+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
20+
COMPONENT_NAME Analysis)
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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 treeCreatorElectronDCA.cxx
13+
/// \brief Basic electron DCA analysis task
14+
///
15+
/// \author Martin Voelkl <[email protected]>, University of Birmingham
16+
17+
#include "CommonConstants/PhysicsConstants.h"
18+
#include "Framework/AnalysisTask.h"
19+
#include "Framework/HistogramRegistry.h"
20+
#include "Framework/O2DatabasePDGPlugin.h"
21+
#include "Framework/runDataProcessing.h"
22+
23+
#include "Common/DataModel/Centrality.h"
24+
25+
#include "PWGHF/Core/HfHelper.h"
26+
#include "PWGHF/Core/SelectorCuts.h"
27+
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
28+
#include "PWGHF/DataModel/CandidateSelectionTables.h"
29+
30+
using namespace o2;
31+
using namespace o2::aod;
32+
using namespace o2::analysis;
33+
using namespace o2::framework;
34+
using namespace o2::framework::expressions;
35+
36+
namespace o2::aod
37+
{
38+
namespace hf_ele_mc_red
39+
{
40+
DECLARE_SOA_COLUMN(Eta, eta, float);
41+
DECLARE_SOA_COLUMN(Phi, phi, float);
42+
DECLARE_SOA_COLUMN(Pt, pt, float);
43+
DECLARE_SOA_COLUMN(SourcePdg, sourcePdg, int);
44+
DECLARE_SOA_COLUMN(DcaXY, dcaXY, float);
45+
DECLARE_SOA_COLUMN(ProductionRadius, productionRadius, float);
46+
47+
} // namespace hf_ele_mc_red
48+
DECLARE_SOA_TABLE(HFeleMCRedTable, "AOD", "HFELERED",
49+
hf_ele_mc_red::Eta, hf_ele_mc_red::Phi, hf_ele_mc_red::Pt, hf_ele_mc_red::SourcePdg, hf_ele_mc_red::DcaXY, hf_ele_mc_red::ProductionRadius);
50+
} // namespace o2::aod
51+
52+
/// Electron DCA analysis task
53+
struct HfTreeCreatorElectronDCA {
54+
Produces<o2::aod::HFeleMCRedTable> hfEleTable;
55+
56+
Configurable<float> etaRange{"etaRange", 0.5, "pseudorapidity range"};
57+
Configurable<float> pTMin{"pTMin", 0.5, "min pT"};
58+
59+
HfHelper hfHelper;
60+
Service<o2::framework::O2DatabasePDG> pdg;
61+
62+
using TracksWExt = soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, o2::aod::TracksDCA, aod::TrackSelection, o2::aod::TrackSelectionExtension, aod::TracksPidPi, aod::TracksPidKa>;
63+
using TracksWExtMc = soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, o2::aod::TracksDCA, aod::TrackSelection, o2::aod::TrackSelectionExtension, aod::TracksPidPi, aod::TracksPidKa, McTrackLabels>;
64+
65+
HistogramRegistry registry{
66+
"registry",
67+
{{"hZVertex", "z Vertex;z_{vtx};counts", {HistType::kTH1F, {{100, -20., 20.}}}},
68+
{"hpTTracks", "pT of tracks; p_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 10.}}}},
69+
{"hpTElectrons", "pT of electrons; p_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 10.}}}}}};
70+
71+
void init(InitContext&)
72+
{
73+
}
74+
75+
void processData(aod::Collisions::iterator const& collision)
76+
{
77+
registry.get<TH1>(HIST("hZVertex"))->Fill(collision.posZ());
78+
}
79+
PROCESS_SWITCH(HfTreeCreatorElectronDCA, processData, "Process Data", true);
80+
81+
void processMc(aod::Collisions::iterator const& collision,
82+
TracksWExtMc const& tracks,
83+
aod::McParticles const&)
84+
{
85+
registry.get<TH1>(HIST("hZVertex"))->Fill(collision.posZ());
86+
int pdgCode = 0, absPDGCode = 0, sourcePDG = 0;
87+
for (const auto& track : tracks) {
88+
if (!track.trackCutFlagFb3())
89+
continue;
90+
registry.get<TH1>(HIST("hpTTracks"))->Fill(track.pt());
91+
if (track.pt() < pTMin)
92+
continue;
93+
if (std::abs(track.eta()) > etaRange)
94+
continue;
95+
if (track.mcParticleId() < 1)
96+
continue;
97+
auto mcTrack = track.mcParticle();
98+
if (std::abs(mcTrack.pdgCode()) == kElectron) {
99+
bool isConversion = false;
100+
bool isBeauty = false;
101+
bool isCharm = false;
102+
double productionRadius = RecoDecay::sqrtSumOfSquares(mcTrack.vx(), mcTrack.vy());
103+
registry.get<TH1>(HIST("hpTElectrons"))->Fill(track.pt());
104+
auto motherTracks = mcTrack.mothers_as<aod::McParticles>();
105+
int numberOfMothers = motherTracks.size();
106+
// Categorise the electron sources
107+
int firstMotherPDG = motherTracks[0].pdgCode();
108+
if (firstMotherPDG == kGamma)
109+
isConversion = true;
110+
while (numberOfMothers == 1) // loop through all generations
111+
{
112+
pdgCode = motherTracks[0].pdgCode();
113+
absPDGCode = std::abs(pdgCode);
114+
if (static_cast<int>(absPDGCode / 100) == 4 || static_cast<int>(absPDGCode / 1000) == 4) {
115+
isCharm = true;
116+
sourcePDG = pdgCode;
117+
}
118+
if (static_cast<int>(absPDGCode / 100) == 5 || static_cast<int>(absPDGCode / 1000) == 5) {
119+
isBeauty = true;
120+
sourcePDG = pdgCode; // already in order, since beauty would decay to charm
121+
}
122+
auto firstMother = motherTracks[0];
123+
motherTracks = firstMother.mothers_as<aod::McParticles>();
124+
numberOfMothers = motherTracks.size();
125+
}
126+
if (!isBeauty && !isCharm) {
127+
if (isConversion)
128+
sourcePDG = kGamma;
129+
else
130+
sourcePDG = firstMotherPDG;
131+
}
132+
hfEleTable(track.eta(), track.phi(), track.pt(), sourcePDG, track.dcaXY(), productionRadius);
133+
}
134+
}
135+
}
136+
PROCESS_SWITCH(HfTreeCreatorElectronDCA, processMc, "Process MC", false);
137+
};
138+
139+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
140+
{
141+
return WorkflowSpec{adaptAnalysisTask<HfTreeCreatorElectronDCA>(cfgc)};
142+
}

0 commit comments

Comments
 (0)