ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
MuonD3PDMaker
src
TruthMuonsToSG.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
11
12
13
#include "
TruthMuonsToSG.h
"
14
15
#include "
xAODTruth/TruthParticleContainer.h
"
16
#include "
TruthUtils/HepMCHelpers.h
"
17
#include "
AthContainers/ConstDataVector.h
"
18
#include "
AthenaKernel/errorcheck.h
"
19
20
21
namespace
D3PD
{
22
23
24
TruthMuonsToSG::TruthMuonsToSG
(
const
std::string& name, ISvcLocator* pSvcLocator)
25
:
AthAlgorithm
(name, pSvcLocator),
26
m_resolver
(name,
evtStore
(),
m_truthContainerKey
),
27
m_classifier
(
"MCTruthClassifier"
)
28
{
29
declareProperty
(
"TruthContainer"
,
m_truthContainerKey
=
"TruthParticle"
);
30
declareProperty
(
"TruthMuonContainer"
,
m_truthMuonContainerKey
=
"TruthMuons"
);
31
declareProperty
(
"Classifier"
,
m_classifier
,
"Classifier tool instance."
);
32
33
}
34
35
StatusCode
TruthMuonsToSG::initialize
() {
36
CHECK
(
m_resolver
.initialize<
xAOD::TruthParticleContainer
>() );
37
CHECK
(
m_classifier
.retrieve() );
38
return
StatusCode::SUCCESS;
39
}
40
41
StatusCode
TruthMuonsToSG::finalize
() {
42
return
StatusCode::SUCCESS;
43
}
44
45
46
StatusCode
TruthMuonsToSG::execute
(
const
EventContext&
/*ctx*/
) {
47
const
xAOD::TruthParticleContainer
*truthCollection =
nullptr
;
48
StatusCode
sc
=
evtStore
()->retrieve( truthCollection,
m_resolver
.key());
49
if
(
sc
.isFailure() || !truthCollection) {
50
ATH_MSG_ERROR
(
"Failed to retrieve xAOD::TruthParticleContainer "
<<
m_resolver
.key());
51
return
StatusCode::FAILURE;
52
}
53
54
// output container for muons
55
ConstDataVector<xAOD::TruthParticleContainer>
* muonColl
56
=
new
ConstDataVector<xAOD::TruthParticleContainer>
(
SG::VIEW_ELEMENTS
);
57
58
for
(
const
xAOD::TruthParticle
* p : *truthCollection) {
59
if
( abs(p->pdgId()) ==
MC::MUON
&&
MC::isStable
(p) ) {
60
muonColl->
push_back
(p);
61
}
62
else
if
(
MC::isPhoton
(p) ) {
63
auto
Classify =
m_classifier
->particleTruthClassifier( p );
64
if
( (
MCTruthPartClassifier::ParticleOrigin
)(Classify.second) ==
MCTruthPartClassifier::FSRPhot
) {
65
muonColl->
push_back
(p);
66
}
67
}
68
}
69
70
if
(
evtStore
()->record(muonColl,
m_truthMuonContainerKey
).isFailure() )
return
StatusCode::FAILURE;
71
return
StatusCode::SUCCESS;
72
}
73
74
75
}
// namespace D3PD
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TruthParticleContainer.h
HepMCHelpers.h
ATLAS-specific HepMC functions.
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
TruthMuonsToSG.h
Create collection of true muons in StoreGate, based on analogous code in TauD3PDMaker.
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
D3PD::TruthMuonsToSG::finalize
StatusCode finalize()
Definition
TruthMuonsToSG.cxx:41
D3PD::TruthMuonsToSG::m_classifier
ToolHandle< IMCTruthClassifier > m_classifier
Definition
TruthMuonsToSG.h:39
D3PD::TruthMuonsToSG::TruthMuonsToSG
TruthMuonsToSG(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TruthMuonsToSG.cxx:24
D3PD::TruthMuonsToSG::m_resolver
SGKeyResolver m_resolver
Helper to resolve SG key for input collection.
Definition
TruthMuonsToSG.h:38
D3PD::TruthMuonsToSG::m_truthMuonContainerKey
std::string m_truthMuonContainerKey
Definition
TruthMuonsToSG.h:35
D3PD::TruthMuonsToSG::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TruthMuonsToSG.cxx:46
D3PD::TruthMuonsToSG::m_truthContainerKey
std::string m_truthContainerKey
Definition
TruthMuonsToSG.h:34
D3PD::TruthMuonsToSG::initialize
StatusCode initialize()
Definition
TruthMuonsToSG.cxx:35
D3PD
Block filler tool for noisy FEB information.
Definition
CaloCellDetailsFillerTool.cxx:29
MCTruthPartClassifier::ParticleOrigin
ParticleOrigin
Definition
TruthClasses.h:53
MCTruthPartClassifier::FSRPhot
@ FSRPhot
Definition
TruthClasses.h:98
MC::MUON
static const int MUON
Definition
HepMCHelpers.h:78
MC::isPhoton
bool isPhoton(const T &p)
Definition
HepMCHelpers.h:383
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition
HepMCHelpers.h:46
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
xAOD::TruthParticleContainer
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticleContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0