Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion sbncode/CAFMaker/RecoUtils/RecoUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,27 @@ caf::Wall_t sbn::GetWallCross(const geo::BoxBoundedGeo &volume, const TVector3 p
TVector3 direction = (p1 - p0) * ( 1. / (p1 - p0).Mag());
std::vector<TVector3> intersections = volume.GetIntersections(p0, direction);

assert(intersections.size() == 2);
//assert(intersections.size() == 2);
/*
* There are either infinity, two, or one, or zero intersection points.
* As per larcorealg/Geometry/BoxBoundedGeo.h documentation:
* If the return std::vector is empty the trajectory does not intersect with the box.
* Normally the return value should have one (if the trajectory originates in the box) or two (else) entries.
* If the return value has two entries the first represents the entry point and the second the exit point
*/
switch( intersections.size() ) {
case 0: // Set kWallNone and return
return caf::kWallNone;
break;
case 1: // Set the second intersection to be the same as the first, and fall through
intersections.emplace_back(intersections.front());
[[fallthrough]];
case 2:
break;
default: // There are infinity points to consider. Just use the first two.
intersections.resize(2);
break;
}

// get the intersection point closer to p0
int intersection_i = ((intersections[0] - p0).Mag() < (intersections[1] - p0).Mag()) ? 0 : 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ std::vector<float> Geant4WeightCalc::GetWeight(art::Event& e, size_t itruth ) {
double Z = p.Position(i).Z();
geo::Point_t testpoint1 { X, Y, Z };
const TGeoMaterial* testmaterial1 = fGeometryService->Material( testpoint1 );
if( ! testmaterial1 || testmaterial1 == nullptr ) {
break; // The trajectory point is outside the world, or the geometry service is unable to handle the point
}
//For now, just going to reweight the points within the LAr of the TPC
// TODO check if this is right
if ( !strcmp( testmaterial1->GetName(), "LAr" ) ){
Expand Down