Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class MCTrackNavigator
/// (of which p needs to be a part itself). The container can be fetched via MCKinematicsReader.
static bool isPhysicalPrimary(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);

/// return true of particle is to be kept for physics analysis in any case
/// (follows logic used in particle stack class
static bool isKeepPhysics(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
static bool isFromPrimaryDecayChain(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);

// some convenience functions for navigation

/// Given an MCTrack p; Return the first primary mother particle in the upward parent chain (follow
Expand Down
40 changes: 40 additions & 0 deletions DataFormats/simulation/src/MCUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,44 @@ bool MCTrackNavigator::isPhysicalPrimary(o2::MCTrack const& p, std::vector<o2::M
} // end else branch produced by generator
}

bool MCTrackNavigator::isFromPrimaryDecayChain(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer)
{
/** check if the particle is from the
decay chain of a primary particle **/

/** check if from decay **/
if (p.getProcess() != kPDecay) {
return false;
}
/** check if mother is primary **/
auto mother = getMother(p, pcontainer);
if (!mother || mother->isPrimary()) {
return true;
}
/** else check if mother is from primary decay **/
return isFromPrimaryDecayChain(*mother, pcontainer);
}

bool MCTrackNavigator::isKeepPhysics(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer)
{
auto isFromPrimaryPairProduction = [&pcontainer](const MCTrack& part) {
/** check if the particle is from
pair production from a particle
belonging to the primary decay chain **/

/** check if from pair production **/
if (part.getProcess() != kPPair) {
return false;
}
auto mother = getMother(part, pcontainer);
if (!mother || mother->isPrimary()) {
return true;
}
/** else check if mother is from primary decay **/
return isFromPrimaryDecayChain(*mother, pcontainer);
};
//
return p.isPrimary() || isFromPrimaryPairProduction(p) || isFromPrimaryDecayChain(p, pcontainer);
}

} // namespace o2::mcutils
9 changes: 9 additions & 0 deletions Detectors/AOD/src/AODProducerWorkflowSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "SimulationDataFormat/MCEventLabel.h"
#include "SimulationDataFormat/MCTrack.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include "SimulationDataFormat/MCUtils.h"
#include "ZDCBase/Constants.h"
#include "GPUTPCGMMergedTrackHit.h"
#include "TOFBase/Utils.h"
Expand Down Expand Up @@ -636,6 +637,14 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader&
mToStore[Triplet_t(source, event, particle)] = 1;
continue;
}
if (o2::mcutils::MCTrackNavigator::isPhysicalPrimary(mcParticles[particle], mcParticles)) {
mToStore[Triplet_t(source, event, particle)] = 1;
continue;
}
if (o2::mcutils::MCTrackNavigator::isKeepPhysics(mcParticles[particle], mcParticles)) {
mToStore[Triplet_t(source, event, particle)] = 1;
continue;
}
if (mToStore.find(Triplet_t(source, event, particle)) == mToStore.end()) {
continue;
}
Expand Down