ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CondSvc Class Reference

#include <CondSvc.h>

Inheritance diagram for CondSvc:
Collaboration diagram for CondSvc:

Classes

class  iAlgHasher
 

Public Member Functions

 CondSvc (const std::string &name, ISvcLocator *svc)
 
 ~CondSvc ()
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual StatusCode start () override
 
virtual StatusCode stop () override
 
virtual StatusCode regHandle (IAlgorithm *alg, const Gaudi::DataHandle &id) override
 
virtual bool getInvalidIDs (const EventContext &, DataObjIDColl &ids)
 
virtual bool getValidIDs (const EventContext &, DataObjIDColl &ids)
 
virtual bool getIDValidity (const EventContext &, DataObjIDColl &validIDs, DataObjIDColl &invalidIDs)
 
virtual bool isValidID (const EventContext &, const DataObjID &) const override
 
virtual const std::set< IAlgorithm * > & condAlgs () const override
 
virtual bool isRegistered (const DataObjID &) const override
 
virtual bool isRegistered (IAlgorithm *) const override
 
virtual const DataObjIDColl & conditionIDs () const override
 
virtual StatusCode validRanges (std::vector< EventIDRange > &ranges, const DataObjID &id) const override
 
virtual void dump (std::ostream &) const override
 
virtual StatusCode setupDone () override
 To be called after changes to the set of conditions containers in the conditions store. More...
 
virtual ConditionSlotFuture * startConditionSetup (const EventContext &) override
 Asynchronously setup conditions. More...
 
virtual StatusCode registerConditionIOSvc (IConditionIOSvc *) override
 register an IConditionIOSvc (alternative to Algorithm processing of Conditions) More...
 

Private Types

typedef std::set< IAlgorithm *, iAlgHasherIAlgHashSet
 
typedef std::map< DataObjID, IAlgHashSetid_map_t
 
typedef std::map< IAlgorithm *, DataObjIDColl, iAlgHasheralg_map_t
 
typedef std::unordered_map< std::string, const CondContBase * > CondContMap_t
 
typedef std::mutex mutex_t
 

Private Member Functions

StatusCode regHandle_i (IAlgorithm *alg, const Gaudi::DataHandle &id)
 

Private Attributes

ServiceHandle< StoreGateSvcm_sgs
 
id_map_t m_idMap
 
alg_map_t m_algMap
 
std::set< IAlgorithm * > m_condAlgs
 
DataObjIDColl m_condIDs
 
CondContMap_t m_condConts
 
mutex_t m_lock
 

Detailed Description

Definition at line 23 of file CondSvc.h.

Member Typedef Documentation

◆ alg_map_t

typedef std::map<IAlgorithm*, DataObjIDColl, iAlgHasher> CondSvc::alg_map_t
private

Definition at line 105 of file CondSvc.h.

◆ CondContMap_t

typedef std::unordered_map<std::string, const CondContBase*> CondSvc::CondContMap_t
private

Definition at line 116 of file CondSvc.h.

◆ IAlgHashSet

typedef std::set<IAlgorithm*, iAlgHasher> CondSvc::IAlgHashSet
private

Definition at line 103 of file CondSvc.h.

◆ id_map_t

typedef std::map<DataObjID, IAlgHashSet> CondSvc::id_map_t
private

Definition at line 104 of file CondSvc.h.

◆ mutex_t

typedef std::mutex CondSvc::mutex_t
private

Definition at line 119 of file CondSvc.h.

Constructor & Destructor Documentation

◆ CondSvc()

CondSvc::CondSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 13 of file CondSvc.cxx.

13  :
14  base_class(name,svcLoc),
15  m_sgs("StoreGateSvc/ConditionStore", name)
16 {
17 }

◆ ~CondSvc()

CondSvc::~CondSvc ( )

Definition at line 21 of file CondSvc.cxx.

21  {
22 }

Member Function Documentation

◆ condAlgs()

virtual const std::set<IAlgorithm*>& CondSvc::condAlgs ( ) const
inlineoverridevirtual

Definition at line 44 of file CondSvc.h.

44 { return m_condAlgs; }

◆ conditionIDs()

const DataObjIDColl & CondSvc::conditionIDs ( ) const
overridevirtual

Definition at line 406 of file CondSvc.cxx.

406  {
407 
408  return m_condIDs;
409 
410 }

◆ dump()

void CondSvc::dump ( std::ostream &  ost) const
overridevirtual

Definition at line 87 of file CondSvc.cxx.

87  {
88 
89  std::lock_guard<mutex_t> lock(m_lock);
90 
91  ost << "CondSvc::dump()";
92 
93  ost << "\ndumping id->alg map\n";
94  for (const auto& ent : m_idMap) {
95  ost << std::endl << " + " << ent.first << " : ";
96  for (const auto& a : ent.second) {
97  ost << " " << a->name();
98  }
99  }
100 
101  ost << "\n\ndumping alg->id map\n";
102  for (const auto& ent : m_algMap) {
103  ost << std::endl << " + " << ent.first->name() << " : ";
104  for (const auto& a : ent.second) {
105  ost << " " << a;
106  }
107  }
108  ost << "\n\ndumping ConditionStore:\n\n";
109 
111  if (m_sgs->retrieve(cib,cie).isSuccess()) {
112  while (cib != cie) {
113  ost << " + ";
114  cib->list(ost);
115  ++cib;
116  }
117  }
118 
119  ost << "\n";
120 
121 }

◆ finalize()

StatusCode CondSvc::finalize ( )
overridevirtual

Definition at line 126 of file CondSvc.cxx.

126  {
127  ATH_MSG_DEBUG( "CondSvc::finalize()" );
128  return StatusCode::SUCCESS;
129 }

◆ getIDValidity()

bool CondSvc::getIDValidity ( const EventContext &  ctx,
DataObjIDColl &  validIDs,
DataObjIDColl &  invalidIDs 
)
virtual

Definition at line 276 of file CondSvc.cxx.

277  {
278  std::lock_guard<mutex_t> lock(m_lock);
279 
280  EventIDBase now(ctx.eventID());
281 
282  std::ostringstream ost;
283  ost << "getValidIDS " << ctx.eventID()
284  << ": retrieving all ConstIterator<CondContBase>";
286  if (m_sgs->retrieve(cib,cie).isSuccess()) {
287  while(cib != cie) {
288  ost << std::endl << " + " << cib.key() << " v: " << cib->valid(now)
289  << " id: " << cib->id();
290 
291  if ( cib->valid(now) ) {
292  validIDs.insert( cib->id() );
293  } else {
294  invalidIDs.insert( cib->id() );
295  }
296 
297  ++cib;
298  }
299  } else {
300  ATH_MSG_DEBUG( ost.str() );
301  ATH_MSG_DEBUG( "Condition store empty." );
302  return false;
303  }
304 
305  ost << std::endl << " -> found " << validIDs.size() << " valid, "
306  << invalidIDs.size() << " invalid IDs";
307 
308  ATH_MSG_DEBUG( ost.str() );
309 
310  return true;
311 }

◆ getInvalidIDs()

bool CondSvc::getInvalidIDs ( const EventContext &  ctx,
DataObjIDColl &  ids 
)
virtual

Definition at line 240 of file CondSvc.cxx.

240  {
241  std::lock_guard<mutex_t> lock(m_lock);
242 
243  EventIDBase now(ctx.eventID());
244 
245  std::ostringstream ost;
246  ost << "getInvalidIDS " << ctx.eventID()
247  << ": retrieving all ConstIterator<CondContBase>";
249  if (m_sgs->retrieve(cib,cie).isSuccess()) {
250  while(cib != cie) {
251  ost << std::endl << " + " << cib.key() << " " << cib->valid(now)
252  << " id: " << cib->id();
253 
254  if (! (cib->valid(now)) ) {
255  invalidIDs.insert( cib->id() );
256  }
257 
258  ++cib;
259  }
260  } else {
261  ATH_MSG_DEBUG(ost.str());
262  ATH_MSG_DEBUG("ConditionStore is empty");
263  return false;
264  }
265 
266  ost << std::endl << " -> found " << invalidIDs.size() << " invalid IDs";
267 
268  ATH_MSG_DEBUG( ost.str() );
269 
270  return true;
271 }

◆ getValidIDs()

bool CondSvc::getValidIDs ( const EventContext &  ctx,
DataObjIDColl &  ids 
)
virtual

Definition at line 316 of file CondSvc.cxx.

316  {
317  std::lock_guard<mutex_t> lock(m_lock);
318 
319  EventIDBase now(ctx.eventID());
320 
321  std::ostringstream ost;
322  ost << "getValidIDS " << ctx.eventID()
323  << ": retrieving all ConstIterator<CondContBase>";
325  if (m_sgs->retrieve(cib,cie).isSuccess()) {
326  while(cib != cie) {
327  ost << std::endl << " + " << cib.key() << " v: " << cib->valid(now)
328  << " id: " << cib->id();
329 
330  if ( cib->valid(now) ) {
331  validIDs.insert( cib->id() );
332  }
333 
334  ++cib;
335  }
336  } else {
337  ATH_MSG_DEBUG( ost.str() );
338  ATH_MSG_DEBUG( "Condition store empty." );
339  return false;
340  }
341 
342  ost << std::endl << " -> found " << validIDs.size() << " valid IDs";
343 
344  ATH_MSG_DEBUG( ost.str() );
345 
346  return true;
347 }

◆ initialize()

StatusCode CondSvc::initialize ( )
overridevirtual

Definition at line 52 of file CondSvc.cxx.

52  {
53 
54  // Initialise mother class in order to print DEBUG messages during initialize()
56  msg().setLevel( m_outputLevel.value() );
57 
58  if (!sc.isSuccess()) {
59  warning () << "Base class could not be initialized" << endmsg;
60  return StatusCode::FAILURE;
61  }
62 
63  if (!m_sgs.isValid()) {
64  error() << "could not get ConditionStore" << endmsg;
65  return StatusCode::FAILURE;
66  }
67 
68  return StatusCode::SUCCESS;
69 
70 }

◆ isRegistered() [1/2]

bool CondSvc::isRegistered ( const DataObjID &  id) const
overridevirtual

Definition at line 386 of file CondSvc.cxx.

386  {
387 
388  return (m_condIDs.find(id) != m_condIDs.end());
389 
390 }

◆ isRegistered() [2/2]

bool CondSvc::isRegistered ( IAlgorithm *  ialg) const
overridevirtual

Definition at line 396 of file CondSvc.cxx.

396  {
397 
398  return (m_condAlgs.find(ialg) != m_condAlgs.end());
399 
400 }

◆ isValidID()

bool CondSvc::isValidID ( const EventContext &  ctx,
const DataObjID &  id 
) const
overridevirtual

Definition at line 352 of file CondSvc.cxx.

352  {
353  // Don't take out the lock here.
354  // In many-thread jobs, a lock here becomes heavily contended.
355  // The only potential conflict is with startConditionSetup(),
356  // which should only be called during START.
357 
358  EventIDBase now(ctx.eventID());
359 
360  // FIXME: this is ugly, but we need to strip out the name of the store.
361  std::string sk = id.key();
362  if (sk.starts_with( StoreID::storeName(StoreID::CONDITION_STORE))) {
363  sk.erase(0,15);
364  }
365 
366  auto it = m_condConts.find (sk);
367  if (it != m_condConts.end()) {
368  bool valid = it->second->valid (now);
369  ATH_MSG_VERBOSE("CondSvc::isValidID: now: " << ctx.eventID() << " id : "
370  << id << (valid ? ": T" : ": F") );
371  return valid;
372  }
373  else {
374  ATH_MSG_ERROR( "Cannot find CondCont " << id );
375  }
376 
377  ATH_MSG_DEBUG("CondSvc::isValidID: now: " << ctx.eventID() << " id: "
378  << id << " : F");
379  return false;
380 
381 }

◆ regHandle()

StatusCode CondSvc::regHandle ( IAlgorithm *  alg,
const Gaudi::DataHandle &  id 
)
overridevirtual

Definition at line 160 of file CondSvc.cxx.

160  {
161 
162  std::lock_guard<mutex_t> lock(m_lock);
163  return regHandle_i(alg, dh);
164 
165 }

◆ regHandle_i()

StatusCode CondSvc::regHandle_i ( IAlgorithm *  alg,
const Gaudi::DataHandle &  id 
)
private

Definition at line 171 of file CondSvc.cxx.

171  {
172 
173  ATH_MSG_DEBUG( "regHandle: alg: " << alg->name() << " id: "
174  << dh.fullKey() );
175 
176  if (dh.mode() != Gaudi::DataHandle::Writer) {
177  info() << dh.fullKey() << " is a ReadHandle. no need to register"
178  << endmsg;
179  return StatusCode::SUCCESS;
180  }
181 
182  id_map_t::iterator itd2 = m_idMap.find(dh.fullKey());
183  if (itd2 != m_idMap.end()) {
184  IAlgorithm *ia = *(itd2->second.begin());
185  if (ia->name() != alg->name()) {
186  error() << "WriteCondHandle " << dh.fullKey()
187  << " is already registered against a different Algorithm "
188  << ia->name()
189  << ". This is not allowed."
190  << endmsg;
191  return StatusCode::FAILURE;
192  }
193  // FIXME : so why is it a set<IAlgorithm*> ??
194  }
195 
196  // m_keyMap[key] = dh.fullKey();
197  m_condAlgs.insert(alg);
198 
199  m_condIDs.emplace( dh.fullKey() );
200 
201  // id_map_t::iterator itd2 = m_idMap.find(dh.fullKey());
202  if (itd2 != m_idMap.end()) {
203  itd2->second.insert( alg );
204  } else {
205  m_idMap[dh.fullKey()] = IAlgHashSet { alg };
206  }
207 
208  alg_map_t::iterator ita2 = m_algMap.find(alg);
209  if (ita2 != m_algMap.end()) {
210  ita2->second.insert( dh.fullKey() );
211  } else {
212  m_algMap[alg] = DataObjIDColl { dh.fullKey() };
213  }
214 
215  StatusCode sc(StatusCode::SUCCESS);
216 
217  CLID clid = dh.fullKey().clid();
218  const SG::BaseInfoBase* bib = SG::BaseInfoBase::find( clid );
219  if ( bib ) {
220  for (CLID clid2 : bib->get_bases()) {
221  if (clid2 != clid) {
222  SG::VarHandleKey vhk(clid2,dh.objKey(),Gaudi::DataHandle::Writer,
224  if (regHandle_i(alg, vhk).isFailure()) {
225  sc = StatusCode::FAILURE;
226  }
227  }
228  }
229  }
230 
231 
232 
233  return sc;
234 
235 }

◆ registerConditionIOSvc()

virtual StatusCode CondSvc::registerConditionIOSvc ( IConditionIOSvc *  )
inlineoverridevirtual

register an IConditionIOSvc (alternative to Algorithm processing of Conditions)

Definition at line 73 of file CondSvc.h.

73  {
74  return StatusCode::FAILURE;
75  }

◆ setupDone()

StatusCode CondSvc::setupDone ( )
overridevirtual

To be called after changes to the set of conditions containers in the conditions store.

May not be called concurrently with any other methods of this class.

Definition at line 415 of file CondSvc.cxx.

416 {
417  std::lock_guard<mutex_t> lock(m_lock);
418 
420  if (m_sgs->retrieve(cib,cie).isSuccess()) {
421  while(cib != cie) {
422  m_condConts[cib.key()] = &*cib;
423  ++cib;
424  }
425  }
426 
427  return StatusCode::SUCCESS;
428 }

◆ start()

StatusCode CondSvc::start ( )
overridevirtual

Definition at line 133 of file CondSvc.cxx.

134 {
135  // Call this now, in case there's no CondInputLoader.
136  ATH_CHECK( setupDone() );
137  return StatusCode::SUCCESS;
138 }

◆ startConditionSetup()

virtual ConditionSlotFuture* CondSvc::startConditionSetup ( const EventContext &  )
inlineoverridevirtual

Asynchronously setup conditions.

Definition at line 67 of file CondSvc.h.

67  {
68  return nullptr;
69  }

◆ stop()

StatusCode CondSvc::stop ( )
overridevirtual

Definition at line 142 of file CondSvc.cxx.

142  {
143 
144  ATH_MSG_DEBUG( "CondSvc::stop()" );
145 
146  if (msgLvl(MSG::DEBUG)) {
147  std::ostringstream ost;
148  dump(ost);
149 
150  ATH_MSG_DEBUG( ost.str() );
151  }
152 
153  return StatusCode::SUCCESS;
154 
155 }

◆ validRanges()

StatusCode CondSvc::validRanges ( std::vector< EventIDRange > &  ranges,
const DataObjID &  id 
) const
overridevirtual

Definition at line 26 of file CondSvc.cxx.

27 {
28  // Direct retrieve doesn't work for some reason
29  /*CondContBase const* condObject;
30  StatusCode sc = m_sgs->retrieve( condObject, id.key() );
31  if ( sc.isSuccess() ) {
32  ranges = condObject->ranges();
33  }*/
34 
35  // Retrieve all conditions data and search
37  StatusCode sc = m_sgs->retrieve( cib, cie );
38  if ( sc.isSuccess() ) {
39  while ( cib != cie ) {
40  if ( cib->id() == id ) {
41  ranges = cib->ranges();
42  }
43  ++cib;
44  }
45  }
46 
47  return sc;
48 }

Member Data Documentation

◆ m_algMap

alg_map_t CondSvc::m_algMap
private

Definition at line 107 of file CondSvc.h.

◆ m_condAlgs

std::set<IAlgorithm*> CondSvc::m_condAlgs
private

Definition at line 110 of file CondSvc.h.

◆ m_condConts

CondContMap_t CondSvc::m_condConts
private

Definition at line 117 of file CondSvc.h.

◆ m_condIDs

DataObjIDColl CondSvc::m_condIDs
private

Definition at line 112 of file CondSvc.h.

◆ m_idMap

id_map_t CondSvc::m_idMap
private

Definition at line 106 of file CondSvc.h.

◆ m_lock

mutex_t CondSvc::m_lock
mutableprivate

Definition at line 120 of file CondSvc.h.

◆ m_sgs

ServiceHandle<StoreGateSvc> CondSvc::m_sgs
private

Definition at line 101 of file CondSvc.h.


The documentation for this class was generated from the following files:
grepfile.info
info
Definition: grepfile.py:38
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
trigbs_pickEvents.ranges
ranges
Definition: trigbs_pickEvents.py:60
CondSvc::m_sgs
ServiceHandle< StoreGateSvc > m_sgs
Definition: CondSvc.h:101
SGout2dot.alg
alg
Definition: SGout2dot.py:243
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
SG::detail::IteratorBase::key
const std::string & key() const
Get the key string with which the current object was stored.
Definition: SGIterator.cxx:155
initialize
void initialize()
Definition: run_EoverP.cxx:894
skel.it
it
Definition: skel.GENtoEVGEN.py:424
CondSvc::m_condConts
CondContMap_t m_condConts
Definition: CondSvc.h:117
CondSvc::dump
virtual void dump(std::ostream &) const override
Definition: CondSvc.cxx:87
PyPoolBrowser.dh
dh
Definition: PyPoolBrowser.py:102
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::BaseInfoBase::get_bases
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
Definition: BaseInfo.cxx:304
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
StoreID::CONDITION_STORE
@ CONDITION_STORE
Definition: StoreID.h:28
calibdata.valid
list valid
Definition: calibdata.py:45
python.handimod.now
now
Definition: handimod.py:675
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
CondSvc::m_condIDs
DataObjIDColl m_condIDs
Definition: CondSvc.h:112
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
CondSvc::m_algMap
alg_map_t m_algMap
Definition: CondSvc.h:107
SG::BaseInfoBase::find
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
Definition: BaseInfo.cxx:569
CondSvc::m_lock
mutex_t m_lock
Definition: CondSvc.h:120
CondSvc::m_condAlgs
std::set< IAlgorithm * > m_condAlgs
Definition: CondSvc.h:110
CondSvc::regHandle_i
StatusCode regHandle_i(IAlgorithm *alg, const Gaudi::DataHandle &id)
Definition: CondSvc.cxx:171
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:62
a
TList * a
Definition: liststreamerinfos.cxx:10
CondSvc::m_idMap
id_map_t m_idMap
Definition: CondSvc.h:106
DEBUG
#define DEBUG
Definition: page_access.h:11
SG::BaseInfoBase
The non-template portion of the BaseInfo implementation.
Definition: Control/AthenaKernel/AthenaKernel/BaseInfo.h:451
python.test_cfgItemList.msg
msg
Definition: test_cfgItemList.py:7
get_generator_info.error
error
Definition: get_generator_info.py:40
CondSvc::IAlgHashSet
std::set< IAlgorithm *, iAlgHasher > IAlgHashSet
Definition: CondSvc.h:103
SG::ConstIterator
Definition: SGIterator.h:163
StoreID::storeName
static const std::string & storeName(const StoreID::type &s)
Definition: StoreID.cxx:77
CondSvc::setupDone
virtual StatusCode setupDone() override
To be called after changes to the set of conditions containers in the conditions store.
Definition: CondSvc.cxx:415