Skip to content

Commit 5a31e63

Browse files
authored
Merge branch 'develop' into feature/mdeltutt_fluxweight_g4bnb
2 parents 72cf2bb + acd7a8b commit 5a31e63

5 files changed

Lines changed: 27 additions & 55 deletions

File tree

sbncode/CAFMaker/FillTrue.cxx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,38 +1260,47 @@ caf::Wall_t caf::GetWallCross(const geo::BoxBoundedGeo &volume, const TVector3 p
12601260
TVector3 direction = (p1 - p0) * ( 1. / (p1 - p0).Mag());
12611261
std::vector<TVector3> intersections = volume.GetIntersections(p0, direction);
12621262

1263-
assert(intersections.size() == 2);
1263+
/*
1264+
* There are either two, or one, or zero intersection points.
1265+
* As per larcorealg/Geometry/BoxBoundedGeo.h documentation:
1266+
* If the return std::vector is empty the trajectory does not intersect with the box.
1267+
* Normally the return value should have one (if the trajectory originates in the box) or two (else) entries.
1268+
* If the return value has two entries the first represents the entry point and the second the exit point
1269+
*/
1270+
1271+
if( intersections.empty() ) return caf::kWallNone;
12641272

12651273
// get the intersection point closer to p0
1266-
int intersection_i = ((intersections[0] - p0).Mag() < (intersections[1] - p0).Mag()) ? 0 : 1;
1274+
TVector3 closestIntersection;
1275+
double minDistance2 = std::numeric_limits<double>::max();
1276+
1277+
for( TVector3 const & point : intersections ) {
1278+
const double d2 = (point - p0).Mag2();
1279+
if( d2 > minDistance2 ) continue;
1280+
minDistance2 = d2;
1281+
closestIntersection = point;
1282+
}
12671283

12681284
double eps = 1e-3;
1269-
if (abs(intersections[intersection_i].X() - volume.MinX()) < eps) {
1270-
//std::cout << "Left\n";
1285+
if (abs(closestIntersection.X() - volume.MinX()) < eps) {
12711286
return caf::kWallLeft;
12721287
}
1273-
else if (abs(intersections[intersection_i].X() - volume.MaxX()) < eps) {
1274-
//std::cout << "Right\n";
1288+
else if (abs(closestIntersection.X() - volume.MaxX()) < eps) {
12751289
return caf::kWallRight;
12761290
}
1277-
else if (abs(intersections[intersection_i].Y() - volume.MinY()) < eps) {
1278-
//std::cout << "Bottom\n";
1291+
else if (abs(closestIntersection.Y() - volume.MinY()) < eps) {
12791292
return caf::kWallBottom;
12801293
}
1281-
else if (abs(intersections[intersection_i].Y() - volume.MaxY()) < eps) {
1282-
//std::cout << "Top\n";
1294+
else if (abs(closestIntersection.Y() - volume.MaxY()) < eps) {
12831295
return caf::kWallTop;
12841296
}
1285-
else if (abs(intersections[intersection_i].Z() - volume.MinZ()) < eps) {
1286-
//std::cout << "Front\n";
1297+
else if (abs(closestIntersection.Z() - volume.MinZ()) < eps) {
12871298
return caf::kWallFront;
12881299
}
1289-
else if (abs(intersections[intersection_i].Z() - volume.MaxZ()) < eps) {
1290-
//std::cout << "Back\n";
1300+
else if (abs(closestIntersection.Z() - volume.MaxZ()) < eps) {
12911301
return caf::kWallBack;
12921302
}
12931303
else assert(false);
1294-
//std::cout << "None\n";
12951304

12961305
return caf::kWallNone;
12971306
}//GetWallCross

sbncode/LArG4/CMakeLists.txt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
add_subdirectory(PhysicsLists)
22

3-
cet_build_plugin(G4InfoReducer art::module
4-
LIBRARIES
5-
larsim::Simulation
6-
larcore::Geometry_Geometry_service
7-
lardata::DetectorInfoServices_DetectorClocksServiceStandard_service
8-
art::Persistency_Common
9-
art::Persistency_Provenance
10-
art::Utilities canvas::canvas
11-
BASENAME_ONLY)
12-
133
set(
144
MODULE_LIBRARIES
155
art::Utilities
@@ -61,14 +51,5 @@ cet_build_plugin(MergeSimSourcesSBN art::EDProducer
6151
BASENAME_ONLY
6252
)
6353

64-
cet_build_plugin(SimpleMerge art::EDProducer
65-
LIBRARIES
66-
lardataobj::MCBase
67-
larcorealg::headers
68-
larcorealg::CoreUtils
69-
messagefacility::MF_MessageLogger
70-
)
71-
7254
install_headers()
73-
install_fhicl()
7455
install_source()

sbncode/LArG4/g4inforeducer.fcl

Lines changed: 0 additions & 12 deletions
This file was deleted.

sbncode/LArG4/simplemerge.fcl

Lines changed: 0 additions & 9 deletions
This file was deleted.

sbncode/SBNEventWeight/Calculators/Geant4/Geant4WeightCalc.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ std::vector<float> Geant4WeightCalc::GetWeight(art::Event& e, size_t itruth ) {
297297
double Z = p.Position(i).Z();
298298
geo::Point_t testpoint1 { X, Y, Z };
299299
const TGeoMaterial* testmaterial1 = fGeometryService->Material( testpoint1 );
300+
if( ! testmaterial1 ) {
301+
break; // The trajectory point is outside the world, or the geometry service is unable to handle the point
302+
}
300303
//For now, just going to reweight the points within the LAr of the TPC
301304
// TODO check if this is right
302305
if ( !strcmp( testmaterial1->GetName(), "LAr" ) ){

0 commit comments

Comments
 (0)