ATLAS Offline Software
Loading...
Searching...
No Matches
ISFEnvelopeDefSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6// ISFEnvelopeDefSvc.cxx, (c) ATLAS Detector software
8
9// class header include
10#include "ISFEnvelopeDefSvc.h"
11
12// STL
13#include <limits>
14
16ISF::ISFEnvelopeDefSvc::ISFEnvelopeDefSvc(const std::string& name, ISvcLocator* svc) :
17 base_class(name,svc),
18 m_atlasEnvDefSvc("AtlasGeometry_EnvelopeDefSvc", name),
20 m_rzInDet(),
23{
24 declareProperty("ATLASEnvelopeDefSvc" , m_atlasEnvDefSvc );
25}
26
27
29{
30 // free memory
31 // TODO :)
32}
33
34
37{
38 ATH_MSG_INFO("Initializing ...");
39
40 // retrieve ATLAS common envelope definition service
41 if ( m_atlasEnvDefSvc.retrieve().isFailure() ){
42 ATH_MSG_FATAL( "Could not retrieve EnvelopeDefinition service ('" << m_atlasEnvDefSvc.typeAndName() << "'). Abort.");
43 return StatusCode::FAILURE;
44 }
45
46 // change InnerDetector boundaries according to ISF conventions
47 // ie. remove the beampipe from inside the ID volume and move the
48 // ID volume all the way down to r==0.
49 //
50 m_rposzInDet = m_atlasEnvDefSvc->getRPositiveZBoundary( AtlasDetDescr::fAtlasID );
51 // will store the lowest radius of the ID volume
52 double rMin = std::numeric_limits<double>::max();
53 double zAtRMin = 0.;
54 {
55 unsigned int rMinPos = 0;
56
57 // find the smallest radius of the ID volume
58 for ( unsigned int curPos=0; curPos<m_rposzInDet.size(); curPos++ ) {
59 double curR = m_rposzInDet[curPos].first;
60 double curZ = m_rposzInDet[curPos].second;
61
62 if (curR < rMin) {
63 rMin = curR;
64 zAtRMin = curZ;
65 rMinPos = curPos;
66 }
67 }
68
69 // set the lowest radius of the ID volume to ZERO
70 ATH_MSG_DEBUG("Will shift ID boundary (r,|z|)=("<<rMin<<","<<zAtRMin<<") to (r,|z|)=("<<0.<<","<<zAtRMin<<")");
71 m_rposzInDet[rMinPos].first = 0.;
72 }
73
74 // change BeamPipe/Forward boundaries according to ISF conventions
75 //
76 bool foundShiftPoint = false;
78 {
79 for ( unsigned int curPos=0; curPos<m_rposzBeamPipe.size(); curPos++ ) {
80 double curR = m_rposzBeamPipe[curPos].first;
81 double curZ = m_rposzBeamPipe[curPos].second;
82
83 // if the current radius and z-coordinate are the same as the identified lowest ID radius
84 // set this radius to ZERO too
85 if ( (fabs(curR-rMin) < 1e-4) && (fabs(curZ-zAtRMin)<1e-4) ) {
86 ATH_MSG_VERBOSE("Found boundary point in BeamPipe volume. Shifting (r,|z|)=("<<curR<<","<<curZ<<") to (r,|z|)=("<<0.<<","<<curZ<<")");
87 foundShiftPoint = true;
88 m_rposzBeamPipe[curPos].first = 0.;
89 }
90 }
91 }
92
93 // if we have shifted an (r,z) point in the ID envelope, but not in the BeamPipe envelope
94 // -> something is wrong, better throw an error!
95 if ( !foundShiftPoint) {
96 ATH_MSG_ERROR("Could not find InDet envelope point (r,z)=("<<rMin<<","<<zAtRMin<<") in the BeamPipe/Forward envelope -> Unable to shift it down to r=0.");
97 return StatusCode::FAILURE;
98 }
99
100 // mirror the RZPairs provided in m_rposz to describe all corner points
101 // in (r,z) space for the BeamPipe/Forward and the InnerDetector envelopes
102 mirrorRZ( m_rposzBeamPipe, m_rzBeamPipe );
103 mirrorRZ( m_rposzInDet , m_rzInDet );
104
105 // debugging output:
106 if (msgLvl(MSG::VERBOSE)) {
107 ATH_MSG_VERBOSE( "Envelope: complete region=" << AtlasDetDescr::fAtlasForward);
108 for ( unsigned int num = 0; num<m_rzBeamPipe.size(); num++) {
109 ATH_MSG_VERBOSE(" pos=" << num << " r=" << m_rzBeamPipe[num].first << " z="<< m_rzBeamPipe[num].second);
110 }
111 ATH_MSG_VERBOSE( "Envelope: complete region=" << AtlasDetDescr::fAtlasID);
112 for ( unsigned int num = 0; num<m_rzInDet.size(); num++) {
113 ATH_MSG_VERBOSE(" pos=" << num << " r=" << m_rzInDet[num].first << " z="<< m_rzInDet[num].second);
114 }
115 }
116
117 ATH_MSG_INFO("Initialize successful.");
118
119 return StatusCode::SUCCESS;
120}
121
122
125{
126 return StatusCode::SUCCESS;
127}
128
129
132
133 // treat Forward/BeamPipe and InnerDetector regions separately
134 if ( region == AtlasDetDescr::fAtlasForward ) return m_rzBeamPipe;
135 else if ( region == AtlasDetDescr::fAtlasID ) return m_rzInDet;
136 else return m_atlasEnvDefSvc->getRZBoundary( region );
137
138}
139
140
143
144 // treat Forward/BeamPipe and InnerDetector regions separately
145 if ( region == AtlasDetDescr::fAtlasForward ) return m_rposzBeamPipe;
146 else if ( region == AtlasDetDescr::fAtlasID ) return m_rposzInDet;
147 else return m_atlasEnvDefSvc->getRPositiveZBoundary( region );
148}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
std::vector< RZPair > RZPairVector
Definition RZPair.h:18
StatusCode finalize()
AthService finalize method.
StatusCode initialize()
AthService initialize method.
ServiceHandle< IEnvelopeDefSvc > m_atlasEnvDefSvc
ServiceHandle to the common ATLAS envelope definition service.
RZPairVector m_rposzBeamPipe
internal (r,z) representation for the positive z-side only, one RZPairVector for BeamPipe and InnerDe...
RZPairVector m_rzBeamPipe
internal (r,z) representation for BeamPipe and InnerDetector volumes
const RZPairVector & getRPositiveZBoundary(AtlasDetDescr::AtlasRegion region) const
return a vector of (r,z) pairs, defining the envelope on the z>0 region
ISFEnvelopeDefSvc(const std::string &name, ISvcLocator *svc)
public AthService constructor
const RZPairVector & getRZBoundary(AtlasDetDescr::AtlasRegion region) const
return a vector of (r,z) pairs, defining the respective envelope
AtlasRegion
A simple enum of ATLAS regions and sub-detectors.
Definition AtlasRegion.h:21