Skip to content

Commit ff68fdc

Browse files
committed
MCTrackNavigator: Access Daugther0 and Daughter1
1 parent 702c4c4 commit ff68fdc

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

DataFormats/simulation/include/SimulationDataFormat/MCUtils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class MCTrackNavigator
4646
/// Given an MCTrack p; Return it's direct daughter or nullptr. (we follow only first daughter)
4747
static o2::MCTrack const* getDaughter(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
4848

49+
/// Given an MCTrack p; Return it's first direct daughter or nullptr.
50+
static o2::MCTrack const* getDaughter0(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
51+
/// Given an MCTrack p; Return it's second direct daughter or nullptr.
52+
static o2::MCTrack const* getDaughter1(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
53+
4954
/// Given an MCTrack p; Fill the complete parent chain (ancestorchain) up to the most fundamental particle (follow only
5055
/// first mothers).
5156
// static void getParentChain(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer, std::vector<o2::MCTrack> &ancestorchain);

DataFormats/simulation/src/MCUtils.cxx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ o2::MCTrack const* MCTrackNavigator::getDaughter(const o2::MCTrack& p, const std
3636
return &(pcontainer[did]);
3737
}
3838

39+
o2::MCTrack const* MCTrackNavigator::getDaughter0(const o2::MCTrack& p, const std::vector<o2::MCTrack>& pcontainer)
40+
{
41+
const auto did = p.getFirstDaughterTrackId();
42+
if (did < 0 or did > pcontainer.size()) {
43+
return nullptr;
44+
}
45+
return &(pcontainer[did]);
46+
}
47+
48+
o2::MCTrack const* MCTrackNavigator::getDaughter1(const o2::MCTrack& p, const std::vector<o2::MCTrack>& pcontainer)
49+
{
50+
const auto did = p.getLastDaughterTrackId();
51+
if (did < 0 or did > pcontainer.size()) {
52+
return nullptr;
53+
}
54+
return &(pcontainer[did]);
55+
}
56+
3957
o2::MCTrack const& MCTrackNavigator::getFirstPrimary(const o2::MCTrack& p, const std::vector<o2::MCTrack>& pcontainer)
4058
{
4159
if (p.isPrimary()) {

0 commit comments

Comments
 (0)