ATLAS Offline Software
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 
16 ISF::ISFEnvelopeDefSvc::ISFEnvelopeDefSvc(const std::string& name, ISvcLocator* svc) :
17  base_class(name,svc),
18  m_atlasEnvDefSvc("AtlasGeometry_EnvelopeDefSvc", name),
19  m_rzBeamPipe(),
20  m_rzInDet(),
21  m_rposzBeamPipe(),
22  m_rposzInDet()
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;
77  m_rposzBeamPipe = m_atlasEnvDefSvc->getRPositiveZBoundary( AtlasDetDescr::fAtlasForward );
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 }
ISFEnvelopeDefSvc.h
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
max
#define max(a, b)
Definition: cfImp.cxx:41
ISF::ISFEnvelopeDefSvc::getRPositiveZBoundary
const RZPairVector & getRPositiveZBoundary(AtlasDetDescr::AtlasRegion region) const
return a vector of (r,z) pairs, defining the envelope on the z>0 region
Definition: ISFEnvelopeDefSvc.cxx:142
AtlasDetDescr::fAtlasForward
@ fAtlasForward
Definition: AtlasRegion.h:34
ISF::ISFEnvelopeDefSvc::~ISFEnvelopeDefSvc
~ISFEnvelopeDefSvc()
Destructor.
Definition: ISFEnvelopeDefSvc.cxx:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
RZPairVector
std::vector< RZPair > RZPairVector
Definition: RZPair.h:18
ISF::ISFEnvelopeDefSvc::initialize
StatusCode initialize()
AthService initialize method.
Definition: ISFEnvelopeDefSvc.cxx:36
AtlasDetDescr::AtlasRegion
AtlasRegion
Definition: AtlasRegion.h:27
ISF::ISFEnvelopeDefSvc::getRZBoundary
const RZPairVector & getRZBoundary(AtlasDetDescr::AtlasRegion region) const
return a vector of (r,z) pairs, defining the respective envelope
Definition: ISFEnvelopeDefSvc.cxx:131
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ISF::ISFEnvelopeDefSvc::ISFEnvelopeDefSvc
ISFEnvelopeDefSvc(const std::string &name, ISvcLocator *svc)
public AthService constructor
Definition: ISFEnvelopeDefSvc.cxx:16
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
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
ISF::ISFEnvelopeDefSvc::finalize
StatusCode finalize()
AthService finalize method.
Definition: ISFEnvelopeDefSvc.cxx:124
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlasDetDescr::fAtlasID
@ fAtlasID
Definition: AtlasRegion.h:33
ISF::ISFEnvelopeDefSvc::m_atlasEnvDefSvc
ServiceHandle< IEnvelopeDefSvc > m_atlasEnvDefSvc
ServiceHandle to the common ATLAS envelope definition service.
Definition: ISFEnvelopeDefSvc.h:46
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
DeMoScan.first
bool first
Definition: DeMoScan.py:534
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14