ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArGeoModel
LArGeoCode
src
DatabaseAccessTool.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
#include "
LArGeoCode/DatabaseAccessTool.h
"
6
#include "
RDBAccessSvc/IRDBAccessSvc.h
"
7
#include "
RDBAccessSvc/IRDBRecord.h
"
8
#include "
RDBAccessSvc/IRDBRecordset.h
"
9
#include "
GeoModelInterfaces/IGeoModelSvc.h
"
10
#include "GaudiKernel/ISvcLocator.h"
11
#include "GaudiKernel/Bootstrap.h"
12
#include <map>
13
14
class
DatabaseAccessTool::Clockwork
{
15
16
public
:
17
18
IRDBAccessSvc
*
pAccessSvc
=
nullptr
;
19
std::string
detectorKey
;
20
std::string
detectorNode
;
21
std::map<std::string, IRDBRecordset_ptr>
recMap
;
22
};
23
24
25
DatabaseAccessTool::DatabaseAccessTool
()
26
:
m_cw
(new
Clockwork
())
27
{
28
ISvcLocator *svcLocator=Gaudi::svcLocator();
29
SmartIF<IGeoModelSvc> geoModel{svcLocator->service(
"GeoModelSvc"
)};
30
if
(!geoModel.isValid()) {
31
throw
std::runtime_error (
"Cannot locate GeoModelSvc!!"
);
32
}
33
34
SmartIF<IRDBAccessSvc> rdbAccess{svcLocator->service(
"RDBAccessSvc"
)};
35
if
(!rdbAccess.isValid()) {
36
throw
std::runtime_error (
"Cannot locate RDBAccessSvc!!"
);
37
}
38
m_cw
->pAccessSvc = rdbAccess.get();
39
40
// Obtain the geometry version information:
41
42
std::string AtlasVersion = geoModel->atlasVersion();
43
std::string LArVersion = geoModel->LAr_VersionOverride();
44
45
m_cw
->detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion;
46
m_cw
->detectorNode = LArVersion.empty() ?
"ATLAS"
:
"LAr"
;
47
48
}
49
50
DatabaseAccessTool::~DatabaseAccessTool
()
51
{
52
delete
m_cw
;
53
}
54
55
double
DatabaseAccessTool::getDouble
(
const
std::string & TableName,
56
const
std::string & FallbackVersion,
57
const
std::string & ColumnName)
const
{
58
59
std::map<std::string, IRDBRecordset_ptr>::iterator m=
m_cw
->recMap.find(TableName);
60
61
IRDBRecordset_ptr
rec = (m==
m_cw
->recMap.end()) ?
m_cw
->pAccessSvc->getRecordsetPtr(TableName,
m_cw
->detectorKey,
m_cw
->detectorNode): (*m).second;
62
if
(rec->
size
()==0) {
63
rec =
m_cw
->pAccessSvc->getRecordsetPtr(TableName,FallbackVersion);
64
if
(rec->
size
()==0) {
65
throw
std::runtime_error((std::string(
"Cannot find the Table: "
) + TableName).c_str());
66
}
67
}
68
double
retval = (*rec)[0]->getDouble(ColumnName);
69
if
(m==
m_cw
->recMap.end()) {
70
m_cw
->recMap[TableName]=std::move(rec);
71
}
72
return
retval;
73
}
DatabaseAccessTool.h
IGeoModelSvc.h
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition
IRDBAccessSvc.h:30
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
DatabaseAccessTool::Clockwork
Definition
DatabaseAccessTool.cxx:14
DatabaseAccessTool::Clockwork::pAccessSvc
IRDBAccessSvc * pAccessSvc
Definition
DatabaseAccessTool.cxx:18
DatabaseAccessTool::Clockwork::recMap
std::map< std::string, IRDBRecordset_ptr > recMap
Definition
DatabaseAccessTool.cxx:21
DatabaseAccessTool::Clockwork::detectorKey
std::string detectorKey
Definition
DatabaseAccessTool.cxx:19
DatabaseAccessTool::Clockwork::detectorNode
std::string detectorNode
Definition
DatabaseAccessTool.cxx:20
DatabaseAccessTool::DatabaseAccessTool
DatabaseAccessTool()
Definition
DatabaseAccessTool.cxx:25
DatabaseAccessTool::~DatabaseAccessTool
~DatabaseAccessTool()
Definition
DatabaseAccessTool.cxx:50
DatabaseAccessTool::getDouble
double getDouble(const std::string &TableName, const std::string &FallbackVersion, const std::string &ColumnName) const
Definition
DatabaseAccessTool.cxx:55
DatabaseAccessTool::m_cw
Clockwork * m_cw
Definition
DatabaseAccessTool.h:41
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition
IRDBAccessSvc.h:45
IRDBRecordset::size
virtual unsigned int size() const =0
Generated on
for ATLAS Offline Software by
1.17.0