ATLAS Offline Software
IOVSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 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,
449  const EventIDBase& now) const {
450 
451  std::lock_guard<std::recursive_mutex> lock(m_lock);
452 
453  IIOVSvcTool *ist = getTool( clid, key );
454  if (ist == 0) {
455  ATH_MSG_ERROR( "getRangeFromDB: proxy for "
456  << fullProxyName(clid,key) << " not registered" );
457  return StatusCode::FAILURE;
458  } else {
459 
460  uint32_t event = now.lumi_block();
461  uint32_t run = now.run_number();
462  IOVTime curTime;
463  curTime.setRunEvent(run,event);
464  // get ns timestamp from event
465  curTime.setTimestamp(1000000000L*static_cast<uint64_t>(now.time_stamp()) + now.time_stamp_ns_offset());
466 
467 
468  return ist->getRangeFromDB( clid, key, range, tag, ioa, curTime );
469  }
470 
471 }
472 
473 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
474 
475 StatusCode
476 IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key,
477  const IOVTime& time, IOVRange& range,
478  std::string& tag,
479  std::unique_ptr<IOpaqueAddress>& ioa) const {
480 
481  std::lock_guard<std::recursive_mutex> lock(m_lock);
482 
483  IIOVSvcTool *ist = getTool( clid, key );
484  if (ist == 0) {
485  ATH_MSG_ERROR( "getRangeFromDB: proxy for "
486  << fullProxyName(clid, key) << " not registered" );
487  return StatusCode::FAILURE;
488  } else {
489  return ist->getRangeFromDB( clid, key, time, range, tag, ioa );
490  }
491 
492 }
493 
494 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
495 
496 StatusCode
497 IOVSvc::setRangeInDB(const CLID& clid, const std::string& key,
498  const IOVRange& range, const std::string &tag) {
499 
500  IIOVSvcTool *ist = getTool( clid, key );
501  if (ist == 0) {
502  ATH_MSG_ERROR( "setRangeInDB: proxy for "
503  << fullProxyName(clid,key) << " not registered" );
504  return StatusCode::FAILURE;
505  } else {
506  return ist->setRangeInDB( clid, key, range, tag );
507  }
508 
509 }
510 
511 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
512 
513 StatusCode
515  const CallBackID& c,
516  const IOVSvcCallBackFcn& fcn,
517  bool trigger) {
518 
519  IIOVSvcTool *ist = getTool( dp );
520  if (ist == 0) {
521  ATH_MSG_ERROR( "regFcn: no IOVSvcTool found containing DataProxy "
522  << fullProxyName( dp )
523  << "-> Need to bind DataHandle first" );
524  return StatusCode::FAILURE;
525  } else {
526  return ist->regFcn( dp, c, fcn, trigger );
527  }
528 
529 }
530 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
531 
532 StatusCode
534  const CallBackID& c2, const IOVSvcCallBackFcn& fcn2,
535  bool trigger) {
536 
537 
538  if (c1 == c2) {
539  ATH_MSG_ERROR( "Cannot register 2nd callback function and assocaited"
540  << " object with itself" );
541  return StatusCode::FAILURE;
542  }
543 
544 
545  IIOVSvcTool *ist = getTool( c1 );
546  if (ist == 0) {
547  ATH_MSG_ERROR( "CallBack function \"" << c2.name()
548  << "\" cannot be registered since function \"" << c1.name()
549  << "\" has not been registered first" );
550  return StatusCode::FAILURE;
551  } else {
552  return ist->regFcn(c1, c2, fcn2, trigger);
553  }
554 
555 }
556 
557 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
558 
559 StatusCode
560 IOVSvc::regFcn(const std::string& toolName,
561  const CallBackID& c2, const IOVSvcCallBackFcn& fcn2,
562  bool trigger) {
563 
564  IAlgTool *ia;
565  if ( p_toolSvc->retrieveTool(toolName, ia, 0, false).isFailure() ) {
566  ATH_MSG_ERROR( "AlgTool " << toolName << " has not yet been created"
567  << " and thus cannot be registered" );
568  return StatusCode::FAILURE;
569  }
570 
571  IIOVSvcTool *ist = getTool( ia );
572  if (ist == 0) {
573  ATH_MSG_ERROR( "No callback registered with AlgTool " << toolName );
574  return StatusCode::FAILURE;
575  } else {
576  return ist->regFcn(ia, c2, fcn2, trigger);
577  }
578 
579 }
580 
581 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
582 
584 IOVSvc::getTriggeredTools(const std::string& key,
585  std::set<std::string>& tools,
586  const std::string& storeName) {
587 
588  IIOVSvcTool *ist = getTool( storeName, false );
589  if (ist == 0) {
590  ATH_MSG_ERROR( "getTriggeredTools: no store \"" << storeName
591  << "\" associated with any IOVSvcTool" );
592  return StatusCode::FAILURE;
593  } else {
594  return ist->getTriggeredTools(key, tools);
595  }
596 
597 }
598 
599 
600 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
601 
602 StatusCode
604 {
605  // Set flag to reset all proxies
606  StatusCode sc;
607  toolMap::iterator itr = m_toolMap.begin();
608  for ( ; itr!=m_toolMap.end(); ++itr) {
609  sc &= itr->second->reinitialize();
610  }
611  return sc;
612 
613 }
614 
615 
616 
617 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
618 
620 IOVSvc::createIOVTool( const std::string& storeName, IIOVSvcTool*& ist ) {
621 
622  std::string store(storeName);
623  std::string toolName("IOVSvcTool");
624  if (storeName == "default") store = defaultStore;
625 
626  // Append the store name if not default
627  if (store != defaultStore) {
628  toolName += '_';
629  toolName += store;
630  }
631 
632  ATH_MSG_DEBUG( "Creating " << toolName << " associated with store \"" << store
633  << "\"" );
634 
635  toolMap::iterator itr = m_toolMap.find( store );
636  if ( itr == m_toolMap.end() ) {
637  ist = nullptr;
638  if (p_toolSvc->retrieveTool( "IOVSvcTool/" + toolName, ist, this ).isFailure()) {
639  ATH_MSG_ERROR( "Unable to create IOVSvcTool associated with store \""
640  << store << "\"" );
641  return StatusCode::FAILURE;
642  } else {
643  m_toolMap[ store ] = ist;
644  ist->setStoreName( store );
645  return StatusCode::SUCCESS;
646  }
647  } else {
648  ATH_MSG_INFO( "an IOVSvcTool already exists associated with store \""
649  << store << "\"" );
650  ist = itr->second;
651  return StatusCode::SUCCESS;
652  }
653 
654 }
655  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
656 
658 IOVSvc::createIOVTool( const std::string& storeName )
659 {
660  IIOVSvcTool* ist = nullptr;
661  return createIOVTool (storeName, ist);
662 }
663 
664 
665 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
666 
667 IIOVSvcTool*
668 IOVSvc::getTool( const std::string& storeName, bool createIF ) {
669 
670  std::string store(storeName);
671  if (storeName == "default") {
673  }
674 
675  toolMap::const_iterator itr = m_toolMap.find( store );
676  IIOVSvcTool *ist(0);
677  if ( itr == m_toolMap.end() ) {
678  ATH_MSG_INFO( "No IOVSvcTool associated with store \"" << store
679  << "\"" );
680 
681  if (createIF) {
682  createIOVTool(store, ist).ignore();
683  }
684 
685  } else {
686  ist = itr->second;
687  }
688 
689  return ist;
690 }
691 
692 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
693 
694 IIOVSvcTool*
696 
697 
698  IIOVSvcTool *ist(0);
699  toolMap::const_iterator itr = m_toolMap.begin();
700  for (; itr != m_toolMap.end(); ++itr) {
701  if (itr->second->holdsProxy( proxy )) {
702  ist = itr->second;
703  return ist;
704  }
705  }
706 
707  return ist;
708 
709 }
710 
711 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
712 
713 IIOVSvcTool*
714 IOVSvc::getTool( const CLID& clid, const std::string& key ) const {
715 
716  IIOVSvcTool *ist(0);
717  toolMap::const_iterator itr = m_toolMap.begin();
718  for (; itr != m_toolMap.end(); ++itr) {
719  if (itr->second->holdsProxy( clid, key )) {
720  ist = itr->second;
721  return ist;
722  }
723  }
724 
725  return ist;
726 
727 }
728 
729 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
730 
731 IIOVSvcTool*
732 IOVSvc::getTool( const CallBackID& c1 ) const {
733 
734  IIOVSvcTool *ist(0);
735  toolMap::const_iterator itr = m_toolMap.begin();
736  for (; itr != m_toolMap.end(); ++itr) {
737  if (itr->second->holdsCallback( c1 )) {
738  ist = itr->second;
739  return ist;
740  }
741  }
742 
743  return ist;
744 
745 }
746 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
747 
748 IIOVSvcTool*
749 IOVSvc::getTool( const IAlgTool* ia ) const {
750 
751  IIOVSvcTool *ist(0);
752  toolMap::const_iterator itr = m_toolMap.begin();
753  for (; itr != m_toolMap.end(); ++itr) {
754  if (itr->second->holdsAlgTool( ia )) {
755  ist = itr->second;
756  return ist;
757  }
758  }
759 
760  return ist;
761 
762 }
763 
764 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
765 
766 std::string
768 
769  return fullProxyName(dp->clID(), dp->name());
770 
771 }
772 
773 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
774 
775 std::string
776 IOVSvc::fullProxyName( const CLID& clid, const std::string& key ) const {
777 
778  std::string fullname, tname;
779  if (p_CLIDSvc->getTypeNameOfID( clid, tname ).isFailure()) {
780  fullname = "[";
781  fullname += std::to_string(clid);
782  fullname += '/';
783  fullname += key;
784  fullname += ']';
785  } else {
786  fullname = "[";
787  fullname += tname;
788  fullname += ':';
789  fullname += std::to_string(clid);
790  fullname += '/';
791  fullname += key;
792  fullname += ']';
793  }
794 
795  return fullname;
796 }
797 
798 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
799 
800 std::vector<std::string>
802 
803  std::vector<std::string> stores;
804 
805  toolMap::const_iterator itr = m_toolMap.begin();
806  for( ; itr!=m_toolMap.end(); ++itr) {
807  stores.push_back( itr->first );
808  }
809 
810  return stores;
811 
812 }
813 
814 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
815 
816 void
818 
819  toolMap::iterator itr = m_toolMap.begin();
820  for (; itr!= m_toolMap.end(); ++itr) {
821  IIOVSvcTool* ist = itr->second;
822  ATH_MSG_DEBUG( "resetting all proxies for store \""
823  << ist->getStoreName() << "\"" );
824  ist->resetAllProxies();
825  }
826 
827 }
828 
829 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
830 
831 StatusCode
832 IOVSvc::createCondObj(CondContBase* ccb, const DataObjID& id,
833  const EventIDBase& now) {
834 
835  ATH_MSG_DEBUG("createCondObj: id: " << id << " t: " << now << " valid: "
836  << ccb->valid(now));
837 
838  if (ccb->valid(now)) {
839  if (msgLvl(MSG::DEBUG)) {
840  EventIDRange r;
841  ccb->range(now,r);
842  ATH_MSG_DEBUG( " range " << r << " for " << id
843  << " is still valid at " << now );
844  }
845  return StatusCode::SUCCESS;
846  }
847 
848  IOVTime t(now.run_number(), now.lumi_block(), (long long)now.time_stamp()*1000000000+now.time_stamp_ns_offset());
849  IOVRange range;
850  std::string tag;
851  // remove storename from key
852  std::string sgKey = id.key();
853  auto sep = sgKey.find('+');
854  if (sep != std::string::npos) {
855  sgKey.erase(0,sep+1);
856  }
857 
858  std::unique_ptr<IOpaqueAddress> ioa;
859  if (getRangeFromDB(id.clid(), sgKey, t, range, tag, ioa).isFailure()) {
860  ATH_MSG_ERROR( "unable to get range from db for time " << t << " clid "
861  << id.clid() << " " << sgKey );
862  return StatusCode::FAILURE;
863  }
864 
865  //In case the conditons-container is a 'mixed' type, we need both run/lb and time-stamps in the range.
866  //Assume infinite IOV in the other dimension
867  EventIDRange eidRange(range);
868  if (ccb->keyType()==CondContBase::KeyType::MIXED) {
870  }
871  ATH_MSG_DEBUG( " new range for ID " << id << " : " << range
872  << " IOA: " << ioa.get());
873 
874  // If the start of the new range matches the start of the last range, then
875  // extend the last range rather than trying to insert a new range.
876  // This can happen when a folder is tagged as `extensible' in IOVDbSvc.
877  EventIDRange r;
878  if (ccb->range (eidRange.start(), r) &&
879  eventIDMatch (r.start(), eidRange.start()))
880  {
881  if (ccb->extendLastRange (eidRange).isSuccess()) {
882  return StatusCode::SUCCESS;
883  }
884  }
885 
886  if (ccb->proxy() == nullptr) {
887  // nb. We don't want to be holding the IOVSvc lock here,
888  // as SGImplSvc can call to IOVSvc with the store lock held.
889  SG::DataProxy* dp = p_detStore->proxy (id.clid(), sgKey);
890  ATH_MSG_DEBUG( " found DataProxy " << dp << " for " << id );
891  ccb->setProxy(dp);
892  }
893 
894  // this will talk to the IOVDbSvc, get current run/event from EventInfo
895  // object, load
896  SG::DataProxy* dp = ccb->proxy();
897  DataObject* dobj(0);
898  void* v(0);
899 
900  if (dp->store()->createObj(dp->loader(), ioa.get(), dobj).isFailure()) {
901  ATH_MSG_ERROR(" could not create a new DataObject ");
902  return StatusCode::FAILURE;
903  } else {
904  ATH_MSG_DEBUG(" created new obj at " << dobj );
905 
906  v = SG::Storable_cast(dobj, id.clid());
907  }
908 
909  // Free the DataBucket that was created along with the object we read.
910  if (DataBucketBase* dbb = dynamic_cast<DataBucketBase*> (dobj)) {
911  dbb->relinquish();
912  delete dobj;
913  dobj = 0;
914  }
915 
916  // Some data objects may be reference counted by the address.
917  // CondCont will take ownership of the object, but doesn't
918  // do refcounting. We'll have gotten a reference via the Storable_cast
919  // above, so it should be ok ... unless CondCont deletes
920  // the new object immediately instead of inserting.
921  // In that case, when we delete the address, it will
922  // follow an invalid pointer. So be sure to delete
923  // the address before the object is added to CondCont.
924  ioa.reset();
925 
926  // DataObject *d2 = static_cast<DataObject*>(v);
927 
928  ATH_MSG_DEBUG( " SG::Storable_cast to obj: " << v );
929 
930  StatusCode sc = ccb->typelessInsert (eidRange, v);
931  if (!sc.isSuccess()) {
932  ATH_MSG_ERROR("unable to insert Object at " << v << " into CondCont "
933  << ccb->id() << " for range " << eidRange );
934  return StatusCode::FAILURE;
935  }
937  // Disable this for now... IOVDbSvc can sometimes produce overlapping
938  // ranges.
939  //ATH_MSG_ERROR ("IOV range overlap.");
940  //return StatusCode::FAILURE;
941  }
942 
943  return sc;
944 
945 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SGTest::store
TestStore store
Definition: TestStore.cxx:23
beamspotman.r
def r
Definition: beamspotman.py:672
CallBackID
Definition: CallBackID.h:24
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:842
CondContBase::typelessInsert
virtual StatusCode typelessInsert(const EventIDRange &r, void *obj, const EventContext &ctx=Gaudi::Hive::currentContext())=0
Insert a new conditions object.
IOVSvc::getRangeFromDB
virtual StatusCode getRangeFromDB(const CLID &clid, const std::string &key, IOVRange &range, std::string &tag, std::unique_ptr< IOpaqueAddress > &ioa, const EventIDBase &now) const override
Get IOVRange from db for current event.
Definition: IOVSvc.cxx:446
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:407
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:497
IOVSvc::m_partialPreLoadData
BooleanProperty m_partialPreLoadData
Definition: IOVSvc.h:174
IOVSvc::getTool
IIOVSvcTool * getTool(const std::string &storeName, bool createIF=true)
Definition: IOVSvc.cxx:668
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:180
IOVSvc::createCondObj
virtual StatusCode createCondObj(CondContBase *, const DataObjID &, const EventIDBase &) override
Definition: IOVSvc.cxx:832
defaultStore
const std::string defaultStore
Definition: IOVSvc.cxx:33
extractSporadic.c1
c1
Definition: extractSporadic.py:133
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:185
SG::TransientAddress
Definition: TransientAddress.h:32
IOVSvc::reinitialize
virtual StatusCode reinitialize() override
Definition: IOVSvc.cxx:603
python.RatesEmulationExample.lock
lock
Definition: RatesEmulationExample.py:148
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:171
IIOVDbSvc.h
Abstract interface to IOVDbSvc to access IOVRange and tag information.
IOVSvc::m_preLoadData
BooleanProperty m_preLoadData
Definition: IOVSvc.h:174
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:514
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:176
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:175
IOVSvc::p_toolSvc
ServiceHandle< IToolSvc > p_toolSvc
Definition: IOVSvc.h:178
IOVSvc::getStoreNames
virtual std::vector< std::string > getStoreNames() const override
Definition: IOVSvc.cxx:801
python.handimod.now
now
Definition: handimod.py:674
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:584
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
IOVSvc::m_forceReset
BooleanProperty m_forceReset
Definition: IOVSvc.h:175
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:767
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:194
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:179
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:240
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:180
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:181
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:37
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 B' along the line B that's closest to a second line A.
Definition: GeoPrimitivesHelpers.h:347
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:174
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:817
CondContBase::proxy
SG::DataProxy * proxy()
Return the associated DataProxy, if any.
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
IOVSvc::createIOVTool
virtual StatusCode createIOVTool(const std::string &storeName) override
Definition: IOVSvc.cxx:658
SG::DataProxy
Definition: DataProxy.h:45
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:174
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
python.SystemOfUnits.L
float L
Definition: SystemOfUnits.py:92
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