Skip to content
Snippets Groups Projects
Commit 129c58cc authored by Ben Couturier's avatar Ben Couturier
Browse files

Improved loop

parent 72f63c1c
No related branches found
No related tags found
1 merge request!38WIP: Added tool to display volumes and materials between two points
Pipeline #1624855 failed with stages
in 1 minute and 51 seconds
......@@ -48,24 +48,21 @@ static long dd4hep_find_intersections( dd4hep::Detector& description, int argc,
nav->SetCurrentPoint( start_point.X(), start_point.Y(), start_point.Z() );
nav->SetCurrentDirection( direction.X(), direction.Y(), direction.Z() );
bool reached_end = false;
double distancesq = ( end_point - start_point ).mag2();
while ( !reached_end ) {
nav->FindNextBoundaryAndStep( 10 );
double prev_distancesq = distancesq;
do {
prev_distancesq = distancesq;
nav->FindNextBoundaryAndStep( std::sqrt(distancesq) );
auto c = nav->GetCurrentPoint();
ROOT::Math::XYZPoint current( c[0], c[1], c[2] );
std::ostringstream os;
os << current << " - " << nav->GetCurrentNode()->GetName() << " - "
<< nav->GetCurrentNode()->GetVolume()->GetMaterial()->GetName();
dd4hep::printout( dd4hep::INFO, "find-_intersec", "%s", os.str().c_str() );
double prev_distancesq = distancesq;
dd4hep::printout( dd4hep::INFO, "find_intersec", "%s", os.str().c_str() );
distancesq = ( end_point - current ).mag2();
if ( distancesq > prev_distancesq ) { reached_end = true; }
}
} while ( distancesq > 0.1 );
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment