ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ReweightUtils
Root
WeightsAgregator.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// ReweightUtils includes
6
#include "
ReweightUtils/WeightsAgregator.h
"
7
8
#include "
xAODParticleEvent/CompositeParticle.h
"
9
10
11
WeightsAgregator::WeightsAgregator
(
const
std::string& name )
12
:
WeightToolBase
( name ),
13
m_eventInfoName
(
"EventInfo"
),
14
m_toolArray
() {
15
declareProperty
(
"Ingredients"
,
m_toolArray
,
"List of helpers to offload some tasks to"
);
16
declareProperty
(
"EventInfoName"
,
m_eventInfoName
,
"Name of the xAOD::EventInfo object"
);
17
}
18
19
20
StatusCode
WeightsAgregator::initialize
() {
21
ATH_MSG_DEBUG
(
"Initializing "
<< name() <<
"..."
);
22
ATH_CHECK
(
WeightToolBase::initialize
());
23
24
// Retrieve the needed weight tools
25
ATH_CHECK
(
m_toolArray
.retrieve());
26
27
return
StatusCode::SUCCESS;
28
}
29
30
31
32
// returns: the value that was calculated from the xAOD::IParticle composite built event
33
double
WeightsAgregator::evaluate
(
const
xAOD::IParticle
* part )
const
34
{
35
ATH_MSG_DEBUG
(
"Evaluating "
<< name() <<
"..."
);
36
37
double
weight=1.0;
38
for
(
const
auto
& wToolHandle :
m_toolArray
){
39
const
IWeightTool
* wtool = &(*wToolHandle);
40
ATH_MSG_DEBUG
(
" In WeightsAgregator::evaluate(), having tool to deal with called "
<< wtool->name());
41
if
(
const
IObservableTool
* obstool =
dynamic_cast<
const
IObservableTool
*
>
( wtool ) )
42
weight *= obstool->evaluate(part);
43
}
44
45
ATH_MSG_DEBUG
(
"Got weight in WeightsAgregator::evaluate() = "
<< weight <<
"."
);
46
return
weight;
47
}
48
49
50
double
WeightsAgregator::getWeight
()
const
{
51
//Retrieveing eventInfo
52
const
xAOD::EventInfo
* evtInfo;
53
StatusCode
sc
=
evtStore
()->retrieve( evtInfo,
m_eventInfoName
);
54
if
(
sc
.isFailure() || !evtInfo) {
55
ATH_MSG_ERROR
(
" EventInfo could not be retrieved !!"
);
56
return
0.;
57
}
58
59
// don't do anything for data
60
if
(!evtInfo->
eventType
(
xAOD::EventInfo::IS_SIMULATION
)){
61
ATH_MSG_DEBUG
(
" Returning weight=1. for data."
);
62
return
1.;
63
}
64
65
float
weight=1.;
66
ToolHandleArray< IWeightTool >::const_iterator itPriv =
m_toolArray
.begin(), itPrivEnd =
m_toolArray
.end();
67
for
( ; itPriv != itPrivEnd; ++itPriv ) {
68
/*if (!(*itPriv))
69
ATH_MSG_ERROR("tool " << (*itPriv).typeAndName() << " failed it's task ... stop!");*/
70
weight *= (*itPriv)->getWeight();
71
}
72
73
//Decorate EventInfo with weight for later use
74
this->
addDecoration
(evtInfo, weight);
75
76
77
ATH_MSG_DEBUG
(
" "
<< name() <<
" returning weight= "
<< weight <<
"."
);
78
return
weight;
79
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
CompositeParticle.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
WeightsAgregator.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
IObservableTool
Interface for tools that want to calculate a quantity from an xAOD::IParticle.
Definition
IObservableTool.h:32
IWeightTool
Interface for tools that want to calculate a weight from different event information.
Definition
IWeightTool.h:21
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
WeightsAgregator::evaluate
virtual double evaluate(const xAOD::IParticle *part) const override
returns: the value that was calculated from the xAOD::IParticle (composite built event object for ins...
Definition
WeightsAgregator.cxx:33
WeightsAgregator::initialize
virtual StatusCode initialize() override
Usual initialize method of the framework.
Definition
WeightsAgregator.cxx:20
WeightsAgregator::getWeight
virtual double getWeight() const override
returns: the value that was calculated from the usual Athena storegate
Definition
WeightsAgregator.cxx:50
WeightsAgregator::m_toolArray
ToolHandleArray< IWeightTool > m_toolArray
Array of ingredient weight tools.
Definition
WeightsAgregator.h:50
WeightsAgregator::WeightsAgregator
WeightsAgregator(const std::string &name)
Create a proper constructor for Athena.
Definition
WeightsAgregator.cxx:11
WeightsAgregator::m_eventInfoName
std::string m_eventInfoName
Name of the xAOD::EventInfo object.
Definition
WeightsAgregator.h:47
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition
EventInfo_v1.h:151
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
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