23#include <unordered_set>
32 std::vector<bool> &particleMask,
33 std::vector<bool> &vertexMask,
37 int headIndex = pHead->
index();
38 particleMask[headIndex] =
true;
46 int decayIndex = decayVtx->
index();
47 vertexMask[decayIndex] =
true;
53 for (
unsigned int i=0; i<nParents; ++i) {
56 isHadVtx = isHadVtx && (idabs<6 || idabs==21);
58 for (
unsigned int i=0; i<nChildren; ++i) {
61 isHadVtx = isHadVtx && ((idabs>=80 && idabs<1000000) ||
65 if( !isHadVtx || keepHadVtx ){
67 for (
unsigned int i=0; i<nChildren; ++i) {
70 particleMask[childIndex] =
true;
77 int prodIndex = prodVtx->
index();
78 vertexMask[prodIndex] =
true;
81 unsigned int nChildren = nSiblings;
85 for (
unsigned int i=0; i<nParents; ++i) {
88 isHadVtx = isHadVtx && (idabs<6 || idabs==21);
90 for (
unsigned int i=0; i<nChildren; ++i) {
93 isHadVtx = isHadVtx && ((idabs>=80 && idabs<1000000) ||
97 if( !isHadVtx || keepHadVtx ){
99 for (
unsigned int i=0; i<nParents; ++i) {
102 particleMask[parentIndex] =
true;
105 for (
unsigned int i=0; i<nSiblings; ++i) {
108 particleMask[siblingIndex] =
true;
117 std::vector<int> &particleList,
118 std::unordered_set<int> &encounteredUniqueIDs) {
121 std::unordered_set<int>::const_iterator found = encounteredUniqueIDs.find(
HepMC::uniqueID(pHead));
122 if (found!=encounteredUniqueIDs.end())
return;
131 particleList.push_back(pHead->
pdgId());
135 for (
int i=0; i<nChildren; ++i) {
144 std::vector<bool> &particleMask,
145 std::vector<bool> &vertexMask,
146 std::unordered_set<int> &encounteredUniqueIDs,
150 if (pHead==
nullptr)
return;
153 std::unordered_set<int>::const_iterator found = encounteredUniqueIDs.find(
HepMC::uniqueID(pHead));
154 if (found!=encounteredUniqueIDs.end())
return;
160 int headIndex = pHead->
index();
161 particleMask[headIndex] =
true;
170 bool saveVertex =
false;
171 for (
int i=0; i<nChildren; ++i) {
179 int vtxIndex = decayVtx->
index();
180 vertexMask[vtxIndex] =
true;
187 std::vector<bool> &particleMask,
188 std::vector<bool> &vertexMask,
189 std::unordered_set<int> &encounteredUniqueIDs ) {
192 if (pHead==
nullptr)
return;
195 std::unordered_set<int>::const_iterator found = encounteredUniqueIDs.find(
HepMC::uniqueID(pHead));
196 if (found!=encounteredUniqueIDs.end())
return;
200 int headIndex = pHead->
index();
201 particleMask[headIndex] =
true;
209 int vtxIndex = prodVtx->
index();
210 vertexMask[vtxIndex] =
true;
219 std::vector<const xAOD::TruthParticle*> &selectedlist,
220 const std::vector<int> &pdgId,
bool allowFromHadron =
false,
221 bool chargedOnly =
false)
const {
229 bool skipPdgCheck = (pdgId.size()==0);
236 if (!skipPdgCheck &&
find(pdgId.begin(), pdgId.end(), abs(particle->pdgId())) == pdgId.end())
continue;
245 if (!allowFromHadron) {
246 if (!acc_class.
isAvailable(*particle))
return false;
247 unsigned int result = acc_class(*particle);
253 selectedlist.push_back(particle);
ATLAS-specific HepMC functions.
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
SG::ConstAccessor< T, ALLOC > ConstAccessor
size_t index() const
Return the index of this element within its container.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
int pdgId() const
PDG ID code.
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
bool hasProdVtx() const
Check for a production vertex on this particle.
bool hasDecayVtx() const
Check for a decay vertex on this particle.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
size_t nOutgoingParticles() const
Get the number of outgoing particles.
size_t nIncomingParticles() const
Get the number of incoming particles.
std::string find(const std::string &s)
return a remapped string
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
int isPrompt(const unsigned int classify, bool allow_prompt_tau_decays=true)
double threeCharge(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
TruthVertex_v1 TruthVertex
Typedef to implementation.
TruthParticle_v1 TruthParticle
Typedef to implementation.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
void descendants(const xAOD::TruthParticle *pHead, std::vector< int > &particleList, std::unordered_set< int > &encounteredUniqueIDs)
void ancestors(const xAOD::TruthParticle *pHead, std::vector< bool > &particleMask, std::vector< bool > &vertexMask, std::unordered_set< int > &encounteredUniqueIDs)
void descendants(const xAOD::TruthParticle *pHead, std::vector< bool > &particleMask, std::vector< bool > &vertexMask, std::unordered_set< int > &encounteredUniqueIDs, bool includeGeant)
void immediateRelatives(const xAOD::TruthParticle *pHead, std::vector< bool > &particleMask, std::vector< bool > &vertexMask, bool keepHadVtx)
bool constructListOfFinalParticles(const xAOD::TruthParticleContainer *allParticles, std::vector< const xAOD::TruthParticle * > &selectedlist, const std::vector< int > &pdgId, bool allowFromHadron=false, bool chargedOnly=false) const