ATLAS Offline Software
CondAlgY.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 "CondAlgY.h"
8 
9 #include "GaudiKernel/ServiceHandle.h"
10 
11 #include <thread>
12 #include <chrono>
13 #include <memory>
14 
15 CondAlgY::CondAlgY( const std::string& name,
16  ISvcLocator* pSvcLocator ) :
17  ::AthAlgorithm( name, pSvcLocator ),
18  m_cds("ASCIICondDbSvc",name)
19 {
20 }
21 
23 
25  ATH_MSG_DEBUG("initialize " << name());
26 
27  ATH_CHECK( m_cds.retrieve() );
28 
31 
34 
35  return StatusCode::SUCCESS;
36 }
37 
39  ATH_MSG_DEBUG("execute " << name());
40 
41  EventIDBase now(getContext().eventID());
42 
45 
46  // do we have a valid m_wch for current time?
47  if ( !wch1.isValid(now) ) {
48 
49  ATH_MSG_DEBUG(" CondHandle " << wch1.key()
50  << " not valid. Getting new info for dbKey \""
51  << wch1.dbKey() << "\" from CondDb");
52 
53  EventIDRange r;
55  if (m_cds->getRange(wch1.dbKey(), getContext(), r, val).isFailure()) {
56  ATH_MSG_ERROR(" could not find dbKey \"" << wch1.dbKey()
57  << "\" in CondSvc registry");
58  return StatusCode::FAILURE;
59  }
60 
61  CondDataObjY* cdo = new CondDataObjY( val );
62  if (wch1.record(r, cdo).isFailure()) {
63  ATH_MSG_ERROR("could not record CondDataObjY " << wch1.key()
64  << " = " << *cdo
65  << " with EventRange " << r);
66  return StatusCode::FAILURE;
67  }
68  ATH_MSG_INFO("recorded new CDO " << wch1.key() << " = " << *cdo
69  << " with range " << r);
70  }
71 
72  // do we have a valid wch for current time?
73  if ( !wch2.isValid(now) ) {
74 
75  ATH_MSG_DEBUG(" CondHandle " << wch2.key()
76  << " not valid. Getting new info for dbKey \""
77  << wch2.dbKey() << "\" from CondDb");
78 
79  EventIDRange r;
81  if (m_cds->getRange(wch2.dbKey(), getContext(), r, val).isFailure()) {
82  ATH_MSG_ERROR(" could not find dbKey \"" << wch2.dbKey()
83  << "\" in CondSvc registry");
84  return StatusCode::FAILURE;
85  }
86 
87  CondDataObjY* cdo = new CondDataObjY( val );
88  if (wch2.record(r, cdo).isFailure()) {
89  ATH_MSG_ERROR("could not record CondDataObjY " << wch2.key()
90  << " = " << *cdo
91  << " with EventRange " << r);
92  return StatusCode::FAILURE;
93  }
94  ATH_MSG_INFO("recorded new CDO " << wch2.key() << " = " << *cdo
95  << " with range " << r);
96  }
97 
98  return StatusCode::SUCCESS;
99 
100 }
101 
beamspotman.r
def r
Definition: beamspotman.py:676
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IASCIICondDbSvc.h
CondAlgY::CondAlgY
CondAlgY(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CondAlgY.cxx:15
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
CondAlgY::execute
virtual StatusCode execute() override
Definition: CondAlgY.cxx:38
CondAlgY::initialize
virtual StatusCode initialize() override
Definition: CondAlgY.cxx:24
CondDataObjY
Definition: CondDataObjY.h:8
CondAlgY::m_dbk1
Gaudi::Property< std::string > m_dbk1
Definition: CondAlgY.h:32
python.handimod.now
now
Definition: handimod.py:675
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CondAlgY::m_cds
ServiceHandle< IASCIICondDbSvc > m_cds
Definition: CondAlgY.h:35
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
CondAlgY::m_wch2
SG::WriteCondHandleKey< CondDataObjY > m_wch2
Definition: CondAlgY.h:30
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CondAlgY::~CondAlgY
virtual ~CondAlgY()
Definition: CondAlgY.cxx:22
CondAlgY.h
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SG::CondHandleKey::setDbKey
void setDbKey(const std::string &dbKey)
Definition: CondHandleKey.h:32
CondAlgY::m_wch1
SG::WriteCondHandleKey< CondDataObjY > m_wch1
Definition: CondAlgY.h:29
CondAlgY::m_dbk2
Gaudi::Property< std::string > m_dbk2
Definition: CondAlgY.h:33