Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ExtrapolatorTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // ExtrapolatorTest.cxx, (c) ATLAS Detector software
8 
9 // Tracking
16 // std
17 #include <cmath>
18 
19 //================ Constructor =================================================
20 
21 Trk::ExtrapolatorTest::ExtrapolatorTest(const std::string& name, ISvcLocator* pSvcLocator) :
22  AthAlgorithm(name,pSvcLocator) {}
23 
24 //================ Destructor =================================================
25 
27 {
28  delete m_gaussDist;
29  delete m_flatDist;
30  // cleanup of the surfaces
31  for (const auto& surfaceTriple : m_referenceSurfaceTriples) {
32  for (const auto* surface : surfaceTriple) {
33  delete surface;
34  }
35  }
36 }
37 
38 
39 //================ Initialisation =================================================
40 
42 {
43  // Code entered here will be executed once at program start.
44 
45  ATH_MSG_INFO(" initialize()");
46 
47  ATH_CHECK( m_extrapolator.retrieve() );
48  ATH_CHECK( m_propagator.retrieve() );
49 
50  m_magFieldProperties = new Trk::MagneticFieldProperties();
51 
52  if (m_referenceSurfaceRadius.size() == m_referenceSurfaceHalflength.size()) {
53  // assign the size
54  m_referenceSurfaces = m_referenceSurfaceRadius.size();
55  // loop over it and create the
56  std::vector<double>::iterator radiusIter = m_referenceSurfaceRadius.begin();
57  std::vector<double>::iterator radiusIterEnd = m_referenceSurfaceRadius.end();
58  std::vector<double>::iterator halfZIter = m_referenceSurfaceHalflength.begin();
59 
60  for ( ; radiusIter != radiusIterEnd; ++radiusIter, ++halfZIter){
61  // create the Surface triplet
62  std::vector< const Trk::Surface*> surfaceTriplet;
63  surfaceTriplet.push_back(new Trk::DiscSurface(Amg::Transform3D(Amg::Translation3D(0.,0.,*halfZIter)),0.,*radiusIter));
64  surfaceTriplet.push_back(new Trk::CylinderSurface(Amg::Transform3D(),*radiusIter, *halfZIter));
65  surfaceTriplet.push_back(new Trk::DiscSurface(Amg::Transform3D(Amg::Translation3D(0.,0.,-(*halfZIter))),0.,*radiusIter));
66 
67  ATH_MSG_INFO("Creating surfaces: R " << *radiusIter << " Z " << *halfZIter);
68  m_referenceSurfaceTriples.push_back(surfaceTriplet);
69 
70  m_referenceSurfaceNegativeBoundary.push_back(atan2(*radiusIter,-(*halfZIter)));
71  m_referenceSurfacePositiveBoundary.push_back(atan2(*radiusIter,(*halfZIter)));
72 
73  }
74  }
75 
76  m_gaussDist = new Rndm::Numbers(randSvc(), Rndm::Gauss(0.,1.));
77  m_flatDist = new Rndm::Numbers(randSvc(), Rndm::Flat(0.,1.));
78 
79  msg(MSG::INFO) << "initialize() successful in " << endmsg;
80 
81  if( m_eventsPerExecute > 0 ){
82  m_perigees.reserve(m_eventsPerExecute);
83  for( int i=0;i<m_eventsPerExecute;++i ) m_perigees.push_back(generatePerigee());
84  }
85 
86  return StatusCode::SUCCESS;
87 }
88 
89 //================ Finalisation =================================================
90 
92 {
93  // Code entered here will be executed once at the end of the program run.
94  return StatusCode::SUCCESS;
95 }
96 
98  // generate with random number generator
99  double d0 = m_gaussDist->shoot() * m_sigmaD0;
100  double z0 = m_gaussDist->shoot() * m_sigmaZ0;
101  double phi = m_minPhi + (m_maxPhi-m_minPhi)* m_flatDist->shoot();
102  double eta = m_minEta + m_flatDist->shoot()*(m_maxEta-m_minEta);
103  double theta = 2.*atan(exp(-eta));
104  double p = m_minP + m_flatDist->shoot()*(m_maxP-m_minP);
105  double charge = (m_flatDist->shoot() > 0.5 ) ? -1. : 1.;
106  double qOverP = charge/(p);
107  const Trk::PerigeeSurface perSurface;
108  return {d0, z0, phi, theta, qOverP,perSurface};
109 }
110 
111 //================ Execution ====================================================
112 
114 {
115 
116  if( m_eventsPerExecute <= 0 ) runTest(generatePerigee());
117  else for( int i=0;i<m_eventsPerExecute;++i ) runTest(m_perigees[i]);
118  return StatusCode::SUCCESS;
119 }
120 
121 
122 void Trk::ExtrapolatorTest::runTest( const Trk::Perigee& initialPerigee ) {
123  Trk::PropDirection propagationDirection = m_direction > 0 ? Trk::alongMomentum : oppositeMomentum;
124 
125  ATH_MSG_VERBOSE("Starting from : " << initialPerigee );
126  ATH_MSG_VERBOSE(" ---> with direction: " << propagationDirection );
127 
128 
129 
130  std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIter = m_referenceSurfaceTriples.begin();
131  std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIterEnd = m_referenceSurfaceTriples.end();
132 
133  std::vector<double>::iterator negRefIter = m_referenceSurfaceNegativeBoundary.begin();
134  std::vector<double>::iterator posRefIter = m_referenceSurfacePositiveBoundary.begin();
135 
136  double theta = initialPerigee.parameters()[Trk::theta];
137 
138  const EventContext& ctx = Gaudi::Hive::currentContext();
139  for (int refSurface = 0 ; surfaceTripleIter != surfaceTripleIterEnd; ++surfaceTripleIter, ++negRefIter, ++posRefIter ){
140  // decide which reference surface to take
141  refSurface = theta < (*posRefIter) ? 2 : 1;
142  refSurface = theta > (*negRefIter) ? 0 : 1;
143 
144  const Trk::Surface* destinationSurface = (*surfaceTripleIter)[refSurface];
145 
146  const auto* destParameters =
147  m_useExtrapolator
148  ? m_extrapolator->extrapolate(
149  ctx,
150  initialPerigee,
151  *destinationSurface,
152  propagationDirection,
153  false,
154  static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release()
155  :
156 
157  m_propagator
158  ->propagate(ctx,
159  initialPerigee,
160  *destinationSurface,
161  propagationDirection,
162  false,
163  *m_magFieldProperties,
164  static_cast<Trk::ParticleHypothesis>(m_particleType.value()))
165  .release();
166 
167  if (destParameters) {
168  // intersection output
169  ATH_MSG_VERBOSE(" [ intersection ] with surface at (x,y,z) = " <<
170  destParameters->position().x() << ", " <<
171  destParameters->position().y() << ", " <<
172  destParameters->position().z() );
173  } else if (!destParameters)
174  ATH_MSG_DEBUG(" Extrapolation not successful! " );
175 
176  delete destParameters;
177  }
178 }
179 
180 //============================================================================================
181 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Trk::MagneticFieldProperties
Definition: MagneticFieldProperties.h:31
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::oppositeMomentum
@ oppositeMomentum
Definition: PropDirection.h:21
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
Trk::ExtrapolatorTest::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition: ExtrapolatorTest.cxx:91
Trk::ExtrapolatorTest::runTest
void runTest(const Trk::Perigee &perigee)
Definition: ExtrapolatorTest.cxx:122
Trk::z0
@ z0
Definition: ParamDefs.h:64
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
Trk::DiscSurface
Definition: DiscSurface.h:54
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
Trk::ExtrapolatorTest::execute
StatusCode execute()
standard Athena-Algorithm method
Definition: ExtrapolatorTest.cxx:113
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
Trk::ExtrapolatorTest::generatePerigee
Trk::Perigee generatePerigee()
Definition: ExtrapolatorTest.cxx:97
MagneticFieldProperties.h
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
Trk::ExtrapolatorTest::~ExtrapolatorTest
~ExtrapolatorTest()
Default Destructor.
Definition: ExtrapolatorTest.cxx:26
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::ExtrapolatorTest::initialize
StatusCode initialize()
standard Athena-Algorithm method
Definition: ExtrapolatorTest.cxx:41
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::theta
@ theta
Definition: ParamDefs.h:66
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::CylinderSurface
Definition: CylinderSurface.h:55
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
CylinderSurface.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ParticleHypothesis.h
AthAlgorithm
Definition: AthAlgorithm.h:47
EventPrimitives.h
Trk::ExtrapolatorTest::ExtrapolatorTest
ExtrapolatorTest(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: ExtrapolatorTest.cxx:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Trk::d0
@ d0
Definition: ParamDefs.h:63
charge
double charge(const T &p)
Definition: AtlasPID.h:931
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
ExtrapolatorTest.h
DiscSurface.h
Trk::phi
@ phi
Definition: ParamDefs.h:75
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7