ATLAS Offline Software
Loading...
Searching...
No Matches
InDetHaloSelector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// InDetHaloSelector.cxx
7// Source file for class InDetHaloSelector
9
12#include "CLHEP/Geometry/Point3D.h"
16
17Trk::InDetHaloSelector::InDetHaloSelector(const std::string& type, const std::string& name,
18 const IInterface* parent)
19 : AthAlgTool (type,name,parent)
20
21{
22 declareInterface<IGenParticleSelector>(this);
23
24}
25
30 ATH_MSG_DEBUG ("initialise in " << name());
31 return StatusCode::SUCCESS;
32}
33
35 ATH_MSG_DEBUG ("starting finalize() in " << name());
36 return StatusCode::SUCCESS;
37}
38
39std::vector<HepMC::ConstGenParticlePtr>*
41
42 if (! SimTracks) return nullptr;
43
44 std::vector<HepMC::ConstGenParticlePtr>* genSignal =
45 new std::vector<HepMC::ConstGenParticlePtr>;
46
47 // pile-up: vector of MCEC has more than one entry
48 DataVector<HepMC::GenEvent>::const_iterator itCollision = SimTracks->begin();
49
50 for( ; itCollision != SimTracks->end(); ++itCollision ) {
51 const HepMC::GenEvent* genEvent = *itCollision;
52
53 for (const auto& particle: *genEvent) {
54
55 // 1) require stable particle from generation or simulation
56 if (!MC::isStable(particle)) continue;
57
58 int pdgCode = particle->pdg_id();
59 if (MC::isNucleus(pdgCode)) continue; // ignore nuclei from hadronic interactions
60 ATH_MSG_DEBUG( "Checking particle " << particle );
61 float charge = MC::charge(pdgCode);
62 ATH_MSG_DEBUG( "particle charge = " << charge );
63 if (std::fabs(charge)<0.5) continue;
64
65 genSignal->push_back(particle);
66
67 } // loop and select particles
68 } // loop and select pile-up vertices
69 return genSignal;
70}
71
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
ATLAS-specific HepMC functions.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
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.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
virtual StatusCode initialize()
initialize
virtual StatusCode finalize()
InDetHaloSelector(const std::string &type, const std::string &name, const IInterface *parent)
virtual std::vector< HepMC::ConstGenParticlePtr > * selectGenSignal(const McEventCollection *) const
main method performing the genparticle selection; it works on the entire collection.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
double charge(const T &p)
bool isNucleus(const T &p)
PDG rule 16 Nuclear codes are given as 10-digit numbers ±10LZZZAAAI.