18 #include "GaudiKernel/SystemOfUnits.h"
27 m_extrapolator(
"Trk::Extrapolator/AtlasExtrapolator"),
28 m_propagator(
"Trk::RungeKuttaPropagator/RungeKuttaPropagator"),
29 m_magFieldProperties(nullptr),
42 m_referenceSurfaces(0),
43 m_eventsPerExecute(-1),
44 m_useExtrapolator(false)
76 std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIter = m_referenceSurfaceTriples.begin();
77 std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIterEnd = m_referenceSurfaceTriples.end();
78 for ( ; surfaceTripleIter != surfaceTripleIterEnd; ++surfaceTripleIter)
80 std::vector<const Trk::Surface*>::const_iterator surfIter = (*surfaceTripleIter).begin();
81 std::vector<const Trk::Surface*>::const_iterator surfIterEnd = (*surfaceTripleIter).end();
82 for ( ; surfIter != surfIterEnd;
delete (*surfIter), ++surfIter);
96 msg(MSG::INFO) <<
" initialize()" <<
endmsg;
99 if (m_extrapolator.retrieve().isFailure()) {
101 return StatusCode::FAILURE;
104 if (m_propagator.retrieve().isFailure()) {
106 return StatusCode::FAILURE;
111 if (m_referenceSurfaceRadius.size() == m_referenceSurfaceHalflength.size()) {
113 m_referenceSurfaces = m_referenceSurfaceRadius.size();
119 for ( ; radiusIter != radiusIterEnd; ++radiusIter, ++halfZIter){
121 std::vector< const Trk::Surface*> surfaceTriplet;
126 ATH_MSG_INFO(
"Creating surfaces: R " << *radiusIter <<
" Z " << *halfZIter);
127 m_referenceSurfaceTriples.push_back(surfaceTriplet);
129 m_referenceSurfaceNegativeBoundary.push_back(atan2(*radiusIter,-(*halfZIter)));
130 m_referenceSurfacePositiveBoundary.push_back(atan2(*radiusIter,(*halfZIter)));
135 m_gaussDist =
new Rndm::Numbers(randSvc(), Rndm::Gauss(0.,1.));
136 m_flatDist =
new Rndm::Numbers(randSvc(), Rndm::Flat(0.,1.));
138 msg(MSG::INFO) <<
"initialize() successful in " <<
endmsg;
140 if( m_eventsPerExecute > 0 ){
141 m_perigees.reserve(m_eventsPerExecute);
142 for(
int i=0;
i<m_eventsPerExecute;++
i ) m_perigees.push_back(generatePerigee());
145 return StatusCode::SUCCESS;
153 return StatusCode::SUCCESS;
158 double d0 = m_gaussDist->shoot() * m_sigmaD0;
159 double z0 = m_gaussDist->shoot() * m_sigmaZ0;
160 double phi = m_minPhi + (m_maxPhi-m_minPhi)* m_flatDist->shoot();
161 double eta = m_minEta + m_flatDist->shoot()*(m_maxEta-m_minEta);
163 double p = m_minP + m_flatDist->shoot()*(m_maxP-m_minP);
164 double charge = (m_flatDist->shoot() > 0.5 ) ? -1. : 1.;
175 if( m_eventsPerExecute <= 0 ) runTest(generatePerigee());
176 else for(
int i=0;
i<m_eventsPerExecute;++
i ) runTest(m_perigees[
i]);
177 return StatusCode::SUCCESS;
189 std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIter = m_referenceSurfaceTriples.begin();
190 std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIterEnd = m_referenceSurfaceTriples.end();
197 const EventContext& ctx = Gaudi::Hive::currentContext();
198 for (
int refSurface = 0 ; surfaceTripleIter != surfaceTripleIterEnd; ++surfaceTripleIter, ++negRefIter, ++posRefIter ){
200 refSurface =
theta < (*posRefIter) ? 2 : 1;
201 refSurface =
theta > (*negRefIter) ? 0 : 1;
203 const Trk::Surface* destinationSurface = (*surfaceTripleIter)[refSurface];
205 const auto* destParameters =
207 ? m_extrapolator->extrapolate(
211 propagationDirection,
220 propagationDirection,
222 *m_magFieldProperties,
226 if (destParameters) {
231 ATH_MSG_VERBOSE(
" [ intersection ] with surface at (x,y,z) = " << destParameters->position().x() <<
", " << destParameters->position().y() <<
", " << destParameters->position().z() );
233 }
else if (!destParameters)
235 delete destParameters;