ATLAS Offline Software
CylinderBounds.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // CylinderBounds.cxx, (c) ATLAS Detector Software
8 
9 // Trk
11 // Gaudi
12 #include "GaudiKernel/MsgStream.h"
13 // STD
14 #include <cmath>
15 #include <iomanip>
16 #include <iostream>
17 
19  : m_boundValues(CylinderBounds::bv_length, 0.)
20  , m_checkPhi(false)
21 {}
22 
24  : m_boundValues(CylinderBounds::bv_length, 0.)
25  , m_checkPhi(false)
26 {
30 }
31 
32 Trk::CylinderBounds::CylinderBounds(double radius, double haphi, double halez)
33  : m_boundValues(CylinderBounds::bv_length, 0.)
34  , m_checkPhi(true)
35 {
39 }
40 
41 Trk::CylinderBounds::CylinderBounds(double radius, double haphi, double averagephi, double halez)
42  : m_boundValues(CylinderBounds::bv_length, 0.)
43  , m_checkPhi(true)
44 {
49 }
50 
51 bool
53 {
54  // check the type first not to compare apples with oranges
55  const Trk::CylinderBounds* cylbo = dynamic_cast<const Trk::CylinderBounds*>(&sbo);
56  if (!cylbo)
57  return false;
58  return (m_boundValues == cylbo->m_boundValues);
59 }
60 
61 double
63 {
64  const double pi2 = 2. * M_PI;
65 
66  double sZ = fabs(pos[locZ]) - m_boundValues[CylinderBounds::bv_halfZ];
67  double wF = m_boundValues[CylinderBounds::bv_halfPhiSector];
68  if (wF >= M_PI)
69  return sZ;
70  double dF =
71  fabs(pos[locRPhi] / m_boundValues[CylinderBounds::bv_radius] - m_boundValues[CylinderBounds::bv_averagePhi]);
72  if (dF > M_PI)
73  dF = pi2 - dF;
74  double sF = 2. * m_boundValues[CylinderBounds::bv_radius] * sin(.5 * (dF - wF));
75 
76  if (sF <= 0. || sZ <= 0.) {
77  if (sF > sZ){
78  return sF;
79  }
80 
81  return sZ;
82  }
83  return sqrt(sF * sF + sZ * sZ);
84 }
85 
86 // ostream operator overload
87 MsgStream&
88 Trk::CylinderBounds::dump(MsgStream& sl) const
89 {
90  sl << std::setiosflags(std::ios::fixed);
91  sl << std::setprecision(7);
92  sl << "Trk::CylinderBounds: (radius, averagePhi, halfPhiSector, halflengthInZ) = ";
93  sl << "(" << this->r() << ", " << this->averagePhi() << ", ";
94  sl << this->halfPhiSector() << ", " << this->halflengthZ() << ")";
95  sl << std::setprecision(-1);
96  return sl;
97 }
98 
99 std::ostream&
100 Trk::CylinderBounds::dump(std::ostream& sl) const
101 {
102  sl << std::setiosflags(std::ios::fixed);
103  sl << std::setprecision(7);
104  sl << "Trk::CylinderBounds: (radius, averagePhi, halfPhiSector, halflengthInZ) = ";
105  sl << "(" << this->r() << ", " << this->averagePhi() << ", ";
106  sl << this->halfPhiSector() << ", " << this->halflengthZ() << ")";
107  sl << std::setprecision(-1);
108  return sl;
109 }
Trk::CylinderBounds::minDistance
virtual double minDistance(const Amg::Vector2D &pos) const override final
Minimal distance to boundary ( > 0 if outside and <=0 if inside)
Definition: CylinderBounds.cxx:62
beamspotman.r
def r
Definition: beamspotman.py:676
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::CylinderBounds::CylinderBounds
CylinderBounds()
Default Constructor.
Definition: CylinderBounds.cxx:18
Trk::SurfaceBounds
Definition: SurfaceBounds.h:47
Trk::locRPhi
@ locRPhi
Definition: ParamDefs.h:40
python.PhysicalConstants.pi2
float pi2
Definition: PhysicalConstants.py:52
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::CylinderBounds::bv_averagePhi
@ bv_averagePhi
Definition: CylinderBounds.h:52
Trk::CylinderBounds::bv_halfPhiSector
@ bv_halfPhiSector
Definition: CylinderBounds.h:53
Trk::CylinderBounds::bv_halfZ
@ bv_halfZ
Definition: CylinderBounds.h:54
Trk::locZ
@ locZ
local cylindrical
Definition: ParamDefs.h:42
Trk::CylinderBounds
Definition: CylinderBounds.h:46
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CylinderBounds.h
Trk::CylinderBounds::dump
virtual MsgStream & dump(MsgStream &sl) const override
Output Method for MsgStream.
Definition: CylinderBounds.cxx:88
Trk::CylinderBounds::operator==
virtual bool operator==(const SurfaceBounds &sbo) const override
Equality operator.
Definition: CylinderBounds.cxx:52
Trk::CylinderBounds::m_boundValues
std::vector< TDD_real_t > m_boundValues
internal storage of the geometry parameters
Definition: CylinderBounds.h:143
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Trk::CylinderBounds::bv_radius
@ bv_radius
Definition: CylinderBounds.h:51