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

#include <SGInputLoader.h>

Inheritance diagram for SGInputLoader:
Collaboration diagram for SGInputLoader:

Public Member Functions

 SGInputLoader (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~SGInputLoader ()
bool isClonable () const override
 this Alg is Clonable (for AthenaMT)
virtual StatusCode initialize () override
virtual StatusCode execute () override
virtual StatusCode finalize () override
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

 SGInputLoader ()
 Default constructor:
void loader (Gaudi::Details::PropertyBase &)
bool loadObjs (const DataObjIDColl &objs) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

DataObjIDColl m_load
 Properties.
Gaudi::Property< bool > m_dump
Gaudi::Property< bool > m_failEvt
Gaudi::Property< bool > m_loadProxies
bool m_first {true}
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 20 of file SGInputLoader.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ SGInputLoader() [1/2]

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

Definition at line 42 of file SGInputLoader.cxx.

43 :
44 ::AthAlgorithm( name, pSvcLocator )
45{
46 //
47 // Property declaration
48 //
49 declareProperty( "Load", m_load, "create Output data dependencies for these objects")
50 ->declareUpdateHandler(&SGInputLoader::loader, this);
51
52}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
void loader(Gaudi::Details::PropertyBase &)
DataObjIDColl m_load
Properties.

◆ ~SGInputLoader()

SGInputLoader::~SGInputLoader ( )
virtual

Definition at line 56 of file SGInputLoader.cxx.

57{}

◆ SGInputLoader() [2/2]

SGInputLoader::SGInputLoader ( )
private

Default constructor:

Member Function Documentation

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

◆ 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 SGInputLoader::execute ( )
overridevirtual

Definition at line 97 of file SGInputLoader.cxx.

98{
99 StatusCode sc(StatusCode::SUCCESS);
100
101 ATH_MSG_DEBUG ("Executing " << name() << "...");
102
103 // add objects automatically added by the Scheduler
104 if (m_first) {
105 if (m_loadProxies.value()) {
106 for (DataObjID obj : outputDataObjs() ) {
107 // Strip any decoration name.
108 std::string::size_type ppos = obj.key().find ('.');
109 if (ppos < obj.key().size()-1) {
110 //obj.updateKey (obj.key().substr (0, ppos));
111 // commented out line above, to keep decoration on key so can distinguish undeclared decorations from undeclared objects
112 // undeclared objects will be an error, undeclared decorations will just be a warning
113 // TODO: restore the above modification (and make all transient proxies an error in loadObj, not just non-decorations) when all decorations are declared
114 }
115 m_load.emplace (std::move(obj));
116 }
117 }
118
119 // check if objects are not in EventStore
120 DataObjIDColl toLoad;
121 for (const DataObjID* obj : sortedDataObjIDColl (m_load)) {
122 // don't load anything that is in the ExtraOutputs list, which is used for objects created e.g. by the eventloopmgr
123 if( extraOutputDeps().count(*obj) ) {
124 ATH_MSG_DEBUG(obj->key() << " is in ExtraOutputs and will not be loaded");
125 continue;
126 } else if(std::string::size_type ppos = obj->key().find ('.'); ppos < obj->key().size()-1) {
127 // see if the object that the decoration is on is declared as extra output. Will assume the extra output
128 // will also provide such a decoration
129 DataObjID objcopy(*obj);
130 objcopy.updateKey(obj->key().substr (0, ppos));
131 if( extraOutputDeps().count(objcopy) ) {
132 ATH_MSG_DEBUG(obj->key() << "'s object/container is in ExtraOutputs and will not be loaded");
133 continue;
134 }
135 }
136 SG::VarHandleKey vhk(obj->clid(),obj->key(),Gaudi::DataHandle::Writer);
137 if (StoreID::findStoreID(vhk.storeHandle().name()) == StoreID::EVENT_STORE) {
138 toLoad.emplace(*obj);
139 }
140 else if (StoreID::findStoreID(vhk.storeHandle().name()) == StoreID::CONDITION_STORE) {
141 ATH_MSG_ERROR("Unresolved conditions dependency: "
142 << *obj);
143 return StatusCode::FAILURE;
144 }
145 else {
146 ATH_MSG_DEBUG("Will not auto-load proxy for non-EventStore object: "
147 << *obj);
148 }
149 }
150 m_load = std::move(toLoad);
151
152 m_first = false;
153 }
154
155 bool b = loadObjs( m_load );
156
157 if (m_dump.value()) {
159 }
160
161 if (m_failEvt.value() && !b) {
162 ATH_MSG_ERROR("autoload of objects failed. aborting event processing");
163 sc = StatusCode::FAILURE;
164 }
165
166 return sc;
167}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
virtual const DataObjIDColl & extraOutputDeps() const override
Return the list of extra output dependencies.
Gaudi::Property< bool > m_failEvt
bool loadObjs(const DataObjIDColl &objs) const
Gaudi::Property< bool > m_dump
Gaudi::Property< bool > m_loadProxies
@ EVENT_STORE
Definition StoreID.h:26
@ CONDITION_STORE
Definition StoreID.h:28
static StoreID::type findStoreID(const std::string &storeName)
Definition StoreID.cxx:21
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
::StatusCode StatusCode
StatusCode definition for legacy code.
std::ostream & dump(std::ostream &out, const I4MomIter iBeg, const I4MomIter iEnd)
Helper to stream out a range of I4Momentum objects.
Definition P4Dumper.h:24

◆ 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 SGInputLoader::finalize ( )
overridevirtual

Definition at line 87 of file SGInputLoader.cxx.

88{
89 ATH_MSG_INFO ("Finalizing " << name() << "...");
90
91 return StatusCode::SUCCESS;
92}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode SGInputLoader::initialize ( )
overridevirtual

Definition at line 62 of file SGInputLoader.cxx.

63{
64 ATH_MSG_VERBOSE ("Initializing " << name() << "...");
65
66 StatusCode sc(StatusCode::SUCCESS);
67
68 if (m_load.size() > 0) {
69 std::ostringstream str;
70 str << "Will explicitly preload the following DataObjects:";
71 for (auto &e : m_load) {
72 str << "\n + " << e;
73 if (e.key().empty()) {
74 sc = StatusCode::FAILURE;
75 str << " ERROR: empty key is not allowed!";
76 }
77 }
78 ATH_MSG_INFO(str.str());
79 }
80
81 return sc;
82}
#define ATH_MSG_VERBOSE(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.

◆ isClonable()

bool SGInputLoader::isClonable ( ) const
inlineoverride

this Alg is Clonable (for AthenaMT)

Definition at line 31 of file SGInputLoader.h.

31{ return true; }

◆ loader()

void SGInputLoader::loader ( Gaudi::Details::PropertyBase & p)
private

Definition at line 172 of file SGInputLoader.cxx.

172 {
173
174 ATH_MSG_DEBUG("Adding to outputs: " << p.toString());
175
176 DataObjIDColl toLoad;
177
178 for (auto obj : m_load) {
179 // add an explicit storename as needed
180 SG::VarHandleKey vhk(obj.clid(),obj.key(),Gaudi::DataHandle::Writer);
181 obj.updateKey( vhk.objKey() );
182 toLoad.emplace(obj);
183 if(!outputDataObjs().count(obj)) { addDependency(obj,Gaudi::DataHandle::Writer); }
184 }
185 m_load = std::move(toLoad);
186
187}

◆ loadObjs()

bool SGInputLoader::loadObjs ( const DataObjIDColl & objs) const
private

Definition at line 192 of file SGInputLoader.cxx.

192 {
193
194 bool ok = true;
195
196 for (auto &obj: objs) {
197
198 std::string::size_type ppos = obj.key().substr(0,obj.key().size()-1).find('.');
199
200 // use the parsing built into the VarHandleKey to get the correct
201 // StoreGate key
202 SG::VarHandleKey vhk(obj.clid(),obj.key().substr(0,ppos),Gaudi::DataHandle::Reader);
203
204 ATH_MSG_DEBUG("trying to load " << obj << " sgkey: " << vhk.key() );
205
206 SG::DataProxy* dp = evtStore()->proxy(obj.clid(), vhk.key());
207 if (dp != 0) {
208 ATH_MSG_DEBUG(" found proxy for " << obj);
209 if (dp->provider() == 0 && extraOutputDeps().find(obj)==extraOutputDeps().end()) {
210 if(ppos==std::string::npos) {
211 ATH_MSG_ERROR(" obj " << obj << " has no provider, and is only Transient - indicative of a missing output declaration" );
212 ok =false;
213 } else { // just warning for now for potentially undeclared decorations, instead of error, because too many cases to fix
214 ATH_MSG_WARNING(" decoration " << obj << " has no provider, and is only Transient - either a decoration output declaration is missing, or a ReadDecorHandleKey is being used to read a non-decoration" );
215 }
216 }
217 } else {
218 ok = false;
219 if (m_failEvt.value()) {
220 ATH_MSG_ERROR("unable to find proxy for " << obj);
221 } else {
222 ATH_MSG_WARNING("unable to find proxy for " << obj);
223 }
224 }
225 }
226
227 return ok;
228
229}
#define ATH_MSG_WARNING(x)
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138

◆ 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}
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ 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_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_dump

Gaudi::Property< bool > SGInputLoader::m_dump
private
Initial value:
{this, "ShowEventDump", false,
"printout contents of EventStore at end of execute()"}

Definition at line 48 of file SGInputLoader.h.

48 {this, "ShowEventDump", false,
49 "printout contents of EventStore at end of execute()"};

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

Gaudi::Property<bool> SGInputLoader::m_failEvt
private
Initial value:
{this, "FailIfNoProxy", true,
"execute returns FAILURE if a requested proxy is not found in store"}

Definition at line 51 of file SGInputLoader.h.

51 {this, "FailIfNoProxy", true,
52 "execute returns FAILURE if a requested proxy is not found in store"};

◆ m_first

bool SGInputLoader::m_first {true}
private

Definition at line 58 of file SGInputLoader.h.

58{true};

◆ m_load

DataObjIDColl SGInputLoader::m_load
private

Properties.

Definition at line 46 of file SGInputLoader.h.

◆ m_loadProxies

Gaudi::Property<bool> SGInputLoader::m_loadProxies
private
Initial value:
{this, "LoadExtraProxies", true,
"load the Proxies attributed to the SGInputLoader by the Scheduler"}

Definition at line 54 of file SGInputLoader.h.

54 {this, "LoadExtraProxies", true,
55 "load the Proxies attributed to the SGInputLoader by the Scheduler"};

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