ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
TruthParticleID
McParticleAlgs
src
TruthParticleBuilder.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
// TruthParticleBuilder.cxx
7
// Implementation file for class TruthParticleBuilder
8
// Author: S.Binet<binet@cern.ch>
10
11
12
// STL includes
13
14
// FrameWork includes
15
#include "Gaudi/Property.h"
16
17
// McParticleKernel includes
18
#include "
McParticleKernel/ITruthParticleFilterTool.h
"
19
#include "
McParticleKernel/ITruthParticleCnvTool.h
"
20
21
// McParticleAlgs includes
22
#include "
TruthParticleBuilder.h
"
23
27
30
TruthParticleBuilder::TruthParticleBuilder
(
const
std::string& name,
31
ISvcLocator* pSvcLocator ) :
32
AthAlgorithm
( name, pSvcLocator )
33
{
34
//
35
// Property declaration
36
//
37
//declareProperty( "Property", m_nProperty );
38
39
std::string descr =
""
;
40
// descr += "Fully qualified name ('[class name]/[instance name]') of the ";
41
// descr += "AlgTool to be ran to create a filtered McEventCollection\n";
42
// descr += "ex: \"EtaPtFilterTool/EtaPtFilterTool\"";
43
// declareProperty( "Filter",
44
// m_filterName = "EtaPtFilterTool",
45
// descr );
46
// m_filterName.declareUpdateHandler( &TruthParticleBuilder::setupFilterTool,
47
// this );
48
49
descr =
"Pointer to the filter algtool (which will create the filtered "
;
50
descr +=
"McEventCollection)"
;
51
declareProperty
(
"FilterTool"
,
52
m_filterTool
=
FilterTool_t
(
"EtaPtFilterTool"
,
53
this
),
54
descr );
55
56
descr =
"Pointer to the converter algtool which will create a "
;
57
descr +=
"TruthParticleContainer from the filtered McEventCollection"
;
58
declareProperty
(
"CnvTool"
,
59
m_cnvTool
=
CnvTool_t
(
"TruthParticleCnvTool"
,
60
this
),
61
descr );
62
63
// switches
64
descr =
"Switch to build or not a filtered McEventCollection"
;
65
declareProperty
(
"DoFiltering"
,
66
m_doFiltering
=
true
,
67
descr );
68
m_doFiltering
.declareUpdateHandler( &
TruthParticleBuilder::setupFilterTool
,
69
this
);
70
71
descr =
"Switch to build or not the TruthParticleContainer from the "
;
72
descr +=
"filtered GenEvent"
;
73
declareProperty
(
"DoTruthParticles"
,
74
m_doTruthParticles
=
true
,
75
descr );
76
m_doTruthParticles
.declareUpdateHandler( &
TruthParticleBuilder::setupCnvTool
,
77
this
);
78
}
79
82
TruthParticleBuilder::~TruthParticleBuilder
()
83
{}
84
87
StatusCode
TruthParticleBuilder::initialize
()
88
{
89
ATH_MSG_INFO
(
"Initializing "
<< name() <<
"..."
);
90
91
// setup the filter tool
92
setupFilterTool
(
m_doFiltering
);
93
94
// setup the converter tool
95
setupCnvTool
(
m_doTruthParticles
);
96
97
return
StatusCode::SUCCESS;
98
}
99
100
StatusCode
TruthParticleBuilder::finalize
()
101
{
102
ATH_MSG_INFO
(
"Finalizing "
<< name() <<
"..."
);
103
return
StatusCode::SUCCESS;
104
}
105
106
StatusCode
TruthParticleBuilder::execute
(
const
EventContext&
/*ctx*/
)
107
{
108
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
"..."
);
109
110
// create a new McEventCollection (AOD) from an old one (ex:ESD)
111
// apply some filtering criterion (if any)
112
if
(
m_doFiltering
&&
113
!
m_filterTool
->execute().isSuccess() ) {
114
ATH_MSG_WARNING
115
(
"Could not build the AOD McEventCollection ! [algtool="
116
<<
m_filterTool
.type() <<
"]"
);
117
return
StatusCode::SUCCESS;
118
}
119
120
// create a TruthParticleContainer from a McEventCollection
121
if
(
m_doTruthParticles
&&
122
!
m_cnvTool
->execute().isSuccess() ) {
123
ATH_MSG_WARNING
124
(
"Could not convert the AOD McEventCollection into "
\
125
"a TruthParticleContainer !"
);
126
return
StatusCode::SUCCESS;
127
}
128
129
return
StatusCode::SUCCESS;
130
}
131
135
136
void
TruthParticleBuilder::setupFilterTool
( Gaudi::Details::PropertyBase&
/*doFiltering*/
)
137
{
138
if
(
m_doFiltering
) {
139
140
if
( !
m_filterTool
.retrieve().isSuccess() ) {
141
ATH_MSG_ERROR
142
(
"Could not retrieve algTool ITruthParticleFilterTool ["
143
<<
m_filterTool
.type() <<
"/"
144
//<< m_filterTool.name()
145
<<
"] !!"
);
146
throw
std::runtime_error(
"Could not setup FilterTool property !"
);
147
}
else
{
148
ATH_MSG_DEBUG
149
(
"Retrieved and configured algTool ["
150
<<
m_filterTool
.type() <<
"/"
151
//<< m_filterTool.name()
152
<<
"]"
);
153
}
154
}
else
{
155
if
( !
m_filterTool
.release().isSuccess() ) {
156
ATH_MSG_WARNING
157
(
"Could not release algTool ITruthParticleFilterTool ["
158
<<
m_filterTool
.type() <<
"/"
159
//<< m_filterTool.name()
160
<<
"] !!"
161
<<
endmsg
162
<<
"Memory won't be freed until ::finalize()..."
);
163
}
else
{
164
ATH_MSG_DEBUG
165
(
"Released algTool ["
<<
m_filterTool
.type() <<
"/"
166
//<< m_filterTool.name()
167
<<
"]"
);
168
}
169
}
170
171
return
;
172
}
173
174
void
TruthParticleBuilder::setupCnvTool
( Gaudi::Details::PropertyBase&
/*doTruthParticles*/
)
175
{
176
if
(
m_doTruthParticles
) {
177
178
if
( !
m_cnvTool
.retrieve().isSuccess() ) {
179
ATH_MSG_ERROR
180
(
"Could not retrieve algTool ITruthParticleCnvTool ["
181
<<
m_cnvTool
.type() <<
"/"
182
//<< m_cnvTool.name()
183
<<
"] !!"
);
184
throw
std::runtime_error(
"Could not setup CnvTool property !"
);
185
}
else
{
186
ATH_MSG_DEBUG
187
(
"Retrieved and configured algTool ["
<<
m_cnvTool
.type() <<
"/"
188
//<< m_cnvTool.name()
189
<<
"]"
);
190
}
191
192
}
else
{
193
if
( !
m_cnvTool
.release().isSuccess() ) {
194
ATH_MSG_WARNING
195
(
"Could not release algTool ITruthParticleCnvTool ["
196
<<
m_cnvTool
.type() <<
"/"
197
//<< m_cnvTool.name()
198
<<
"] !!"
199
<<
endmsg
200
<<
"Memory won't be freed until ::finalize()..."
);
201
}
else
{
202
ATH_MSG_DEBUG
203
(
"Released algTool ["
<<
m_cnvTool
.type() <<
"/"
204
//<< m_cnvTool.name()
205
<<
"]"
);
206
}
207
}
208
209
return
;
210
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ITruthParticleCnvTool.h
ITruthParticleFilterTool.h
TruthParticleBuilder.h
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
TruthParticleBuilder::execute
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TruthParticleBuilder.cxx:106
TruthParticleBuilder::m_doFiltering
BooleanProperty m_doFiltering
Switch to build or not a filtered McEventCollection.
Definition
TruthParticleBuilder.h:86
TruthParticleBuilder::finalize
virtual StatusCode finalize()
Definition
TruthParticleBuilder.cxx:100
TruthParticleBuilder::~TruthParticleBuilder
virtual ~TruthParticleBuilder()
Destructor:
Definition
TruthParticleBuilder.cxx:82
TruthParticleBuilder::CnvTool_t
ToolHandle< ITruthParticleCnvTool > CnvTool_t
Definition
TruthParticleBuilder.h:78
TruthParticleBuilder::m_doTruthParticles
BooleanProperty m_doTruthParticles
Switch to build or not the TruthParticleContainer from the filtered GenEvent.
Definition
TruthParticleBuilder.h:91
TruthParticleBuilder::m_cnvTool
CnvTool_t m_cnvTool
Pointer to the converter algtool which will create a TruthParticleContainer from the filtered McEvent...
Definition
TruthParticleBuilder.h:82
TruthParticleBuilder::TruthParticleBuilder
TruthParticleBuilder()
Default constructor:
TruthParticleBuilder::m_filterTool
FilterTool_t m_filterTool
Pointer to the filter algtool (which will create the filtered McEventCollection).
Definition
TruthParticleBuilder.h:76
TruthParticleBuilder::setupCnvTool
void setupCnvTool(Gaudi::Details::PropertyBase &doTruthParticles)
Call-back method to configure the converter tool if needed (this is defined by the state of the "DoTr...
Definition
TruthParticleBuilder.cxx:174
TruthParticleBuilder::FilterTool_t
ToolHandle< ITruthParticleFilterTool > FilterTool_t
Definition
TruthParticleBuilder.h:72
TruthParticleBuilder::setupFilterTool
void setupFilterTool(Gaudi::Details::PropertyBase &doFiltering)
Call-back method to configure the filter tool if needed (this is defined by the state of the "DoFilte...
Definition
TruthParticleBuilder.cxx:136
TruthParticleBuilder::initialize
virtual StatusCode initialize()
Athena Algorithm's Hooks.
Definition
TruthParticleBuilder.cxx:87
Generated on
for ATLAS Offline Software by
1.17.0