ATLAS Offline Software
Tracking
TrkValidation
TrkValTools
src
InDetHaloSelector.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// InDetHaloSelector.cxx
7
// Source file for class InDetHaloSelector
9
// (c) ATLAS Detector software
11
12
#include "
TrkValTools/InDetHaloSelector.h
"
13
#include "
AtlasHepMC/GenVertex.h
"
14
#include "CLHEP/Geometry/Point3D.h"
15
#include "HepPDT/ParticleData.hh"
16
#include "GaudiKernel/IPartPropSvc.h"
17
#include "
AtlasHepMC/GenParticle.h
"
18
#include "
TruthUtils/HepMCHelpers.h
"
19
#include "
GeneratorObjects/McEventCollection.h
"
20
21
Trk::InDetHaloSelector::InDetHaloSelector
(
const
std::string&
type
,
const
std::string&
name
,
22
const
IInterface*
parent
)
23
:
AthAlgTool
(
type
,
name
,
parent
),
24
m_particleDataTable{}
25
26
{
27
declareInterface<IGenParticleSelector>(
this
);
28
29
}
30
34
StatusCode
Trk::InDetHaloSelector::initialize
() {
35
36
// get the Particle Properties Service
37
IPartPropSvc* partPropSvc =
nullptr
;
38
StatusCode
sc
= service(
"PartPropSvc"
, partPropSvc,
true
);
39
if
(
sc
.isFailure()) {
40
ATH_MSG_FATAL
(
" Could not initialize Particle Properties Service"
);
41
return
StatusCode::FAILURE;
42
}
43
m_particleDataTable = partPropSvc->PDT();
44
45
ATH_MSG_DEBUG
(
"initialise in "
<<
name
());
46
return
StatusCode::SUCCESS;
47
}
48
49
StatusCode
Trk::InDetHaloSelector::finalize
() {
50
ATH_MSG_DEBUG
(
"starting finalize() in "
<<
name
());
51
return
StatusCode::SUCCESS;
52
}
53
54
std::vector<HepMC::ConstGenParticlePtr>*
55
Trk::InDetHaloSelector::selectGenSignal
(
const
McEventCollection
* SimTracks)
const
{
56
57
if
(! SimTracks)
return
nullptr
;
58
59
std::vector<HepMC::ConstGenParticlePtr>* genSignal =
60
new
std::vector<HepMC::ConstGenParticlePtr>;
61
62
// pile-up: vector of MCEC has more than one entry
63
DataVector<HepMC::GenEvent>::const_iterator
itCollision = SimTracks->
begin
();
64
65
for
( ; itCollision != SimTracks->
end
(); ++itCollision ) {
66
const
HepMC::GenEvent* genEvent = *itCollision;
67
68
for
(
const
auto
&
particle
: *genEvent) {
69
70
// 1) require stable particle from generation or simulation
71
if
(!
MC::isStable
(
particle
))
continue
;
72
73
int
pdgCode =
particle
->pdg_id();
74
if
(
MC::isNucleus
(pdgCode))
continue
;
// ignore nuclei from hadronic interactions
75
const
HepPDT::ParticleData* pd = m_particleDataTable->particle(std::abs(pdgCode));
76
ATH_MSG_DEBUG
(
"Checking particle "
<<
particle
);
77
if
(!pd) {
// nuclei excluded, still problems with a given type?
78
ATH_MSG_INFO
(
"Could not get particle data for particle"
<<
particle
);
79
continue
;
80
}
81
float
charge
= pd->charge();
82
ATH_MSG_DEBUG
(
"particle charge = "
<<
charge
);
83
if
(std::fabs(
charge
)<0.5)
continue
;
84
85
genSignal->push_back(
particle
);
86
87
}
// loop and select particles
88
}
// loop and select pile-up vertices
89
return
genSignal;
90
}
91
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition:
AthMsgStreamMacros.h:34
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition:
ParticleHypothesis.h:76
isNucleus
bool isNucleus(const T &p)
Definition:
AtlasPID.h:212
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
Trk::InDetHaloSelector::selectGenSignal
virtual std::vector< HepMC::ConstGenParticlePtr > * selectGenSignal(const McEventCollection *) const
main method performing the genparticle selection; it works on the entire collection.
Definition:
InDetHaloSelector.cxx:55
GenVertex.h
GenParticle.h
Trk::InDetHaloSelector::initialize
virtual StatusCode initialize()
initialize
Definition:
InDetHaloSelector.cxx:34
AthenaPoolTestRead.sc
sc
Definition:
AthenaPoolTestRead.py:27
Trk::InDetHaloSelector::finalize
virtual StatusCode finalize()
Definition:
InDetHaloSelector.cxx:49
McEventCollection.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition:
test_pyathena.py:15
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition:
McEventCollection.h:33
DataVector
Derived DataVector<T>.
Definition:
DataVector.h:581
Trk::InDetHaloSelector::InDetHaloSelector
InDetHaloSelector(const std::string &type, const std::string &name, const IInterface *parent)
Definition:
InDetHaloSelector.cxx:21
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:192
charge
double charge(const T &p)
Definition:
AtlasPID.h:494
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
MC::isStable
bool isStable(const T &p)
Definition:
HepMCHelpers.h:30
InDetHaloSelector.h
python.CaloScaleNoiseConfig.type
type
Definition:
CaloScaleNoiseConfig.py:78
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.
Generated on Sun Jun 30 2024 21:17:35 for ATLAS Offline Software by
1.8.18