ATLAS Offline Software
Tracking
TrkValidation
TrkValTools
src
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
10
#include "
TrkValTools/InDetPrimaryConversionSelector.h
"
11
#include "
AtlasHepMC/GenVertex.h
"
12
#include "CLHEP/Geometry/Point3D.h"
13
#include "CLHEP/Units/SystemOfUnits.h"
14
#include "
AtlasHepMC/GenParticle.h
"
15
#include "
TruthUtils/HepMCHelpers.h
"
16
#include "
GeneratorObjects/McEventCollection.h
"
17
18
Trk::InDetPrimaryConversionSelector::InDetPrimaryConversionSelector
(
const
std::string&
type
,
const
std::string&
name
,
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
38
StatusCode
Trk::InDetPrimaryConversionSelector::initialize
() {
39
ATH_MSG_INFO
(
"initialise in "
<<
name
());
40
return
StatusCode::SUCCESS;
41
}
42
43
StatusCode
Trk::InDetPrimaryConversionSelector::finalize
() {
44
ATH_MSG_INFO
(
"starting finalize() in "
<<
name
());
45
return
StatusCode::SUCCESS;
46
}
47
48
std::vector<HepMC::ConstGenParticlePtr>*
49
Trk::InDetPrimaryConversionSelector::selectGenSignal
(
const
McEventCollection
* SimTracks)
const
{
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
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition:
ParticleHypothesis.h:76
isNucleus
bool isNucleus(const T &p)
PDG rule 16: Nuclear codes are given as 10-digit numbersĀ±10LZZZAAAI.
Definition:
AtlasPID.h:583
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition:
AthCommonDataStore.h:145
GenVertex.h
Trk::InDetPrimaryConversionSelector::m_maxRStartAll
float m_maxRStartAll
Max R of start vertex for primaries and secondaries.
Definition:
InDetPrimaryConversionSelector.h:47
GenParticle.h
McEventCollection.h
Trk::InDetPrimaryConversionSelector::InDetPrimaryConversionSelector
InDetPrimaryConversionSelector(const std::string &type, const std::string &name, const IInterface *parent)
Definition:
InDetPrimaryConversionSelector.cxx:18
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::InDetPrimaryConversionSelector::finalize
virtual StatusCode finalize()
Definition:
InDetPrimaryConversionSelector.cxx:43
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition:
EgammaxAODHelpers.cxx:12
CLHEP
STD'S.
Definition:
IAtRndmGenSvc.h:19
test_pyathena.parent
parent
Definition:
test_pyathena.py:15
Trk::InDetPrimaryConversionSelector::m_maxZStartAll
float m_maxZStartAll
Max z of start vertex for primaries + sec.
Definition:
InDetPrimaryConversionSelector.h:48
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition:
McEventCollection.h:33
InDetPrimaryConversionSelector.h
DataVector
Derived DataVector<T>.
Definition:
DataVector.h:794
Trk::InDetPrimaryConversionSelector::m_minPt
float m_minPt
Definition:
InDetPrimaryConversionSelector.h:45
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:228
Trk::InDetPrimaryConversionSelector::m_maxEta
float m_maxEta
Definition:
InDetPrimaryConversionSelector.h:46
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
python.SystemOfUnits.mm
int mm
Definition:
SystemOfUnits.py:83
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition:
HepMCHelpers.h:45
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition:
AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition:
CaloScaleNoiseConfig.py:78
xAOD::EgammaHelpers::isPhoton
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
Definition:
EgammaxAODHelpers.cxx:21
Trk::InDetPrimaryConversionSelector::selectGenSignal
virtual std::vector< HepMC::ConstGenParticlePtr > * selectGenSignal(const McEventCollection *) const
main method performing the genparticle selection; it works on the entire collection.
Definition:
InDetPrimaryConversionSelector.cxx:49
AthAlgTool
Definition:
AthAlgTool.h:26
HepMCHelpers.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Trk::InDetPrimaryConversionSelector::initialize
virtual StatusCode initialize()
initialize
Definition:
InDetPrimaryConversionSelector.cxx:38
Generated on Tue Dec 24 2024 21:11:44 for ATLAS Offline Software by
1.8.18