1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006
|
/*
* VNavigator.h
*
* Created on: 17.09.2015
* Author: swenzel
*/
#ifndef NAVIGATION_VNAVIGATOR_H_
#define NAVIGATION_VNAVIGATOR_H_
#include "VecGeom/base/Global.h"
#include "VecGeom/base/Vector3D.h"
#include "VecGeom/base/SOA3D.h"
#include "VecGeom/base/Transformation3D.h"
#include "VecGeom/navigation/NavigationState.h"
#include "VecGeom/navigation/GlobalLocator.h"
#include "VecGeom/volumes/PlacedVolume.h"
#include "VecGeom/volumes/LogicalVolume.h"
#include "VecGeom/navigation/VSafetyEstimator.h"
#include "VecGeom/navigation/NavStateFwd.h"
namespace vecgeom {
inline namespace VECGEOM_IMPL_NAMESPACE {
// some forward declarations
template <typename T>
class Vector3D;
// class NavigationState;
class LogicalVolume;
class Transformation3D;
class VPlacedVolume;
//! base class defining basic interface for navigation ( hit-detection )
//! sub classes implement optimized algorithms for logical volumes
class VNavigator {
public:
VNavigator() : fSafetyEstimator(nullptr) {}
VECCORE_ATT_HOST_DEVICE
VSafetyEstimator const *GetSafetyEstimator() const { return fSafetyEstimator; }
//! computes the step (distance) to the next object in the geometry hierarchy obtained
//! by propagating with step along the ray
//! the next object could be after a boundary and does not necessarily coincide with the object
//! hit by the ray
//! this methods transforms the global coordinates into local ones usually calls more specialized methods
//! like the hit detection on local coordinates
VECCORE_ATT_HOST_DEVICE
virtual Precision ComputeStepAndPropagatedState(Vector3D<Precision> const & /*globalpoint*/,
Vector3D<Precision> const & /*globaldir*/,
Precision /*(physics) step limit */,
NavigationState const & /*in_state*/,
NavigationState & /*out_state*/) const = 0;
//! computes the step (distance) to the next object in the geometry hierarchy obtained
//! by propagating with step along the ray
//! updates out_state to contain information about the next hitting boundary:
//! - if a daugher is hit: out_state.Top() will be daughter
//! - if ray leaves volume: out_state.Top() will point to current volume
//! - if step limit > step: out_state == in_state
//!
//! This function is essentialy equal to ComputeStepAndPropagatedState without
//! the relocation part
virtual Precision ComputeStep(Vector3D<Precision> const & /*globalpoint*/, Vector3D<Precision> const & /*globaldir*/,
Precision /*(physics) step limit */, NavigationState const & /*in_state*/,
NavigationState & /*out_state*/) const = 0;
//! as above ... also returns the safety ... does not give_back an out_state
//! but the in_state might be modified to contain the next daughter when
//! user specifies indicateDaughterHit = true
VECCORE_ATT_HOST_DEVICE
virtual Precision ComputeStepAndSafety(Vector3D<Precision> const & /*globalpoint*/,
Vector3D<Precision> const & /*globaldir*/, Precision /*(physics) step limit */,
NavigationState & /*in_state*/, bool /*calcsafety*/, Precision & /*safety*/,
bool indicateDaughterHit = false) const = 0;
// an alias interface ( using TGeo name )
VECCORE_ATT_HOST_DEVICE
void FindNextBoundaryAndStep(Vector3D<Precision> const &globalpoint, Vector3D<Precision> const &globaldir,
NavigationState const &in_state, NavigationState &out_state, Precision step_limit,
Precision &step) const
{
step = ComputeStepAndPropagatedState(globalpoint, globaldir, step_limit, in_state, out_state);
}
// an alias interface ( using TGeo name )
void FindNextBoundaryAndStepAndSafety(Vector3D<Precision> const &globalpoint, Vector3D<Precision> const &globaldir,
NavigationState const &in_state, NavigationState &out_state,
Precision step_limit, Precision &step, bool calcsafety, Precision &safety) const
{
step = ComputeStepAndSafetyAndPropagatedState(globalpoint, globaldir, step_limit, in_state, out_state, calcsafety,
safety);
}
// a similar interface, in addition also returning the safety as a result
VECCORE_ATT_HOST_DEVICE
virtual Precision ComputeStepAndSafetyAndPropagatedState(Vector3D<Precision> const & /*globalpoint*/,
Vector3D<Precision> const & /*globaldir*/,
Precision /*(physics) step limit */,
NavigationState const & /*in_state*/,
NavigationState & /*out_state*/, bool /*calcsafefty*/,
Precision & /*safety_out*/) const = 0;
// the bool return type indicates if out_state was already modified; this may happen in assemblies;
// in this case we don't need to copy the in_state to the out state later on
// NavigationState a pointer since we might want to pass nullptr
VECCORE_ATT_HOST_DEVICE
virtual bool CheckDaughterIntersections(LogicalVolume const * /*lvol*/, Vector3D<Precision> const & /*localpoint*/,
Vector3D<Precision> const & /*localdir*/,
NavigationState const * /*in_state*/, NavigationState * /*out_state*/,
Precision & /*step*/, VPlacedVolume const *& /*hitcandidate*/) const = 0;
/// check if a ray given by localpoint, localdir intersects with any daughter. Possibility
/// to pass a volume which is blocked/should be ignored in the query. Updates the step as well as the hitcandidate
/// volume. (This version is useful for G4; assemblies not supported)
VECCORE_ATT_HOST_DEVICE
virtual bool CheckDaughterIntersections(LogicalVolume const * /*lvol*/, Vector3D<Precision> const & /*localpoint*/,
Vector3D<Precision> const & /*localdir*/, VPlacedVolume const * /*blocked*/,
Precision & /*step*/, VPlacedVolume const *& /*hitcandidate*/) const
{
assert(false); // Not implemented --- notify of failure !!
return false;
}
// interfaces for vector/basket navigation
virtual void ComputeStepsAndPropagatedStates(SOA3D<Precision> const & /*globalpoints*/,
SOA3D<Precision> const & /*globaldirs*/,
Precision const * /*(physics) step limits */,
NavigationState const *const * /*in_states*/,
NavigationState ** /*out_states*/, Precision * /*out_steps*/) const = 0;
// for vector navigation
VECCORE_ATT_HOST_DEVICE
virtual void ComputeStepsAndSafetiesAndPropagatedStates(SOA3D<Precision> const &points, SOA3D<Precision> const &dirs,
Precision const *psteps, NavStatePool const &instates,
NavStatePool &outstates, Precision *outsteps,
bool const *calcsafety, Precision *safeties) const = 0;
VECCORE_ATT_HOST_DEVICE
virtual void ComputeStepsAndSafetiesAndPropagatedStates(SOA3D<Precision> const & /*globalpoints*/,
SOA3D<Precision> const & /*globaldirs*/,
Precision const * /*(physics) step limits */,
NavigationState const *const * /*in_states*/,
NavigationState ** /*out_states*/, Precision * /*out_steps*/,
bool const * /*calcsafety*/,
Precision * /*out_safeties*/) const = 0;
// for vector navigation (not doing relocation) -- interface for GeantV
VECCORE_ATT_HOST_DEVICE
virtual void ComputeStepsAndSafeties(SOA3D<Precision> const & /*globalpoints*/,
SOA3D<Precision> const & /*globaldirs*/,
Precision const * /*(physics) step limits */,
NavigationState const *const * /*in_states*/, Precision * /*out_steps*/,
bool const * /*calcsafety*/, Precision * /*out_safeties*/) const = 0;
protected:
// a common relocate method ( to calculate propagated states after the boundary )
VECCORE_ATT_HOST_DEVICE
virtual void Relocate(Vector3D<Precision> const & /*localpoint*/, NavigationState const &__restrict__ /*in_state*/,
NavigationState &__restrict__ /*out_state*/) const = 0;
// a common function to be used by all navigators to ensure consistency in transporting points
// after a boundary
VECGEOM_FORCE_INLINE
VECCORE_ATT_HOST_DEVICE
static Vector3D<Precision> MovePointAfterBoundary(Vector3D<Precision> const &localpoint,
Vector3D<Precision> const &dir, Precision step)
{
const Precision extra = 1E-6; // TODO: to be revisited (potentially going for a more relative approach)
return localpoint + (step + extra) * dir;
}
public:
VECCORE_ATT_DEVICE
virtual ~VNavigator(){};
// get name of implementing class
virtual const char *GetName() const = 0;
typedef VSafetyEstimator SafetyEstimator_t;
protected:
VECCORE_ATT_HOST_DEVICE
VNavigator(VSafetyEstimator *s) : fSafetyEstimator(s) {}
VSafetyEstimator *fSafetyEstimator; // a pointer to the safetyEstimator which can be used by the Navigator
// some common code to prepare the outstate
VECGEOM_FORCE_INLINE
VECCORE_ATT_HOST_DEVICE
static Precision PrepareOutState(NavigationState const &__restrict__ in_state,
NavigationState &__restrict__ out_state, Precision geom_step, Precision step_limit,
VPlacedVolume const *hitcandidate, bool &doneafterthisstep)
{
// now we have the candidates and we prepare the out_state
in_state.CopyTo(&out_state);
doneafterthisstep = false;
// if the following is the case we are in the wrong volume;
// assuming that DistanceToIn returns negative number when point is inside
// do nothing (step=0) and retry one level higher
// TODO: put diagnostic code here ( like in original SimpleNavigator )
if (geom_step == kInfLength && step_limit > 0.) {
geom_step = vecgeom::kTolerance;
out_state.SetBoundaryState(true);
do {
out_state.Pop();
} while (out_state.Top()->GetLogicalVolume()->GetUnplacedVolume()->IsAssembly());
doneafterthisstep = true;
return geom_step;
}
// is geometry further away than physics step?
// this is a physics step
if (geom_step > step_limit) {
// don't need to do anything
geom_step = step_limit;
out_state.SetBoundaryState(false);
return geom_step;
}
// otherwise it is a geometry step
out_state.SetBoundaryState(true);
out_state.SetLastExited();
if (hitcandidate) out_state.Push(hitcandidate);
if (geom_step < 0.) {
// std::cerr << "WARNING: STEP NEGATIVE; NEXTVOLUME " << nexthitvolume << std::endl;
// InspectEnvironmentForPointAndDirection( globalpoint, globaldir, currentstate );
geom_step = 0.;
}
return geom_step;
}
// kernel to be used with both scalar and vector types
template <typename T>
VECGEOM_FORCE_INLINE
VECCORE_ATT_HOST_DEVICE
static T TreatDistanceToMother(VPlacedVolume const *pvol, Vector3D<T> const &localpoint, Vector3D<T> const &localdir,
T step_limit)
{
T step;
assert(pvol != nullptr && "currentvolume is null in navigation");
step = pvol->DistanceToOut(localpoint, localdir, step_limit);
vecCore::MaskedAssign(step, step < T(0.), T(0.));
return step;
}
// default static function doing the global to local transformation
// may be redefined in concrete implementations ( for instance in cases where we know the form of the global matrix
// a-priori )
// input
// TODO: think about how we can have scalar + SIMD version
// note: the last argument is a trick to pass information across function calls ( only exploited in specialized
// navigators )
template <typename T>
VECGEOM_FORCE_INLINE
VECCORE_ATT_HOST_DEVICE
static void DoGlobalToLocalTransformation(NavigationState const &in_state, Vector3D<T> const &globalpoint,
Vector3D<T> const &globaldir, Vector3D<T> &localpoint,
Vector3D<T> &localdir)
{
// calculate local point/dir from global point/dir
Transformation3D m;
in_state.TopMatrix(m);
localpoint = m.Transform(globalpoint);
localdir = m.TransformDirection(globaldir);
}
// version used for SIMD processing
// should be specialized in Impl for faster treatment
template <typename T, unsigned int ChunkSize>
VECGEOM_FORCE_INLINE
VECCORE_ATT_HOST_DEVICE
static void DoGlobalToLocalTransformations(NavigationState const *const *in_states,
SOA3D<Precision> const &globalpoints, SOA3D<Precision> const &globaldirs,
unsigned int from_index, Vector3D<T> &localpoint, Vector3D<T> &localdir)
{
for (unsigned int i = 0; i < ChunkSize; ++i) {
unsigned int trackid = from_index + i;
Transformation3D m;
// assert(in_states[trackid]->Top()->GetLogicalVolume() == lvol &&
// "not all states in same logical volume"); // the logical volume of all the states should be the same
in_states[trackid]->TopMatrix(m); // could benefit from interal vec
auto tmp = m.Transform(globalpoints[trackid]); // could benefit from internal vec
using vecCore::AssignLane;
AssignLane(localpoint.x(), i, tmp.x());
AssignLane(localpoint.y(), i, tmp.y());
AssignLane(localpoint.z(), i, tmp.z());
tmp = m.TransformDirection(globaldirs[trackid]); // could benefit from internal vec
AssignLane(localdir.x(), i, tmp.x());
AssignLane(localdir.y(), i, tmp.y());
AssignLane(localdir.z(), i, tmp.z());
}
}
// version used for SIMD processing
// should be specialized in Impl for faster treatment
template <typename T, unsigned int ChunkSize>
VECGEOM_FORCE_INLINE
VECCORE_ATT_HOST_DEVICE
static void DoGlobalToLocalTransformations(NavStatePool const &in_states, SOA3D<Precision> const &globalpoints,
SOA3D<Precision> const &globaldirs, unsigned int from_index,
Vector3D<T> &localpoint, Vector3D<T> &localdir)
{
for (unsigned int i = 0; i < ChunkSize; ++i) {
unsigned int trackid = from_index + i;
Transformation3D m;
// assert(in_states[trackid]->Top()->GetLogicalVolume() == lvol &&
// "not all states in same logical volume"); // the logical volume of all the states should be the same
in_states[trackid]->TopMatrix(m); // could benefit from internal vec
auto tmp = m.Transform(globalpoints[trackid]); // could benefit from internal vec
using vecCore::AssignLane;
AssignLane(localpoint.x(), i, tmp.x());
AssignLane(localpoint.y(), i, tmp.y());
AssignLane(localpoint.z(), i, tmp.z());
tmp = m.TransformDirection(globaldirs[trackid]); // could benefit from internal vec
AssignLane(localdir.x(), i, tmp.x());
AssignLane(localdir.y(), i, tmp.y());
AssignLane(localdir.z(), i, tmp.z());
}
}
};
//! template class providing a standard implementation for
//! some interfaces in VNavigator (using the CRT pattern)
template <typename Impl, bool MotherIsConvex = false>
class VNavigatorHelper : public VNavigator {
protected:
using VNavigator::VNavigator;
public:
// the default implementation for hit detection with daughters for a chunk of data
// is to loop over the implementation for the scalar case
// this static function may be overridden by the specialized implementations (such as done in NewSimpleNavigator)
// the from_index, to_index indicate which states from the NavigationState ** are actually treated
// in the worst case, we might have to implement this stuff over there
template <typename T, unsigned int ChunkSize>
VECCORE_ATT_HOST_DEVICE
static void DaughterIntersectionsLooper(VNavigator const *nav, LogicalVolume const *lvol,
Vector3D<T> const &localpoint, Vector3D<T> const &localdir,
NavigationState const *const *in_states, NavigationState **out_states,
unsigned int from_index, Precision *out_steps,
VPlacedVolume const *hitcandidates[ChunkSize])
{
// dispatch to ordinary implementation ( which itself might be vectorized )
using vecCore::LaneAt;
for (unsigned int i = 0; i < ChunkSize; ++i) {
unsigned int trackid = from_index + i;
((Impl *)nav)
->Impl::CheckDaughterIntersections(
lvol,
Vector3D<Precision>(LaneAt(localpoint.x(), i), LaneAt(localpoint.y(), i), LaneAt(localpoint.z(), i)),
Vector3D<Precision>(LaneAt(localdir.x(), i), LaneAt(localdir.y(), i), LaneAt(localdir.z(), i)),
in_states[trackid], out_states[trackid], out_steps[trackid], hitcandidates[i]);
}
}
// the default implementation for hit detection with daughters for a chunk of data
// is to loop over the implementation for the scalar case
// this static function may be overridden by the specialized implementations (such as done in NewSimpleNavigator)
// the from_index, to_index indicate which states from the NavigationState ** are actually treated
// in the worst case, we might have to implement this stuff over there
template <typename T, unsigned int ChunkSize>
VECCORE_ATT_HOST_DEVICE
static void DaughterIntersectionsLooper(VNavigator const *nav, LogicalVolume const *lvol,
Vector3D<T> const &localpoint, Vector3D<T> const &localdir,
NavStatePool const &in_states, NavStatePool &out_states,
unsigned int from_index, Precision *out_steps,
VPlacedVolume const *hitcandidates[ChunkSize])
{
// dispatch to ordinary implementation ( which itself might be vectorized )
using vecCore::LaneAt;
for (unsigned int i = 0; i < ChunkSize; ++i) {
unsigned int trackid = from_index + i;
((Impl *)nav)
->Impl::CheckDaughterIntersections(
lvol,
Vector3D<Precision>(LaneAt(localpoint.x(), i), LaneAt(localpoint.y(), i), LaneAt(localpoint.z(), i)),
Vector3D<Precision>(LaneAt(localdir.x(), i), LaneAt(localdir.y(), i), LaneAt(localdir.z(), i)),
in_states[trackid], out_states[trackid], out_steps[trackid], hitcandidates[i]);
}
}
// the default implementation for hit detection with daughters for a chunk of data
// is to loop over the implementation for the scalar case
// similar to previous version; does not care about out_state
template <typename T, unsigned int ChunkSize>
VECCORE_ATT_HOST_DEVICE
static void DaughterIntersectionsLooper(VNavigator const *nav, LogicalVolume const *lvol,
Vector3D<T> const &localpoint, Vector3D<T> const &localdir,
NavigationState const *const *in_states, unsigned int from_index,
Precision *out_steps, VPlacedVolume const *hitcandidates[ChunkSize])
{
// dispatch to ordinary implementation ( which itself might be vectorized )
using vecCore::LaneAt;
for (unsigned int i = 0; i < ChunkSize; ++i) {
unsigned int trackid = from_index + i;
((Impl *)nav)
->Impl::CheckDaughterIntersections(
lvol,
Vector3D<Precision>(LaneAt(localpoint.x(), i), LaneAt(localpoint.y(), i), LaneAt(localpoint.z(), i)),
Vector3D<Precision>(LaneAt(localdir.x(), i), LaneAt(localdir.y(), i), LaneAt(localdir.z(), i)),
in_states[trackid], nullptr, out_steps[trackid], hitcandidates[i]);
}
}
// the default implementation for safety calculation for a chunk of data
template <typename T, unsigned int ChunkSize> // we may go to Backend as template parameter in future
VECCORE_ATT_HOST_DEVICE static void SafetyLooper(VNavigator const *nav, VPlacedVolume const *pvol,
Vector3D<T> const &localpoint, unsigned int from_index,
bool const *calcsafeties, Precision *out_safeties)
{
// dispatch to ordinary implementation ( which itself might be vectorized )
// TODO: check calcsafeties if we need to do this at all
using SafetyE_t = typename Impl::SafetyEstimator_t;
using Bool_v = vecCore::Mask_v<T>;
Bool_v m;
for (unsigned int i = 0; i < ChunkSize; ++i) {
vecCore::AssignMaskLane(m, i, calcsafeties[from_index + i]);
}
T safety(0.);
if (!vecCore::MaskEmpty(m)) {
safety = ((SafetyE_t *)nav->GetSafetyEstimator())->ComputeSafetyForLocalPoint(localpoint, pvol, m);
}
vecCore::Store(safety, &out_safeties[from_index]);
}
public:
VECCORE_ATT_HOST_DEVICE
virtual Precision ComputeStepAndPropagatedState(Vector3D<Precision> const &globalpoint,
Vector3D<Precision> const &globaldir, Precision step_limit,
NavigationState const &in_state,
NavigationState &out_state) const override
{
#ifdef DEBUGNAV
static size_t counter = 0;
counter++;
#endif
// calculate local point/dir from global point/dir
// call the static function for this provided/specialized by the Impl
Vector3D<Precision> localpoint;
Vector3D<Precision> localdir;
Impl::DoGlobalToLocalTransformation(in_state, globalpoint, globaldir, localpoint, localdir);
VPlacedVolume const *hitcandidate = nullptr;
auto pvol = in_state.Top();
auto lvol = pvol->GetLogicalVolume();
Precision step = Impl::TreatDistanceToMother(pvol, localpoint, localdir, step_limit);
// "suck in" algorithm from Impl and treat hit detection in local coordinates for daughters
if (lvol->GetDaughters().size() > 0)
((Impl *)this)
->Impl::CheckDaughterIntersections(lvol, localpoint, localdir, &in_state, &out_state, step, hitcandidate);
// fix state
bool done;
step = Impl::PrepareOutState(in_state, out_state, step, step_limit, hitcandidate, done);
if (done) {
if (out_state.Top() != nullptr) {
assert(!out_state.Top()->GetLogicalVolume()->GetUnplacedVolume()->IsAssembly());
}
return step;
}
// step was physics limited
if (!out_state.IsOnBoundary()) return step;
// otherwise if necessary do a relocation
// try relocation to refine out_state to correct location after the boundary
((Impl *)this)->Impl::Relocate(MovePointAfterBoundary(localpoint, localdir, step), in_state, out_state);
if (out_state.Top() != nullptr) {
while (out_state.Top()->IsAssembly()) {
out_state.Pop();
}
assert(!out_state.Top()->GetLogicalVolume()->GetUnplacedVolume()->IsAssembly());
}
return step;
}
virtual Precision ComputeStep(Vector3D<Precision> const &globalpoint, Vector3D<Precision> const &globaldir,
Precision step_limit, NavigationState const &in_state,
NavigationState &out_state) const override
{
#ifdef DEBUGNAV
static size_t counter = 0;
counter++;
#endif
// calculate local point/dir from global point/dir
// call the static function for this provided/specialized by the Impl
Vector3D<Precision> localpoint;
Vector3D<Precision> localdir;
Impl::DoGlobalToLocalTransformation(in_state, globalpoint, globaldir, localpoint, localdir);
VPlacedVolume const *hitcandidate = nullptr;
auto pvol = in_state.Top();
auto lvol = pvol->GetLogicalVolume();
Precision step = Impl::TreatDistanceToMother(pvol, localpoint, localdir, step_limit);
// "suck in" algorithm from Impl and treat hit detection in local coordinates for daughters
if (lvol->GetDaughters().size() > 0)
((Impl *)this)
->Impl::CheckDaughterIntersections(lvol, localpoint, localdir, &in_state, &out_state, step, hitcandidate);
// fix state
bool done;
step = Impl::PrepareOutState(in_state, out_state, step, step_limit, hitcandidate, done);
if (done) {
if (out_state.Top() != nullptr) {
assert(!out_state.Top()->GetLogicalVolume()->GetUnplacedVolume()->IsAssembly());
}
return step;
}
// step was physics limited
if (!out_state.IsOnBoundary()) return step;
return step;
}
VECCORE_ATT_HOST_DEVICE
virtual Precision ComputeStepAndSafety(Vector3D<Precision> const &globalpoint, Vector3D<Precision> const &globaldir,
Precision step_limit, NavigationState &in_state, bool calcsafety,
Precision &safety, bool indicateDaughterHit = false) const override
{
// FIXME: combine this kernel and the one for ComputeStep() into one generic function
#ifdef DEBUGNAV
static size_t counter = 0;
counter++;
#endif
// calculate local point/dir from global point/dir
// call the static function for this provided/specialized by the Impl
Vector3D<Precision> localpoint;
Vector3D<Precision> localdir;
NavigationState *out_state = nullptr;
Impl::DoGlobalToLocalTransformation(in_state, globalpoint, globaldir, localpoint, localdir);
// get safety first ( the benefit here is that we reuse the local points )
using SafetyE_t = typename Impl::SafetyEstimator_t;
if (calcsafety) {
// call the appropriate safety Estimator
safety = ((SafetyE_t *)fSafetyEstimator)->SafetyE_t::ComputeSafetyForLocalPoint(localpoint, in_state.Top());
}
VPlacedVolume const *hitcandidate = nullptr;
auto pvol = in_state.Top();
auto lvol = pvol->GetLogicalVolume();
Precision step = step_limit;
// is the next object certainly further away than the safety
bool safetydone = calcsafety && safety >= step;
if (!safetydone) {
step = Impl::TreatDistanceToMother(pvol, localpoint, localdir, step_limit);
// "suck in" algorithm from Impl and treat hit detection in local coordinates for daughters
if (lvol->GetDaughters().size() > 0)
((Impl *)this)
->Impl::CheckDaughterIntersections(lvol, localpoint, localdir, &in_state, out_state, step, hitcandidate);
}
if (indicateDaughterHit && hitcandidate) in_state.Push(hitcandidate);
return Min(step, step_limit);
}
VECCORE_ATT_HOST_DEVICE
virtual void ComputeStepsAndSafeties(SOA3D<Precision> const &globalpoints, SOA3D<Precision> const &globaldirs,
Precision const *step_limits, NavigationState const *const *in_states,
Precision *out_steps, bool const *calcsafeties,
Precision *out_safeties) const override
{
// process SIMD part and TAIL part
using Real_v = vecgeom::VectorBackend::Real_v;
(void)(Real_v *)(nullptr); // Avoid spurrious warning: unused type alias 'Real_v' [-Wunused-local-typedef]
const auto size = globalpoints.size();
auto pvol = in_states[0]->Top();
auto lvol = pvol->GetLogicalVolume();
// loop over all tracks in chunks
auto i = decltype(size){0};
constexpr auto kVS = vecCore::VectorSize<Real_v>();
for (; i < (size - (kVS - 1)); i += kVS) {
NavigateAChunkNoReloc<Real_v, kVS>(this, pvol, lvol, globalpoints, globaldirs, step_limits, in_states, out_steps,
calcsafeties, out_safeties, i);
}
// fall back to scalar interface for tail treatment
for (; i < size; ++i) {
out_steps[i] = ((Impl *)this)
->Impl::ComputeStepAndSafety(globalpoints[i], globaldirs[i], step_limits[i],
*const_cast<NavigationState *>(in_states[i]), calcsafeties[i],
out_safeties[i]);
}
i = decltype(size){0};
for (; i < size; ++i)
out_steps[i] = vecCore::math::Min(out_steps[i], step_limits[i]);
}
// this kernel is a generic implementation to navigate with chunks of data
// can be used also for the scalar implementation
template <typename T, unsigned int ChunkSize>
static void NavigateAChunk(VNavigator const *__restrict__ nav, VPlacedVolume const *__restrict__ pvol,
LogicalVolume const *__restrict__ lvol, SOA3D<Precision> const &__restrict__ globalpoints,
SOA3D<Precision> const &__restrict__ globaldirs, Precision const *__restrict__ step_limits,
NavigationState const *const *__restrict__ in_states,
NavigationState **__restrict__ out_states, Precision *__restrict__ out_steps,
unsigned int from_index)
{
VPlacedVolume const *hitcandidates[ChunkSize] = {}; // initialize all to nullptr
Vector3D<T> localpoint, localdir;
Impl::template DoGlobalToLocalTransformations<T, ChunkSize>(in_states, globalpoints, globaldirs, from_index,
localpoint, localdir);
T slimit(vecCore::FromPtr<T>(step_limits + from_index));
// need to calc DistanceToOut first
T step = Impl::template TreatDistanceToMother<T>(pvol, localpoint, localdir, slimit);
vecCore::Store(step, out_steps + from_index);
// "suck in" algorithm from Impl and treat hit detection in local coordinates for daughters
Impl::template DaughterIntersectionsLooper<T, ChunkSize>(nav, lvol, localpoint, localdir, in_states, out_states,
from_index, out_steps, hitcandidates);
// fix state ( seems to be serial so we iterate over indices )
for (unsigned int i = 0; i < ChunkSize; ++i) {
unsigned int trackid = from_index + i;
bool done;
out_steps[trackid] = Impl::PrepareOutState(*in_states[trackid], *out_states[trackid], out_steps[trackid],
vecCore::LaneAt(slimit, i), hitcandidates[i], done);
if (done) continue;
// step was physics limited
if (!out_states[trackid]->IsOnBoundary()) continue;
// otherwise if necessary do a relocation
// try relocation to refine out_state to correct location after the boundary
using vecCore::LaneAt;
((Impl *)nav)
->Impl::Relocate(
MovePointAfterBoundary(
Vector3D<Precision>(LaneAt(localpoint.x(), i), LaneAt(localpoint.y(), i), LaneAt(localpoint.z(), i)),
Vector3D<Precision>(LaneAt(localdir.x(), i), LaneAt(localdir.y(), i), LaneAt(localdir.z(), i)),
out_steps[trackid]),
*in_states[trackid], *out_states[trackid]);
}
}
// this kernel is a generic implementation to navigate with chunks of data
// can be used also for the scalar imple
// same as above but including safety treatment
// TODO: remerge with above to avoid code duplication
template <typename T, unsigned int ChunkSize>
VECCORE_ATT_HOST_DEVICE
static void NavigateAChunk(VNavigator const *__restrict__ nav, VPlacedVolume const *__restrict__ pvol,
LogicalVolume const *__restrict__ lvol, SOA3D<Precision> const &__restrict__ globalpoints,
SOA3D<Precision> const &__restrict__ globaldirs, Precision const *__restrict__ step_limits,
NavigationState const *const *__restrict__ in_states,
NavigationState **__restrict__ out_states, Precision *__restrict__ out_steps,
bool const *__restrict__ calcsafeties, Precision *__restrict__ out_safeties,
unsigned int from_index)
{
VPlacedVolume const *hitcandidates[ChunkSize] = {}; // initialize all to nullptr
Vector3D<T> localpoint, localdir;
Impl::template DoGlobalToLocalTransformations<T, ChunkSize>(in_states, globalpoints, globaldirs, from_index,
localpoint, localdir);
// safety part
Impl::template SafetyLooper<T, ChunkSize>(nav, pvol, localpoint, from_index, calcsafeties, out_safeties);
T slimit(vecCore::FromPtr<T>(step_limits + from_index)); // will only work with new ScalarWrapper
// need to calc DistanceToOut first
T step = Impl::template TreatDistanceToMother<T>(pvol, localpoint, localdir, slimit);
vecCore::Store(step, out_steps + from_index);
// "suck in" algorithm from Impl and treat hit detection in local coordinates for daughters
Impl::template DaughterIntersectionsLooper<T, ChunkSize>(nav, lvol, localpoint, localdir, in_states, out_states,
from_index, out_steps, hitcandidates);
using vecCore::LaneAt;
// fix state ( seems to be serial so we iterate over indices )
for (unsigned int i = 0; i < ChunkSize; ++i) {
unsigned int trackid = from_index + i;
bool done;
out_steps[trackid] = Impl::PrepareOutState(*in_states[trackid], *out_states[trackid], out_steps[trackid],
LaneAt(slimit, i), hitcandidates[i], done);
if (done) continue;
// step was physics limited
if (!out_states[trackid]->IsOnBoundary()) continue;
// otherwise if necessary do a relocation
// try relocation to refine out_state to correct location after the boundary
((Impl *)nav)
->Impl::Relocate(
MovePointAfterBoundary(
Vector3D<Precision>(LaneAt(localpoint.x(), i), LaneAt(localpoint.y(), i), LaneAt(localpoint.z(), i)),
Vector3D<Precision>(LaneAt(localdir.x(), i), LaneAt(localdir.y(), i), LaneAt(localdir.z(), i)),
out_steps[trackid]),
*in_states[trackid], *out_states[trackid]);
}
}
// this kernel is a generic implementation to navigate with chunks of data
// can be used also for the scalar implementation
// same as above but including safety treatment
// TODO: remerge with above to avoid code duplication
template <typename T, unsigned int ChunkSize>
VECCORE_ATT_HOST_DEVICE
static void NavigateAChunk(VNavigator const *__restrict__ nav, VPlacedVolume const *__restrict__ pvol,
LogicalVolume const *__restrict__ lvol, SOA3D<Precision> const &__restrict__ globalpoints,
SOA3D<Precision> const &__restrict__ globaldirs, Precision const *__restrict__ step_limits,
NavStatePool const &in_states, NavStatePool &out_states, Precision *__restrict__ out_steps,
bool const *__restrict__ calcsafeties, Precision *__restrict__ out_safeties,
unsigned int from_index)
{
VPlacedVolume const *hitcandidates[ChunkSize] = {}; // initialize all to nullptr
Vector3D<T> localpoint, localdir;
Impl::template DoGlobalToLocalTransformations<T, ChunkSize>(in_states, globalpoints, globaldirs, from_index,
localpoint, localdir);
// safety part
Impl::template SafetyLooper<T, ChunkSize>(nav, pvol, localpoint, from_index, calcsafeties, out_safeties);
T slimit(vecCore::FromPtr<T>(step_limits + from_index)); // will only work with new ScalarWrapper
// need to calc DistanceToOut first
T step = Impl::template TreatDistanceToMother<T>(pvol, localpoint, localdir, slimit);
vecCore::Store(step, out_steps + from_index);
// "suck in" algorithm from Impl and treat hit detection in local coordinates for daughters
Impl::template DaughterIntersectionsLooper<T, ChunkSize>(nav, lvol, localpoint, localdir, in_states, out_states,
from_index, out_steps, hitcandidates);
using vecCore::LaneAt;
// fix state ( seems to be serial so we iterate over indices )
for (unsigned int i = 0; i < ChunkSize; ++i) {
unsigned int trackid = from_index + i;
bool done;
out_steps[trackid] = Impl::PrepareOutState(*in_states[trackid], *out_states[trackid], out_steps[trackid],
LaneAt(slimit, i), hitcandidates[i], done);
if (done) continue;
// step was physics limited
if (!out_states[trackid]->IsOnBoundary()) continue;
// otherwise if necessary do a relocation
// try relocation to refine out_state to correct location after the boundary
((Impl *)nav)
->Impl::Relocate(
MovePointAfterBoundary(
Vector3D<Precision>(LaneAt(localpoint.x(), i), LaneAt(localpoint.y(), i), LaneAt(localpoint.z(), i)),
Vector3D<Precision>(LaneAt(localdir.x(), i), LaneAt(localdir.y(), i), LaneAt(localdir.z(), i)),
out_steps[trackid]),
*in_states[trackid], *out_states[trackid]);
}
}
// this kernel is a generic implementation to navigate with chunks of data
// can be used also for the scalar implementation
// same as above but including safety treatment
// TODO: remerge with above to avoid code duplication
template <typename T, unsigned int ChunkSize>
VECCORE_ATT_HOST_DEVICE
static void NavigateAChunkNoReloc(VNavigator const *__restrict__ nav, VPlacedVolume const *__restrict__ pvol,
LogicalVolume const *__restrict__ lvol,
SOA3D<Precision> const &__restrict__ globalpoints,
SOA3D<Precision> const &__restrict__ globaldirs,
Precision const *__restrict__ step_limits,
NavigationState const *const *__restrict__ in_states,
Precision *__restrict__ out_steps, bool const *__restrict__ calcsafeties,
Precision *__restrict__ out_safeties, unsigned int from_index)
{
VPlacedVolume const *hitcandidates[ChunkSize] = {}; // initialize all to nullptr
Vector3D<T> localpoint, localdir;
Impl::template DoGlobalToLocalTransformations<T, ChunkSize>(in_states, globalpoints, globaldirs, from_index,
localpoint, localdir);
// safety part
Impl::template SafetyLooper<T, ChunkSize>(nav, pvol, localpoint, from_index, calcsafeties, out_safeties);
T slimit(vecCore::FromPtr<T>(step_limits + from_index));
// need to calc DistanceToOut first
T step = Impl::template TreatDistanceToMother<T>(pvol, localpoint, localdir, slimit);
vecCore::Store(step, out_steps + from_index);
// "suck in" algorithm from Impl and treat hit detection in local coordinates for daughters
Impl::template DaughterIntersectionsLooper<T, ChunkSize>(nav, lvol, localpoint, localdir, in_states, from_index,
out_steps, hitcandidates);
}
// generic implementation for the vector interface
// this implementation tries to process everything in vector CHUNKS
// at the very least this enables at least the DistanceToOut call to be vectorized
virtual void ComputeStepsAndPropagatedStates(SOA3D<Precision> const &__restrict__ globalpoints,
SOA3D<Precision> const &__restrict__ globaldirs,
Precision const *__restrict__ step_limit,
NavigationState const *const *__restrict__ in_states,
NavigationState **__restrict__ out_states,
Precision *__restrict__ out_steps) const override
{
// process SIMD part and TAIL part
// something like
using Real_v = vecgeom::VectorBackend::Real_v;
(void)(Real_v *)(nullptr); // Avoid spurrious warning: unused type alias 'Real_v' [-Wunused-local-typedef]
const auto size = globalpoints.size();
auto pvol = in_states[0]->Top();
auto lvol = pvol->GetLogicalVolume();
// loop over all tracks in chunks
auto i = decltype(size){0};
constexpr auto kVS = vecCore::VectorSize<Real_v>();
for (; i < (size - (kVS - 1)); i += kVS) {
NavigateAChunk<Real_v, kVS>(this, pvol, lvol, globalpoints, globaldirs, step_limit, in_states, out_states,
out_steps, i);
}
// fall back to scalar interface for tail treatment
for (; i < size; ++i) {
out_steps[i] = ((Impl *)this)
->Impl::ComputeStepAndPropagatedState(globalpoints[i], globaldirs[i], step_limit[i],
*in_states[i], *out_states[i]);
}
}
// generic implementation for the vector interface -- using NavStatePool instead of NavigationState**
// this implementation tries to process everything in vector CHUNKS
// at the very least this enables at least the DistanceToOut call to be vectorized
VECCORE_ATT_HOST_DEVICE
virtual void ComputeStepsAndSafetiesAndPropagatedStates(SOA3D<Precision> const &__restrict__ globalpoints,
SOA3D<Precision> const &__restrict__ globaldirs,
Precision const *__restrict__ step_limit,
NavStatePool const &in_states, NavStatePool &out_states,
Precision *__restrict__ out_steps,
bool const *__restrict__ calcsafeties,
Precision *__restrict__ out_safeties) const override
{
// process SIMD part and TAIL part
// something like
const auto size = globalpoints.size();
auto pvol = in_states[0]->Top();
auto lvol = pvol->GetLogicalVolume();
// loop over all tracks in chunks
auto i = decltype(size){0};
constexpr auto kVS = vecCore::VectorSize<Real_v>();
for (; i < (size - (kVS - 1)); i += kVS) {
NavigateAChunk<Real_v, kVS>(this, pvol, lvol, globalpoints, globaldirs, step_limit, in_states, out_states,
out_steps, calcsafeties, out_safeties, i);
}
// fall back to scalar interface for tail treatment
for (; i < size; ++i) {
out_steps[i] = ((Impl *)this)
->Impl::ComputeStepAndSafetyAndPropagatedState(globalpoints[i], globaldirs[i], step_limit[i],
*in_states[i], *out_states[i], calcsafeties[i],
out_safeties[i]);
}
}
// generic implementation for the vector interface
// this implementation tries to process everything in vector CHUNKS
// at the very least this enables at least the DistanceToOut call to be vectorized
VECCORE_ATT_HOST_DEVICE
virtual void ComputeStepsAndSafetiesAndPropagatedStates(
SOA3D<Precision> const &__restrict__ globalpoints, SOA3D<Precision> const &__restrict__ globaldirs,
Precision const *__restrict__ step_limit, NavigationState const *const *__restrict__ in_states,
NavigationState **__restrict__ out_states, Precision *__restrict__ out_steps,
bool const *__restrict__ calcsafeties, Precision *__restrict__ out_safeties) const override
{
// process SIMD part and TAIL part
// something like
using Real_v = vecgeom::VectorBackend::Real_v;
(void)(Real_v *)(nullptr); // Avoid spurrious warning: unused type alias 'Real_v' [-Wunused-local-typedef]
const auto size = globalpoints.size();
auto pvol = in_states[0]->Top();
auto lvol = pvol->GetLogicalVolume();
// loop over all tracks in chunks
auto i = decltype(size){0};
constexpr auto kVS = vecCore::VectorSize<Real_v>();
for (; i < (size - (kVS - 1)); i += kVS) {
NavigateAChunk<Real_v, kVS>(this, pvol, lvol, globalpoints, globaldirs, step_limit, in_states, out_states,
out_steps, calcsafeties, out_safeties, i);
}
// fall back to scalar interface for tail treatment
for (; i < size; ++i) {
out_steps[i] = ((Impl *)this)
->Impl::ComputeStepAndSafetyAndPropagatedState(globalpoints[i], globaldirs[i], step_limit[i],
*in_states[i], *out_states[i], calcsafeties[i],
out_safeties[i]);
}
}
#ifdef TRIVIAL
// another generic implementation for the vector interface
// this implementation just loops over the scalar interface
virtual void ComputeStepsAndPropagatedStates(SOA3D<Precision> const &__restrict__ globalpoints,
SOA3D<Precision> const &__restrict__ globaldirs,
Precision const *__restrict__ step_limit,
NavigationState const *const *__restrict__ in_states,
NavigationState **__restrict__ out_states,
Precision *__restrict__ out_steps) const override
{
for (unsigned int i = 0; i < globalpoints.size(); ++i) {
out_steps[i] = ((Impl *)this)
->Impl::ComputeStepAndPropagatedState(globalpoints[i], globaldirs[i], step_limit[i],
*in_states[i], *out_states[i]);
}
}
VECCORE_ATT_HOST_DEVICE
virtual void ComputeStepsAndSafetiesAndPropagatedStates(
SOA3D<Precision> const &__restrict__ globalpoints, SOA3D<Precision> const &__restrict__ globaldirs,
Precision const *__restrict__ step_limit, NavigationState const *const *__restrict__ in_states,
NavigationState **__restrict__ out_states, Precision *__restrict__ out_steps,
bool const *__restrict__ calcsafeties, Precision *__restrict__ out_safeties) const override
{
for (unsigned int i = 0; i < globalpoints.size(); ++i) {
out_steps[i] = ((Impl *)this)
->Impl::ComputeStepAndSafetyAndPropagatedState(globalpoints[i], globaldirs[i], step_limit[i],
*in_states[i], *out_states[i], calcsafeties[i],
out_safeties[i]);
}
}
#endif
// a similar interface also returning the safety
// TODO: reduce this evident code duplication with ComputeStepAndPropagatedState
VECCORE_ATT_HOST_DEVICE
virtual Precision ComputeStepAndSafetyAndPropagatedState(Vector3D<Precision> const &globalpoint,
Vector3D<Precision> const &globaldir, Precision step_limit,
NavigationState const &__restrict__ in_state,
NavigationState &__restrict__ out_state, bool calcsafety,
Precision &safety_out) const override
{
// calculate local point/dir from global point/dir
Vector3D<Precision> localpoint;
Vector3D<Precision> localdir;
Impl::DoGlobalToLocalTransformation(in_state, globalpoint, globaldir, localpoint, localdir);
// get safety first ( the benefit here is that we reuse the local points )
using SafetyE_t = typename Impl::SafetyEstimator_t;
safety_out = 0.;
if (calcsafety) {
// call the appropriate safety Estimator
safety_out = ((SafetyE_t *)fSafetyEstimator)->SafetyE_t::ComputeSafetyForLocalPoint(localpoint, in_state.Top());
}
VPlacedVolume const *hitcandidate = nullptr;
auto pvol = in_state.Top();
auto lvol = pvol->GetLogicalVolume();
Precision step = Impl::TreatDistanceToMother(pvol, localpoint, localdir, step_limit);;
if (lvol->GetDaughters().size() > 0)
// "suck in" algorithm from Impl and treat hit detection in local coordinates for daughters
((Impl *)this)
->Impl::CheckDaughterIntersections(lvol, localpoint, localdir, &in_state, &out_state, step, hitcandidate);
// fix state
bool done;
step = Impl::PrepareOutState(in_state, out_state, step, step_limit, hitcandidate, done);
if (done) return step;
// step was physics limited
if (!out_state.IsOnBoundary()) return step;
// otherwise if necessary do a relocation
// try relocation to refine out_state to correct location after the boundary
((Impl *)this)->Impl::Relocate(MovePointAfterBoundary(localpoint, localdir, step), in_state, out_state);
return step;
}
protected:
// a common relocate method ( to calculate propagated states after the boundary )
VECGEOM_FORCE_INLINE
VECCORE_ATT_HOST_DEVICE
virtual void Relocate(Vector3D<Precision> const &pointafterboundary, NavigationState const &__restrict__ in_state,
NavigationState &__restrict__ out_state) const override
{
// this means that we are leaving the mother
// alternatively we could use nextvolumeindex like before
if (out_state.Top() == in_state.Top()) {
GlobalLocator::RelocatePointFromPathForceDifferent(pointafterboundary, out_state);
#ifdef CHECK_RELOCATION_ERRORS
assert(in_state.Distance(out_state) != 0 && " error relocating when leaving ");
#endif
} else {
// continue directly further down ( next volume should have been stored in out_state already )
VPlacedVolume const *nextvol = out_state.Top();
out_state.Pop();
GlobalLocator::LocateGlobalPoint(nextvol, nextvol->GetTransformation()->Transform(pointafterboundary), out_state,
false);
#ifdef CHECK_RELOCATION_ERRORS
assert(in_state.Distance(out_state) != 0 && " error relocating when entering ");
#endif
return;
}
}
public:
static const char *GetClassName() { return Impl::gClassNameString; }
virtual const char *GetName() const override { return GetClassName(); }
}; // end class VNavigatorHelper
} // namespace VECGEOM_IMPL_NAMESPACE
} // namespace vecgeom
#endif /* NAVIGATION_VNAVIGATOR_H_ */
|