ATLAS Offline Software
IOVSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*****************************************************************************
6  *
7  * IOVSvc.cxx
8  * IOVSvc
9  *
10  * Author: Charles Leggett
11  *
12  * Provides automatic updating and callbacks for time dependent data
13  *
14  *****************************************************************************/
15 
16 #include "IOVSvc.h"
17 
18 #include "GaudiKernel/ISvcLocator.h"
19 #include "GaudiKernel/IAlgTool.h"
20 #include "GaudiKernel/IToolSvc.h"
21 #include "GaudiKernel/IClassIDSvc.h"
22 #include "GaudiKernel/IConversionSvc.h"
23 
26 #include "AthenaKernel/IIOVDbSvc.h"
28 #include "IOVSvc/IIOVSvcTool.h"
29 
30 using SG::DataProxy;
32 
33 const std::string defaultStore = "StoreGateSvc";
34 
35 
36 namespace {
37 
38 
44 bool eventIDMatch (const EventIDBase& e1, const EventIDBase& e2)
45 {
46  if (e1.isRunLumi()) {
47  if (e1.run_number() != e2.run_number()) return false;
48  if (e1.lumi_block() != e2.lumi_block()) return false;
49  }
50  if (e1.isTimeStamp()) {
51  if (e1.time_stamp() != e2.time_stamp()) return false;
52  if (e1.time_stamp_ns_offset() != e2.time_stamp_ns_offset()) return false;
53  }
54  return true;
55 }
56 
57 
58 } // anonymous namespace
59 
60 
61 
62 //
64 //
65 
66 IOVSvc::IOVSvc( const std::string& name, ISvcLocator* svc )
67  : base_class( name, svc ),
68  p_toolSvc("ToolSvc",name),
69  p_CLIDSvc("ClassIDSvc",name),
70  p_sgs("StoreGateSvc",name),
71  p_detStore("StoreGateSvc/DetectorStore",name),
72  p_condSvc("CondSvc",name)
73 {
74 
75  declareProperty("preLoadRanges",m_preLoadRanges=false);
76  declareProperty("preLoadData",m_preLoadData=false);
77  declareProperty("partialPreLoadData",m_partialPreLoadData=true);
78  declareProperty("preLoadExtensibleFolders", m_preLoadExtensibleFolders=true);
79  declareProperty("updateInterval", m_updateInterval="Event");
80  declareProperty("sortKeys",m_sortKeys=true);
81  declareProperty("forceResetAtBeginRun", m_forceReset=false);
82 
83 }
84 
85 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
86 
88 
89 }
90 
91 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
92 
94 
95  msg().setLevel( m_outputLevel.value() );
96  ATH_MSG_DEBUG( "Initializing IOVSvc" );
97 
98  if (!p_sgs.isValid()) {
99  ATH_MSG_ERROR("could not get the Event Store");
100  return StatusCode::FAILURE;
101  }
102 
103  if (!p_detStore.isValid()) {
104  ATH_MSG_ERROR("could not get the Detector Store");
105  return StatusCode::FAILURE;
106  }
107 
108  if (!p_condSvc.isValid()) {
109  ATH_MSG_ERROR("could not get the ConditionSvc");
110  return StatusCode::FAILURE;
111  }
112 
113  return StatusCode::SUCCESS;
114 }
115 
116 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
117 
119 {
120  ATH_MSG_DEBUG( "Service finalised successfully" );
121  return StatusCode::SUCCESS;
122 }
123 
124 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
125 
129 StatusCode
130 IOVSvc::regProxy( DataProxy *proxy, const std::string& key,
131  const std::string& storeName ) {
132 
133  std::lock_guard<std::recursive_mutex> lock(m_lock);
134  IIOVSvcTool *ist = getTool( storeName );
135  if (ist == 0) {
136  ATH_MSG_ERROR( "regProxy: no IOVSvcTool associated with store \""
137  << storeName << "\" and failed to create one" );
138  return (StatusCode::FAILURE);
139  }
140 
141  IIOVSvcTool *ist2 = getTool( proxy );
142  if (ist2 != 0) {
143  if (ist2 != ist) {
144  ATH_MSG_ERROR( "regProxy: when registering proxy for "
145  << fullProxyName(proxy) << " with store \"" << storeName
146  << "\", it is already registered with store \""
147  << ist2->getStoreName() << "\"" );
148  return StatusCode::FAILURE;
149  } else {
150  ATH_MSG_DEBUG( "regProxy: proxy for " << fullProxyName(proxy)
151  << " already registered with store \"" << storeName << "\""
152  );
153  return StatusCode::SUCCESS;
154  }
155  }
156 
157  return ist->regProxy( proxy, key );
158 
159 }
160 
161 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
162 
166 StatusCode
167 IOVSvc::regProxy( const CLID& clid, const std::string& key,
168  const std::string& storeName ) {
169 
170  std::lock_guard<std::recursive_mutex> lock(m_lock);
171  IIOVSvcTool *ist = getTool( storeName );
172  if (ist == 0) {
173  ATH_MSG_ERROR( "regProxy: no IOVSvcTool associated with store \""
174  << storeName << "\" and failed to create one." );
175  return (StatusCode::FAILURE);
176  }
177 
178  IIOVSvcTool *ist2 = getTool( clid, key );
179  if (ist2 != 0) {
180  if (ist2 != ist) {
181  ATH_MSG_ERROR( "regProxy: when registering proxy for "
182  << fullProxyName(clid,key)
183  << " with store " << storeName
184  << ", it is already registered with store \""
185  << ist2->getStoreName() << "\"" );
186  return StatusCode::FAILURE;
187  } else {
188  ATH_MSG_DEBUG( "regProxy: proxy for " << fullProxyName(clid,key)
189  << " already registered with store \"" << storeName << "\""
190  );
191  return StatusCode::SUCCESS;
192  }
193  }
194 
195  return ist->regProxy( clid, key );
196 
197 }
198 
199 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
200 
204 StatusCode
206 
207 
208  std::lock_guard<std::recursive_mutex> lock(m_lock);
209  IIOVSvcTool *ist = getTool( proxy );
210  if (ist == 0) {
211  ATH_MSG_ERROR( "deregProxy: no IOVSvcTool found for proxy "
212  << fullProxyName( proxy ) );
213  return (StatusCode::FAILURE);
214  }
215 
216  return ist->deregProxy( proxy );
217 
218 }
219 
220 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
221 
225 StatusCode
226 IOVSvc::deregProxy( const CLID& clid, const std::string& key ) {
227 
228 
229  std::lock_guard<std::recursive_mutex> lock(m_lock);
230  IIOVSvcTool *ist = getTool( clid, key );
231  if (ist == 0) {
232  ATH_MSG_ERROR( "deregProxy: no IOVSvcTool found for proxy "
233  << fullProxyName(clid,key) );
234  return StatusCode::FAILURE;
235  }
236 
237  return ist->deregProxy( clid, key );
238 
239 }
240 
241 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
242 
246 void
247 IOVSvc::ignoreProxy( const CLID& clid, const std::string& key,
248  const std::string& storeName ) {
249 
250 
251  IIOVSvcTool *ist = getTool( storeName );
252  if (ist == 0) {
253  ATH_MSG_ERROR( "ignoreProxy: no IOVSvcTool found for store "
254  << storeName << " and failed to create one" );
255  return;
256  }
257 
258  return ist->ignoreProxy( clid, key );
259 }
260 
261 
262 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
263 
267 StatusCode
269  const std::string& storeName ) {
270 
271  StatusCode sc(StatusCode::FAILURE);
272  IIOVSvcTool *ist = getTool( storeName );
273  if (0 != ist) {
274  sc = ist->replaceProxy(pOld, pNew);
275  } else {
276  ATH_MSG_ERROR( "regProxy: no IOVSvcTool associated with store \""
277  << storeName << "\" and failed to create one." );
278  }
279  return sc;
280 }
281 
282 
283 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
284 
288 
289 StatusCode
291  const std::string& storeName ) {
292 
293 
294  IIOVSvcTool *ist = getTool( storeName );
295  if (ist == 0) {
296  ATH_MSG_ERROR( "preLoadTAD: no IOVSvcTool associated with store \""
297  << storeName << "\" and failed to create one." );
298  return StatusCode::FAILURE;
299  } else {
300  return ist->preLoadTAD( tad );
301  }
302 
303 }
304 
305 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
306 
310 StatusCode
312  const std::string& storeName ) {
313 
314  IIOVSvcTool *ist = getTool( storeName );
315  if (ist == 0) {
316  ATH_MSG_ERROR( "preLoadDataTAD: no IOVSvcTool associated with store \""
317  << storeName << "\" and failed to create one." );
318  return StatusCode::FAILURE;
319  } else {
320  return ist->preLoadDataTAD( tad );
321  }
322 
323 }
324 
325 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
326 
327 StatusCode
328 IOVSvc::setRange(const CLID& clid, const std::string& key,
329  IOVRange& iovr) {
330 
331  std::lock_guard<std::recursive_mutex> lock(m_lock);
332 
333  IIOVSvcTool *ist = getTool( clid, key );
334  if (ist == 0) {
335 
336  // FIXME - this should be eliminated once the IOVDbSvc is set up to
337  // use store names. There should be no default store for setRange
338 
339  ATH_MSG_WARNING( "setRange(CLID,key,range) for unregistered proxies "
340  << "is deprecated - you need to specify a store! "
341  << "This will be an ERROR soon!" );
342 
343  return setRange(clid,key,iovr, defaultStore );
344 
345  } else {
346  return ist->setRange( clid, key, iovr );
347  }
348 
349 }
350 
351 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
352 
353 StatusCode
354 IOVSvc::setRange(const CLID& clid, const std::string& key,
355  IOVRange& iovr, const std::string& storeName) {
356 
357  std::lock_guard<std::recursive_mutex> lock(m_lock);
358 
359  IIOVSvcTool *ist = getTool( storeName );
360  if (ist == 0) {
361  ATH_MSG_ERROR( "setRange: no IOVSvcTool associated with store \""
362  << storeName << "\" and failed to create one." );
363  return StatusCode::FAILURE;
364  }
365 
366  IIOVSvcTool *ist2 = getTool( clid, key );
367  if (ist2 == 0) {
368  ATH_MSG_INFO( "setRange: proxy for " << fullProxyName(clid,key)
369  << " not registered with store \"" << storeName << "\". Doing it now"
370  );
371  if (ist->regProxy(clid, key).isFailure()) {
372  return StatusCode::FAILURE;
373  }
374  } else if (ist2 != ist) {
375  ATH_MSG_INFO( "setRange: when registering proxy (clid: "
376  << clid << " key: " << key << ") with store \"" << storeName
377  << "\" --> already registered with store \"" << ist2->getStoreName()
378  << "\"" );
379  return StatusCode::FAILURE;
380  }
381 
382  return ist->setRange( clid, key, iovr );
383 
384 }
385 
386 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
387 
389 IOVSvc::dropObjectFromDB(const CLID& clid, const std::string& key,
390  const std::string& storeName) {
391 
392  std::lock_guard<std::recursive_mutex> lock(m_lock);
393 
394  IIOVSvcTool *ist = getTool( clid, key );
395  if (ist == nullptr) {
396  ATH_MSG_ERROR( "dropObjectFromDB: no IOVSvcTool associated with store "
397  << storeName << " and failed to create one." );
398  return StatusCode::FAILURE;
399  }
400 
401  DataProxy* proxy = p_detStore->proxy(clid, key);
402  if (proxy == nullptr) {
403  ATH_MSG_DEBUG("Proxy for (clid: " << clid << " key: " << key << ") in store " << storeName
404  << " does not exist. Cannot drop associated object.");
405  return StatusCode::SUCCESS;
406  }
407 
408  // Set IOV in the past to trigger reload on next range check
409  IOVRange iovr(IOVTime(0, 0), IOVTime(0, 0));
410  ATH_CHECK( ist->setRange(clid, key, iovr) );
411 
412  IIOVDbSvc *iovDB = dynamic_cast<IIOVDbSvc*>(proxy->provider());
413  if (iovDB != nullptr) {
414  ATH_MSG_DEBUG("Dropping " << key << "via IOVDBSvc");
415  ATH_CHECK( iovDB->dropObject(key, /*resetCache=*/true) );
416  } else {
417  ATH_MSG_ERROR("dropObjectFromDB: Provider for " << key << " is not an IIOVDbSvc.");
418  return StatusCode::FAILURE;
419  }
420 
421  return StatusCode::SUCCESS;
422 }
423 
424 
425 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
426 
427 StatusCode
428 IOVSvc::getRange(const CLID& clid, const std::string& key,
429  IOVRange& iov) const {
430 
431 
432  IIOVSvcTool *ist = getTool( clid, key );
433  if (ist == 0) {
434  ATH_MSG_ERROR( "getRange: proxy for " << fullProxyName(clid,key)
435  << " not registered" );
436  return StatusCode::FAILURE;
437  } else {
438  return ist->getRange( clid, key, iov );
439  }
440 
441 }
442 
443 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
444 
445 StatusCode
446 IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key,
447  IOVRange& range, std::string& tag,
448  std::unique_ptr<IOpaqueAddress>& ioa) const {
449 
450  std::lock_guard<std::recursive_mutex> lock(m_lock);
451 
452  IIOVSvcTool *ist = getTool( clid, key );
453  if (ist == 0) {
454  ATH_MSG_ERROR( "getRangeFromDB: proxy for "
455  << fullProxyName(clid,key) << " not registered" );
456  return StatusCode::FAILURE;
457  } else {
458 
459  //Get current time form thread-local context
460  const EventContext& context = Gaudi::Hive::currentContext();
461  const EventIDBase& eventID = context.eventID();
462  uint32_t event = eventID.lumi_block();
463  uint32_t run = eventID.run_number();
464  IOVTime curTime;
465  curTime.setRunEvent(run,event);
466  // get ns timestamp from event
467  curTime.setTimestamp(1000000000L*(uint64_t)eventID.time_stamp() + eventID.time_stamp_ns_offset());
468 
469 
470  return ist->getRangeFromDB( clid, key, range, tag, ioa, curTime );
471  }
472 
473 }
474 
475 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
476 
477 StatusCode
478 IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key,
479  const IOVTime& time, IOVRange& range,
480  std::string& tag,
481  std::unique_ptr<IOpaqueAddress>& ioa) const {
482 
483  std::lock_guard<std::recursive_mutex> lock(m_lock);
484 
485  IIOVSvcTool *ist = getTool( clid, key );
486  if (ist == 0) {
487  ATH_MSG_ERROR( "getRangeFromDB: proxy for "
488  << fullProxyName(clid, key) << " not registered" );
489  return StatusCode::FAILURE;
490  } else {
491  return ist->getRangeFromDB( clid, key, time, range, tag, ioa );
492  }
493 
494 }
495 
496 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
497 
498 StatusCode
499 IOVSvc::setRangeInDB(const CLID& clid, const std::string& key,
500  const IOVRange& range, const std::string &tag) {
501 
502  IIOVSvcTool *ist = getTool( clid, key );
503  if (ist == 0) {
504  ATH_MSG_ERROR( "setRangeInDB: proxy for "
505  << fullProxyName(clid,key) << " not registered" );
506  return StatusCode::FAILURE;
507  } else {
508  return ist->setRangeInDB( clid, key, range, tag );
509  }
510 
511 }
512 
513 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
514 
515 StatusCode
517  const CallBackID& c,
518  const IOVSvcCallBackFcn& fcn,
519  bool trigger) {
520 
521  IIOVSvcTool *ist = getTool( dp );
522  if (ist == 0) {
523  ATH_MSG_ERROR( "regFcn: no IOVSvcTool found containing DataProxy "
524  << fullProxyName( dp )
525  << "-> Need to bind DataHandle first" );
526  return StatusCode::FAILURE;
527  } else {
528  return ist->regFcn( dp, c, fcn, trigger );
529  }
530 
531 }
532 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
533 
534 StatusCode
536  const CallBackID& c2, const IOVSvcCallBackFcn& fcn2,
537  bool trigger) {
538 
539 
540  if (c1 == c2) {
541  ATH_MSG_ERROR( "Cannot register 2nd callback function and assocaited"
542  << " object with itself" );
543  return StatusCode::FAILURE;
544  }
545 
546 
547  IIOVSvcTool *ist = getTool( c1 );
548  if (ist == 0) {
549  ATH_MSG_ERROR( "CallBack function \"" << c2.name()
550  << "\" cannot be registered since function \"" << c1.name()
551  << "\" has not been registered first" );
552  return StatusCode::FAILURE;
553  } else {
554  return ist->regFcn(c1, c2, fcn2, trigger);
555  }
556 
557 }
558 
559 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
560 
561 StatusCode
562 IOVSvc::regFcn(const std::string& toolName,
563  const CallBackID& c2, const IOVSvcCallBackFcn& fcn2,
564  bool trigger) {
565 
566  IAlgTool *ia;
567  if ( p_toolSvc->retrieveTool(toolName, ia, 0, false).isFailure() ) {
568  ATH_MSG_ERROR( "AlgTool " << toolName << " has not yet been created"
569  << " and thus cannot be registered" );
570  return StatusCode::FAILURE;
571  }
572 
573  IIOVSvcTool *ist = getTool( ia );
574  if (ist == 0) {
575  ATH_MSG_ERROR( "No callback registered with AlgTool " << toolName );
576  return StatusCode::FAILURE;
577  } else {
578  return ist->regFcn(ia, c2, fcn2, trigger);
579  }
580 
581 }
582 
583 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
584 
586 IOVSvc::getTriggeredTools(const std::string& key,
587  std::set<std::string>& tools,
588  const std::string& storeName) {
589 
590  IIOVSvcTool *ist = getTool( storeName, false );
591  if (ist == 0) {
592  ATH_MSG_ERROR( "getTriggeredTools: no store \"" << storeName
593  << "\" associated with any IOVSvcTool" );
594  return StatusCode::FAILURE;
595  } else {
596  return ist->getTriggeredTools(key, tools);
597  }
598 
599 }
600 
601 
602 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
603 
604 StatusCode
606 {
607  // Set flag to reset all proxies
608  StatusCode sc;
609  toolMap::iterator itr = m_toolMap.begin();
610  for ( ; itr!=m_toolMap.end(); ++itr) {
611  sc &= itr->second->reinitialize();
612  }
613  return sc;
614 
615 }
616 
617 
618 
619 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
620 
622 IOVSvc::createIOVTool( const std::string& storeName, IIOVSvcTool*& ist ) {
623 
624  std::string store(storeName);
625  std::string toolName("IOVSvcTool");
626  if (storeName == "default") store = defaultStore;
627 
628  // Append the store name if not default
629  if (store != defaultStore) {
630  toolName += '_';
631  toolName += store;
632  }
633 
634  ATH_MSG_DEBUG( "Creating " << toolName << " associated with store \"" << store
635  << "\"" );
636 
637  toolMap::iterator itr = m_toolMap.find( store );
638  if ( itr == m_toolMap.end() ) {
639  ist = nullptr;
640  if (p_toolSvc->retrieveTool( "IOVSvcTool/" + toolName, ist, this ).isFailure()) {
641  ATH_MSG_ERROR( "Unable to create IOVSvcTool associated with store \""
642  << store << "\"" );
643  return StatusCode::FAILURE;
644  } else {
645  m_toolMap[ store ] = ist;
646  ist->setStoreName( store );
647  return StatusCode::SUCCESS;
648  }
649  } else {
650  ATH_MSG_INFO( "an IOVSvcTool already exists associated with store \""
651  << store << "\"" );
652  ist = itr->second;
653  return StatusCode::SUCCESS;
654  }
655 
656 }
657  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
658 
660 IOVSvc::createIOVTool( const std::string& storeName )
661 {
662  IIOVSvcTool* ist = nullptr;
663  return createIOVTool (storeName, ist);
664 }
665 
666 
667 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
668 
669 IIOVSvcTool*
670 IOVSvc::getTool( const std::string& storeName, bool createIF ) {
671 
672  std::string store(storeName);
673  if (storeName == "default") {
675  }
676 
677  toolMap::const_iterator itr = m_toolMap.find( store );
678  IIOVSvcTool *ist(0);
679  if ( itr == m_toolMap.end() ) {
680  ATH_MSG_INFO( "No IOVSvcTool associated with store \"" << store
681  << "\"" );
682 
683  if (createIF) {
684  createIOVTool(store, ist).ignore();
685  }
686 
687  } else {
688  ist = itr->second;
689  }
690 
691  return ist;
692 }
693 
694 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
695 
696 IIOVSvcTool*
698 
699 
700  IIOVSvcTool *ist(0);
701  toolMap::const_iterator itr = m_toolMap.begin();
702  for (; itr != m_toolMap.end(); ++itr) {
703  if (itr->second->holdsProxy( proxy )) {
704  ist = itr->second;
705  return ist;
706  }
707  }
708 
709  return ist;
710 
711 }
712 
713 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
714 
715 IIOVSvcTool*
716 IOVSvc::getTool( const CLID& clid, const std::string& key ) const {
717 
718  IIOVSvcTool *ist(0);
719  toolMap::const_iterator itr = m_toolMap.begin();
720  for (; itr != m_toolMap.end(); ++itr) {
721  if (itr->second->holdsProxy( clid, key )) {
722  ist = itr->second;
723  return ist;
724  }
725  }
726 
727  return ist;
728 
729 }
730 
731 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
732 
733 IIOVSvcTool*
734 IOVSvc::getTool( const CallBackID& c1 ) const {
735 
736  IIOVSvcTool *ist(0);
737  toolMap::const_iterator itr = m_toolMap.begin();
738  for (; itr != m_toolMap.end(); ++itr) {
739  if (itr->second->holdsCallback( c1 )) {
740  ist = itr->second;
741  return ist;
742  }
743  }
744 
745  return ist;
746 
747 }
748 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
749 
750 IIOVSvcTool*
751 IOVSvc::getTool( const IAlgTool* ia ) const {
752 
753  IIOVSvcTool *ist(0);
754  toolMap::const_iterator itr = m_toolMap.begin();
755  for (; itr != m_toolMap.end(); ++itr) {
756  if (itr->second->holdsAlgTool( ia )) {
757  ist = itr->second;
758  return ist;
759  }
760  }
761 
762  return ist;
763 
764 }
765 
766 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
767 
768 std::string
770 
771  return fullProxyName(dp->clID(), dp->name());
772 
773 }
774 
775 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
776 
777 std::string
778 IOVSvc::fullProxyName( const CLID& clid, const std::string& key ) const {
779 
780  std::string fullname, tname;
781  if (p_CLIDSvc->getTypeNameOfID( clid, tname ).isFailure()) {
782  fullname = "[";
783  fullname += std::to_string(clid);
784  fullname += '/';
785  fullname += key;
786  fullname += ']';
787  } else {
788  fullname = "[";
789  fullname += tname;
790  fullname += ':';
791  fullname += std::to_string(clid);
792  fullname += '/';
793  fullname += key;
794  fullname += ']';
795  }
796 
797  return fullname;
798 }
799 
800 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
801 
802 std::vector<std::string>
804 
805  std::vector<std::string> stores;
806 
807  toolMap::const_iterator itr = m_toolMap.begin();
808  for( ; itr!=m_toolMap.end(); ++itr) {
809  stores.push_back( itr->first );
810  }
811 
812  return stores;
813 
814 }
815 
816 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
817 
818 void
820 
821  toolMap::iterator itr = m_toolMap.begin();
822  for (; itr!= m_toolMap.end(); ++itr) {
823  IIOVSvcTool* ist = itr->second;
824  ATH_MSG_DEBUG( "resetting all proxies for store \""
825  << ist->getStoreName() << "\"" );
826  ist->resetAllProxies();
827  }
828 
829 }
830 
831 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
832 
833 StatusCode
834 IOVSvc::createCondObj(CondContBase* ccb, const DataObjID& id,
835  const EventIDBase& now) {
836 
837  ATH_MSG_DEBUG("createCondObj: id: " << id << " t: " << now << " valid: "
838  << ccb->valid(now));
839 
840  if (ccb->valid(now)) {
841  if (msgLvl(MSG::DEBUG)) {
842  EventIDRange r;
843  ccb->range(now,r);
844  ATH_MSG_DEBUG( " range " << r << " for " << id
845  << " is still valid at " << now );
846  }
847  return StatusCode::SUCCESS;
848  }
849 
850  IOVTime t(now.run_number(), now.lumi_block(), (long long)now.time_stamp()*1000000000+now.time_stamp_ns_offset());
851  IOVRange range;
852  std::string tag;
853  // remove storename from key
854  std::string sgKey = id.key();
855  auto sep = sgKey.find('+');
856  if (sep != std::string::npos) {
857  sgKey.erase(0,sep+1);
858  }
859 
860  std::unique_ptr<IOpaqueAddress> ioa;
861  if (getRangeFromDB(id.clid(), sgKey, t, range, tag, ioa).isFailure()) {
862  ATH_MSG_ERROR( "unable to get range from db for "
863  << id.clid() << " " << sgKey );
864  return StatusCode::FAILURE;
865  }
866 
867  //In case the conditons-container is a 'mixed' type, we need both run/lb and time-stamps in the range.
868  //Assume infinite IOV in the other dimension
869  EventIDRange eidRange(range);
870  if (ccb->keyType()==CondContBase::KeyType::MIXED) {
872  }
873  ATH_MSG_DEBUG( " new range for ID " << id << " : " << range
874  << " IOA: " << ioa.get());
875 
876  // If the start of the new range matches the start of the last range, then
877  // extend the last range rather than trying to insert a new range.
878  // This can happen when a folder is tagged as `extensible' in IOVDbSvc.
879  EventIDRange r;
880  if (ccb->range (eidRange.start(), r) &&
881  eventIDMatch (r.start(), eidRange.start()))
882  {
883  if (ccb->extendLastRange (eidRange).isSuccess()) {
884  return StatusCode::SUCCESS;
885  }
886  }
887 
888  if (ccb->proxy() == nullptr) {
889  // nb. We don't want to be holding the IOVSvc lock here,
890  // as SGImplSvc can call to IOVSvc with the store lock held.
891  SG::DataProxy* dp = p_detStore->proxy (id.clid(), sgKey);
892  ATH_MSG_DEBUG( " found DataProxy " << dp << " for " << id );
893  ccb->setProxy(dp);
894  }
895 
896  // this will talk to the IOVDbSvc, get current run/event from EventInfo
897  // object, load
898  SG::DataProxy* dp = ccb->proxy();
899  DataObject* dobj(0);
900  void* v(0);
901 
902  if (dp->store()->createObj(dp->loader(), ioa.get(), dobj).isFailure()) {
903  ATH_MSG_ERROR(" could not create a new DataObject ");
904  return StatusCode::FAILURE;
905  } else {
906  ATH_MSG_DEBUG(" created new obj at " << dobj );
907 
908  v = SG::Storable_cast(dobj, id.clid());
909  }
910 
911  // Free the DataBucket that was created along with the object we read.
912  if (DataBucketBase* dbb = dynamic_cast<DataBucketBase*> (dobj)) {
913  dbb->relinquish();
914  delete dobj;
915  dobj = 0;
916  }
917 
918  // Some data objects may be reference counted by the address.
919  // CondCont will take ownership of the object, but doesn't
920  // do refcounting. We'll have gotten a reference via the Storable_cast
921  // above, so it should be ok ... unless CondCont deletes
922  // the new object immediately instead of inserting.
923  // In that case, when we delete the address, it will
924  // follow an invalid pointer. So be sure to delete
925  // the address before the object is added to CondCont.
926  ioa.reset();
927 
928  // DataObject *d2 = static_cast<DataObject*>(v);
929 
930  ATH_MSG_DEBUG( " SG::Storable_cast to obj: " << v );
931 
932  StatusCode sc = ccb->typelessInsert (eidRange, v);
933  if (!sc.isSuccess()) {
934  ATH_MSG_ERROR("unable to insert Object at " << v << " into CondCont "
935  << ccb->id() << " for range " << eidRange );
936  return StatusCode::FAILURE;
937  }
939  // Disable this for now... IOVDbSvc can sometimes produce overlapping
940  // ranges.
941  //ATH_MSG_ERROR ("IOV range overlap.");
942  //return StatusCode::FAILURE;
943  }
944 
945  return sc;
946 
947 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
beamspotman.r
def r
Definition: beamspotman.py:676
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
CallBackID
Definition: CallBackID.h:24
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
CondContBase::typelessInsert
virtual StatusCode typelessInsert(const EventIDRange &r, void *obj, const EventContext &ctx=Gaudi::Hive::currentContext())=0
Insert a new conditions object.
IIOVSvcTool.h
IIOVSvcTool::preLoadTAD
virtual StatusCode preLoadTAD(const SG::TransientAddress *)=0
IIOVSvcTool::setRangeInDB
virtual StatusCode setRangeInDB(const CLID &clid, const std::string &key, const IOVRange &range, const std::string &tag)=0
dqt_zlumi_alleff_HIST.iov
iov
Definition: dqt_zlumi_alleff_HIST.py:119
IOVRange
Validity Range object. Holds two IOVTimes (start and stop)
Definition: IOVRange.h:30
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DataBucketBase
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
Definition: DataBucketBase.h:24
IOVSvc::setRangeInDB
virtual StatusCode setRangeInDB(const CLID &clid, const std::string &key, const IOVRange &range, const std::string &tag) override
Set a particular IOVRange in db (and memory)
Definition: IOVSvc.cxx:499
IOVSvc::m_partialPreLoadData
BooleanProperty m_partialPreLoadData
Definition: IOVSvc.h:173
IOVSvc::getTool
IIOVSvcTool * getTool(const std::string &storeName, bool createIF=true)
Definition: IOVSvc.cxx:670
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
egammaEnergyPositionAllSamples::e1
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling
DataBucketBase.h
IOVSvc::p_detStore
ServiceHandle< StoreGateSvc > p_detStore
Definition: IOVSvc.h:179
IOVSvc::createCondObj
virtual StatusCode createCondObj(CondContBase *, const DataObjID &, const EventIDBase &) override
Definition: IOVSvc.cxx:834
defaultStore
const std::string defaultStore
Definition: IOVSvc.cxx:33
extractSporadic.c1
c1
Definition: extractSporadic.py:134
IOVInfiniteRange::infiniteMixed
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
Definition: IOVInfiniteRange.h:55
IOVSvc::m_lock
std::recursive_mutex m_lock
Definition: IOVSvc.h:184
SG::TransientAddress
Definition: TransientAddress.h:32
IOVSvc::reinitialize
virtual StatusCode reinitialize() override
Definition: IOVSvc.cxx:605
CondContBase::keyType
KeyType keyType() const
Return the key type for this container.
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
CondContBase::valid
virtual bool valid(const EventIDBase &t) const =0
Test to see if a given IOV time is mapped in the container.
IIOVDbSvc
Abstract interface to IOVDbSvc to access IOVRange and tag information.
Definition: IIOVDbSvc.h:38
IOVSvc::m_toolMap
toolMap m_toolMap
Definition: IOVSvc.h:170
IIOVDbSvc.h
Abstract interface to IOVDbSvc to access IOVRange and tag information.
IOVSvc::m_preLoadData
BooleanProperty m_preLoadData
Definition: IOVSvc.h:173
IIOVSvcTool::ignoreProxy
virtual void ignoreProxy(SG::DataProxy *proxy)=0
IIOVSvcTool::getTriggeredTools
virtual StatusCode getTriggeredTools(const std::string &key, std::set< std::string > &tools)=0
IOVSvc::getRange
virtual StatusCode getRange(const CLID &clid, const std::string &key, IOVRange &io) const override
Definition: IOVSvc.cxx:428
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IOVSvc::regFcn
virtual StatusCode regFcn(SG::DataProxy *dp, const CallBackID &c, const IOVSvcCallBackFcn &fcn, bool trigger=false) override
register callback functions
Definition: IOVSvc.cxx:516
IOVSvc::initialize
virtual StatusCode initialize() override
Definition: IOVSvc.cxx:93
IIOVSvcTool::deregProxy
virtual StatusCode deregProxy(SG::DataProxy *proxy)=0
IOVSvc::m_updateInterval
std::string m_updateInterval
Definition: IOVSvc.h:175
IIOVSvcTool
Definition: IIOVSvcTool.h:27
IOVTime
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
Definition: IOVTime.h:33
IOVSvc.h
IOVSvc::m_sortKeys
BooleanProperty m_sortKeys
Definition: IOVSvc.h:174
IOVSvc::p_toolSvc
ServiceHandle< IToolSvc > p_toolSvc
Definition: IOVSvc.h:177
IOVSvc::getStoreNames
virtual std::vector< std::string > getStoreNames() const override
Definition: IOVSvc.cxx:803
python.handimod.now
now
Definition: handimod.py:675
IOVSvc::getTriggeredTools
virtual StatusCode getTriggeredTools(const std::string &key, std::set< std::string > &tools, const std::string &storeName) override
return list of tools (or functions) that have been triggered by key will return FAILURE if no tools f...
Definition: IOVSvc.cxx:586
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
IOVSvc::getRangeFromDB
virtual StatusCode getRangeFromDB(const CLID &clid, const std::string &key, IOVRange &range, std::string &tag, std::unique_ptr< IOpaqueAddress > &ioa) const override
Get IOVRange from db for current event.
Definition: IOVSvc.cxx:446
IOVSvc::m_forceReset
BooleanProperty m_forceReset
Definition: IOVSvc.h:174
IIOVSvcTool::resetAllProxies
virtual void resetAllProxies()=0
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
CondContBase::range
virtual bool range(const EventIDBase &t, EventIDRange &r) const =0
Return the mapped validity range for an IOV time.
CondContBase::id
const DataObjID & id() const
Return CLID/key corresponding to this container.
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
IOVSvc::fullProxyName
std::string fullProxyName(const SG::DataProxy *proxy) const
Definition: IOVSvc.cxx:769
IIOVSvcTool::getStoreName
virtual const std::string & getStoreName() const =0
CondContBase
Base class for all conditions containers.
Definition: CondCont.h:140
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
IOVSvcCallBackFcn
boost::function< StatusCode(IOVSVC_CALLBACK_ARGS) > IOVSvcCallBackFcn
the type of an IOVSvc call back: it wraps both the method and the object the method is called on
Definition: IOVSvcDefs.h:58
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
IOVSvc::p_CLIDSvc
ServiceHandle< IClassIDSvc > p_CLIDSvc
Definition: IOVSvc.h:178
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IOVSvc::preLoadDataTAD
virtual StatusCode preLoadDataTAD(const SG::TransientAddress *, const std::string &storeName) override
supply a list of TADs whose data will be preloaded
Definition: IOVSvc.cxx:311
IIOVDbSvc::dropObject
virtual bool dropObject(const std::string &key, const bool resetCache=false)=0
run
Definition: run.py:1
IOVSvc::dropObjectFromDB
virtual StatusCode dropObjectFromDB(const CLID &clid, const std::string &key, const std::string &storeName) override
Drop the associated object from the db and trigger reload.
Definition: IOVSvc.cxx:389
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
IOVTime::setTimestamp
void setTimestamp(uint64_t timestamp) noexcept
Definition: IOVTime.cxx:72
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
IIOVSvcTool::getRangeFromDB
virtual StatusCode getRangeFromDB(const CLID &clid, const std::string &key, IOVRange &range, std::string &tag, std::unique_ptr< IOpaqueAddress > &ioa, const IOVTime &curTime) const =0
IIOVSvcTool::replaceProxy
virtual StatusCode replaceProxy(SG::DataProxy *pOld, SG::DataProxy *pNew)=0
IOVSvc::setRange
virtual StatusCode setRange(const CLID &clid, const std::string &key, IOVRange &) override
Update Range from dB.
Definition: IOVSvc.cxx:328
grepfile.sep
sep
Definition: grepfile.py:38
IOVInfiniteRange.h
tools
Definition: DataQuality/ZLumiScripts/python/tools/__init__.py:1
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
CondContBase::extendLastRange
virtual StatusCode extendLastRange(const EventIDRange &newRange, const EventContext &ctx=Gaudi::Hive::currentContext())=0
Extend the range of the last IOV.
CondContBase::KeyType::MIXED
@ MIXED
Mixed Run+lbn / timestamp container.
CondContBase::Category::isOverlap
static bool isOverlap(code_t code)
Helper to test whether a code is OVERLAP.
Definition: CondCont.cxx:242
IIOVSvcTool::getRange
virtual StatusCode getRange(const CLID &clid, const std::string &key, IOVRange &iov) const =0
IOVSvc::p_sgs
ServiceHandle< StoreGateSvc > p_sgs
Definition: IOVSvc.h:179
IOVSvc::regProxy
virtual StatusCode regProxy(SG::DataProxy *proxy, const std::string &key, const std::string &storeName) override
Subscribe method for DataProxy. key StoreGate key.
Definition: IOVSvc.cxx:130
python.PyAthena.v
v
Definition: PyAthena.py:154
python.DataFormatRates.c2
c2
Definition: DataFormatRates.py:123
IOVSvc::p_condSvc
ServiceHandle< ICondSvc > p_condSvc
Definition: IOVSvc.h:180
IIOVSvcTool::setStoreName
virtual void setStoreName(const std::string &storeName)=0
SG::Storable_cast
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:47
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
egammaEnergyPositionAllSamples::e2
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
Amg::intersect
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point of closest approach of two lines.
Definition: GeoPrimitivesHelpers.h:325
IOVSvc::IOVSvc
IOVSvc(const std::string &name, ISvcLocator *svc)
Definition: IOVSvc.cxx:66
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
IIOVSvcTool::regFcn
virtual StatusCode regFcn(SG::DataProxy *dp, const CallBackID &c, const IOVSvcCallBackFcn &fcn, bool trigger)=0
IOVSvc::~IOVSvc
virtual ~IOVSvc()
Definition: IOVSvc.cxx:87
DEBUG
#define DEBUG
Definition: page_access.h:11
IOVSvc::finalize
virtual StatusCode finalize() override
Definition: IOVSvc.cxx:118
IOVTime::setRunEvent
void setRunEvent(uint32_t run, uint32_t event) noexcept
Definition: IOVTime.cxx:96
IOVSvc::m_preLoadExtensibleFolders
BooleanProperty m_preLoadExtensibleFolders
Definition: IOVSvc.h:173
IIOVSvcTool::preLoadDataTAD
virtual StatusCode preLoadDataTAD(const SG::TransientAddress *)=0
IOVSvc::deregProxy
virtual StatusCode deregProxy(SG::DataProxy *proxy) override
Deregister a DataProxy with the service.
Definition: IOVSvc.cxx:205
CondContBase::setProxy
void setProxy(SG::DataProxy *)
Set the associated DataProxy.
Definition: CondCont.cxx:276
IAddressProvider.h
IIOVSvcTool::regProxy
virtual StatusCode regProxy(SG::DataProxy *proxy, const std::string &key)=0
IOVSvc::resetAllProxies
virtual void resetAllProxies() override
Definition: IOVSvc.cxx:819
CondContBase::proxy
SG::DataProxy * proxy()
Return the associated DataProxy, if any.
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
IOVSvc::createIOVTool
virtual StatusCode createIOVTool(const std::string &storeName) override
Definition: IOVSvc.cxx:660
SG::DataProxy
Definition: DataProxy.h:44
IOVSvc::replaceProxy
virtual StatusCode replaceProxy(SG::DataProxy *pOld, SG::DataProxy *pNew, const std::string &storeName) override
replace a registered DataProxy with a new version
Definition: IOVSvc.cxx:268
IOVSvc::m_preLoadRanges
BooleanProperty m_preLoadRanges
Definition: IOVSvc.h:173
python.compressB64.c
def c
Definition: compressB64.py:93
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
IOVSvc::preLoadTAD
virtual StatusCode preLoadTAD(const SG::TransientAddress *, const std::string &storeName) override
supply a list of TADs whose proxies will be preloaded
Definition: IOVSvc.cxx:290
IIOVSvcTool::setRange
virtual StatusCode setRange(const CLID &clid, const std::string &key, IOVRange &)=0
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
IOVSvc::ignoreProxy
virtual void ignoreProxy(const CLID &clid, const std::string &key, const std::string &storeName) override
ignore proxy
Definition: IOVSvc.cxx:247