Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ActsPropagator.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ActsPropagator.cc
1 #include "ActsPropagator.h"
2 
4 
10 
13 
20 
23 {
24  return Acts::Surface::makeShared<Acts::PerigeeSurface>(
26  vertex->get_y() * Acts::UnitConstants::cm,
27  vertex->get_z() * Acts::UnitConstants::cm));
28 }
31 {
32  return Acts::Surface::makeShared<Acts::PerigeeSurface>(
33  vertex * Acts::UnitConstants::cm);
34 }
37  int trackCharge,
39 {
40  Acts::Vector3 momentum(state->get_px(),
41  state->get_py(),
42  state->get_pz());
44  state->get_y() * Acts::UnitConstants::cm,
45  state->get_z() * Acts::UnitConstants::cm,
47 
48  ActsTransformations transformer;
49  Acts::BoundSquareMatrix cov = transformer.rotateSvtxTrackCovToActs(state);
50 
52  surf,
54  actsFourPos, momentum,
55  trackCharge / momentum.norm(),
56  cov,
58 }
61  SvtxVertexMap* vertexMap)
62 {
63  Acts::Vector3 momentum(track->get_px(),
64  track->get_py(),
65  track->get_pz());
66 
67  auto vertexId = track->get_vertex_id();
68  const SvtxVertex* svtxVertex = vertexMap->get(vertexId);
69  Acts::Vector3 vertex = Acts::Vector3::Zero();
70  if (svtxVertex)
71  {
72  vertex(0) = svtxVertex->get_x() * Acts::UnitConstants::cm;
73  vertex(1) = svtxVertex->get_y() * Acts::UnitConstants::cm;
74  vertex(2) = svtxVertex->get_z() * Acts::UnitConstants::cm;
75  }
76 
77  auto perigee =
78  Acts::Surface::makeShared<Acts::PerigeeSurface>(vertex);
79  auto actsFourPos =
81  track->get_y() * Acts::UnitConstants::cm,
82  track->get_z() * Acts::UnitConstants::cm,
84 
85  ActsTransformations transformer;
86 
87  Acts::BoundSquareMatrix cov = transformer.rotateSvtxTrackCovToActs(track);
88 
91  actsFourPos, momentum,
92  track->get_charge() / track->get_p(),
93  cov,
96 }
97 
100  const unsigned int sphenixLayer)
101 {
102  unsigned int actsvolume, actslayer;
103  if (!checkLayer(sphenixLayer, actsvolume, actslayer) or !m_geometry)
104  {
105  return Acts::Result<BoundTrackParamPair>::failure(std::error_code(0, std::generic_category()));
106  }
107 
108  if (m_verbosity > 1)
109  {
110  printTrackParams(params);
111  }
112 
113  auto propagator = makePropagator();
114 
115  using Actors = Acts::ActionList<>;
116  using Aborters = Acts::AbortList<ActsAborter>;
117 
121 
122  options.abortList.get<ActsAborter>().abortlayer = actslayer;
123  options.abortList.get<ActsAborter>().abortvolume = actsvolume;
124 
125  auto result = propagator.propagate(params, options);
126 
127  if (result.ok())
128  {
129  auto finalparams = *result.value().endParameters;
130  auto pathlength = result.value().pathLength;
131  auto pair = std::make_pair(pathlength, finalparams);
132 
134  }
135 
136  return result.error();
137 }
138 
141  const SurfacePtr& surface)
142 {
143  if (m_verbosity > 1)
144  {
145  printTrackParams(params);
146  }
147 
148  auto propagator = makePropagator();
149 
152 
153  auto result = propagator.propagate(params, *surface,
154  options);
155 
156  if (result.ok())
157  {
158  auto finalparams = *result.value().endParameters;
159  auto pathlength = result.value().pathLength;
160  auto pair = std::make_pair(pathlength, finalparams);
161 
163  }
164 
165  return result.error();
166 }
167 
170  const SurfacePtr& surface)
171 {
172  if (m_verbosity > 1)
173  {
174  printTrackParams(params);
175  }
176 
177  auto propagator = makeFastPropagator();
178 
181 
182  auto result = propagator.propagate(params, *surface,
183  options);
184 
185  if (result.ok())
186  {
187  auto finalparams = *result.value().endParameters;
188  auto pathlength = result.value().pathLength;
189  auto pair = std::make_pair(pathlength, finalparams);
190 
192  }
193 
194  return result.error();
195 }
196 
198 {
199  auto field = m_geometry->geometry().magField;
200 
201  if (m_constField)
202  {
203  if (m_verbosity > 2)
204  {
205  std::cout << "Using const field of val " << m_fieldval << std::endl;
206  }
207  Acts::Vector3 fieldVec(0, 0, m_fieldval);
208  field = std::make_shared<Acts::ConstantBField>(fieldVec);
209  }
210 
212 
214  if (m_verbosity > 3)
215  {
216  logLevel = Acts::Logging::VERBOSE;
217  }
218 
219  std::shared_ptr<const Acts::Logger> logger = Acts::getDefaultLogger("ActsPropagator", logLevel);
220 
222  logger);
223 }
225 {
226  auto field = m_geometry->geometry().magField;
227 
228  if (m_constField)
229  {
230  Acts::Vector3 fieldVec(0, 0, m_fieldval);
231  field = std::make_shared<Acts::ConstantBField>(fieldVec);
232  }
233 
237  cfg.resolvePassive = false;
238  cfg.resolveMaterial = true;
239  cfg.resolveSensitive = true;
241 
243  if (m_verbosity > 3)
244  {
245  logLevel = Acts::Logging::VERBOSE;
246  }
247 
248  std::shared_ptr<const Acts::Logger> logger = Acts::getDefaultLogger("ActsPropagator", logLevel);
249  return SphenixPropagator(stepper, navigator, logger);
250 }
251 
252 bool ActsPropagator::checkLayer(const unsigned int& sphenixlayer,
253  unsigned int& actsvolume,
254  unsigned int& actslayer)
255 {
256  /*
257  * Acts geometry is defined in terms of volumes and layers. Within a volume
258  * layers always begin at 2 and iterate in 2s, i.e. the MVTX is defined as a
259  * volume and the 3 layers are identifiable as 2, 4, and 6.
260  * So we convert the sPHENIX layer number here to the Acts volume and
261  * layer number that can interpret where to navigate to in the propagation.
262  * The only exception is the TPOT, which is interpreted as a single layer.
263  */
264 
266  if (sphenixlayer < 3)
267  {
268  actsvolume = 10;
269  actslayer = (sphenixlayer + 1) * 2;
270  }
271 
273  else if (sphenixlayer < 7)
274  {
275  actsvolume = 12;
276  actslayer = ((sphenixlayer - 3) + 1) * 2;
277  }
278 
280  else if (sphenixlayer < 55)
281  {
282  actsvolume = 14;
283  actslayer = ((sphenixlayer - 7) + 1) * 2;
284  }
286  else
287  {
288  actsvolume = 16;
289  actslayer = 2;
290  }
291 
293  auto tgeometry = m_geometry->geometry().tGeometry;
294 
295  bool foundlayer = false;
296  bool foundvolume = false;
297 
298  tgeometry->visitSurfaces([&](const Acts::Surface* srf)
299  {
300  if (srf != nullptr) {
301  auto layer = srf->geometryId().layer();
302  auto volume = srf->geometryId().volume();
303  if(volume == actsvolume and layer == actslayer)
304  {
305  foundlayer = true;
306  foundvolume = true;
307  return;
308  }
309  } });
310 
311  if (!foundlayer or !foundvolume)
312  {
313  std::cout << "trackreco::ActsPropagator::checkLayer Could not identify Acts volume and layer to propagate to. Can't continue. "
314  << std::endl;
315 
316  return false;
317  }
318 
319  return true;
320 }
321 
323 {
324  std::cout << "Propagating final track fit with momentum: "
325  << params.momentum() << " and position "
326  << params.position(m_geometry->geometry().getGeoContext())
327  << std::endl
328  << "track fit phi/eta "
329  << atan2(params.momentum()(1),
330  params.momentum()(0))
331  << " and "
332  << atanh(params.momentum()(2) / params.momentum().norm())
333  << std::endl;
334 }