ATLAS Offline Software
Loading...
Searching...
No Matches
RandomSurfacesBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// RandomSurfaceBuilder.cxx, (c) ATLAS Detector software
8
9// Trk include
18// Amg
21
22// constructor
23Trk::RandomSurfaceBuilder::RandomSurfaceBuilder(const std::string& t, const std::string& n, const IInterface* p)
24: AthAlgTool(t,n,p),
25 m_gaussDist(nullptr),
26 m_flatDist(nullptr),
28 m_enableCones(false)
29{
30
31 declareInterface<ISurfaceBuilder>(this);
32
33 // the active dimensions
34 declareProperty("NumberOfSurfaces", m_numberOfSurfaces);
35 declareProperty("WorldDimensions", m_worldDimensions);
36}
37
38// destructor
44
45
46// Athena standard methods
47// initialize
49{
50
51 // Random number service
52 m_rndmSvc = service("RndmGenSvc");
53 ATH_CHECK( m_rndmSvc.isValid() );
54
55 // intialize the random number generators
56 m_gaussDist = new Rndm::Numbers(m_rndmSvc, Rndm::Gauss(0.,1.));
57 m_flatDist = new Rndm::Numbers(m_rndmSvc, Rndm::Flat(0.,1.));
58
59 return StatusCode::SUCCESS;
60}
61
62// finalize
64{
65 ATH_MSG_INFO( "finalize() successful." );
66 return StatusCode::SUCCESS;
67}
68
69
70const std::vector<const Trk::Surface*>* Trk::RandomSurfaceBuilder::surfaces() const
71{
72 std::vector<const Trk::Surface*>* cSurfaces = new std::vector<const Trk::Surface*>();
73 cSurfaces->reserve(m_numberOfSurfaces);
74 for ( size_t isf = 0; isf < m_numberOfSurfaces; ++isf ){
75 const Trk::Surface* csf = surface();
76 if (csf) cSurfaces->push_back(csf);
77 }
78 // check how many surfaces had been created
79 if ( cSurfaces->size() != m_numberOfSurfaces )
80 ATH_MSG_WARNING("Number of created surfaces (" << cSurfaces->size()
81 << ") does not correspond to chosen number (" << m_numberOfSurfaces << ")." );
82 return cSurfaces;
83
84}
85
86
88{
89 if (m_worldDimensions.size() < 3 ) return nullptr;
90
91 const Trk::Surface* surface = nullptr;
92 int sType = std::floor(m_flatDist->shoot()*6);
93
94 // neglect 0 if you don't do cones
95 if (!m_enableCones && !sType){
96 while (!sType)
97 sType = std::floor(m_flatDist->shoot()*6);
98 }
99
100 sType = sType == 6 ? 5 : sType;
101 // create the transform parameters
102 double tx = m_worldDimensions[0]*(2*m_flatDist->shoot()-1);
103 double ty = m_worldDimensions[1]*(2*m_flatDist->shoot()-1);
104 double tz = m_worldDimensions[2]*(2*m_flatDist->shoot()-1);
105 double dx = m_flatDist->shoot();
106 double dy = m_flatDist->shoot();
107 double dz = m_flatDist->shoot();
108
109 std::unique_ptr<Amg::Transform3D> transform( new Amg::Transform3D );
110 // the direciton and curvilinear UVT frame
111 Amg::Vector3D direction(dx,dy,dz);
112
113 Trk::CurvilinearUVT curvUVT(direction.normalized());
114 // translation
115 Amg::Translation3D translation(tx, ty, tz);
116
117 // create the rotation
118 Amg::RotationMatrix3D rotation;
119 rotation.col(0) = curvUVT.curvU();
120 rotation.col(1) = curvUVT.curvV();
121 rotation.col(2) = curvUVT.curvT();
122 // curvilinear surfaces are boundless
123 (*transform) = translation;
124 (*transform).rotate(rotation);
125 ATH_MSG_VERBOSE("Created transform is : " << Amg::toString(*transform));
126
127 // create the surface
128 switch (sType) {
129 // create a cone surface - cone does not exist for old EDM as Measured
130 case 0 : {
131 surface = new Trk::ConeSurface(*transform, m_flatDist->shoot()*0.7*M_PI);
132 } break;
133 case 1 : {
134 surface = new Trk::CylinderSurface(*transform, 50.+m_worldDimensions[0]*m_flatDist->shoot(), m_worldDimensions[2]);
135 } break;
136 // create a disc surface
137 case 2 : {
138 surface = new Trk::DiscSurface(*transform, 0., m_worldDimensions[1]);
139 } break;
140 // create a perigee surface
141 case 3 : {
143 } break;
144 // create a plane surface
145 case 4 : {
147 } break;
148 // create a straight line surface
149 case 5 : {
150 surface = new Trk::StraightLineSurface(*transform, 50., m_worldDimensions[2]);
151 } break;
152 default : break;
153 }
154 return surface;
155}
#define M_PI
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Class for a conical surface in the ATLAS detector.
Definition ConeSurface.h:51
simple class that constructs the curvilinear vectors curvU and curvV from a given momentum direction ...
const Amg::Vector3D & curvU() const
Access methods.
const Amg::Vector3D & curvT() const
const Amg::Vector3D & curvV() const
Class for a CylinderSurface in the ATLAS detector.
Class for a DiscSurface in the ATLAS detector.
Definition DiscSurface.h:54
Class describing the Line to which the Perigee refers to.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
StatusCode finalize()
AlgTool finalize method.
StatusCode initialize()
AlgTool initialize method.
SmartIF< IRndmGenSvc > m_rndmSvc
random number engine used
RandomSurfaceBuilder(const std::string &, const std::string &, const IInterface *)
Constructor.
const Surface * surface() const
SurfaceBuilder interface method - provice a single surface.
virtual ~RandomSurfaceBuilder()
Destructor.
const std::vector< const Surface * > * surfaces() const
SurfaceBuilder interface method - provide a vector of surfaces -.
std::vector< double > m_worldDimensions
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
Abstract Base Class for tracking surfaces.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D