ATLAS Offline Software
Loading...
Searching...
No Matches
SumOfWeightsAlg Class Reference

#include <SumOfWeightsAlg.h>

Inheritance diagram for SumOfWeightsAlg:
Collaboration diagram for SumOfWeightsAlg:

Public Member Functions

 SumOfWeightsAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
 ~SumOfWeightsAlg ()
 Destructor:
StatusCode initialize ATLAS_NOT_THREAD_SAFE ()
 Athena algorithm's Hooks.
StatusCode execute ()
StatusCode finalize ()
virtual StatusCode sysInitialize () override
 Initialization method invoked by the framework.
virtual void setFilterPassed (bool state) const
 Set the filter passed flag to the specified state.
void setFilterDescription (const std::string &descr)
 helper method to ease the setting of this filter's description in derived classes Note that this method should be called in the c-tor of derived classes
ServiceHandle< ICutFlowSvc > & cutFlowSvc ()
 return a handle to an ICutFlowSvc instance
CutIdentifier cutID ()
 return the CutIdentifier corresponding to the top-level cut of this filter algorithm
const SG::ReadHandleKey< xAOD::EventInfo > & eventInfoKey () const
 EventInfo key for use in derived classes.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< ICutFlowSvcICutFlowSvc_t
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

 SumOfWeightsAlg ()
 Default constructor:
void doNotResetSelfDescription (Gaudi::Details::PropertyBase &)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandleArray< IWeightToolm_weightTools
 Athena configured tools.
unsigned long m_eventsProcessed
 number of events processed
std::vector< CutIdentifierm_cutIDs
 cut IDs
CutIdentifier m_cutID
 The CutIdentifier for this filter algorithm.
ICutFlowSvc_t m_cutFlowSvc
 handle to the service holding tables of cut-flows for filtering algs.
std::string m_filterDescr
 filter description: describes what this filter does.
bool m_resetSelfDescription
SG::ReadHandleKey< xAOD::EventInfom_eventInfoKey { this, "EventInfoKey", "EventInfo", "" }
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 30 of file SumOfWeightsAlg.h.

Member Typedef Documentation

◆ ICutFlowSvc_t

Definition at line 84 of file AthFilterAlgorithm.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ SumOfWeightsAlg() [1/2]

SumOfWeightsAlg::SumOfWeightsAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters:

Definition at line 16 of file SumOfWeightsAlg.cxx.

16 :
17 ::AthFilterAlgorithm( name, pSvcLocator ), m_eventsProcessed(0), m_cutIDs() {
18 declareProperty( "WeightTools", m_weightTools);
19}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
AthFilterAlgorithm()
Default constructor:
ToolHandleArray< IWeightTool > m_weightTools
Athena configured tools.
std::vector< CutIdentifier > m_cutIDs
cut IDs
unsigned long m_eventsProcessed
number of events processed

◆ ~SumOfWeightsAlg()

SumOfWeightsAlg::~SumOfWeightsAlg ( )

Destructor:

Definition at line 23 of file SumOfWeightsAlg.cxx.

23{ }

◆ SumOfWeightsAlg() [2/2]

SumOfWeightsAlg::SumOfWeightsAlg ( )
private

Default constructor:

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

StatusCode initialize SumOfWeightsAlg::ATLAS_NOT_THREAD_SAFE ( )

Athena algorithm's Hooks.

◆ cutFlowSvc()

ServiceHandle< ICutFlowSvc > & AthFilterAlgorithm::cutFlowSvc ( )
inlineinherited

return a handle to an ICutFlowSvc instance

Definition at line 108 of file AthFilterAlgorithm.h.

109{
110 return m_cutFlowSvc;
111}
ICutFlowSvc_t m_cutFlowSvc
handle to the service holding tables of cut-flows for filtering algs.

◆ cutID()

CutIdentifier AthFilterAlgorithm::cutID ( )
inlineinherited

return the CutIdentifier corresponding to the top-level cut of this filter algorithm

Definition at line 116 of file AthFilterAlgorithm.h.

117{
118 return m_cutID;
119}
CutIdentifier m_cutID
The CutIdentifier for this filter algorithm.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ doNotResetSelfDescription()

void AthFilterAlgorithm::doNotResetSelfDescription ( Gaudi::Details::PropertyBase & )
inlineprivateinherited

Definition at line 124 of file AthFilterAlgorithm.h.

125{
127}

◆ eventInfoKey()

const SG::ReadHandleKey< xAOD::EventInfo > & AthFilterAlgorithm::eventInfoKey ( ) const
inherited

EventInfo key for use in derived classes.

Definition at line 134 of file AthFilterAlgorithm.cxx.

135{
136 return m_eventInfoKey;
137}
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode SumOfWeightsAlg::execute ( )

Definition at line 65 of file SumOfWeightsAlg.cxx.

65 {
66 ATH_MSG_DEBUG ("Executing " << name() << ", will loop over WeightTools...");
67 setFilterPassed(true);
68
69 for (std::size_t i = 0; i < m_cutIDs.size(); ++i) {
70 float weight = m_weightTools[i]->getWeight();
71 ATH_MSG_DEBUG(" got weight = " << weight << " for " << m_weightTools[i]->name());
73 cutFlowSvc()->addEvent(cutID, weight);
74 }
75
77 return StatusCode::SUCCESS;
78}
#define ATH_MSG_DEBUG(x)
uint32_t CutIdentifier
InstanceIdentifier is a unique identifer used for every AthFilterAlgorithm instance.
Definition ICutFlowSvc.h:26
ServiceHandle< ICutFlowSvc > & cutFlowSvc()
return a handle to an ICutFlowSvc instance
CutIdentifier cutID()
return the CutIdentifier corresponding to the top-level cut of this filter algorithm
virtual void setFilterPassed(bool state) const
Set the filter passed flag to the specified state.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode SumOfWeightsAlg::finalize ( )

Definition at line 82 of file SumOfWeightsAlg.cxx.

82 {
83 ATH_MSG_INFO ("Finalizing " << name() << "...");
84 return StatusCode::SUCCESS;
85}
#define ATH_MSG_INFO(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterDescription()

void AthFilterAlgorithm::setFilterDescription ( const std::string & descr)
inherited

helper method to ease the setting of this filter's description in derived classes Note that this method should be called in the c-tor of derived classes

helper function to ease the setting of this filter's description in derived classes

Definition at line 118 of file AthFilterAlgorithm.cxx.

119{
120 if( cutFlowSvc()==0 ){
122 }
123 else if( m_resetSelfDescription and cutID() ){
124 cutFlowSvc()->setFilterDescription(cutID(),descr);
125 }
126 else{
127 ATH_MSG_INFO("problem setting filter description with cutflow-svc");
128 }
129
130 return;
131}
std::string m_filterDescr
filter description: describes what this filter does.
list descr
print "%s.properties()" % self.__name__

◆ setFilterPassed()

void AthFilterAlgorithm::setFilterPassed ( bool state) const
virtualinherited

Set the filter passed flag to the specified state.

Definition at line 99 of file AthFilterAlgorithm.cxx.

100{
101 AthAlgorithm::setFilterPassed(state);
102
103 if (state) {
104 const EventContext& ctx = Gaudi::Hive::currentContext();
105 SG::ReadHandle<xAOD::EventInfo> evtInfo (m_eventInfoKey, ctx);
106 // Only try to access the mcEventWeight if we are running on Monte Carlo, duhhh!
107 if ( evtInfo->eventType(xAOD::EventInfo::IS_SIMULATION) ) {
108 m_cutFlowSvc->addEvent(m_cutID, evtInfo->mcEventWeights());
109 } else {
110 m_cutFlowSvc->addEvent(m_cutID, 1.0);
111 }
112 }
113}
@ IS_SIMULATION
true: simulation, false: data

◆ sysInitialize()

StatusCode AthFilterAlgorithm::sysInitialize ( )
overridevirtualinherited

Initialization method invoked by the framework.

This method is responsible for any bookkeeping of initialization required by the framework itself. It will in turn invoke the initialize() method of the derived algorithm, and of any sub-algorithms which it creates.

Reimplemented from AthAlgorithm.

Definition at line 65 of file AthFilterAlgorithm.cxx.

66{
67 // ---- stolen from GaudiKernel/Algorithm::sysInitialize -------
68 // Bypass the initialization if the algorithm
69 // has already been initialized.
70 if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS;
71
72 // Set the Algorithm's properties
73 bindPropertiesTo( serviceLocator()->getOptsSvc() );
74
75 // Bypass the initialization if the algorithm is disabled.
76 // Need to do this after bindPropertiesTo.
77 if ( !isEnabled( ) ) return StatusCode::SUCCESS;
78
79 // ---- stolen from GaudiKernel/Algorithm::sysInitialize ------- END ---
80
81 // register ourselves with the cutFlowSvc
82 if ( cutFlowSvc().retrieve().isSuccess()) {
83 m_cutID = cutFlowSvc()->registerFilter(this->name(), m_filterDescr, false);
84 if (0 == m_cutID) {
85 ATH_MSG_INFO("problem registering myself with cutflow-svc");
86 } else {
87 ATH_MSG_VERBOSE("registered with cutflow-svc");
88 }
89 }
90
91 ATH_CHECK( m_eventInfoKey.initialize() );
92
93 // re-direct to base class...
95}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
virtual StatusCode sysInitialize() override
Override sysInitialize.
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_cutFlowSvc

ICutFlowSvc_t AthFilterAlgorithm::m_cutFlowSvc
privateinherited

handle to the service holding tables of cut-flows for filtering algs.

Definition at line 86 of file AthFilterAlgorithm.h.

◆ m_cutID

CutIdentifier AthFilterAlgorithm::m_cutID
privateinherited

The CutIdentifier for this filter algorithm.

Definition at line 82 of file AthFilterAlgorithm.h.

◆ m_cutIDs

std::vector<CutIdentifier> SumOfWeightsAlg::m_cutIDs
private

cut IDs

Definition at line 57 of file SumOfWeightsAlg.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_eventInfoKey

SG::ReadHandleKey<xAOD::EventInfo> AthFilterAlgorithm::m_eventInfoKey { this, "EventInfoKey", "EventInfo", "" }
privateinherited

Definition at line 96 of file AthFilterAlgorithm.h.

97{ this, "EventInfoKey", "EventInfo", "" };

◆ m_eventsProcessed

unsigned long SumOfWeightsAlg::m_eventsProcessed
private

number of events processed

Definition at line 54 of file SumOfWeightsAlg.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_filterDescr

std::string AthFilterAlgorithm::m_filterDescr
privateinherited

filter description: describes what this filter does.

this is usually pushed to the ICutFlowSvc

Definition at line 90 of file AthFilterAlgorithm.h.

◆ m_resetSelfDescription

bool AthFilterAlgorithm::m_resetSelfDescription
privateinherited

Definition at line 93 of file AthFilterAlgorithm.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_weightTools

ToolHandleArray<IWeightTool> SumOfWeightsAlg::m_weightTools
private

Athena configured tools.

Definition at line 51 of file SumOfWeightsAlg.h.


The documentation for this class was generated from the following files: