Skip to content

Commit d7110f2

Browse files
authored
Merge pull request #501 from SBNSoftware/feature/gputnam-fix-v10
Fix bugs in v10 upgrade.
2 parents 2950670 + b7a6e6b commit d7110f2

7 files changed

Lines changed: 22 additions & 16 deletions

File tree

sbncode/CAFMaker/FillTrue.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ namespace caf {
300300
double cosgamma = std::abs(std::sin(angletovert)*dir.Y() + std::cos(angletovert)*dir.Z());
301301
double pitch;
302302
if (cosgamma) {
303-
pitch = plane.View()/cosgamma;
303+
pitch = plane.WirePitch()/cosgamma;
304304
}
305305
else {
306306
pitch = 0.;

sbncode/Cluster3D/SnippetHit3DBuilderSBN_tool.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,8 +1633,8 @@ geo::WireID SnippetHit3DBuilderSBN::NearestWireID(const Eigen::Vector3f& positio
16331633
mf::LogWarning("Cluster3D") << "Exception caught finding nearest wire, position - " << exc.what() << std::endl;
16341634

16351635
// Assume extremum for wire number depending on z coordinate
1636-
if (position[2] < 0.5 * m_geometry->TPC({0,0}).Length()) wire = 0;
1637-
else wire = m_wireReadoutAlg->Nwires(wireIDIn.asPlaneID()) - 1;
1636+
if (position[2] < m_geometry->TPC({0,0}).ActiveLength()*0.5) wire = 0;
1637+
else wire = m_wireReadoutAlg->Nwires(wireIDIn.asPlaneID()) - 1;
16381638
}
16391639

16401640
geo::WireID wireID(wireIDIn.Cryostat,wireIDIn.TPC,wireIDIn.Plane,wire);

sbncode/TPCReco/NuVertexChargeTree_module.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -949,9 +949,9 @@ void sbn::NuVertexChargeTree::FillNeutrino(const simb::MCTruth &nu,
949949
geo::TPCGeo const* firstTPC = geo.PositionToTPCptr(start_loc);
950950
if (firstTPC) {
951951
geo::TPCID firstTPCID = firstTPC->ID();
952-
fFSPPitch0.push_back(sbn::GetPitch(wireReadout, sce, start_loc, start_dir, wireReadout.Plane(geo::PlaneID(firstTPCID, 0)).View(), *firstTPC, true, true));
953-
fFSPPitch1.push_back(sbn::GetPitch(wireReadout, sce, start_loc, start_dir, wireReadout.Plane(geo::PlaneID(firstTPCID, 1)).View(), *firstTPC, true, true));
954-
fFSPPitch2.push_back(sbn::GetPitch(wireReadout, sce, start_loc, start_dir, wireReadout.Plane(geo::PlaneID(firstTPCID, 2)).View(), *firstTPC, true, true));
952+
fFSPPitch0.push_back(sbn::GetPitch(wireReadout, sce, start_loc, start_dir, wireReadout.Plane(geo::PlaneID(firstTPCID, 0)).View(), geo::PlaneID(firstTPCID, 0), true, true));
953+
fFSPPitch1.push_back(sbn::GetPitch(wireReadout, sce, start_loc, start_dir, wireReadout.Plane(geo::PlaneID(firstTPCID, 1)).View(), geo::PlaneID(firstTPCID, 1), true, true));
954+
fFSPPitch2.push_back(sbn::GetPitch(wireReadout, sce, start_loc, start_dir, wireReadout.Plane(geo::PlaneID(firstTPCID, 2)).View(), geo::PlaneID(firstTPCID, 2), true, true));
955955
}
956956
else {
957957
fFSPPitch0.push_back(-1);

sbncode/TPCReco/VertexStub/StubBuilder.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ sbn::Stub sbn::StubBuilder::FromVertexHit(const art::Ptr<recob::Slice> &slice,
270270

271271
// See if we can compute a track pitch
272272
if (pfp_ind >= 0 && trks[pfp_ind]) {
273-
stub.trkpitch.push_back(sbn::GetPitch(wireReadout, sce, trks[pfp_ind]->Start(), trks[pfp_ind]->StartDirection(), wireReadout.Plane(vhit_hit.WireID()).View(), geometry.TPC(vhit_hit.WireID()), true, fPositionsAreSCECorrected));
273+
stub.trkpitch.push_back(sbn::GetPitch(wireReadout, sce, trks[pfp_ind]->Start(), trks[pfp_ind]->StartDirection(), wireReadout.Plane(vhit_hit.WireID()).View(), vhit_hit.WireID(), true, fPositionsAreSCECorrected));
274274
}
275275
else {
276276
stub.trkpitch.push_back(-1.);

sbncode/TPCReco/VertexStub/StubMergeAlgorithms.cxx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "StubMergeAlgorithms.h"
22

33
#include "larcorealg/Geometry/WireReadoutGeom.h"
4+
#include "larcore/Geometry/Geometry.h"
5+
#include "larcore/CoreUtils/ServiceUtil.h"
6+
#include "larcorealg/Geometry/GeometryCore.h"
47

58
geo::Point_t sbn::GetLocation(const spacecharge::SpaceCharge *sce, geo::Point_t loc_w, geo::TPCID TPC, float xsign) {
69
if (sce && sce->EnableCalSpatialSCE()) {
@@ -49,14 +52,17 @@ geo::Point_t sbn::GetLocationAtWires(const spacecharge::SpaceCharge *sce, geo::P
4952
double sbn::GetPitch(
5053
const geo::WireReadoutGeom &wireReadout, const spacecharge::SpaceCharge *sce,
5154
geo::Point_t loc, geo::Vector_t dir,
52-
geo::View_t view, geo::TPCGeo const& tpc,
55+
geo::View_t view, geo::PlaneID const& plane_id,
5356
bool correct_sce, bool track_is_sce_corrected, float xsign) {
5457

55-
double angleToVert = wireReadout.WireAngleToVertical(view, tpc.ID()) - 0.5*::util::pi<>();
58+
const geo::GeometryCore *geo = lar::providerFrom<geo::Geometry>();
59+
60+
double angleToVert = wireReadout.WireAngleToVertical(view, plane_id) - 0.5*::util::pi<>();
5661

5762
geo::Vector_t dir_w;
5863

59-
geo::PlaneGeo const& plane = wireReadout.Plane(geo::PlaneID{0, 0, view});
64+
geo::PlaneGeo const& plane = wireReadout.Plane(plane_id);
65+
geo::TPCGeo const& tpc = geo->TPC(plane_id);
6066
// "dir_w" should be the direction that the wires see. If the track already has the field
6167
// distortion corrections applied, then we need to de-apply them to get the direction as
6268
// seen by the wire planes
@@ -92,8 +98,8 @@ double sbn::GetPitch(
9298
loc_w = sbn::GetLocationAtWires(sce, loc, tpc.DriftDir(), xsign);
9399
}
94100

95-
geo::Point_t locw_traj = (correct_sce) ? sbn::GetLocation(sce, loc_w, tpc.ID(), xsign) : loc_w;
96-
geo::Point_t locw_pdx_traj = (correct_sce) ? sbn::GetLocation(sce, loc_w + pitch * dir_w, tpc.ID(), xsign) : (loc_w + pitch * dir_w);
101+
geo::Point_t locw_traj = (correct_sce) ? sbn::GetLocation(sce, loc_w, plane_id, xsign) : loc_w;
102+
geo::Point_t locw_pdx_traj = (correct_sce) ? sbn::GetLocation(sce, loc_w + pitch * dir_w, plane_id, xsign) : (loc_w + pitch * dir_w);
97103

98104
pitch = (locw_traj - locw_pdx_traj).R();
99105

@@ -222,8 +228,8 @@ float sbn::StubPeakdQdxOffset(const sbn::StubInfo &A, const sbn::StubInfo &B,
222228
geo::Vector_t dir((end-vtx).Unit());
223229

224230
// Input point, dir are always space charge corrected here
225-
float Apitch = GetPitch(wireReadout, sce, end, dir, A.vhit_hit->View(), geometry.TPC(A.vhit_hit->WireID()), true, true);
226-
float Bpitch = GetPitch(wireReadout, sce, end, dir, B.vhit_hit->View(), geometry.TPC(B.vhit_hit->WireID()), true, true);
231+
float Apitch = GetPitch(wireReadout, sce, end, dir, A.vhit_hit->View(), A.vhit_hit->WireID(), true, true);
232+
float Bpitch = GetPitch(wireReadout, sce, end, dir, B.vhit_hit->View(), B.vhit_hit->WireID(), true, true);
227233

228234
return abs(A.vhit->charge / Apitch - B.vhit->charge / Bpitch);
229235
}

sbncode/TPCReco/VertexStub/StubMergeAlgorithms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct StubInfo {
4747
double GetPitch(
4848
const geo::WireReadoutGeom &wireReadout, const spacecharge::SpaceCharge *sce,
4949
geo::Point_t loc, geo::Vector_t dir,
50-
geo::View_t view, geo::TPCGeo const& tpc,
50+
geo::View_t view, geo::PlaneID const& plane_id,
5151
bool correct_sce, bool track_is_sce_corrected, float xsign=1.);
5252

5353
/// Get the location in the presence of space charge

sbncode/TPCReco/VertexStub/VertexChargeVacuum_module.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ void sbn::VertexChargeVacuum::produce(art::Event& evt)
430430

431431
// Compute the pitch. Since we have used the corrected vertex and Space-Point position, the
432432
// pt and dir here are space-charge corrected regardless of the input configuration
433-
vhit.pitch = sbn::GetPitch(wireReadout, sce, spXYZ, dir, hit.View(), geo->TPC(hit.WireID()), fCorrectSCE, true);
433+
vhit.pitch = sbn::GetPitch(wireReadout, sce, spXYZ, dir, hit.View(), hit.WireID(), fCorrectSCE, true);
434434

435435
vhit.dqdx = vhit.charge / vhit.pitch;
436436

0 commit comments

Comments
 (0)