ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
12#include <string>
13
14//**********************************************************************
15
16StatusCode 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 const std::string allStreamsStr{"AllStreams"};
27 for (size_t itool = 0; itool < ntool; ++itool ) {
28 ATH_MSG_DEBUG(" " << m_weightTools[itool]->name());
29 if(msgLvl(MSG::DEBUG)) m_weightTools[itool]->print();
30 // Get the tool's message property:
31 const WeightToolBase* tool = dynamic_cast< const WeightToolBase* >( m_weightTools[ itool ].operator->() );
32 if( ! tool ) {
33 ATH_MSG_ERROR( "The received tool is not an WeightToolBase?!?" );
34 return StatusCode::FAILURE;
35 }
36 //strip the 'ToolSvc.' off the weight name
37 std::string toolName = m_weightTools[itool]->name();
38 if(toolName.starts_with ("ToolSvc.")) toolName.replace(0,8,"");
39 CutIdentifier cID = m_cutFlowSvc->registerTopFilter( toolName,
40 toolName, // description (can be improved FIXME)
42 allStreamsStr,
43 true);
44 m_cutIDs.push_back(cID);
45 }
46
47 return StatusCode::SUCCESS;
48}
49
50//**********************************************************************
51
52StatusCode SumOfWeightsAlg::execute(const EventContext& /* ctx */) const {
53 ATH_MSG_DEBUG ("Executing " << name() << ", will loop over WeightTools...");
54
55 for (std::size_t i = 0; i < m_cutIDs.size(); ++i) {
56 float weight = m_weightTools[i]->getWeight();
57 ATH_MSG_DEBUG(" got weight = " << weight << " for " << m_weightTools[i]->name());
58 const CutIdentifier cutID = m_cutIDs[i];
59 m_cutFlowSvc->addEvent(cutID, weight);
60 }
61
62 return StatusCode::SUCCESS;
63}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
uint32_t CutIdentifier
InstanceIdentifier is a unique identifer used for every filter.
Definition ICutFlowSvc.h:25
StatusCode SumOfWeightsAlg::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Define macros for attributes used to control the static checker.
PublicToolHandleArray< IWeightTool > m_weightTools
std::vector< CutIdentifier > m_cutIDs
cut IDs
ServiceHandle< ICutFlowSvc > m_cutFlowSvc
Athena configured components.
virtual StatusCode execute(const EventContext &ctx) const override