ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ReweightUtils
Root
WeightToolBase.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
// ReweightUtils includes
6
#include "
ReweightUtils/WeightToolBase.h
"
7
8
#include "
xAODParticleEvent/CompositeParticle.h
"
9
#include "
AthContainers/Decorator.h
"
10
11
// #include <TLorentzVector.h>
12
13
14
WeightToolBase::WeightToolBase
(
const
std::string& name )
15
:
asg
::
AsgTool
( name ),
16
m_prefixWeightDecoration
(
"weight_"
){
17
declareProperty
(
"PrefixWeightDecoration"
,
m_prefixWeightDecoration
);
18
}
19
20
21
StatusCode
WeightToolBase::initialize
() {
22
// Default implementation, such that users don't have to implement this any
23
// more for the simplest use cases.
24
ATH_MSG_DEBUG
(
"Initializing "
<< name() <<
"..."
);
25
//setting weight name for decoration
26
m_weightName
=
m_prefixWeightDecoration
+ this->name();
27
m_weightName
.replace(
m_weightName
.find(
"ToolSvc."
), std::string(
"ToolSvc."
).length(),
""
);
28
29
return
StatusCode::SUCCESS;
30
}
31
32
33
StatusCode
WeightToolBase::finalize
()
34
{
35
// Default implementation, such that users don't have to implement this any
36
// more for the simplest use cases.
37
ATH_MSG_DEBUG
(
"Finalizing "
<< name() <<
"..."
);
38
return
StatusCode::SUCCESS;
39
}
40
41
42
bool
WeightToolBase::addDecoration
(
const
xAOD::EventInfo
* evtInfo,
float
weight)
const
{
43
if
(!evtInfo) {
44
ATH_MSG_ERROR
(
"Cannot decorate empty EventInfo in "
<< this->name());
45
return
false
;
46
}
47
SG::Decorator< float >
dec(
m_weightName
);
48
if
(! dec.isAvailable( *evtInfo ) )
49
dec( *evtInfo ) = weight;
50
return
true
;
51
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:28
Decorator.h
Helper class to provide type-safe access to aux data.
CompositeParticle.h
WeightToolBase.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
WeightToolBase::m_weightName
std::string m_weightName
Definition
WeightToolBase.h:62
WeightToolBase::m_prefixWeightDecoration
std::string m_prefixWeightDecoration
Definition
WeightToolBase.h:61
WeightToolBase::WeightToolBase
WeightToolBase(const std::string &name)
Create a proper constructor for Athena.
Definition
WeightToolBase.cxx:14
WeightToolBase::addDecoration
bool addDecoration(const xAOD::EventInfo *evtInfo, float weight) const
Definition
WeightToolBase.cxx:42
WeightToolBase::initialize
virtual StatusCode initialize() override
Usual initialize method of the framework.
Definition
WeightToolBase.cxx:21
WeightToolBase::finalize
virtual StatusCode finalize() override
Usual finalize method of the framework.
Definition
WeightToolBase.cxx:33
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
SG::Decorator
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition
AuxElement.h:576
asg
Definition
DataHandleTestTool.h:28
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
Generated on
for ATLAS Offline Software by
1.17.0