ATLAS Offline Software
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
7 
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 
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
27  m_weightName.replace(m_weightName.find("ToolSvc."), std::string("ToolSvc.").length(), "");
28 
29  return StatusCode::SUCCESS;
30 }
31 
32 
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  }
48  if (! dec.isAvailable( *evtInfo ) )
49  dec( *evtInfo ) = weight;
50  return true;
51 }
CompositeParticle.h
WeightToolBase.h
WeightToolBase::finalize
virtual StatusCode finalize() override
Usual finalize method of the framework.
Definition: WeightToolBase.cxx:33
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
WeightToolBase::initialize
virtual StatusCode initialize() override
Usual initialize method of the framework.
Definition: WeightToolBase.cxx:21
asg
Definition: DataHandleTestTool.h:28
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator< float >
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
WeightToolBase::m_prefixWeightDecoration
std::string m_prefixWeightDecoration
Definition: WeightToolBase.h:61
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
WeightToolBase::WeightToolBase
WeightToolBase(const std::string &name)
Create a proper constructor for Athena.
Definition: WeightToolBase.cxx:14
SG::Decorator::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
WeightToolBase::m_weightName
std::string m_weightName
Definition: WeightToolBase.h:62
Decorator.h
Helper class to provide type-safe access to aux data.
WeightToolBase::addDecoration
bool addDecoration(const xAOD::EventInfo *evtInfo, float weight) const
Definition: WeightToolBase.cxx:42