ATLAS Offline Software
CondAlgX.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 #include "CondAlgX.h"
7 
9 
10 #include "GaudiKernel/ServiceHandle.h"
11 
12 #include "GaudiKernel/EventIDBase.h"
13 #include "GaudiKernel/EventIDRange.h"
14 
15 #include <thread>
16 #include <chrono>
17 #include <memory>
18 
19 CondAlgX::CondAlgX( const std::string& name,
20  ISvcLocator* pSvcLocator ) :
21  ::AthAlgorithm( name, pSvcLocator ),
22  m_cds("ASCIICondDbSvc",name)
23 {
24 }
25 
27 
29  ATH_MSG_DEBUG("initialize " << name());
30 
32 
33  ATH_CHECK( m_cds.retrieve() );
34 
37 
38  return StatusCode::SUCCESS;
39 }
40 
42  ATH_MSG_DEBUG("execute " << name());
43 
45  if (!evt.isValid()) {
46  ATH_MSG_ERROR ("Could not retrieve EventInfo");
47  return StatusCode::FAILURE;
48  }
49 
50  ATH_MSG_DEBUG(" EventInfo: r: " << evt->runNumber()
51  << " e: " << evt->eventNumber() );
52 
53 
55 
56  EventIDBase now(getContext().eventID());
57 
58  if (evt->eventNumber() == 10) {
59  std::this_thread::sleep_for(std::chrono::milliseconds( 500 ));
60  }
61 
62  // do we have a valid m_wch for current time?
63  if ( wch.isValid(now) ) {
64  ATH_MSG_DEBUG("CondHandle is already valid for " << now
65  << ". In theory this should not be called, but may happen"
66  << " if multiple concurrent events are being processed out of order.");
67 
68  } else {
69 
70  ATH_MSG_DEBUG(" CondHandle " << wch.key()
71  << " not valid. Getting new info for dbKey \""
72  << wch.dbKey() << "\" from CondDb");
73 
74  EventIDRange r;
76  if (m_cds->getRange(wch.dbKey(), getContext(), r, val).isFailure()) {
77  ATH_MSG_ERROR(" could not find dbKey \"" << wch.dbKey()
78  << "\" in CondSvc registry");
79  return StatusCode::FAILURE;
80  }
81 
82  CondDataObj* cdo = new CondDataObj( val );
83  if (wch.record(r, cdo).isFailure()) {
84  ATH_MSG_ERROR("could not record CondDataObj " << wch.key()
85  << " = " << *cdo
86  << " with EventRange " << r);
87  return StatusCode::FAILURE;
88  }
89  ATH_MSG_INFO("recorded new CDO " << wch.key() << " = " << *cdo
90  << " with range " << r);
91  }
92 
93 
94 
95  return StatusCode::SUCCESS;
96 
97 }
98 
beamspotman.r
def r
Definition: beamspotman.py:676
CondAlgX::initialize
virtual StatusCode initialize() override
Definition: CondAlgX.cxx:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IASCIICondDbSvc.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
CondAlgX::m_dbKey
Gaudi::Property< std::string > m_dbKey
Definition: CondAlgX.h:36
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
CondAlgX::m_cds
ServiceHandle< IASCIICondDbSvc > m_cds
Definition: CondAlgX.h:38
python.handimod.now
now
Definition: handimod.py:675
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
WriteCondHandle.h
SG::WriteCondHandle::dbKey
const std::string & dbKey() const
Definition: WriteCondHandle.h:87
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CondDataObj
Definition: CondDataObj.h:8
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
AthAlgorithm
Definition: AthAlgorithm.h:47
IASCIICondDbSvc::dbData_t
float dbData_t
Definition: IASCIICondDbSvc.h:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
CondAlgX::CondAlgX
CondAlgX(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CondAlgX.cxx:19
CondAlgX::~CondAlgX
virtual ~CondAlgX()
Definition: CondAlgX.cxx:26
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
CondAlgX.h
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
CondAlgX::m_evt
SG::ReadHandleKey< xAOD::EventInfo > m_evt
Definition: CondAlgX.h:32
CondAlgX::m_wchk
SG::WriteCondHandleKey< CondDataObj > m_wchk
Definition: CondAlgX.h:34
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SG::CondHandleKey::setDbKey
void setDbKey(const std::string &dbKey)
Definition: CondHandleKey.h:32
CondAlgX::execute
virtual StatusCode execute() override
Definition: CondAlgX.cxx:41