ATLAS Offline Software
Loading...
Searching...
No Matches
DetDescrDBEnvelopeSvc Class Reference

#include <DetDescrDBEnvelopeSvc.h>

Inheritance diagram for DetDescrDBEnvelopeSvc:
Collaboration diagram for DetDescrDBEnvelopeSvc:

Public Member Functions

 DetDescrDBEnvelopeSvc (const std::string &name, ISvcLocator *svc)
 public AthService constructor
 ~DetDescrDBEnvelopeSvc ()
 Destructor.
virtual StatusCode initialize () override
 AthService initialize method.
virtual const RZPairVectorgetRZBoundary (AtlasDetDescr::AtlasRegion region) const override
 return a vector of (r,z) pairs, defining the respective envelope
virtual const RZPairVectorgetRPositiveZBoundary (AtlasDetDescr::AtlasRegion region) const override
 return a vector of (r,z) pairs, defining the envelope on the z>0 region

Private Member Functions

StatusCode retrieveRZBoundaryOptionalFallback (const std::string &dbNode, const FallbackDoubleVector &r, const FallbackDoubleVector &z, RZPairVector &rzVec)
 retrieve and store the (r,z) values locally for the given DB node.
StatusCode retrieveRZBoundary (const std::string &node, RZPairVector &rzVec)
 retrieve and store the (r,z) values locally for the given DB node
StatusCode fallbackRZBoundary (const FallbackDoubleVector &r, const FallbackDoubleVector &z, RZPairVector &rzVec)
 use the fallback approach (python arguments) to set the (r,z) values
bool enableFallback ()
 enable fallback solution:

Private Attributes

ServiceHandle< IRDBAccessSvcm_dbAccess {this, "RDBAccessSvc", "RDBAccessSvc"}
 the DetectorDescription database access method
ServiceHandle< IGeoModelSvcm_geoModelSvc {this, "GeoModelSvc", "GeoModelSvc"}
 ATLAS GeoModel.
std::string m_atlasNode {"ATLAS"}
 main DDDB node for the ATLAS detector
std::string m_atlasVersionTag {"AUTO"}
std::array< StringProperty, AtlasDetDescr::fNumAtlasRegionsm_node
 the names of the DB nodes for the respective AtlasRegion
RZPairVector m_rz [AtlasDetDescr::fNumAtlasRegions] {}
 internal (r,z) representation, one RZPairVector for each AtlasRegion
RZPairVector m_rposz [AtlasDetDescr::fNumAtlasRegions] {}
 internal (r,z) representation for the positive z-side only, one RZPairVector for each AtlasRegion
Gaudi::Property< bool > m_allowFallback {this, "EnableFallback", false}
 fallback solution, in case something goes wrong with the DB
bool m_doFallback {false}
std::array< DoubleArrayProperty, AtlasDetDescr::fNumAtlasRegionsm_fallbackR
std::array< DoubleArrayProperty, AtlasDetDescr::fNumAtlasRegionsm_fallbackZ

Detailed Description

Definition at line 34 of file DetDescrDBEnvelopeSvc.h.

Constructor & Destructor Documentation

◆ DetDescrDBEnvelopeSvc()

DetDescrDBEnvelopeSvc::DetDescrDBEnvelopeSvc ( const std::string & name,
ISvcLocator * svc )

public AthService constructor

Constructor.

Definition at line 26 of file DetDescrDBEnvelopeSvc.cxx.

26 :
27 base_class(name,svc)
28{
29}

◆ ~DetDescrDBEnvelopeSvc()

DetDescrDBEnvelopeSvc::~DetDescrDBEnvelopeSvc ( )
default

Destructor.

Member Function Documentation

◆ enableFallback()

bool DetDescrDBEnvelopeSvc::enableFallback ( )
private

enable fallback solution:

enable fallback solution (if allowed)

Returns
true if fallback mode is allowed, false if no fallback allowed

Definition at line 34 of file DetDescrDBEnvelopeSvc.cxx.

35{
36 // fallback solution is already enabled
37 if (m_doFallback) return true;
38
39 // fallback solution not enabled yet
40 if (m_allowFallback) {
41 ATH_MSG_INFO("Unable to retrieve envelope definitions from DDDB. Enabling Python-based fallback definitions.");
42 m_doFallback=true;
43 } else {
44 ATH_MSG_ERROR("Unable to retrieve envelope definitions from DDDB and Python-based fallback definitions are disabled.");
45 m_doFallback = false;
46 }
47
48 return m_doFallback;
49}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
Gaudi::Property< bool > m_allowFallback
fallback solution, in case something goes wrong with the DB

◆ fallbackRZBoundary()

StatusCode DetDescrDBEnvelopeSvc::fallbackRZBoundary ( const FallbackDoubleVector & r,
const FallbackDoubleVector & z,
RZPairVector & rzVec )
private

use the fallback approach (python arguments) to set the (r,z) values

retrieve and store the (r,z) values locally for the given DB node

Definition at line 223 of file DetDescrDBEnvelopeSvc.cxx.

226{
227 unsigned short len = r.size();
228
229 // r and z vectors must have same length
230 if ( len != z.size() ) {
231 ATH_MSG_ERROR("Unable to construct fallback envelope definition in (r,z) space, as the provided r and z vectors have different length");
232 rzVec.clear();
233 return StatusCode::FAILURE;
234 }
235
236 // loop over the given pairs of (r,z) values
237 for ( unsigned short pos=0; pos<len; ++pos) {
238
239 // read-in (r,z) duplet
240 double curR = r[pos];
241 double curZ = z[pos];
242 // store (r,z) duplet locally
243 rzVec.emplace_back(curR, curZ );
244 }
245
246 return StatusCode::SUCCESS;
247}
#define z
int r
Definition globals.cxx:22

◆ getRPositiveZBoundary()

virtual const RZPairVector & DetDescrDBEnvelopeSvc::getRPositiveZBoundary ( AtlasDetDescr::AtlasRegion region) const
inlineoverridevirtual

return a vector of (r,z) pairs, defining the envelope on the z>0 region

Definition at line 50 of file DetDescrDBEnvelopeSvc.h.

50{ return m_rposz[region]; }
RZPairVector m_rposz[AtlasDetDescr::fNumAtlasRegions]
internal (r,z) representation for the positive z-side only, one RZPairVector for each AtlasRegion

◆ getRZBoundary()

virtual const RZPairVector & DetDescrDBEnvelopeSvc::getRZBoundary ( AtlasDetDescr::AtlasRegion region) const
inlineoverridevirtual

return a vector of (r,z) pairs, defining the respective envelope

Definition at line 47 of file DetDescrDBEnvelopeSvc.h.

47{ return m_rz[region]; }
RZPairVector m_rz[AtlasDetDescr::fNumAtlasRegions]
internal (r,z) representation, one RZPairVector for each AtlasRegion

◆ initialize()

StatusCode DetDescrDBEnvelopeSvc::initialize ( )
overridevirtual

AthService initialize method.

Athena AthService initialize hook.

Definition at line 52 of file DetDescrDBEnvelopeSvc.cxx.

53{
54 ATH_MSG_INFO("Initializing ...");
55
56 // retrieve DataBase access service
57 ServiceHandle<IGeoDbTagSvc> geoDbTag("GeoDbTagSvc",name());
58 ATH_CHECK(geoDbTag.retrieve());
59
60 m_dbAccess.setName(geoDbTag->getParamSvcName());
61 if ( m_dbAccess.retrieve().isFailure()) {
62 ATH_MSG_ERROR("Could not locate RDBAccessSvc");
63 if ( !enableFallback()) return StatusCode::FAILURE;
64 }
65
66 // retrieve the GeoModelSvc
67 if ( !m_doFallback && (m_geoModelSvc.retrieve().isFailure()) ) {
68 ATH_MSG_ERROR("Could not locate GeoModelSvc");
69 if ( !enableFallback()) return StatusCode::FAILURE;
70 }
71
72
73 // (#) use the DB to retrieve the RZ values
74 if ( !m_doFallback) {
75 // geo model tag
76 m_atlasVersionTag = m_geoModelSvc->atlasVersion();
77 if( m_atlasVersionTag == "AUTO") m_atlasVersionTag = "ATLAS-00";
78
79 // cache the volume definitions locally
80 for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
82 m_fallbackR[region].value(),
83 m_fallbackZ[region].value(),
84 m_rposz[region] );
85
86 if (sc.isFailure()) {
87 ATH_MSG_ERROR("Unable to retrieve subdetector envelope for detector region '" <<
89 return StatusCode::FAILURE;
90 }
91 }
92
93 }
94
95 // (#) or use the fallback solution right away
96 else {
97 // cache the volume definitions locally
98 for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
99 StatusCode sc = fallbackRZBoundary( m_fallbackR[region].value(), m_fallbackZ[region].value(), m_rposz[region] );
100
101 if (sc.isFailure()) {
102 ATH_MSG_ERROR("Unable to retrieve sub-detector envelope in (r,z)-space for detector region '" <<
104 return StatusCode::FAILURE;
105 }
106 }
107 }
108
109 // mirror the RZPairs provided in m_rposz to describe all corner points
110 // in (r,z) space for each envelope volume
111 for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
112 ATH_MSG_VERBOSE( "Envelope: positive-z region=" << region);
113 mirrorRZ( m_rposz[region], m_rz[region] );
114 }
115
116 // debugging output:
117 if (msgLvl(MSG::VERBOSE)) {
118 for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
119 int numEntries = m_rz[region].size();
120 ATH_MSG_VERBOSE( "Envelope: complete region=" << region);
121 for ( int num = 0; num<numEntries; num++) {
122 ATH_MSG_VERBOSE(" pos=" << num << " r=" << m_rz[region][num].first << " z="<< m_rz[region][num].second);
123 }
124 }
125 }
126
127 ATH_MSG_INFO("Initialize successful.");
128
129 return StatusCode::SUCCESS;
130}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
static Double_t sc
static const char * getName(int region)
bool enableFallback()
enable fallback solution:
std::array< DoubleArrayProperty, AtlasDetDescr::fNumAtlasRegions > m_fallbackR
ServiceHandle< IGeoModelSvc > m_geoModelSvc
ATLAS GeoModel.
std::array< StringProperty, AtlasDetDescr::fNumAtlasRegions > m_node
the names of the DB nodes for the respective AtlasRegion
StatusCode fallbackRZBoundary(const FallbackDoubleVector &r, const FallbackDoubleVector &z, RZPairVector &rzVec)
use the fallback approach (python arguments) to set the (r,z) values
StatusCode retrieveRZBoundaryOptionalFallback(const std::string &dbNode, const FallbackDoubleVector &r, const FallbackDoubleVector &z, RZPairVector &rzVec)
retrieve and store the (r,z) values locally for the given DB node.
ServiceHandle< IRDBAccessSvc > m_dbAccess
the DetectorDescription database access method
std::array< DoubleArrayProperty, AtlasDetDescr::fNumAtlasRegions > m_fallbackZ
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ retrieveRZBoundary()

StatusCode DetDescrDBEnvelopeSvc::retrieveRZBoundary ( const std::string & node,
RZPairVector & rzVec )
private

retrieve and store the (r,z) values locally for the given DB node

@TODO: implement positioning, see: http://alxr.usatlas.bnl.gov/lxr/source/atlas/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx?v=head#054 const IRDBRecordset *DBPosition = m_dbAccess->getRecordset( m_dbPositionNode, m_atlasVersionTag, m_atlasNode );

Definition at line 165 of file DetDescrDBEnvelopeSvc.cxx.

167{
168 // clear the output RZPairVector
169 rzVec.clear();
170
171 // @TODO: implement checks and do output with the actual child tags taken
172 // some output about the used tags
173 //const std::string &detVersionTag = m_dbAccess->getChildTag( detNode /* child node */,
174 // m_atlasVersionTag /* parent tag */,
175 // m_atlasNode /* parent node */,
176 // false /*don't fetch data*/ );
177 //const std::string &parentVersionTag = m_dbAccess->getChildTag( parentNode,
178 // detVersionTag,
179 // detNode,
180 // false);
181 //const std::string &envVersionTag = m_dbAccess->getChildTag( envNode,
182 // parentVersionTag,
183 // parentNode,
184 // false );
185 //ATH_MSG_INFO( "DDDB tags used for envelope construction: "
186 // << m_atlasVersionTag << " / " << detVersionTag << " / "
187 // << parentVersionTag << " / " << envVersionTag );
188
189 // get a handle on the DB entries (don't delete, handeled internally)
190 IRDBRecordset_ptr envelopeRec = m_dbAccess->getRecordsetPtr( node,
192 m_atlasNode );
193
197
198
199 // entries in the database table
200 size_t numEntries = envelopeRec ? envelopeRec->size() : 0;
201 if ( !numEntries) {
202 ATH_MSG_INFO("No entries for table '" << node << "' in Detector Description Database (DDDB). Maybe you are using Python-based envelope definitions...");
203 return StatusCode::RECOVERABLE;
204 }
205
206 // retrieve data from the DB
207 IRDBRecordset::const_iterator recIt = envelopeRec->begin();
208 IRDBRecordset::const_iterator recEnd = envelopeRec->end();
209 for ( ; recIt!=recEnd; ++recIt) {
210
211 // read-in (r,z) duplet
212 double curR = (*recIt)->getDouble("R") * CLHEP::mm;
213 double curZ = (*recIt)->getDouble("Z") * CLHEP::mm;
214 // store (r,z) duplet locally
215 rzVec.emplace_back(curR, curZ );
216 }
217
218 return StatusCode::SUCCESS;
219}
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
std::string m_atlasNode
main DDDB node for the ATLAS detector
RecordsVector::const_iterator const_iterator
virtual const_iterator begin() const =0
virtual const_iterator end() const =0
virtual unsigned int size() const =0

◆ retrieveRZBoundaryOptionalFallback()

StatusCode DetDescrDBEnvelopeSvc::retrieveRZBoundaryOptionalFallback ( const std::string & dbNode,
const FallbackDoubleVector & r,
const FallbackDoubleVector & z,
RZPairVector & rzVec )
private

retrieve and store the (r,z) values locally for the given DB node.

if there are problems with retrieving this from DDDB, try the fallback approach if allowed

Definition at line 135 of file DetDescrDBEnvelopeSvc.cxx.

139{
140 // clear the output RZPairVector
141 rzVec.clear();
142
143 // try the DB approach to retrieve the (r,z) values
144 StatusCode sc = retrieveRZBoundary(dbNode, rzVec);
145
146 // if empty vector returned -> unsuccessfully read DDDB
147 if (sc.isFailure()) {
148 ATH_MSG_DEBUG("Will try reading Python-based envelope definition for '" << dbNode << "'.");
149
150 // try fallback approach
152 if (sc.isFailure()) {
153 ATH_MSG_WARNING("Could not create envelope volume for '" << dbNode << "'.");
154 return StatusCode::FAILURE;
155 } else {
156 ATH_MSG_INFO("Sucessfully read Python-based envelope definition for '" << dbNode << "'.");
157 }
158 }
159
160 return StatusCode::SUCCESS;
161}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
StatusCode retrieveRZBoundary(const std::string &node, RZPairVector &rzVec)
retrieve and store the (r,z) values locally for the given DB node

Member Data Documentation

◆ m_allowFallback

Gaudi::Property<bool> DetDescrDBEnvelopeSvc::m_allowFallback {this, "EnableFallback", false}
private

fallback solution, in case something goes wrong with the DB

Definition at line 100 of file DetDescrDBEnvelopeSvc.h.

100{this, "EnableFallback", false};

◆ m_atlasNode

std::string DetDescrDBEnvelopeSvc::m_atlasNode {"ATLAS"}
private

main DDDB node for the ATLAS detector

Definition at line 80 of file DetDescrDBEnvelopeSvc.h.

80{"ATLAS"};

◆ m_atlasVersionTag

std::string DetDescrDBEnvelopeSvc::m_atlasVersionTag {"AUTO"}
private

Definition at line 81 of file DetDescrDBEnvelopeSvc.h.

81{"AUTO"};

◆ m_dbAccess

ServiceHandle<IRDBAccessSvc> DetDescrDBEnvelopeSvc::m_dbAccess {this, "RDBAccessSvc", "RDBAccessSvc"}
private

the DetectorDescription database access method

Definition at line 74 of file DetDescrDBEnvelopeSvc.h.

74{this, "RDBAccessSvc", "RDBAccessSvc"};

◆ m_doFallback

bool DetDescrDBEnvelopeSvc::m_doFallback {false}
private

Definition at line 101 of file DetDescrDBEnvelopeSvc.h.

101{false};

◆ m_fallbackR

std::array<DoubleArrayProperty,AtlasDetDescr::fNumAtlasRegions> DetDescrDBEnvelopeSvc::m_fallbackR
private
Initial value:
{{
{this, "FallbackUndefinedR", {}}
, {this, "FallbackInDetR", {}}
, {this, "FallbackBeamPipeR", {}}
, {this, "FallbackCaloR", {}}
, {this, "FallbackMuonR", {}}
, {this, "FallbackCavernR", {}}
}}

Definition at line 103 of file DetDescrDBEnvelopeSvc.h.

103 {{
104 {this, "FallbackUndefinedR", {}} //Dummy
105 , {this, "FallbackInDetR", {}}
106 , {this, "FallbackBeamPipeR", {}}
107 , {this, "FallbackCaloR", {}}
108 , {this, "FallbackMuonR", {}}
109 , {this, "FallbackCavernR", {}}
110 }};

◆ m_fallbackZ

std::array<DoubleArrayProperty,AtlasDetDescr::fNumAtlasRegions> DetDescrDBEnvelopeSvc::m_fallbackZ
private
Initial value:
{{
{this, "FallbackUndefinedZ", {}}
, {this, "FallbackInDetZ", {}}
, {this, "FallbackBeamPipeZ", {}}
, {this, "FallbackCaloZ", {}}
, {this, "FallbackMuonZ", {}}
, {this, "FallbackCavernZ", {}}
}}

Definition at line 112 of file DetDescrDBEnvelopeSvc.h.

112 {{
113 {this, "FallbackUndefinedZ", {}} //Dummy
114 , {this, "FallbackInDetZ", {}}
115 , {this, "FallbackBeamPipeZ", {}}
116 , {this, "FallbackCaloZ", {}}
117 , {this, "FallbackMuonZ", {}}
118 , {this, "FallbackCavernZ", {}}
119 }};

◆ m_geoModelSvc

ServiceHandle<IGeoModelSvc> DetDescrDBEnvelopeSvc::m_geoModelSvc {this, "GeoModelSvc", "GeoModelSvc"}
private

ATLAS GeoModel.

Definition at line 77 of file DetDescrDBEnvelopeSvc.h.

77{this, "GeoModelSvc", "GeoModelSvc"};

◆ m_node

std::array<StringProperty,AtlasDetDescr::fNumAtlasRegions> DetDescrDBEnvelopeSvc::m_node
private
Initial value:
{{
{this, "DBUndefinedNode", ""}
, {this, "DBInDetNode","InDetEnvelope"}
, {this, "DBBeamPipeNode", "BeamPipeEnvelope"}
, {this, "DBCaloNode", "CaloEnvelope"}
, {this, "DBMSNode", "MuonEnvelope"}
, {this, "DBCavernNode", "CavernEnvelope"}
}}

the names of the DB nodes for the respective AtlasRegion

Definition at line 84 of file DetDescrDBEnvelopeSvc.h.

84 {{
85 {this, "DBUndefinedNode", ""} // Dummy
86 , {this, "DBInDetNode","InDetEnvelope"}
87 , {this, "DBBeamPipeNode", "BeamPipeEnvelope"}
88 , {this, "DBCaloNode", "CaloEnvelope"}
89 , {this, "DBMSNode", "MuonEnvelope"}
90 , {this, "DBCavernNode", "CavernEnvelope"}
91 }};

◆ m_rposz

RZPairVector DetDescrDBEnvelopeSvc::m_rposz[AtlasDetDescr::fNumAtlasRegions] {}
private

internal (r,z) representation for the positive z-side only, one RZPairVector for each AtlasRegion

Definition at line 97 of file DetDescrDBEnvelopeSvc.h.

97{};

◆ m_rz

RZPairVector DetDescrDBEnvelopeSvc::m_rz[AtlasDetDescr::fNumAtlasRegions] {}
private

internal (r,z) representation, one RZPairVector for each AtlasRegion

Definition at line 94 of file DetDescrDBEnvelopeSvc.h.

94{};

The documentation for this class was generated from the following files: