Skip to content

Commit

Permalink
Accommodate more geometry changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
knoepfel committed Dec 15, 2022
1 parent 2c50d32 commit 97a0273
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 81 deletions.
31 changes: 14 additions & 17 deletions lardata/ArtDataHelper/TrackUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,17 @@ double lar::util::TrackPitchInView(recob::Track const& track,
geo::PlaneGeo const& plane = geom.PositionToTPC(point.position).Plane(view);

#if 0 // this can be enabled after `geo::PlaneGeo::InterWireProjectedDistance()` becomes available in larcorealg
double const d = plane.InterWireProjectedDistance(point.direction());

// do we prefer to just return the value and let the caller check it?
if (d > 50.0 * plane.WirePitch()) { // after many pitches track would scatter
throw cet::exception("Track")
<< "track at point #" << trajectory_point
<< " is almost parallel to the wires in view "
<< geo::PlaneGeo::ViewName(view) << " (wire direction is "
<< plane.GetWireDirection<geo::Vector_t>() << "; track direction is "
<< point.direction()
<< ").\n";
}
return d;
double const d = plane.InterWireProjectedDistance(point.direction());

// do we prefer to just return the value and let the caller check it?
if (d > 50.0 * plane.WirePitch()) { // after many pitches track would scatter
throw cet::exception("Track") << "track at point #" << trajectory_point
<< " is almost parallel to the wires in view "
<< geo::PlaneGeo::ViewName(view) << " (wire direction is "
<< plane.GetWireDirection() << "; track direction is "
<< point.direction() << ").\n";
}
return d;

#else // !0
//
Expand All @@ -125,10 +123,9 @@ double lar::util::TrackPitchInView(recob::Track const& track,
throw cet::exception("Track") << "track at point #" << trajectory_point
<< " is almost parallel to the wires in view "
<< geo::PlaneGeo::ViewName(view) << " (wire direction is "
<< plane.GetWireDirection<geo::Vector_t>()
<< "; track direction is " << point.direction()
<< ", its projection on plane " << plane.ID() << " is " << proj
<< ").\n";
<< plane.GetWireDirection() << "; track direction is "
<< point.direction() << ", its projection on plane " << plane.ID()
<< " is " << proj << ").\n";
}

//
Expand Down
4 changes: 2 additions & 2 deletions lardata/RawData/utils/LArRawInputDriver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ namespace {

digitList[i] =
raw::RawDigit((c1.ch - 1), c1.samples, adclist); //subtract one from ch. number...
//hence offline channels will always be one lower
//than the DAQ480 definition. - mitch 7/8/2009
//hence offline channels will always be one lower
//than the DAQ480 definition. - mitch 7/8/2009
digitList[i].SetPedestal(400.); //carl b assures me this will never change. bjr 4/15/2009
}
//read in footer section of file...though it's currently empty.
Expand Down
2 changes: 1 addition & 1 deletion lardata/RecoObjects/SurfWireLine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace trkf {

// Update base class.

*static_cast<SurfYZLine*>(this) = SurfYZLine(x, xyz[1], xyz[2], phi);
*static_cast<SurfYZLine*>(this) = SurfYZLine(x, xyz.Y(), xyz.Z(), phi);
}

/// Destructor.
Expand Down
4 changes: 2 additions & 2 deletions lardata/RecoObjects/SurfWireX.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ namespace trkf {

// Update base class.

*static_cast<SurfYZPlane*>(this) = SurfYZPlane(0., xyz[1], xyz[2], phi);
*static_cast<SurfYZPlane*>(this) = SurfYZPlane(0., xyz.Y(), xyz.Z(), phi);
}

/// Destructor.
SurfWireX::~SurfWireX() {}
SurfWireX::~SurfWireX() = default;

} // end namespace trkf
71 changes: 34 additions & 37 deletions lardata/RecoObjects/TrackingPlaneHelper.h
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
#ifndef TRACKINGPLANEHELPER_H
#define TRACKINGPLANEHELPER_H

/// \file lardata/RecoObjects/TrackingPlaneHelper.h
///
/// \author G. Cerati (FNAL, MicroBooNE)
/// \date 2017
/// \version 1.0

#include "TMath.h"
#include "larcorealg/Geometry/WireGeo.h"
#include "lardata/RecoObjects/SurfWireX.h"
#include "lardataobj/RecoBase/TrackingPlane.h"
#include "lardataobj/RecoBase/Trajectory.h"

namespace recob {
namespace tracking {

/// \file lardata/RecoObjects/TrackingPlaneHelper.h
///
/// \author G. Cerati (FNAL, MicroBooNE)
/// \date 2017
/// \version 1.0

/// helper function to construct a recob::tracking::Plane from a Point_t and a Vector_t; the point is on the plane, the vector is orthogonal to the plane.
inline Plane makePlane(recob::tracking::Point_t const& pos,
recob::tracking::Vector_t const& dir)
{
return Plane(pos, dir);
}

/// helper function to construct a recob::tracking::Plane from a recob::Trajectory::TrajectoryPoint_t.
inline Plane makePlane(recob::Trajectory::TrajectoryPoint_t const& s)
{
return Plane(s.position, s.direction());
}

/// helper function to construct a recob::tracking::Plane from a trkf::SurfWireX object.
inline Plane makePlane(trkf::SurfWireX const& s)
{
return Plane(Point_t(s.x0(), s.y0(), s.z0()),
Vector_t(0, -std::sin(s.phi()), std::cos(s.phi())));
}

/// helper function to construct a recob::tracking::Plane from a geo::WireGeo object. The plane will contain the wire and the x axis, assumed to be the drift direction (to be generalized).
inline Plane makePlane(geo::WireGeo const& wgeom)
{
auto xyz = wgeom.GetCenter<Point_t>();
xyz.SetX(0.);
double const phi = TMath::PiOver2() - wgeom.ThetaZ();
return Plane{xyz, Vector_t{0, -std::sin(phi), std::cos(phi)}};
}
namespace recob::tracking {

/// helper function to construct a recob::tracking::Plane from a Point_t and a Vector_t; the point is on the plane, the vector is orthogonal to the plane.
inline Plane makePlane(recob::tracking::Point_t const& pos, recob::tracking::Vector_t const& dir)
{
return Plane(pos, dir);
}

/// helper function to construct a recob::tracking::Plane from a recob::Trajectory::TrajectoryPoint_t.
inline Plane makePlane(recob::Trajectory::TrajectoryPoint_t const& s)
{
return Plane(s.position, s.direction());
}

/// helper function to construct a recob::tracking::Plane from a trkf::SurfWireX object.
inline Plane makePlane(trkf::SurfWireX const& s)
{
return Plane(Point_t(s.x0(), s.y0(), s.z0()),
Vector_t(0, -std::sin(s.phi()), std::cos(s.phi())));
}

/// helper function to construct a recob::tracking::Plane from a geo::WireGeo object. The plane will contain the wire and the x axis, assumed to be the drift direction (to be generalized).
inline Plane makePlane(geo::WireGeo const& wgeom)
{
auto xyz = wgeom.GetCenter();
xyz.SetX(0.);
double const phi = TMath::PiOver2() - wgeom.ThetaZ();
return Plane{xyz, Vector_t{0, -std::sin(phi), std::cos(phi)}};
}

}

#endif
36 changes: 16 additions & 20 deletions lardata/Utilities/GeometryUtilities.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
////////////////////////////////////////////////////////////////////////

#include "lardata/Utilities/GeometryUtilities.h"
#include "cetlib/pow.h"
#include "larcorealg/Geometry/GeometryCore.h"
#include "larcorealg/Geometry/PlaneGeo.h"
#include "larcorealg/Geometry/WireGeo.h"
Expand All @@ -17,6 +16,8 @@
#include "lardataalg/DetectorInfo/DetectorPropertiesData.h"
#include "messagefacility/MessageLogger/MessageLogger.h"

#include "cetlib/pow.h"

#include "TLorentzVector.h"

#include <cmath>
Expand Down Expand Up @@ -565,17 +566,14 @@ namespace util {
// the shower.
unsigned int chan1 = fGeom.PlaneWireToChannel(geo::WireID(0, 0, p0->plane, p0->w));
unsigned int chan2 = fGeom.PlaneWireToChannel(geo::WireID(0, 0, p1->plane, p1->w));
const double origin[3] = {0.};
double pos[3] = {0.};
fGeom.Plane(geo::PlaneID(0, 0, p0->plane)).LocalToWorld(origin, pos);
double x = (p0->t - trigger_offset(fClocks)) * fTimetoCm + pos[0];
geo::PlaneGeo::LocalPoint_t const origin{};
auto pos = fGeom.Plane(geo::PlaneID(0, 0, p0->plane)).toWorldCoords(origin);
double x = (p0->t - trigger_offset(fClocks)) * fTimetoCm + pos.X();

double y, z;
if (!fGeom.ChannelsIntersect(chan1, chan2, y, z)) return -1;

pos[0] = x;
pos[1] = y;
pos[2] = z;
pos.SetCoordinates(x, y, z);

pN = Get2DPointProjection(pos, pN.plane);

Expand Down Expand Up @@ -650,10 +648,9 @@ namespace util {
//////////////////////////////////////////////////////////
int GeometryUtilities::GetXYZ(const PxPoint* p0, const PxPoint* p1, double* xyz) const
{
const double origin[3] = {0.};
double pos[3] = {0.};
fGeom.Plane(geo::PlaneID{0, 0, p0->plane}).LocalToWorld(origin, pos);
double x = (p0->t) - trigger_offset(fClocks) * fTimetoCm + pos[0];
geo::PlaneGeo::LocalPoint_t const origin{};
auto const pos = fGeom.Plane(geo::PlaneID{0, 0, p0->plane}).toWorldCoords(origin);
double x = (p0->t) - trigger_offset(fClocks) * fTimetoCm + pos.X();
double yz[2];

GetYZ(p0, p1, yz);
Expand All @@ -667,16 +664,16 @@ namespace util {

//////////////////////////////////////////////////////////////

PxPoint GeometryUtilities::Get2DPointProjection(double const* xyz, unsigned int plane) const
PxPoint GeometryUtilities::Get2DPointProjection(geo::Point_t const& xyz, unsigned int plane) const
{
geo::PlaneID const planeID{0, 0, plane};
PxPoint pN(0, 0, 0);
geo::PlaneGeo::LocalPoint_t const origin{};
auto pos = fGeom.Plane(planeID).toWorldCoords(origin);
double drifttick = (xyz[0] / fDriftVelocity) * (1. / fTimeTick);
double drifttick = (xyz.X() / fDriftVelocity) * (1. / fTimeTick);

pos.SetY(xyz[1]);
pos.SetZ(xyz[2]);
pos.SetY(xyz.Y());
pos.SetZ(xyz.Z());

///\todo: this should use the cryostat and tpc as well in the NearestWire
/// method
Expand Down Expand Up @@ -728,12 +725,11 @@ namespace util {

double GeometryUtilities::GetTimeTicks(double x, unsigned int plane) const
{
const double origin[3] = {0.};
double pos[3];
fGeom.Plane(geo::PlaneID{0, 0, plane}).LocalToWorld(origin, pos);
geo::PlaneGeo::LocalPoint_t const origin{};
auto const pos = fGeom.Plane(geo::PlaneID{0, 0, plane}).toWorldCoords(origin);
double drifttick = (x / fDriftVelocity) * (1. / fTimeTick);

return drifttick - (pos[0] / fDriftVelocity) * (1. / fTimeTick) + trigger_offset(fClocks);
return drifttick - (pos.X() / fDriftVelocity) * (1. / fTimeTick) + trigger_offset(fClocks);
}

//----------------------------------------------------------------------
Expand Down
10 changes: 8 additions & 2 deletions lardata/Utilities/GeometryUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#ifndef UTIL_GEOMETRYUTILITIES_H
#define UTIL_GEOMETRYUTILITIES_H

#include "RtypesCore.h"
#include "larcorealg/Geometry/geo_vectors_utils.h"
#include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h"

#include "TVector3.h"

#include "PxUtils.h"
Expand Down Expand Up @@ -111,7 +113,11 @@ namespace util {
double ort_intercept,
PxPoint& pointonline) const;

PxPoint Get2DPointProjection(double const* xyz, unsigned int plane) const;
inline PxPoint Get2DPointProjection(double const* xyz, unsigned int plane) const
{
return Get2DPointProjection(geo::vect::toPoint(xyz), plane);
}
PxPoint Get2DPointProjection(geo::Point_t const& xyz, unsigned int plane) const;

PxPoint Get2DPointProjectionCM(std::vector<double> const& xyz, unsigned int plane) const;

Expand Down

0 comments on commit 97a0273

Please sign in to comment.