ATLAS Offline Software
Loading...
Searching...
No Matches
xAODMaker::DynVarFixerAlg Class Reference

Algorithm for fixing dynamic variable corruption on xAOD containers. More...

#include <DynVarFixerAlg.h>

Inheritance diagram for xAODMaker::DynVarFixerAlg:
Collaboration diagram for xAODMaker::DynVarFixerAlg:

Public Member Functions

StatusCode initialize () override
 Function initialising the algorithm.
StatusCode execute () override
 Function executing the algorithm.
 AthAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Inherit the base class's constructor.
virtual StatusCode sysInitialize () override
 Override sysInitialize.
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< StoreGateSvcStoreGateSvc_t

Private Member Functions

::TClass * getClass (SG::auxid_t auxid)
 Get the dictionary describing an auxiliary vector variable.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKeyArray< SG::IAuxStoreIOm_ioKeys
 Containers to access with the SG::IAuxStoreIO interface.
std::vector< ::TClass * > m_dicts
 Cache of the dictionaries used.
std::vector< bool > m_noDict
 Flag showing which variables don't have a dictionary for them.
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
Algorithm properties
SG::ReadHandleKeyArray< SG::IConstAuxStorem_constKeys
 Containers to access with the SG::IConstAuxStore interface.

Detailed Description

Algorithm for fixing dynamic variable corruption on xAOD containers.

This is a general algorithm for fixing problems where a dynamic auxiliary variable of a container is not the right size. Which can happen when the algorithm creating the container doesn't consistently create dynamic variables for all objects. (Not creating some variables if some selection fails for instance.)

This is a generalisation of algorithms like xAODMaker::TrackLinkFixerAlg and xAODMaker::BTaggingAuxFixerAlg.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 41 of file DynVarFixerAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Member Function Documentation

◆ AthAlgorithm()

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

Inherit the base class's constructor.

Definition at line 51 of file AthAlgorithm.cxx.

25 :
27{
28 // Set up to run AthAlgorithmDHUpdate in sysInitialize before
29 // merging dependency lists. This extends the output dependency
30 // list with any symlinks implied by inheritance relations.
31 m_updateDataHandles =
32 std::make_unique<AthenaBaseComps::AthAlgorithmDHUpdate>
34 std::move (m_updateDataHandles));
35}
DataObjIDColl m_extendedExtraObjects
AthCommonDataStore(const std::string &name, T... args)

◆ 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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ 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.

◆ 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 xAODMaker::DynVarFixerAlg::execute ( )
override

Function executing the algorithm.

Definition at line 47 of file DynVarFixerAlg.cxx.

47 {
48
49 // Construct the SG::IConstAuxStore and SG::IAuxStoreIO read handles.
50 auto constHandles = m_constKeys.makeHandles();
51 auto ioHandles = m_ioKeys.makeHandles();
52 assert( constHandles.size() == ioHandles.size() );
53
54 // Loop over the specified containers:
55 for( std::size_t i = 0; i < constHandles.size(); ++i ) {
56
57 // Access the appropriate handles.
58 SG::ReadHandle< SG::IConstAuxStore >& constHandle =
59 constHandles.at( i );
60 SG::ReadHandle< SG::IAuxStoreIO >& ioHandle =
61 ioHandles.at( i );
62
63 // If the store is empty, stop here.
64 if( constHandle->size() == 0 ) {
65 continue;
66 }
67
68 // Remember the store's name and size.
69 const std::string& cname = constHandle.key();
70 const size_t size = constHandle->size();
71 ATH_MSG_VERBOSE( "Size of container \"" << cname << "\": " << size );
72
73 // Loop over all dynamic variables of the container:
74 for( SG::auxid_t auxid : ioHandle->getDynamicAuxIDs() ) {
75
76 // Access the registry:
77 static const auto& reg = SG::AuxTypeRegistry::instance();
78
79 // Tell the user what's happening.
80 ATH_MSG_VERBOSE( "Checking variable \"" << cname
81 << reg.getName( auxid ) << "\"" );
82
83 // Access the std::vector variable:
84 const void* vecPtr = ioHandle->getIOData( auxid );
85
86 // Get a dictionary for the variable:
87 ::TClass* cl = getClass( auxid );
88 if( ! cl ) {
89 continue;
90 }
91
92 // Get the collection proxy for the class:
93 ::TVirtualCollectionProxy* proxy = cl->GetCollectionProxy();
94 if( ! proxy ) {
95 ATH_MSG_FATAL( "Couldn't get collection proxy for variable \""
96 << reg.getName( auxid ) << "\"" );
97 return StatusCode::FAILURE;
98 }
99
100 // Attach the proxy to the auxiliary variable:
101 ::TVirtualCollectionProxy::TPushPop helper( proxy,
102 ( void* ) vecPtr );
103
104 // Check if the variable is of the right size. If it is, don't
105 // bother the variable any longer.
106 if( proxy->Size() == size ) {
107 continue;
108 }
109 ATH_MSG_VERBOSE( "Size of variable \"" << cname
110 << reg.getName( auxid ) << "\": "
111 << proxy->Size() );
112
113 // If it's not, then try to resize it using the TGenCollectionProxy
114 // interface:
115 ::TGenCollectionProxy* genProxy =
116 dynamic_cast< ::TGenCollectionProxy* >( proxy );
117 if( ! genProxy ) {
118 ATH_MSG_WARNING( "Variable \"" << reg.getName( auxid )
119 << "\" doesn't have a TGenCollectionProxy. "
120 << "Variable not fixed!" );
121 continue;
122 }
123
124 // Resize the variable to the right size:
125 static const ::Bool_t FORCE_DELETE = kFALSE;
126 genProxy->Resize( size, FORCE_DELETE );
127 ATH_MSG_VERBOSE( "Size of variable \"" << cname
128 << reg.getName( auxid ) << "\" after resize: "
129 << proxy->Size() );
130 ATH_MSG_DEBUG( "Fixed variable: \"" << cname << reg.getName( auxid )
131 << "\"" );
132 }
133 }
134
135 // Return gracefully.
136 return StatusCode::SUCCESS;
137 }
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static AuxTypeRegistry & instance()
Return the singleton registry instance.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
SG::ReadHandleKeyArray< SG::IConstAuxStore > m_constKeys
Containers to access with the SG::IConstAuxStore interface.
::TClass * getClass(SG::auxid_t auxid)
Get the dictionary describing an auxiliary vector variable.
SG::ReadHandleKeyArray< SG::IAuxStoreIO > m_ioKeys
Containers to access with the SG::IAuxStoreIO interface.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]

◆ 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}

◆ getClass()

TClass * xAODMaker::DynVarFixerAlg::getClass ( SG::auxid_t auxid)
private

Get the dictionary describing an auxiliary vector variable.

Definition at line 139 of file DynVarFixerAlg.cxx.

139 {
140
141 // Check if we already checked, and there's no dictionary available for
142 // this type:
143 if( ( m_noDict.size() > auxid ) && m_noDict[ auxid ] ) {
144 return nullptr;
145 }
146
147 // Check if the cache already has this variable:
148 if( ( m_dicts.size() > auxid ) && m_dicts[ auxid ] ) {
149 return m_dicts[ auxid ];
150 }
151
152 // Make sure that the cache variables are large enough:
153 if( m_dicts.size() <= auxid ) {
154 m_dicts.resize( auxid + 1, nullptr );
155 }
156 if( m_noDict.size() <= auxid ) {
157 m_noDict.resize( auxid + 1, false );
158 }
159
160 // If not, then look for a dictionary for this type:
161 static const auto& reg = SG::AuxTypeRegistry::instance();
162 static const ::Bool_t LOAD = kTRUE;
163 static const ::Bool_t SILENT = kTRUE;
164 ::TClass* cl = ::TClass::GetClass( reg.getVecTypeName( auxid ).c_str(),
165 LOAD, SILENT );
166
167 // Cache the result:
168 if( cl ) {
169 m_dicts[ auxid ] = cl;
170 } else {
171 ATH_MSG_INFO( "No dictionary available for variable \""
172 << reg.getName( auxid ) << "\"" );
173 m_noDict[ auxid ] = true;
174 }
175
176 // Return what we found:
177 return cl;
178 }
#define ATH_MSG_INFO(x)
std::vector< bool > m_noDict
Flag showing which variables don't have a dictionary for them.
std::vector< ::TClass * > m_dicts
Cache of the dictionaries used.
@ SILENT
don't print anything and return success

◆ initialize()

StatusCode xAODMaker::DynVarFixerAlg::initialize ( )
override

Function initialising the algorithm.

Definition at line 24 of file DynVarFixerAlg.cxx.

24 {
25
26 // Greet the user.
27 ATH_MSG_INFO( "Initialising" );
28 ATH_MSG_DEBUG( "Will be fixing dynamic variables in container(s):" );
29 ATH_MSG_DEBUG( " " << m_constKeys );
30
31 // Initialise the read handle keys.
32 ATH_CHECK( m_constKeys.initialize() );
33 std::vector< std::string > keys( m_constKeys.size() );
34 std::transform( m_constKeys.begin(), m_constKeys.end(), keys.begin(),
35 []( const SG::ReadHandleKey< SG::IConstAuxStore >& key ) {
36 return key.key(); } );
37 ATH_CHECK( m_ioKeys.assign( keys ) );
38 ATH_CHECK( m_ioKeys.initialize() );
39
40 // Reset the cache variable.
41 m_dicts.clear();
42
43 // Return gracefully.
44 return StatusCode::SUCCESS;
45 }
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ 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 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_ERROR(x)
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ 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_constKeys

SG::ReadHandleKeyArray< SG::IConstAuxStore > xAODMaker::DynVarFixerAlg::m_constKeys
private
Initial value:
{
this, "Containers", {}, "Containers to fix up the dynamic variables of" }

Containers to access with the SG::IConstAuxStore interface.

Definition at line 60 of file DynVarFixerAlg.h.

60 {
61 this, "Containers", {}, "Containers to fix up the dynamic variables of" };

◆ 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_dicts

std::vector< ::TClass* > xAODMaker::DynVarFixerAlg::m_dicts
private

Cache of the dictionaries used.

Definition at line 74 of file DynVarFixerAlg.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_ioKeys

SG::ReadHandleKeyArray< SG::IAuxStoreIO > xAODMaker::DynVarFixerAlg::m_ioKeys
private

Containers to access with the SG::IAuxStoreIO interface.

Note that this variable is not set up as a property on the algorithm. It is instead filled by the algorithm in its initialize() function. (Based on the content of m_constKeys )

Definition at line 71 of file DynVarFixerAlg.h.

◆ m_noDict

std::vector< bool > xAODMaker::DynVarFixerAlg::m_noDict
private

Flag showing which variables don't have a dictionary for them.

Definition at line 76 of file DynVarFixerAlg.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.


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