ATLAS Offline Software
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
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
() {
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
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition:
OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition:
AthCommonDataStore.h:145
TruthParticleContainer.h
D3PD::SGKeyResolver::initialize
StatusCode initialize(CLID clid, const std::string &typname)
Initialize.
Definition:
SGKeyResolver.cxx:44
AthenaPoolTestRead.sc
sc
Definition:
AthenaPoolTestRead.py:27
FSRPhot
@ FSRPhot
Definition:
TruthClasses.h:96
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition:
AthCommonDataStore.h:85
D3PD::TruthMuonsToSG::m_truthContainerKey
std::string m_truthContainerKey
Definition:
TruthMuonsToSG.h:34
D3PD
Block filler tool for noisy FEB information.
Definition:
CaloCellDetailsFillerTool.cxx:29
python.utils.AtlRunQueryDQUtils.p
p
Definition:
AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
D3PD::TruthMuonsToSG::m_truthMuonContainerKey
std::string m_truthMuonContainerKey
Definition:
TruthMuonsToSG.h:35
ParticleOrigin
ParticleOrigin
Definition:
TruthClasses.h:51
D3PD::TruthMuonsToSG::execute
StatusCode execute()
Definition:
TruthMuonsToSG.cxx:46
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition:
TruthParticle_v1.h:37
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition:
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataVector
Derived DataVector<T>.
Definition:
DataVector.h:794
AthAlgorithm
Definition:
AthAlgorithm.h:47
D3PD::TruthMuonsToSG::m_classifier
ToolHandle< IMCTruthClassifier > m_classifier
Definition:
TruthMuonsToSG.h:39
D3PD::SGKeyResolver::key
std::string key()
Return the SG key we should use.
Definition:
SGKeyResolver.cxx:55
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:228
errorcheck.h
Helpers for checking error return status codes and reporting errors.
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TruthMuonsToSG.h
Create collection of true muons in StoreGate, based on analogous code in TauD3PDMaker.
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition:
HepMCHelpers.h:45
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition:
ConstDataVector.h:76
xAOD::EgammaHelpers::isPhoton
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
Definition:
EgammaxAODHelpers.cxx:21
D3PD::TruthMuonsToSG::finalize
StatusCode finalize()
Definition:
TruthMuonsToSG.cxx:41
D3PD::TruthMuonsToSG::initialize
StatusCode initialize()
Definition:
TruthMuonsToSG.cxx:35
HepMCHelpers.h
D3PD::TruthMuonsToSG::m_resolver
SGKeyResolver m_resolver
Helper to resolve SG key for input collection.
Definition:
TruthMuonsToSG.h:38
D3PD::TruthMuonsToSG::TruthMuonsToSG
TruthMuonsToSG(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
TruthMuonsToSG.cxx:24
Generated on Sun Dec 22 2024 21:22:06 for ATLAS Offline Software by
1.8.18