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.
StatusCode initialize ()
 AthService initialize method.
StatusCode finalize ()
 AthService finalize method.
const RZPairVectorgetRZBoundary (AtlasDetDescr::AtlasRegion region) const
 return a vector of (r,z) pairs, defining the respective envelope
const RZPairVectorgetRPositiveZBoundary (AtlasDetDescr::AtlasRegion region) const
 return a vector of (r,z) pairs, defining the envelope on the z>0 region

Private Member Functions

StatusCode retrieveRZBoundaryOptionalFallback (std::string &dbNode, FallbackDoubleVector &r, FallbackDoubleVector &z, RZPairVector &rzVec)
 retrieve and store the (r,z) values locally for the given DB node.
StatusCode retrieveRZBoundary (std::string &node, RZPairVector &rzVec)
 retrieve and store the (r,z) values locally for the given DB node
StatusCode fallbackRZBoundary (FallbackDoubleVector &r, 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
 main DDDB node for the ATLAS detector
std::string m_atlasVersionTag
std::string m_node [AtlasDetDescr::fNumAtlasRegions]
 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
bool m_allowFallback
 fallback solution, in case something goes wrong with the DB
bool m_doFallback
FallbackDoubleVector m_fallbackR [AtlasDetDescr::fNumAtlasRegions]
FallbackDoubleVector m_fallbackZ [AtlasDetDescr::fNumAtlasRegions]

Detailed Description

Definition at line 33 of file DetDescrDBEnvelopeSvc.h.

Constructor & Destructor Documentation

◆ DetDescrDBEnvelopeSvc()

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

public AthService constructor

Constructor.

Definition at line 31 of file DetDescrDBEnvelopeSvc.cxx.

31 :
32 base_class(name,svc),
33 m_atlasNode("ATLAS"),
34 m_atlasVersionTag("AUTO"),
35 m_node(),
36 m_rz(),
37 m_rposz(),
38 m_allowFallback(false),
39 m_doFallback(false),
42{
43 declareProperty( "DBBeamPipeNode" , m_node[AtlasDetDescr::fAtlasForward]="BeamPipeEnvelope" );
44 declareProperty( "DBInDetNode" , m_node[AtlasDetDescr::fAtlasID]="InDetEnvelope" );
45 declareProperty( "DBCaloNode" , m_node[AtlasDetDescr::fAtlasCalo]="CaloEnvelope" );
46 declareProperty( "DBMSNode" , m_node[AtlasDetDescr::fAtlasMS]="MuonEnvelope" );
47 declareProperty( "DBCavernNode" , m_node[AtlasDetDescr::fAtlasCavern]="CavernEnvelope" );
48
49 // in case something goes wrong with the DB, the user can define
50 // fallback RZ values
51 declareProperty( "EnableFallback" , m_allowFallback );
52 declareProperty( "FallbackBeamPipeR" , m_fallbackR[AtlasDetDescr::fAtlasForward] );
53 declareProperty( "FallbackBeamPipeZ" , m_fallbackZ[AtlasDetDescr::fAtlasForward] );
54 declareProperty( "FallbackInDetR" , m_fallbackR[AtlasDetDescr::fAtlasID] );
55 declareProperty( "FallbackInDetZ" , m_fallbackZ[AtlasDetDescr::fAtlasID] );
56 declareProperty( "FallbackCaloR" , m_fallbackR[AtlasDetDescr::fAtlasCalo] );
57 declareProperty( "FallbackCaloZ" , m_fallbackZ[AtlasDetDescr::fAtlasCalo] );
58 declareProperty( "FallbackMuonR" , m_fallbackR[AtlasDetDescr::fAtlasMS] );
59 declareProperty( "FallbackMuonZ" , m_fallbackZ[AtlasDetDescr::fAtlasMS] );
60 declareProperty( "FallbackCavernR" , m_fallbackR[AtlasDetDescr::fAtlasCavern] );
61 declareProperty( "FallbackCavernZ" , m_fallbackZ[AtlasDetDescr::fAtlasCavern] );
62}
bool m_allowFallback
fallback solution, in case something goes wrong with the DB
std::string m_node[AtlasDetDescr::fNumAtlasRegions]
the names of the DB nodes for the respective AtlasRegion
FallbackDoubleVector m_fallbackR[AtlasDetDescr::fNumAtlasRegions]
RZPairVector m_rposz[AtlasDetDescr::fNumAtlasRegions]
internal (r,z) representation for the positive z-side only, one RZPairVector for each AtlasRegion
std::string m_atlasNode
main DDDB node for the ATLAS detector
FallbackDoubleVector m_fallbackZ[AtlasDetDescr::fNumAtlasRegions]
RZPairVector m_rz[AtlasDetDescr::fNumAtlasRegions]
internal (r,z) representation, one RZPairVector for each AtlasRegion

◆ ~DetDescrDBEnvelopeSvc()

DetDescrDBEnvelopeSvc::~DetDescrDBEnvelopeSvc ( )

Destructor.

Definition at line 65 of file DetDescrDBEnvelopeSvc.cxx.

66{
67 // free memory
68 // TODO :)
69}

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 73 of file DetDescrDBEnvelopeSvc.cxx.

74{
75 // fallback solution is already enabled
76 if (m_doFallback) return true;
77
78 // fallback solution not enabled yet
79 if (m_allowFallback) {
80 ATH_MSG_INFO("Unable to retrieve envelope definitions from DDDB. Enabling Python-based fallback definitions.");
81 m_doFallback=true;
82 } else {
83 ATH_MSG_ERROR("Unable to retrieve envelope definitions from DDDB and Python-based fallback definitions are disabled.");
84 m_doFallback = false;
85 }
86
87 return m_doFallback;
88}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)

◆ fallbackRZBoundary()

StatusCode DetDescrDBEnvelopeSvc::fallbackRZBoundary ( FallbackDoubleVector & r,
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 269 of file DetDescrDBEnvelopeSvc.cxx.

272{
273 unsigned short len = r.size();
274
275 // r and z vectors must have same length
276 if ( len != z.size() ) {
277 ATH_MSG_ERROR("Unable to construct fallback envelope definition in (r,z) space, as the provided r and z vectors have different length");
278 rzVec.clear();
279 return StatusCode::FAILURE;
280 }
281
282 // loop over the given pairs of (r,z) values
283 for ( unsigned short pos=0; pos<len; ++pos) {
284
285 // read-in (r,z) duplet
286 double curR = r[pos];
287 double curZ = z[pos];
288 // store (r,z) duplet locally
289 rzVec.emplace_back(curR, curZ );
290 }
291
292 return StatusCode::SUCCESS;
293}
#define z
int r
Definition globals.cxx:22

◆ finalize()

StatusCode DetDescrDBEnvelopeSvc::finalize ( )

AthService finalize method.

Athena AthService finalize hook.

Definition at line 173 of file DetDescrDBEnvelopeSvc.cxx.

174{
175 return StatusCode::SUCCESS;
176}

◆ getRPositiveZBoundary()

const RZPairVector & DetDescrDBEnvelopeSvc::getRPositiveZBoundary ( AtlasDetDescr::AtlasRegion region) const
inline

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

Definition at line 52 of file DetDescrDBEnvelopeSvc.h.

53 { return m_rposz[region]; }

◆ getRZBoundary()

const RZPairVector & DetDescrDBEnvelopeSvc::getRZBoundary ( AtlasDetDescr::AtlasRegion region) const
inline

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

Definition at line 48 of file DetDescrDBEnvelopeSvc.h.

49 { return m_rz[region]; }

◆ initialize()

StatusCode DetDescrDBEnvelopeSvc::initialize ( )

AthService initialize method.

Athena AthService initialize hook.

Definition at line 91 of file DetDescrDBEnvelopeSvc.cxx.

92{
93 ATH_MSG_INFO("Initializing ...");
94
95 // retrieve DataBase access service
96 ServiceHandle<IGeoDbTagSvc> geoDbTag("GeoDbTagSvc",name());
97 ATH_CHECK(geoDbTag.retrieve());
98
99 m_dbAccess.setName(geoDbTag->getParamSvcName());
100 if ( m_dbAccess.retrieve().isFailure()) {
101 ATH_MSG_ERROR("Could not locate RDBAccessSvc");
102 if ( !enableFallback()) return StatusCode::FAILURE;
103 }
104
105 // retrieve the GeoModelSvc
106 if ( !m_doFallback && (m_geoModelSvc.retrieve().isFailure()) ) {
107 ATH_MSG_ERROR("Could not locate GeoModelSvc");
108 if ( !enableFallback()) return StatusCode::FAILURE;
109 }
110
111
112 // (#) use the DB to retrieve the RZ values
113 if ( !m_doFallback) {
114 // geo model tag
115 m_atlasVersionTag = m_geoModelSvc->atlasVersion();
116 if( m_atlasVersionTag == "AUTO") m_atlasVersionTag = "ATLAS-00";
117
118 // cache the volume definitions locally
119 for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
121 m_fallbackR[region],
122 m_fallbackZ[region],
123 m_rposz[region] );
124
125 if (sc.isFailure()) {
126 ATH_MSG_ERROR("Unable to retrieve subdetector envelope for detector region '" <<
128 return StatusCode::FAILURE;
129 }
130 }
131
132 }
133
134 // (#) or use the fallback solution right away
135 else {
136 // cache the volume definitions locally
137 for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
138 StatusCode sc = fallbackRZBoundary( m_fallbackR[region], m_fallbackZ[region], m_rposz[region] );
139
140 if (sc.isFailure()) {
141 ATH_MSG_ERROR("Unable to retrieve sub-detector envelope in (r,z)-space for detector region '" <<
143 return StatusCode::FAILURE;
144 }
145 }
146 }
147
148 // mirror the RZPairs provided in m_rposz to describe all corner points
149 // in (r,z) space for each envelope volume
150 for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
151 ATH_MSG_VERBOSE( "Envelope: positive-z region=" << region);
152 mirrorRZ( m_rposz[region], m_rz[region] );
153 }
154
155 // debugging output:
156 if (msgLvl(MSG::VERBOSE)) {
157 for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
158 int numEntries = m_rz[region].size();
159 ATH_MSG_VERBOSE( "Envelope: complete region=" << region);
160 for ( int num = 0; num<numEntries; num++) {
161 ATH_MSG_VERBOSE(" pos=" << num << " r=" << m_rz[region][num].first << " z="<< m_rz[region][num].second);
162 }
163 }
164 }
165
166 ATH_MSG_INFO("Initialize successful.");
167
168 return StatusCode::SUCCESS;
169}
#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:
ServiceHandle< IGeoModelSvc > m_geoModelSvc
ATLAS GeoModel.
StatusCode fallbackRZBoundary(FallbackDoubleVector &r, FallbackDoubleVector &z, RZPairVector &rzVec)
use the fallback approach (python arguments) to set the (r,z) values
StatusCode retrieveRZBoundaryOptionalFallback(std::string &dbNode, FallbackDoubleVector &r, 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
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ retrieveRZBoundary()

StatusCode DetDescrDBEnvelopeSvc::retrieveRZBoundary ( 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 211 of file DetDescrDBEnvelopeSvc.cxx.

213{
214 // clear the output RZPairVector
215 rzVec.clear();
216
217 // @TODO: implement checks and do output with the actual child tags taken
218 // some output about the used tags
219 //const std::string &detVersionTag = m_dbAccess->getChildTag( detNode /* child node */,
220 // m_atlasVersionTag /* parent tag */,
221 // m_atlasNode /* parent node */,
222 // false /*don't fetch data*/ );
223 //const std::string &parentVersionTag = m_dbAccess->getChildTag( parentNode,
224 // detVersionTag,
225 // detNode,
226 // false);
227 //const std::string &envVersionTag = m_dbAccess->getChildTag( envNode,
228 // parentVersionTag,
229 // parentNode,
230 // false );
231 //ATH_MSG_INFO( "DDDB tags used for envelope construction: "
232 // << m_atlasVersionTag << " / " << detVersionTag << " / "
233 // << parentVersionTag << " / " << envVersionTag );
234
235 // get a handle on the DB entries (don't delete, handeled internally)
236 IRDBRecordset_ptr envelopeRec = m_dbAccess->getRecordsetPtr( node,
238 m_atlasNode );
239
243
244
245 // entries in the database table
246 size_t numEntries = envelopeRec ? envelopeRec->size() : 0;
247 if ( !numEntries) {
248 ATH_MSG_INFO("No entries for table '" << node << "' in Detector Description Database (DDDB). Maybe you are using Python-based envelope definitions...");
249 return StatusCode::RECOVERABLE;
250 }
251
252 // retrieve data from the DB
253 IRDBRecordset::const_iterator recIt = envelopeRec->begin();
254 IRDBRecordset::const_iterator recEnd = envelopeRec->end();
255 for ( ; recIt!=recEnd; ++recIt) {
256
257 // read-in (r,z) duplet
258 double curR = (*recIt)->getDouble("R") * CLHEP::mm;
259 double curZ = (*recIt)->getDouble("Z") * CLHEP::mm;
260 // store (r,z) duplet locally
261 rzVec.emplace_back(curR, curZ );
262 }
263
264 return StatusCode::SUCCESS;
265}
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
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 ( std::string & dbNode,
FallbackDoubleVector & r,
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 181 of file DetDescrDBEnvelopeSvc.cxx.

185{
186 // clear the output RZPairVector
187 rzVec.clear();
188
189 // try the DB approach to retrieve the (r,z) values
190 StatusCode sc = retrieveRZBoundary(dbNode, rzVec);
191
192 // if empty vector returned -> unsuccessfully read DDDB
193 if (sc.isFailure()) {
194 ATH_MSG_DEBUG("Will try reading Python-based envelope definition for '" << dbNode << "'.");
195
196 // try fallback approach
198 if (sc.isFailure()) {
199 ATH_MSG_WARNING("Could not create envelope volume for '" << dbNode << "'.");
200 return StatusCode::FAILURE;
201 } else {
202 ATH_MSG_INFO("Sucessfully read Python-based envelope definition for '" << dbNode << "'.");
203 }
204 }
205
206 return StatusCode::SUCCESS;
207}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
StatusCode retrieveRZBoundary(std::string &node, RZPairVector &rzVec)
retrieve and store the (r,z) values locally for the given DB node

Member Data Documentation

◆ m_allowFallback

bool DetDescrDBEnvelopeSvc::m_allowFallback
private

fallback solution, in case something goes wrong with the DB

Python flag

Definition at line 96 of file DetDescrDBEnvelopeSvc.h.

◆ m_atlasNode

std::string DetDescrDBEnvelopeSvc::m_atlasNode
private

main DDDB node for the ATLAS detector

Definition at line 83 of file DetDescrDBEnvelopeSvc.h.

◆ m_atlasVersionTag

std::string DetDescrDBEnvelopeSvc::m_atlasVersionTag
private

Definition at line 84 of file DetDescrDBEnvelopeSvc.h.

◆ m_dbAccess

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

the DetectorDescription database access method

Definition at line 77 of file DetDescrDBEnvelopeSvc.h.

77{this, "RDBAccessSvc", "RDBAccessSvc"};

◆ m_doFallback

bool DetDescrDBEnvelopeSvc::m_doFallback
private

Definition at line 97 of file DetDescrDBEnvelopeSvc.h.

◆ m_fallbackR

FallbackDoubleVector DetDescrDBEnvelopeSvc::m_fallbackR[AtlasDetDescr::fNumAtlasRegions]
private

Definition at line 98 of file DetDescrDBEnvelopeSvc.h.

◆ m_fallbackZ

FallbackDoubleVector DetDescrDBEnvelopeSvc::m_fallbackZ[AtlasDetDescr::fNumAtlasRegions]
private

Definition at line 99 of file DetDescrDBEnvelopeSvc.h.

◆ m_geoModelSvc

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

ATLAS GeoModel.

Definition at line 80 of file DetDescrDBEnvelopeSvc.h.

80{this, "GeoModelSvc", "GeoModelSvc"};

◆ m_node

std::string DetDescrDBEnvelopeSvc::m_node[AtlasDetDescr::fNumAtlasRegions]
private

the names of the DB nodes for the respective AtlasRegion

Definition at line 87 of file DetDescrDBEnvelopeSvc.h.

◆ 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 93 of file DetDescrDBEnvelopeSvc.h.

◆ m_rz

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

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

Definition at line 90 of file DetDescrDBEnvelopeSvc.h.


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