ATLAS Offline Software
Loading...
Searching...
No Matches
InDetPrimaryConversionSelector.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// InDetPrimaryConversionSelector.cxx
7// Source file for class InDetPrimaryConversionSelector
9
12#include "CLHEP/Geometry/Point3D.h"
13#include "CLHEP/Units/SystemOfUnits.h"
17
19 const IInterface* parent)
20 : AthAlgTool (type,name,parent),
21 m_minPt ( 500. ),
22 m_maxEta ( 2.5 ),
23 m_maxRStartAll ( 800.0*CLHEP::mm),
24 m_maxZStartAll (2000.0*CLHEP::mm)
25
26{
27 declareInterface<IGenParticleSelector>(this);
28
29 declareProperty("MinPt", m_minPt);
30 declareProperty("MaxEta", m_maxEta);
31 declareProperty("MaxRStartAll", m_maxRStartAll, "production vtx r for all");
32 declareProperty("MaxZStartAll", m_maxZStartAll, "production vtx z for all");
33}
34
39 ATH_MSG_INFO ("initialise in " << name());
40 return StatusCode::SUCCESS;
41}
42
44 ATH_MSG_INFO ("starting finalize() in " << name());
45 return StatusCode::SUCCESS;
46}
47
48std::vector<HepMC::ConstGenParticlePtr>*
50
51 if (! SimTracks) return nullptr;
52
53 std::vector<HepMC::ConstGenParticlePtr>* genSignal =
54 new std::vector<HepMC::ConstGenParticlePtr>;
55 // pile-up: vector of MCEC has more than one entry
56 DataVector<HepMC::GenEvent>::const_iterator itCollision = SimTracks->begin();
57
58 for( ; itCollision != SimTracks->end(); ++itCollision ) {
59 const HepMC::GenEvent* genEvent = *itCollision;
60
61 for (const auto& particle: *genEvent) {
62
63 // 1) require stable particle from generation or simulation
64 if (!MC::isStable(particle)) continue;
65
66 if(!particle->production_vertex()) {
67 ATH_MSG_WARNING ("GenParticle without production vertex - simulation corrupt? ");
68 ATH_MSG_DEBUG ("It's this one: " << particle);
69 continue;
70 } else {
71
72 // 2) require track inside ID - relaxed definition including decays of neutrals (secondaries)
73 if ( std::fabs(particle->production_vertex()->position().perp()) > m_maxRStartAll ||
74 std::fabs(particle->production_vertex()->position().z()) > m_maxZStartAll ) continue;
75
76 int pdgCode = particle->pdg_id();
77 if (MC::isNucleus(pdgCode)) continue; // ignore nuclei from hadronic interactions
78 ATH_MSG_DEBUG ("found particle = " << particle);
79
80 // assume for the moment we're only running over single gamma MC files ...
81 auto prodVertex = particle->production_vertex();
82 if ( std::abs(pdgCode) == 11 ) {
83 ATH_MSG_DEBUG ("Electron/Positron detected -- checking for production process ...");
84#ifdef HEPMC3
85 for ( const auto& inParticle: prodVertex->particles_in()) {
86#else
87 HepMC::GenVertex::particles_in_const_iterator ItinParticle = prodVertex->particles_in_const_begin();
88 HepMC::GenVertex::particles_out_const_iterator ItinParticleEnd = prodVertex->particles_in_const_end();
89 for ( ; ItinParticle != ItinParticleEnd; ++ItinParticle) {
90 auto inParticle=*ItinParticle;
91#endif
92 ATH_MSG_DEBUG(" --> checking morther: " << inParticle );
93 if ( MC::isPhoton(inParticle) || MC::isElectron(inParticle) ){
94 if (std::fabs(particle->momentum().perp()) > m_minPt && std::fabs(particle->momentum().pseudoRapidity()) < m_maxEta ) {
95 genSignal->push_back(particle);
96 ATH_MSG_DEBUG ("Selected this electron/positron!");
97 break;
98 } // if (particle pt, eta)
99 } // if (mother is electron or gamma ...)
100 } // loop over mother particles
101 } // if (have electron/positron)
102 } // if (have stable particle)
103 } // loop and select particles
104 } // loop and select pile-up vertices
105 return genSignal;
106}
107
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
ATLAS-specific HepMC functions.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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...
InDetPrimaryConversionSelector(const std::string &type, const std::string &name, const IInterface *parent)
float m_maxZStartAll
Max z of start vertex for primaries + sec.
virtual std::vector< HepMC::ConstGenParticlePtr > * selectGenSignal(const McEventCollection *) const
main method performing the genparticle selection; it works on the entire collection.
float m_maxRStartAll
Max R of start vertex for primaries and secondaries.
bool isPhoton(const T &p)
bool isElectron(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
bool isNucleus(const T &p)
PDG rule 16 Nuclear codes are given as 10-digit numbers ±10LZZZAAAI.