ATLAS Offline Software
Loading...
Searching...
No Matches
RandomSurfacesBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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{
26 declareInterface<ISurfaceBuilder>(this);
27}
28
29// destructor
34
35
36// Athena standard methods
37// initialize
39{
40
41 // Random number service
42 m_rndmSvc = service("RndmGenSvc");
43 ATH_CHECK( m_rndmSvc.isValid() );
44
45 // intialize the random number generators
46 m_flatDist = new Rndm::Numbers(m_rndmSvc, Rndm::Flat(0.,1.));
47
48 return StatusCode::SUCCESS;
49}
50
51// finalize
53{
54 ATH_MSG_INFO( "finalize() successful." );
55 return StatusCode::SUCCESS;
56}
57
58
59const std::vector<const Trk::Surface*>* Trk::RandomSurfaceBuilder::surfaces() const
60{
61 std::vector<const Trk::Surface*>* cSurfaces = new std::vector<const Trk::Surface*>();
62 cSurfaces->reserve(m_numberOfSurfaces);
63 for ( size_t isf = 0; isf < m_numberOfSurfaces; ++isf ){
64 const Trk::Surface* csf = surface();
65 if (csf) cSurfaces->push_back(csf);
66 }
67 // check how many surfaces had been created
68 if ( cSurfaces->size() != m_numberOfSurfaces )
69 ATH_MSG_WARNING("Number of created surfaces (" << cSurfaces->size()
70 << ") does not correspond to chosen number (" << m_numberOfSurfaces << ")." );
71 return cSurfaces;
72
73}
74
75
77{
78 if (m_worldDimensions.size() < 3 ) return nullptr;
79
80 const Trk::Surface* surface = nullptr;
81 int sType = std::floor(m_flatDist->shoot()*6);
82
83 // neglect 0 if you don't do cones
84 if (!sType){
85 while (!sType)
86 sType = std::floor(m_flatDist->shoot()*6);
87 }
88
89 sType = sType == 6 ? 5 : sType;
90 // create the transform parameters
91 double tx = m_worldDimensions[0]*(2*m_flatDist->shoot()-1);
92 double ty = m_worldDimensions[1]*(2*m_flatDist->shoot()-1);
93 double tz = m_worldDimensions[2]*(2*m_flatDist->shoot()-1);
94 double dx = m_flatDist->shoot();
95 double dy = m_flatDist->shoot();
96 double dz = m_flatDist->shoot();
97
98 std::unique_ptr<Amg::Transform3D> transform( new Amg::Transform3D );
99 // the direciton and curvilinear UVT frame
100 Amg::Vector3D direction(dx,dy,dz);
101
102 Trk::CurvilinearUVT curvUVT(direction.normalized());
103 // translation
104 Amg::Translation3D translation(tx, ty, tz);
105
106 // create the rotation
107 Amg::RotationMatrix3D rotation;
108 rotation.col(0) = curvUVT.curvU();
109 rotation.col(1) = curvUVT.curvV();
110 rotation.col(2) = curvUVT.curvT();
111 // curvilinear surfaces are boundless
112 (*transform) = translation;
113 (*transform).rotate(rotation);
114 ATH_MSG_VERBOSE("Created transform is : " << Amg::toString(*transform));
115
116 // create the surface
117 switch (sType) {
118 // create a cone surface - cone does not exist for old EDM as Measured
119 case 0 : {
120 surface = new Trk::ConeSurface(*transform, m_flatDist->shoot()*0.7*M_PI);
121 } break;
122 case 1 : {
123 surface = new Trk::CylinderSurface(*transform, 50.+m_worldDimensions[0]*m_flatDist->shoot(), m_worldDimensions[2]);
124 } break;
125 // create a disc surface
126 case 2 : {
127 surface = new Trk::DiscSurface(*transform, 0., m_worldDimensions[1]);
128 } break;
129 // create a perigee surface
130 case 3 : {
132 } break;
133 // create a plane surface
134 case 4 : {
136 } break;
137 // create a straight line surface
138 case 5 : {
139 surface = new Trk::StraightLineSurface(*transform, 50., m_worldDimensions[2]);
140 } break;
141 default : break;
142 }
143 return surface;
144}
#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:
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.
Gaudi::Property< std::vector< double > > m_worldDimensions
virtual ~RandomSurfaceBuilder()
Destructor.
const std::vector< const Surface * > * surfaces() const
SurfaceBuilder interface method - provide a vector of surfaces -.
Gaudi::Property< size_t > m_numberOfSurfaces
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
Abstract Base Class for tracking surfaces.
Definition Surface.h:79
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
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.