ATLAS Offline Software
RandomSurfacesBuilder.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 // 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_rndmSvc("RndmGenSvc", n),
26  m_gaussDist(nullptr),
27  m_flatDist(nullptr),
28  m_numberOfSurfaces(100),
29  m_enableCones(false)
30 {
31 
32  declareInterface<ISurfaceBuilder>(this);
33 
34  // the active dimensions
35  declareProperty("NumberOfSurfaces", m_numberOfSurfaces);
36  declareProperty("WorldDimensions", m_worldDimensions);
37 }
38 
39 // destructor
41 {
42  delete m_gaussDist;
43  delete m_flatDist;
44 }
45 
46 
47 // Athena standard methods
48 // initialize
50 {
51 
52  // Random number service
53  if ( m_rndmSvc.retrieve().isFailure() ) {
54  ATH_MSG_FATAL( "Could not retrieve " << m_rndmSvc );
55  return StatusCode::FAILURE;
56  }
57 
58  // intialize the random number generators
59  m_gaussDist = new Rndm::Numbers(&*m_rndmSvc, Rndm::Gauss(0.,1.));
60  m_flatDist = new Rndm::Numbers(&*m_rndmSvc, Rndm::Flat(0.,1.));
61 
62  return StatusCode::SUCCESS;
63 }
64 
65 // finalize
67 {
68  ATH_MSG_INFO( "finalize() successful." );
69  return StatusCode::SUCCESS;
70 }
71 
72 
73 const std::vector<const Trk::Surface*>* Trk::RandomSurfaceBuilder::surfaces() const
74 {
75  std::vector<const Trk::Surface*>* cSurfaces = new std::vector<const Trk::Surface*>();
76  cSurfaces->reserve(m_numberOfSurfaces);
77  for ( size_t isf = 0; isf < m_numberOfSurfaces; ++isf ){
78  const Trk::Surface* csf = surface();
79  if (csf) cSurfaces->push_back(csf);
80  }
81  // check how many surfaces had been created
82  if ( cSurfaces->size() != m_numberOfSurfaces )
83  ATH_MSG_WARNING("Number of created surfaces (" << cSurfaces->size()
84  << ") does not correspond to chosen number (" << m_numberOfSurfaces << ")." );
85  return cSurfaces;
86 
87 }
88 
89 
91 {
92  if (m_worldDimensions.size() < 3 ) return nullptr;
93 
94  const Trk::Surface* surface = nullptr;
95  int sType = std::floor(m_flatDist->shoot()*6);
96 
97  // neglect 0 if you don't do cones
98  if (!m_enableCones && !sType){
99  while (!sType)
100  sType = std::floor(m_flatDist->shoot()*6);
101  }
102 
103  sType = sType == 6 ? 5 : sType;
104  // create the transform parameters
105  double tx = m_worldDimensions[0]*(2*m_flatDist->shoot()-1);
106  double ty = m_worldDimensions[1]*(2*m_flatDist->shoot()-1);
107  double tz = m_worldDimensions[2]*(2*m_flatDist->shoot()-1);
108  double dx = m_flatDist->shoot();
109  double dy = m_flatDist->shoot();
110  double dz = m_flatDist->shoot();
111 
112  std::unique_ptr<Amg::Transform3D> transform( new Amg::Transform3D );
113  // the direciton and curvilinear UVT frame
114  Amg::Vector3D direction(dx,dy,dz);
115 
116  Trk::CurvilinearUVT curvUVT(direction.normalized());
117  // translation
118  Amg::Translation3D translation(tx, ty, tz);
119 
120  // create the rotation
122  rotation.col(0) = curvUVT.curvU();
123  rotation.col(1) = curvUVT.curvV();
124  rotation.col(2) = curvUVT.curvT();
125  // curvilinear surfaces are boundless
126  (*transform) = translation;
127  (*transform).rotate(rotation);
128  ATH_MSG_VERBOSE("Created transform is : " << Amg::toString(*transform));
129 
130  // create the surface
131  switch (sType) {
132  // create a cone surface - cone does not exist for old EDM as Measured
133  case 0 : {
134  surface = new Trk::ConeSurface(*transform, m_flatDist->shoot()*0.7*M_PI);
135  } break;
136  case 1 : {
137  surface = new Trk::CylinderSurface(*transform, 50.+m_worldDimensions[0]*m_flatDist->shoot(), m_worldDimensions[2]);
138  } break;
139  // create a disc surface
140  case 2 : {
141  surface = new Trk::DiscSurface(*transform, 0., m_worldDimensions[1]);
142  } break;
143  // create a perigee surface
144  case 3 : {
145  surface = new Trk::PerigeeSurface(Amg::Vector3D(tx,ty,tz));
146  } break;
147  // create a plane surface
148  case 4 : {
149  surface = new Trk::PlaneSurface(*transform, m_worldDimensions[0], m_worldDimensions[0]);
150  } break;
151  // create a straight line surface
152  case 5 : {
153  surface = new Trk::StraightLineSurface(*transform, 50., m_worldDimensions[2]);
154  } break;
155  default : break;
156  }
157  return surface;
158 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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:40
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:90
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:66
GeoPrimitives.h
Trk::RandomSurfaceBuilder::m_numberOfSurfaces
size_t m_numberOfSurfaces
Definition: RandomSurfaceBuilder.h:60
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:73
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
CylinderSurface.h
Trk::RandomSurfaceBuilder::initialize
StatusCode initialize()
AlgTool initialize method.
Definition: RandomSurfacesBuilder.cxx:49
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