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 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)
41 "AllStreams",
42 true);
43 m_cutIDs.push_back(cID);
44 }
45
46 return StatusCode::SUCCESS;
47}
48
49//**********************************************************************
50
51StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(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