ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonValidation
MuonPRDTest
Root
TruthVariables.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MuonPRDTest/TruthVariables.h
"
6
7
#include "
AtlasHepMC/GenEvent.h
"
8
#include "
AtlasHepMC/GenVertex.h
"
9
namespace
MuonPRDTest
{
10
TruthVariables::TruthVariables
(
MuonTesterTree
&
tree
,
const
std::string& container_name, MSG::Level msglvl) :
11
PrdTesterModule
(
tree
,
"TruthTestModule"
, msglvl),
m_key
{container_name} {}
12
bool
TruthVariables::declare_keys
() {
return
declare_dependency
(
m_key
); }
13
14
bool
TruthVariables::fill
(
const
EventContext& ctx) {
15
SG::ReadHandle<McEventCollection>
truthContainer{
m_key
, ctx};
16
if
(!truthContainer.
isValid
()) {
17
ATH_MSG_FATAL
(
"Failed to retrieve container "
<<
m_key
.fullKey());
18
return
false
;
19
}
20
unsigned
int
truth_vertices{0}, truth_parts{0};
21
for
(
auto
it : *truthContainer) {
22
const
HepMC::GenEvent
* subEvent = it;
23
for
(
const
auto
& vertex : subEvent->vertices()) {
24
m_Truth_vertex
.push_back(vertex->position());
25
m_Truth_vertexId
.push_back(vertex->status());
26
++truth_vertices;
27
}
28
for
(
const
auto
& particle : subEvent->particles()) {
29
m_truthParticleP4
.push_back(particle->momentum());
30
m_Truth_particlePdg_id
.push_back(particle->pdg_id());
31
m_Truth_particleStatus
.push_back(particle->status());
32
m_Truth_particleBarcode
.push_back(
HepMC::barcode
(particle));
33
auto
production_vertex = particle->production_vertex();
34
m_Truth_particleProduction_vertex_id
.push_back(production_vertex ? production_vertex->status() : -1);
35
auto
end_vertex = particle->end_vertex();
36
m_Truth_particleEnd_vertex_id
.push_back(end_vertex ? end_vertex->status() : -1);
37
++truth_parts;
38
}
39
40
}
41
m_Truth_nVertices
= truth_vertices;
42
m_Truth_nParticles
= truth_parts;
43
return
true
;
44
}
45
}
// namespace MuonPRDTest
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
GenEvent.h
GenVertex.h
TruthVariables.h
MuonPRDTest::PrdTesterModule::PrdTesterModule
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
Definition
PrdTesterModule.cxx:8
MuonPRDTest::TruthVariables::m_Truth_vertexId
VectorBranch< int > & m_Truth_vertexId
Definition
TruthVariables.h:23
MuonPRDTest::TruthVariables::m_Truth_particleStatus
VectorBranch< int > & m_Truth_particleStatus
Definition
TruthVariables.h:28
MuonPRDTest::TruthVariables::m_Truth_particleEnd_vertex_id
VectorBranch< int > & m_Truth_particleEnd_vertex_id
Definition
TruthVariables.h:31
MuonPRDTest::TruthVariables::m_Truth_nVertices
ScalarBranch< unsigned int > & m_Truth_nVertices
Definition
TruthVariables.h:20
MuonPRDTest::TruthVariables::m_Truth_particleProduction_vertex_id
VectorBranch< int > & m_Truth_particleProduction_vertex_id
Definition
TruthVariables.h:30
MuonPRDTest::TruthVariables::m_key
SG::ReadHandleKey< McEventCollection > m_key
Definition
TruthVariables.h:19
MuonPRDTest::TruthVariables::declare_keys
bool declare_keys() override final
Definition
TruthVariables.cxx:12
MuonPRDTest::TruthVariables::m_Truth_particleBarcode
VectorBranch< int > & m_Truth_particleBarcode
Definition
TruthVariables.h:29
MuonPRDTest::TruthVariables::TruthVariables
TruthVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
Definition
TruthVariables.cxx:10
MuonPRDTest::TruthVariables::m_truthParticleP4
PtEtaPhiEBranch m_truthParticleP4
Definition
TruthVariables.h:26
MuonPRDTest::TruthVariables::m_Truth_vertex
CartesFourVecBranch m_Truth_vertex
Definition
TruthVariables.h:22
MuonPRDTest::TruthVariables::m_Truth_nParticles
ScalarBranch< unsigned int > & m_Truth_nParticles
Definition
TruthVariables.h:25
MuonPRDTest::TruthVariables::fill
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
Definition
TruthVariables.cxx:14
MuonPRDTest::TruthVariables::m_Truth_particlePdg_id
VectorBranch< int > & m_Truth_particlePdg_id
Definition
TruthVariables.h:27
MuonVal::MuonTesterBranch::declare_dependency
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
MuonVal::MuonTesterBranch::tree
TTree * tree() override final
Returns the underlying TTree object.
Definition
MuonTesterBranch.cxx:53
MuonVal::MuonTesterTree
Definition
MuonTesterTree.h:38
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
HepMC::barcode
int barcode(const T *p)
Definition
Barcode.h:15
HepMC::GenEvent
HepMC3::GenEvent GenEvent
Definition
GenEvent.h:39
MuonPRDTest
Definition
MuonHitTesterAlg.h:15
Generated on
for ATLAS Offline Software by
1.17.0