ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ReweightUtils
src
SumOfWeightsAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// ReweightUtils includes
6
#include "
SumOfWeightsAlg.h
"
7
8
#include "
CxxUtils/checker_macros.h
"
9
#include "
ReweightUtils/WeightToolBase.h
"
10
#include "
xAODCutFlow/CutBookkeeper.h
"
11
12
#include <string>
13
14
//**********************************************************************
15
16
StatusCode SumOfWeightsAlg::initialize
ATLAS_NOT_THREAD_SAFE
() {
17
// ^ due to registerTopFilter
18
19
ATH_MSG_DEBUG
(
"Initializing "
<< name() <<
"..."
);
20
ATH_MSG_DEBUG
(
"Retrieving tools..."
);
21
ATH_CHECK
(m_weightTools.retrieve());
22
23
ATH_MSG_DEBUG
(
"Tool retrieval completed."
);
24
unsigned
int
ntool = m_weightTools.size();
25
ATH_MSG_DEBUG
(
" Tool count: "
<< ntool);
26
for
(
size_t
itool = 0; itool < ntool; ++itool ) {
27
ATH_MSG_DEBUG
(
" "
<< m_weightTools[itool]->name());
28
if
(msgLvl(MSG::DEBUG)) m_weightTools[itool]->print();
29
// Get the tool's message property:
30
const
WeightToolBase
* tool =
dynamic_cast<
const
WeightToolBase
*
>
( m_weightTools[ itool ].operator->() );
31
if
( ! tool ) {
32
ATH_MSG_ERROR
(
"The received tool is not an WeightToolBase?!?"
);
33
return
StatusCode::FAILURE;
34
}
35
//strip the 'ToolSvc.' off the weight name
36
std::string toolName = m_weightTools[itool]->name();
37
if
(toolName.starts_with (
"ToolSvc."
)) toolName.replace(0,8,
""
);
38
CutIdentifier
cID = m_cutFlowSvc->registerTopFilter( toolName,
39
toolName,
// description (can be improved FIXME)
40
xAOD::CutBookkeeper::CutLogic::ALLEVENTSPROCESSED
,
41
"AllStreams"
,
42
true
);
43
m_cutIDs.push_back(cID);
44
}
45
46
return
StatusCode::SUCCESS;
47
}
48
49
//**********************************************************************
50
51
StatusCode
SumOfWeightsAlg::execute
(
const
EventContext&
/* ctx */
)
const
{
52
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
", will loop over WeightTools..."
);
53
54
for
(std::size_t i = 0; i <
m_cutIDs
.size(); ++i) {
55
float
weight =
m_weightTools
[i]->getWeight();
56
ATH_MSG_DEBUG
(
" got weight = "
<< weight <<
" for "
<<
m_weightTools
[i]->name());
57
const
CutIdentifier
cutID =
m_cutIDs
[i];
58
m_cutFlowSvc
->addEvent(cutID, weight);
59
}
60
61
return
StatusCode::SUCCESS;
62
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CutBookkeeper.h
CutIdentifier
uint32_t CutIdentifier
InstanceIdentifier is a unique identifer used for every filter.
Definition
ICutFlowSvc.h:25
ATLAS_NOT_THREAD_SAFE
StatusCode SumOfWeightsAlg::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition
SumOfWeightsAlg.cxx:16
SumOfWeightsAlg.h
WeightToolBase.h
checker_macros.h
Define macros for attributes used to control the static checker.
SumOfWeightsAlg::m_weightTools
PublicToolHandleArray< IWeightTool > m_weightTools
Definition
SumOfWeightsAlg.h:40
SumOfWeightsAlg::m_cutIDs
std::vector< CutIdentifier > m_cutIDs
cut IDs
Definition
SumOfWeightsAlg.h:43
SumOfWeightsAlg::m_cutFlowSvc
ServiceHandle< ICutFlowSvc > m_cutFlowSvc
Athena configured components.
Definition
SumOfWeightsAlg.h:39
SumOfWeightsAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
SumOfWeightsAlg.cxx:51
WeightToolBase
Definition
WeightToolBase.h:29
xAOD::CutBookkeeper_v1::ALLEVENTSPROCESSED
@ ALLEVENTSPROCESSED
Definition
CutBookkeeper_v1.h:36
Generated on
for ATLAS Offline Software by
1.17.0