ATLAS Offline Software
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
23 Trk::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),
27  m_numberOfSurfaces(100),
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
40 {
41  delete m_gaussDist;
42  delete m_flatDist;
43 }
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 
70 const 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
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 : {
142  surface = new Trk::PerigeeSurface(Amg::Vector3D(tx,ty,tz));
143  } break;
144  // create a plane surface
145  case 4 : {
146  surface = new Trk::PlaneSurface(*transform, m_worldDimensions[0], m_worldDimensions[0]);
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 }
StraightLineSurface.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PerigeeSurface.h
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::RandomSurfaceBuilder::~RandomSurfaceBuilder
virtual ~RandomSurfaceBuilder()
Destructor.
Definition: RandomSurfacesBuilder.cxx:39
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::RandomSurfaceBuilder::surface
const Surface * surface() const
SurfaceBuilder interface method - provice a single surface.
Definition: RandomSurfacesBuilder.cxx:87
Trk::DiscSurface
Definition: DiscSurface.h:54
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::RandomSurfaceBuilder::finalize
StatusCode finalize()
AlgTool finalize method.
Definition: RandomSurfacesBuilder.cxx:63
GeoPrimitives.h
Trk::RandomSurfaceBuilder::m_numberOfSurfaces
size_t m_numberOfSurfaces
Definition: RandomSurfaceBuilder.h:60
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ConeSurface.h
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
Trk::CurvilinearUVT::curvT
const Amg::Vector3D & curvT() const
Trk::CurvilinearUVT::curvU
const Amg::Vector3D & curvU() const
Access methods.
RandomSurfaceBuilder.h
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::CylinderSurface
Definition: CylinderSurface.h:55
xAOD::rotation
rotation
Definition: TrackSurface_v1.cxx:15
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Trk::RandomSurfaceBuilder::surfaces
const std::vector< const Surface * > * surfaces() const
SurfaceBuilder interface method - provide a vector of surfaces -.
Definition: RandomSurfacesBuilder.cxx:70
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
CylinderSurface.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::RandomSurfaceBuilder::initialize
StatusCode initialize()
AlgTool initialize method.
Definition: RandomSurfacesBuilder.cxx:48
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
CurvilinearUVT.h
Trk::RandomSurfaceBuilder::m_worldDimensions
std::vector< double > m_worldDimensions
Definition: RandomSurfaceBuilder.h:62
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
Trk::CurvilinearUVT
Definition: CurvilinearUVT.h:45
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::PlaneSurface
Definition: PlaneSurface.h:64
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
Trk::CurvilinearUVT::curvV
const Amg::Vector3D & curvV() const
PlaneSurface.h
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
Trk::RandomSurfaceBuilder::RandomSurfaceBuilder
RandomSurfaceBuilder(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: RandomSurfacesBuilder.cxx:23
GeoPrimitivesToStringConverter.h
DiscSurface.h
Trk::ConeSurface
Definition: ConeSurface.h:51
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
AthAlgTool
Definition: AthAlgTool.h:26
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
TileDCSDataPlotter.tx
tx
Definition: TileDCSDataPlotter.py:878
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51