ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::TargetSurfaces Class Reference

#include <TargetSurfaces.h>

Collaboration diagram for Trk::TargetSurfaces:

Public Member Functions

 TargetSurfaces ()=default
 Constructor. More...
 
 ~TargetSurfaces ()=default
 Destructor. More...
 
Trk::ExtrapolationCode setOnInput (const Trk::ExCellCharged &, const Trk::Surface *sf, const BoundaryCheck &bc)
 Extract surfaces for charged propagation, step into new frame volume. More...
 
Trk::ExtrapolationCode setOnInput (const Amg::Vector3D &position, const Amg::Vector3D &direction, const Trk::TrackingVolume *, const Trk::Surface *sf, const BoundaryCheck &bc)
 Extract surfaces for charged propagation, step into new frame volume. More...
 
TargetSurfaceVector orderedIntersections (const Trk::ExCellNeutral &, const Trk::Surface *sf, const BoundaryCheck &bc)
 Ordered intersections for neutral transport, step into new frame volume. More...
 
TargetSurfaceVector orderedIntersections (const Amg::Vector3D &position, const Amg::Vector3D &direction, const Trk::TrackingVolume *, const Trk::Surface *sf, const BoundaryCheck &bc)
 Ordered intersections for neutral transport, step into new frame volume. More...
 
bool initFrameVolume (const Amg::Vector3D &position, const Amg::Vector3D &direction, const Trk::TrackingVolume *)
 update of target surfaces at input or at frame volume boundary More...
 
void fillSolutions (int index, Amg::Vector3D gp, TargetSurfaceVector &solutions)
 intersections More...
 
bool checkDistance (const Amg::Vector3D &position, const Amg::Vector3D &direction, double nextStep)
 distance reevaluation More...
 
double distanceToNext ()
 estimated distance along path to the nearest surface More...
 
bool flipDirection ()
 step over intersection More...
 
int nextSf ()
 index of nearest surface More...
 
unsigned numSf ()
 number of intersections along path More...
 
bool debugMode ()
 debug mode More...
 
void setDebugModeOn ()
 set debug mode More...
 
void setDebugModeOff ()
 set debug mode More...
 
const Trk::TrackingVolumecurrentDense ()
 current material volume/input for propagation More...
 
const Trk::TrackingVolumecurrentFrame ()
 current material volume/input for propagation More...
 

Private Member Functions

void evaluateInputDistance (Trk::TargetSurface &tt, const Amg::Vector3D &pos, const Amg::Vector3D &dir, bool base)
 
void save (Trk::TargetSurface &tt, bool base)
 
void findNext ()
 
TargetSurfaceVector orderIntersections () const
 
bool updateDistance (int index, Trk::TargetSurface &tt, const Amg::Vector3D &position, const Amg::Vector3D &direction)
 

Private Attributes

bool m_orderTrue {true}
 
bool m_flipDirection {false}
 
bool m_absDist {false}
 
bool m_debugMode {false}
 
float m_tolerance {0.001}
 
TargetSurfaceVector m_baseSurfaces
 
std::vector< TargetSurfaceVectorm_tempSurfaces
 
TargetSurfaceVector m_ordered
 
Amg::Vector3D m_probePos
 
Amg::Vector3D m_probeDir
 
unsigned int m_numAlongPath {0}
 
int m_nextSf {-1}
 
double m_distanceToNext {1e6}
 
double m_lastStep {0}
 
double m_flipDistance {0}
 
const Trk::TrackingVolumem_currentFrame {}
 
const Trk::TrackingVolumem_currentDense {}
 

Detailed Description

This class handles selection and distance estimate of surfaces whis can be reached in propagation/transport of particles.

Author
sarka.nosp@m..tod.nosp@m.orova.nosp@m.@cer.nosp@m.n.ch

Definition at line 125 of file TargetSurfaces.h.

Constructor & Destructor Documentation

◆ TargetSurfaces()

Trk::TargetSurfaces::TargetSurfaces ( )
default

Constructor.

◆ ~TargetSurfaces()

Trk::TargetSurfaces::~TargetSurfaces ( )
default

Destructor.

Member Function Documentation

◆ checkDistance()

bool Trk::TargetSurfaces::checkDistance ( const Amg::Vector3D position,
const Amg::Vector3D direction,
double  nextStep 
)

distance reevaluation

Definition at line 471 of file TargetSurfaces.cxx.

474 {
475 
476  m_lastStep = (pos - m_probePos).mag();
477 
478  if (not(m_lastStep > 0.)) {
479  if (m_debugMode)
480  std::cout << "DEBUG:check distance with 0 step:"
481  << "next,dist:" << m_nextSf << "," << m_distanceToNext
482  << std::endl;
483  return true;
484  }
485 
486  // dont overwrite previous estimates before full loop finished
487  // limit the number of reevaluations by using rough estimates
488 
489  int nextSfCandidate = -1;
490  m_distanceToNext = 1.e08;
491  m_numAlongPath = 0;
492  m_flipDirection = false;
493  m_flipDistance = 0.;
494 
495  // index running over all selected surfaces
496  int index = 0;
497 
499  while (is != m_baseSurfaces.end()) {
500  // reevaluate distance if : status = -1 ( leaving surface with possibility
501  // of re-entry,
502  // switch to 0 when abs.distance >
503  // tolerance )
504  // abs.distance < 2*nextStep
505  // otherwise just subtract distance stepped for rough estimate
506 
507  if ((*is).status == -1 ||
508  (fabs((*is).distance) - m_lastStep) < 2 * fabs(nextStep) || m_absDist) {
509  if (m_lastStep > m_tolerance)
510  (*is).setStatus(0);
511  updateDistance(index, (*is), pos, dir);
512  } else {
513  (*is).fastDistanceUpdate(m_lastStep);
514  }
515 
516  if (m_debugMode)
517  std::cout << "DEBUG:check distance:" << index << ":" << (*is).status
518  << "," << (*is).distanceAlongPath << "," << (*is).distance
519  << "," << (*is).signAbsDist
520  << ":flip dir,dist:" << m_flipDirection << "," << m_flipDistance
521  << std::endl;
522  if ((*is).status != -1 || (*is).distanceAlongPath > m_tolerance) {
523  if ((*is).distanceAlongPath > -m_tolerance) {
524  ++m_numAlongPath;
525  double dd = (*is).distanceAlongPath;
526  if (dd > m_tolerance && dd < (*is).distance)
527  dd = (*is).distance;
528  if (dd < m_distanceToNext) {
529  nextSfCandidate = index;
531  }
532  }
533  }
534 
535  ++index;
536  ++is;
537  }
538 
539  m_absDist = false;
540 
541  // distanceAlongPath negative : switch to absolute distance
542  if (nextSfCandidate < 0 && m_distanceToNext > 0.) {
543  if (!m_currentFrame->inside(pos, 0.001)) {
544  std::cout << "ERROR:frame volume left, aborting:"
545  << m_currentFrame->volumeName() << std::endl;
546  return false;
547  }
548  index = 0;
549  is = m_baseSurfaces.begin();
550  while (is != m_baseSurfaces.end()) {
551  updateDistance(index, (*is), pos, dir);
552  if ((*is).status != -1 || (*is).distance > m_tolerance) {
553  if ((*is).distance > -m_tolerance) {
554  ++m_numAlongPath;
555  double dd = (*is).distance;
556  if (dd < m_distanceToNext) {
557  nextSfCandidate = index;
559  }
560  }
561  }
562  ++index;
563  ++is;
564  }
565  if (m_debugMode)
566  std::cout << "DEBUG:closest frame estimate based on absolute distance:"
567  << nextSfCandidate << ":" << m_distanceToNext
568  << ", inside frame volume?" << m_currentFrame->inside(pos, 0.)
569  << std::endl;
570  m_absDist = true;
571  }
572 
573  for (auto & tempSurface : m_tempSurfaces) {
574  is = tempSurface.begin();
575 
576  while (is != tempSurface.end()) {
577 
578  if ((*is).status == -1 ||
579  (fabs((*is).distance) - m_lastStep) < 2 * fabs(nextStep)) {
580  updateDistance(index, (*is), pos, dir);
581  } else {
582  (*is).fastDistanceUpdate(m_lastStep);
583  }
584 
585  if ((*is).status != -1 || (*is).distanceAlongPath > m_tolerance) {
586  if ((*is).distanceAlongPath > -m_tolerance) {
587  ++m_numAlongPath;
588  double dd = (*is).distanceAlongPath;
589  if (dd > m_tolerance && dd < (*is).distance)
590  dd = (*is).distance;
591  if (dd < m_distanceToNext) {
592  nextSfCandidate = index;
594  }
595  }
596  }
597 
598  ++index;
599  ++is;
600  }
601  }
602 
603  // distanceToNext estimate reliable for distances below 2*|nextStep| only
604  if (!m_flipDirection && nextSfCandidate != m_nextSf)
605  m_nextSf = nextSfCandidate;
606  // if ( !m_flipDirection && nextSfCandidate != m_nextSf &&
607  // m_distanceToNext<2*fabs(nextStep) ) m_nextSf = nextSfCandidate;
608 
609  // flip direction
610  if (m_flipDirection)
612 
613  m_probePos = pos;
614  m_probeDir = dir;
615 
616  if (m_debugMode)
617  std::cout << "DEBUG:check distance returns:next,dist:" << m_nextSf << ","
618  << m_distanceToNext << std::endl;
619 
620  return true;
621 }

◆ currentDense()

const Trk::TrackingVolume * Trk::TargetSurfaces::currentDense ( )
inline

current material volume/input for propagation

Definition at line 267 of file TargetSurfaces.h.

268 {
269  return m_currentDense;
270 }

◆ currentFrame()

const Trk::TrackingVolume * Trk::TargetSurfaces::currentFrame ( )
inline

current material volume/input for propagation

Definition at line 273 of file TargetSurfaces.h.

274 {
275  return m_currentFrame;
276 }

◆ debugMode()

bool Trk::TargetSurfaces::debugMode ( )
inline

debug mode

Definition at line 261 of file TargetSurfaces.h.

262 {
263  return m_debugMode;
264 }

◆ distanceToNext()

double Trk::TargetSurfaces::distanceToNext ( )
inline

estimated distance along path to the nearest surface

Definition at line 237 of file TargetSurfaces.h.

238 {
239  return m_distanceToNext;
240 }

◆ evaluateInputDistance()

void Trk::TargetSurfaces::evaluateInputDistance ( Trk::TargetSurface tt,
const Amg::Vector3D pos,
const Amg::Vector3D dir,
bool  base 
)
private

Definition at line 218 of file TargetSurfaces.cxx.

222 {
223  Trk::DistanceSolution distSol =
224  tt.surf->straightLineDistanceEstimate(pos, mom);
225 
226  double dist = distSol.first();
227  Amg::Vector3D posi = pos + dist * mom;
228  // skip trivial solutions
229  if (distSol.numberOfSolutions() > 1 && dist < m_tolerance &&
230  distSol.second() > m_tolerance) {
231  dist = distSol.second();
232  posi = pos + dist * mom;
233  if (m_orderTrue &&
234  !tt.surf->isOnSurface(posi, tt.bcheck, m_tolerance, m_tolerance))
235  return;
236  double dAbs = distSol.currentDistance(true);
237  tt.setDistance(dist,
238  fabs(dAbs),
239  distSol.signedDistance() && dAbs != 0. ? dAbs / fabs(dAbs)
240  : 0.);
241  tt.setPosition(posi);
242  if (fabs(dAbs) < m_tolerance)
243  tt.setStatus(-1);
244  else
245  tt.setStatus(1);
246  save(tt, base);
247  return;
248  }
249  // save closest solution
250  if (!m_orderTrue || dist > m_tolerance) {
251  double dAbs = distSol.currentDistance(true);
252  tt.setDistance(dist,
253  fabs(dAbs),
254  distSol.signedDistance() && dAbs != 0. ? dAbs / fabs(dAbs)
255  : 0.);
256  tt.setPosition(posi);
257  if (fabs(dAbs) < m_tolerance)
258  tt.setStatus(-1);
259  else if (dist > m_tolerance)
260  tt.setStatus(1);
261  save(tt, base);
262  }
263 
264  // save multiple intersection for neutral transport
265  if (distSol.numberOfSolutions() > 1 && distSol.second() > m_tolerance &&
266  m_orderTrue) {
267  dist = distSol.second();
268  posi = pos + dist * mom;
269  if (tt.surf->isOnSurface(posi, tt.bcheck, m_tolerance, m_tolerance)) {
270  double dAbs = distSol.currentDistance(true);
271  tt.setDistance(dist,
272  fabs(dAbs),
273  distSol.signedDistance() && dAbs != 0. ? dAbs / fabs(dAbs)
274  : 0.);
275  tt.setPosition(posi);
276  if (fabs(dAbs) < m_tolerance)
277  tt.setStatus(-1);
278  else
279  tt.setStatus(1);
280  save(tt, base);
281  }
282  }
283 }

◆ fillSolutions()

void Trk::TargetSurfaces::fillSolutions ( int  index,
Amg::Vector3D  gp,
TargetSurfaceVector solutions 
)

intersections

Definition at line 624 of file TargetSurfaces.cxx.

627 {
628  // index running over all selected surfaces
629  int index = 0;
630 
631  if (m_debugMode)
632  std::cout << "fill solutions at R,z,phi:" << gp.perp() << "," << gp.z()
633  << "," << gp.phi() << std::endl;
634 
636  while (is != m_baseSurfaces.end()) {
637 
638  if ((*is).status != -1) {
639 
640  if (index == hitSf ||
641  fabs((*is).distanceAlongPath) < 0.01) { // onSurface && boundary check
642  if (m_debugMode)
643  std::cout << "DEBUG: onSurface, without bcheck, twice tolerance:"
644  << (*is).surf->isOnSurface(
645  gp, (*is).bcheck, m_tolerance, m_tolerance)
646  << ","
647  << (*is).surf->isOnSurface(
648  gp, false, m_tolerance, m_tolerance)
649  << ","
650  << (*is).surf->isOnSurface(
651  gp, (*is).bcheck, 2 * m_tolerance, 2 * m_tolerance)
652  << std::endl;
653  if ((*is).surf->isOnSurface(gp, (*is).bcheck, m_tolerance, m_tolerance))
654  solutions.push_back((*is));
655  else if ((*is).surf->isOnSurface(
656  gp,
657  false,
658  m_tolerance,
659  m_tolerance)) { // probably numerical precision problem
660  solutions.push_back((*is)); // in boundary check,
662  gp, m_tolerance)) // possible navigation break
663  std::cout << "DEBUG: frame boundary crossed outside volume "
664  << m_currentFrame->volumeName() << std::endl;
665  } else if (index == hitSf)
666  (*is).status = -1;
667  }
668  }
669 
670  ++index;
671  ++is;
672  }
673 
674  for (auto & tempSurface : m_tempSurfaces) {
675  is = tempSurface.begin();
676 
677  while (is != tempSurface.end()) {
678 
679  if ((*is).status != -1) {
680 
681  if (index == hitSf ||
682  (*is).distanceAlongPath < 0.01) { // onSurface && boundary check
683  if ((*is).surf->isOnSurface(
684  gp, (*is).bcheck, m_tolerance, m_tolerance))
685  solutions.push_back((*is));
686  else if (index == hitSf)
687  (*is).status = -1.;
688  }
689  }
690 
691  ++index;
692  ++is;
693  }
694  }
695 }

◆ findNext()

void Trk::TargetSurfaces::findNext ( )
private

Definition at line 418 of file TargetSurfaces.cxx.

419 {
420 
421  m_nextSf = -1;
422  m_distanceToNext = 1.e06;
423  m_numAlongPath = 0;
424 
425  // index running over all selected surfaces
426  int index = 0;
427 
429  while (is != m_baseSurfaces.end()) {
430  if ((*is).status == -1 && (*is).distanceAlongPath > m_tolerance) {
431  m_numAlongPath++;
432  double dd = (*is).distanceAlongPath;
433  if (dd < m_distanceToNext) {
434  m_nextSf = index;
436  }
437  }
438  if ((*is).status != -1 && (*is).distanceAlongPath > m_tolerance) {
439  m_numAlongPath++;
440  double dd = (*is).distanceAlongPath;
441  if (dd > m_tolerance && dd < (*is).distance)
442  dd = (*is).distance;
443  if (dd < m_distanceToNext) {
444  m_nextSf = index;
446  }
447  }
448  ++index;
449  ++is;
450  }
451  for (auto & tempSurface : m_tempSurfaces) {
452  is = tempSurface.begin();
453  while (is != tempSurface.end()) {
454  if ((*is).status != -1 && (*is).distanceAlongPath > m_tolerance) {
455  ++m_numAlongPath;
456  double dd = (*is).distanceAlongPath;
457  if (dd > m_tolerance && dd < (*is).distance)
458  dd = (*is).distance;
459  if (dd < m_distanceToNext) {
460  m_nextSf = index;
462  }
463  }
464  ++index;
465  ++is;
466  }
467  }
468 }

◆ flipDirection()

bool Trk::TargetSurfaces::flipDirection ( )
inline

step over intersection

Definition at line 243 of file TargetSurfaces.h.

244 {
245  return m_flipDirection;
246 }

◆ initFrameVolume()

bool Trk::TargetSurfaces::initFrameVolume ( const Amg::Vector3D position,
const Amg::Vector3D direction,
const Trk::TrackingVolume fVol 
)

update of target surfaces at input or at frame volume boundary

Definition at line 117 of file TargetSurfaces.cxx.

120 {
121  if (!fVol)
122  return true;
123 
124  m_currentFrame = fVol; //
125  m_currentDense = fVol; // default
126 
127  if (m_debugMode)
128  std::cout << "DEBUG:input frame volume:" << fVol->volumeName()
129  << " at position z:" << fVol->center().z() << std::endl;
130 
131  m_tolerance = 0.001;
132 
133  // save probe coordinates
134  m_probePos = pos;
135  m_probeDir = dir;
136 
137  // clear cache : keep target surfaces
139  while (is != m_baseSurfaces.end() &&
140  (*is).sfType == Trk::SurfNavigType::Target)
141  ++is;
142  if (is != m_baseSurfaces.end())
143  m_baseSurfaces.erase(is, m_baseSurfaces.end());
144  m_tempSurfaces.clear();
145 
146  // static frame boundaries
147  const auto& bounds = fVol->boundarySurfaces();
148  for (unsigned int ib = 0; ib < bounds.size(); ++ib) {
149  const Trk::Surface& surf = (bounds[ib])->surfaceRepresentation();
150  Trk::TargetSurface bb(&surf,
151  true,
153  ib,
154  fVol,
156  evaluateInputDistance(bb, pos, dir, true);
157  if (m_debugMode)
158  std::cout << "DEBUG:frame input:id:status:distance:" << ib << ":"
159  << bb.status << ":" << bb.distanceAlongPath << std::endl;
160  }
161 
162  // check early exit
163  m_nextSf = -1;
164  double dExit = 0.;
165 
166  // index running over frame boundary only
167  int index = 0;
168 
169  is = m_baseSurfaces.begin();
170  while (is != m_baseSurfaces.end()) {
171  if ((*is).sfType == Trk::SurfNavigType::BoundaryFrame) {
172  double dist = (*is).distanceAlongPath;
173  if (dist < m_tolerance && dist > dExit) {
174  Amg::Vector3D probe = pos + dir * dist;
175  if ((*is).surf->isOnSurface(probe, true, m_tolerance, m_tolerance)) {
176  const Trk::TrackingVolume* nextVolume =
177  bounds[(*is).index]->attachedVolume(
178  probe, dir, Trk::alongMomentum);
179  if (nextVolume != fVol) {
180  dExit = dist;
181  m_nextSf = index;
182  }
183  }
184  }
185  ++index;
186  }
187  ++is;
188  }
189 
190  // if (m_debugMode) {
191  // findNext();
192  // std::cout <<"resolving SL exit from volume:"<<fVol->volumeName()<<":"<<
193  // m_nextSf<< ","<<dExit<<std::endl;
194  //}
195 
196  if (m_nextSf > -1) {
197 
198  m_distanceToNext = dExit;
199  if (m_debugMode)
200  std::cout << "DEBUG:early exit detected at boundary index:" << m_nextSf
201  << "," << dExit << std::endl;
202  return false;
203  }
204 
205  // fill frame volume
206 
207  // find closest surface and distance
208  findNext();
209 
210  if (m_debugMode)
211  std::cout << "DEBUG:volume exit resolved (SL estimate):" << m_nextSf << ","
212  << m_distanceToNext << std::endl;
213 
214  return true;
215 }

◆ nextSf()

int Trk::TargetSurfaces::nextSf ( )
inline

index of nearest surface

Definition at line 249 of file TargetSurfaces.h.

250 {
251  return m_nextSf;
252 }

◆ numSf()

unsigned int Trk::TargetSurfaces::numSf ( )
inline

number of intersections along path

Definition at line 255 of file TargetSurfaces.h.

256 {
257  return m_numAlongPath;
258 }

◆ orderedIntersections() [1/2]

Trk::TargetSurfaceVector Trk::TargetSurfaces::orderedIntersections ( const Amg::Vector3D position,
const Amg::Vector3D direction,
const Trk::TrackingVolume fVol,
const Trk::Surface sf,
const BoundaryCheck bc 
)

Ordered intersections for neutral transport, step into new frame volume.

Definition at line 81 of file TargetSurfaces.cxx.

86 {
88 
89  // clear cache
90  m_baseSurfaces.clear();
91  m_tempSurfaces.clear();
92  m_ordered.clear();
93  m_orderTrue = true;
94 
95  // destination surface(s) first
96  if (sf) {
98  bcheck,
100  0,
101  nullptr,
103  evaluateInputDistance(tt, position, direction, true);
104  // abort if no valid intersection
105  if (m_baseSurfaces.empty() ||
106  (m_baseSurfaces.back().distanceAlongPath < 0 &&
107  !sf->isOnSurface(position, bcheck, m_tolerance)))
108  return empty;
109  }
110 
111  if (initFrameVolume(position, direction, fVol))
112  return orderIntersections();
113  return empty; // failure navigation?
114 }

◆ orderedIntersections() [2/2]

Trk::TargetSurfaceVector Trk::TargetSurfaces::orderedIntersections ( const Trk::ExCellNeutral eCell,
const Trk::Surface sf,
const BoundaryCheck bc 
)

Ordered intersections for neutral transport, step into new frame volume.

Definition at line 69 of file TargetSurfaces.cxx.

72 {
73  Amg::Vector3D gp = eCell.leadParameters->position();
74  Amg::Vector3D mom = eCell.leadParameters->momentum().normalized();
76 
77  return orderedIntersections(gp, mom * dir, eCell.leadVolume, sf, bcheck);
78 }

◆ orderIntersections()

Trk::TargetSurfaceVector Trk::TargetSurfaces::orderIntersections ( ) const
private

Definition at line 385 of file TargetSurfaces.cxx.

386 {
387 
389 
390  // base surfaces
391  if (m_baseSurfaces.empty())
392  return tsOrd;
393 
394  std::vector<unsigned int> sols(m_baseSurfaces.size());
395  for (unsigned int i = 0; i < m_baseSurfaces.size(); ++i) {
396  sols[i] = i;
397  }
398 
399  unsigned int itest = 1;
400  while (itest < sols.size()) {
401  if (m_baseSurfaces[sols[itest]].distanceAlongPath <
402  m_baseSurfaces[sols[itest - 1]].distanceAlongPath) {
403  unsigned int iex = sols[itest - 1];
404  sols[itest - 1] = sols[itest];
405  sols[itest] = iex;
406  itest = 1;
407  } else
408  ++itest;
409  }
410 
411  for (unsigned int i = 0; i < m_baseSurfaces.size(); ++i)
412  tsOrd.push_back(m_baseSurfaces[sols[i]]);
413 
414  return tsOrd;
415 }

◆ save()

void Trk::TargetSurfaces::save ( Trk::TargetSurface tt,
bool  base 
)
private

Definition at line 368 of file TargetSurfaces.cxx.

369 {
370 
371  if (base)
372  m_baseSurfaces.push_back(tt);
373  else {
374  if (m_tempSurfaces.empty() ||
375  tt.assocVol != m_tempSurfaces.back()[0].assocVol) {
377  local.push_back(tt);
378  m_tempSurfaces.push_back(local);
379  } else
380  m_tempSurfaces.back().push_back(tt);
381  }
382 }

◆ setDebugModeOff()

void Trk::TargetSurfaces::setDebugModeOff ( )
inline

set debug mode

Definition at line 192 of file TargetSurfaces.h.

192 { m_debugMode = false; }

◆ setDebugModeOn()

void Trk::TargetSurfaces::setDebugModeOn ( )
inline

set debug mode

Definition at line 189 of file TargetSurfaces.h.

189 { m_debugMode = true; }

◆ setOnInput() [1/2]

Trk::ExtrapolationCode Trk::TargetSurfaces::setOnInput ( const Amg::Vector3D position,
const Amg::Vector3D direction,
const Trk::TrackingVolume fVol,
const Trk::Surface sf,
const BoundaryCheck bc 
)

Extract surfaces for charged propagation, step into new frame volume.

Definition at line 35 of file TargetSurfaces.cxx.

40 {
41  // clear cache
42  m_baseSurfaces.clear();
43  m_tempSurfaces.clear();
44  m_ordered.clear();
45  m_orderTrue = false;
46 
47  // destination surface(s) first
48  if (sf) {
50  bcheck,
52  0,
53  nullptr,
55  evaluateInputDistance(tt, position, direction, true);
56  // abort if no valid intersection
57  if (m_baseSurfaces.empty() ||
58  (m_baseSurfaces.back().distanceAlongPath < 0 &&
59  !sf->isOnSurface(position, bcheck, m_tolerance)))
61  }
62 
63  if (initFrameVolume(position, direction, fVol))
65  return Trk::ExtrapolationCode::FailureLoop; // failure navigation?
66 }

◆ setOnInput() [2/2]

Trk::ExtrapolationCode Trk::TargetSurfaces::setOnInput ( const Trk::ExCellCharged eCell,
const Trk::Surface sf,
const BoundaryCheck bc 
)

Extract surfaces for charged propagation, step into new frame volume.

Definition at line 23 of file TargetSurfaces.cxx.

26 {
27  Amg::Vector3D gp = eCell.leadParameters->position();
28  Amg::Vector3D mom = eCell.leadParameters->momentum().normalized();
30 
31  return setOnInput(gp, mom * dir, eCell.leadVolume, sf, bcheck);
32 }

◆ updateDistance()

bool Trk::TargetSurfaces::updateDistance ( int  index,
Trk::TargetSurface tt,
const Amg::Vector3D position,
const Amg::Vector3D direction 
)
private

Definition at line 286 of file TargetSurfaces.cxx.

290 {
291  double previousDistance = tt.distanceAlongPath;
292 
293  Trk::DistanceSolution distSol =
294  tt.surf->straightLineDistanceEstimate(pos, dir);
295 
296  double dist = 1.e08;
297 
298  // catch step across surface
299  if (distSol.numberOfSolutions() > 0) {
300  dist = distSol.first();
301  if (distSol.numberOfSolutions() > 1 &&
302  fabs(distSol.first() + m_lastStep - previousDistance) >
303  fabs(distSol.second() + m_lastStep - previousDistance) &&
304  distSol.second() <= 0.) {
305  dist = distSol.second();
306  }
307  }
308 
309  // verify true intersection and flip direction if necessary
310  if (previousDistance * dist < 0. && fabs(dist) > m_tolerance) {
311  // verify change of sign in signedDistance ( after eliminating situations
312  // where this is meaningless )
313  if (!distSol.signedDistance() ||
314  fabs(distSol.currentDistance(true)) < m_tolerance ||
315  tt.distance < m_tolerance ||
316  tt.signAbsDist * distSol.currentDistance(true) <
317  0) { // true intersection
318  // if ( !distSol.signedDistance() ||
319  // tt.signAbsDist*distSol.currentDistance(true)<0) { // true intersection
320  if (index == m_nextSf) {
321  if (m_debugMode)
322  std::cout << "DEBUG:flipping intersection:signed ? true dist:"
323  << distSol.signedDistance() << ":"
324  << tt.signAbsDist * distSol.currentDistance(true)
325  << std::endl;
326  m_flipDirection = true;
327  m_flipDistance = dist;
328  } else if (tt.distance > m_tolerance &&
329  fabs(distSol.currentDistance(true)) > m_tolerance) {
330  // here we need to compare with distance from current closest
331  if (index > m_nextSf) { // easy case, already calculated
332  if (dist < (m_flipDistance - m_tolerance) && tt.status != -1) {
333  m_flipDirection = true;
334  m_flipDistance = dist;
335  m_nextSf = index;
336  }
337  } else if (m_distanceToNext > 0.) { // set as nearest (if not iterating
338  // already), will be rewritten later
339  if (tt.status != -1) {
340  m_flipDirection = true;
341  m_flipDistance = dist;
342  m_nextSf = index;
343  }
344  }
345  }
346  }
347  }
348 
349  // continue iteration if appropriate
350  if (index == m_nextSf && dist < 0. && previousDistance < dist)
351  m_distanceToNext = dist;
352 
353  // save current distance to surface
354  Amg::Vector3D posi = pos + dist * dir;
355  double dAbs = distSol.currentDistance(true);
356  tt.setDistance(dist,
357  fabs(dAbs),
358  distSol.signedDistance() && dAbs != 0. ? dAbs / fabs(dAbs)
359  : 0.);
360  tt.setPosition(posi);
361  if (tt.status == -1 && fabs(dAbs) > m_tolerance)
362  tt.status = dist > 0 ? 1 : 0;
363 
364  return true;
365 }

Member Data Documentation

◆ m_absDist

bool Trk::TargetSurfaces::m_absDist {false}
private

Definition at line 215 of file TargetSurfaces.h.

◆ m_baseSurfaces

TargetSurfaceVector Trk::TargetSurfaces::m_baseSurfaces
private

Definition at line 219 of file TargetSurfaces.h.

◆ m_currentDense

const Trk::TrackingVolume* Trk::TargetSurfaces::m_currentDense {}
private

Definition at line 233 of file TargetSurfaces.h.

◆ m_currentFrame

const Trk::TrackingVolume* Trk::TargetSurfaces::m_currentFrame {}
private

Definition at line 232 of file TargetSurfaces.h.

◆ m_debugMode

bool Trk::TargetSurfaces::m_debugMode {false}
private

Definition at line 216 of file TargetSurfaces.h.

◆ m_distanceToNext

double Trk::TargetSurfaces::m_distanceToNext {1e6}
private

Definition at line 228 of file TargetSurfaces.h.

◆ m_flipDirection

bool Trk::TargetSurfaces::m_flipDirection {false}
private

Definition at line 214 of file TargetSurfaces.h.

◆ m_flipDistance

double Trk::TargetSurfaces::m_flipDistance {0}
private

Definition at line 230 of file TargetSurfaces.h.

◆ m_lastStep

double Trk::TargetSurfaces::m_lastStep {0}
private

Definition at line 229 of file TargetSurfaces.h.

◆ m_nextSf

int Trk::TargetSurfaces::m_nextSf {-1}
private

Definition at line 227 of file TargetSurfaces.h.

◆ m_numAlongPath

unsigned int Trk::TargetSurfaces::m_numAlongPath {0}
private

Definition at line 226 of file TargetSurfaces.h.

◆ m_ordered

TargetSurfaceVector Trk::TargetSurfaces::m_ordered
private

Definition at line 222 of file TargetSurfaces.h.

◆ m_orderTrue

bool Trk::TargetSurfaces::m_orderTrue {true}
private

Definition at line 213 of file TargetSurfaces.h.

◆ m_probeDir

Amg::Vector3D Trk::TargetSurfaces::m_probeDir
private

Definition at line 225 of file TargetSurfaces.h.

◆ m_probePos

Amg::Vector3D Trk::TargetSurfaces::m_probePos
private

Definition at line 224 of file TargetSurfaces.h.

◆ m_tempSurfaces

std::vector<TargetSurfaceVector> Trk::TargetSurfaces::m_tempSurfaces
private

Definition at line 221 of file TargetSurfaces.h.

◆ m_tolerance

float Trk::TargetSurfaces::m_tolerance {0.001}
private

Definition at line 217 of file TargetSurfaces.h.


The documentation for this class was generated from the following files:
Trk::TargetSurfaces::m_absDist
bool m_absDist
Definition: TargetSurfaces.h:215
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Trk::DistanceSolution::currentDistance
double currentDistance(bool signedDist=false) const
Current distance to surface (spatial), signed (along/opposite to surface normal) if input argument tr...
base
std::string base
Definition: hcg.cxx:78
Trk::DistanceSolution::signedDistance
bool signedDistance() const
This method indicates availability of signed current distance (false for Perigee and StraighLineSurfa...
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
Trk::TargetSurfaces::m_numAlongPath
unsigned int m_numAlongPath
Definition: TargetSurfaces.h:226
Trk::TargetSurfaces::save
void save(Trk::TargetSurface &tt, bool base)
Definition: TargetSurfaces.cxx:368
Trk::TargetSurfaces::m_orderTrue
bool m_orderTrue
Definition: TargetSurfaces.h:213
Trk::DistanceSolution
Definition: DistanceSolution.h:25
Trk::TargetSurfaces::findNext
void findNext()
Definition: TargetSurfaces.cxx:418
Trk::Volume::inside
bool inside(const Amg::Vector3D &gp, double tol=0.) const
Inside() method for checks.
Definition: Volume.cxx:90
Trk::TargetSurface
target surface info ( navigation )
Definition: TargetSurfaces.h:56
Trk::DistanceSolution::numberOfSolutions
int numberOfSolutions() const
Number of intersection solutions.
index
Definition: index.py:1
Trk::TrackingVolume::boundarySurfaces
std::vector< SharedObject< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
Definition: TrackingVolume.cxx:982
Trk::ExtrapolationCell::propDirection
PropDirection propDirection
this is the propagation direction
Definition: ExtrapolationCell.h:260
Trk::TargetSurfaces::m_currentDense
const Trk::TrackingVolume * m_currentDense
Definition: TargetSurfaces.h:233
Trk::TargetSurfaces::m_debugMode
bool m_debugMode
Definition: TargetSurfaces.h:216
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
Trk::TargetSurfaces::m_probeDir
Amg::Vector3D m_probeDir
Definition: TargetSurfaces.h:225
Trk::DistanceSolution::first
double first() const
Distance to first intersection solution along direction.
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
Trk::ExtrapolationCode::FailureDestination
@ FailureDestination
Definition: ExtrapolationCell.h:120
python.ElectronD3PDObject.Target
Target
Definition: ElectronD3PDObject.py:172
Trk::TargetSurfaces::m_nextSf
int m_nextSf
Definition: TargetSurfaces.h:227
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::DistanceSolution::second
double second() const
Distance to second intersection solution along direction (for a cylinder surface)
Trk::Volume::center
const Amg::Vector3D & center() const
returns the center of the volume
Definition: Volume.h:86
Trk::TargetSurfaces::updateDistance
bool updateDistance(int index, Trk::TargetSurface &tt, const Amg::Vector3D &position, const Amg::Vector3D &direction)
Definition: TargetSurfaces.cxx:286
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::TargetSurfaces::orderIntersections
TargetSurfaceVector orderIntersections() const
Definition: TargetSurfaces.cxx:385
Trk::BoundaryFrame
@ BoundaryFrame
Definition: TargetSurfaces.h:41
InDetDD::local
@ local
Definition: InDetDD_Defs.h:16
Trk::TargetSurfaces::m_lastStep
double m_lastStep
Definition: TargetSurfaces.h:229
Trk::TrackingVolume::volumeName
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
Trk::TargetSurfaces::m_ordered
TargetSurfaceVector m_ordered
Definition: TargetSurfaces.h:222
Trk::TargetSurfaces::m_distanceToNext
double m_distanceToNext
Definition: TargetSurfaces.h:228
Trk::TargetSurfaces::initFrameVolume
bool initFrameVolume(const Amg::Vector3D &position, const Amg::Vector3D &direction, const Trk::TrackingVolume *)
update of target surfaces at input or at frame volume boundary
Definition: TargetSurfaces.cxx:117
Trk::TargetSurfaces::m_tempSurfaces
std::vector< TargetSurfaceVector > m_tempSurfaces
Definition: TargetSurfaces.h:221
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
library_scraper.dd
list dd
Definition: library_scraper.py:46
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
DeMoScan.index
string index
Definition: DeMoScan.py:364
Trk::ExtrapolationCell::leadParameters
T * leadParameters
the one last truely valid parameter in the stream
Definition: ExtrapolationCell.h:246
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
Trk::TargetSurfaces::evaluateInputDistance
void evaluateInputDistance(Trk::TargetSurface &tt, const Amg::Vector3D &pos, const Amg::Vector3D &dir, bool base)
Definition: TargetSurfaces.cxx:218
Trk::TargetSurfaceVector
std::vector< TargetSurface > TargetSurfaceVector
Definition: TargetSurfaces.h:121
Trk::TargetSurfaces::m_probePos
Amg::Vector3D m_probePos
Definition: TargetSurfaces.h:224
Trk::TargetSurfaces::m_flipDirection
bool m_flipDirection
Definition: TargetSurfaces.h:214
Trk::Frame
@ Frame
Definition: TargetSurfaces.h:49
Trk::TargetSurfaces::m_tolerance
float m_tolerance
Definition: TargetSurfaces.h:217
Trk::TargetSurfaces::m_flipDistance
double m_flipDistance
Definition: TargetSurfaces.h:230
Trk::ExtrapolationCode::FailureLoop
@ FailureLoop
Definition: ExtrapolationCell.h:121
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::ExtrapolationCell::leadVolume
const TrackingVolume * leadVolume
the lead Volume - carrying the navigation stream
Definition: ExtrapolationCell.h:248
Trk::TrackingVolume
Definition: TrackingVolume.h:121
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
Trk::TargetSurfaces::orderedIntersections
TargetSurfaceVector orderedIntersections(const Trk::ExCellNeutral &, const Trk::Surface *sf, const BoundaryCheck &bc)
Ordered intersections for neutral transport, step into new frame volume.
Definition: TargetSurfaces.cxx:69
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
Trk::TargetSurfaces::setOnInput
Trk::ExtrapolationCode setOnInput(const Trk::ExCellCharged &, const Trk::Surface *sf, const BoundaryCheck &bc)
Extract surfaces for charged propagation, step into new frame volume.
Definition: TargetSurfaces.cxx:23
Trk::TargetSurfaces::m_baseSurfaces
TargetSurfaceVector m_baseSurfaces
Definition: TargetSurfaces.h:219
Trk::ExtrapolationCode::InProgress
@ InProgress
Definition: ExtrapolationCell.h:111
Trk::TargetSurfaces::m_currentFrame
const Trk::TrackingVolume * m_currentFrame
Definition: TargetSurfaces.h:232