11 #include "art/Utilities/ToolMacros.h"
25 namespace ShowerRecoTools {
45 art::ServiceHandle<geo::Geometry>
fGeom;
60 const fhicl::ParameterSet& pset)
62 , fVerbose(pset.
get<int>(
"Verbose"))
63 , fSlidingFitHalfWindow(pset.
get<float>(
"SlidingFitHalfWindow"))
64 , fMinTrajectoryPoints(pset.
get<float>(
"MinTrajectoryPoints"))
65 , fInitialTrackOutputLabel(pset.
get<
std::string>(
"InitialTrackOutputLabel"))
66 , fInitialTrackLengthOutputLabel(pset.
get<
std::string>(
"InitialTrackLengthOutputLabel"))
67 , fShowerStartPositionInputLabel(pset.
get<
std::string>(
"ShowerStartPositionInputLabel"))
68 , fShowerDirectionInputLabel(pset.
get<
std::string>(
"ShowerDirectionInputLabel"))
69 , fInitialTrackSpacePointsInputLabel(pset.
get<
std::string>(
"InitialTrackSpacePointsInputLabel"))
70 , fInitialTrackHitsInputLabel(pset.
get<
std::string>(
"InitialTrackHitsInputLabel"))
78 InitialiseProduct<art::Assns<recob::Shower, recob::Track>>(
"ShowerTrackAssn");
79 InitialiseProduct<art::Assns<recob::Track, recob::Hit>>(
"ShowerTrackHitAssn");
85 const art::Ptr<recob::PFParticle>& pfparticle,
92 mf::LogError(
"ShowerPandoraSlidingFitTrackFinder")
93 <<
"Start position not set, returning " << std::endl;
98 mf::LogError(
"ShowerPandoraSlidingFitTrackFinder")
99 <<
"Direction not set, returning " << std::endl;
104 mf::LogError(
"ShowerPandoraSlidingFitTrackFinder")
105 <<
"Initial Spacepoints not set, returning " << std::endl;
109 TVector3 ShowerStartPosition = {-999, -999, -999};
112 TVector3 ShowerDirection = {-999, -999, -999};
115 std::vector<art::Ptr<recob::SpacePoint>> spacepoints;
122 mf::LogWarning(
"ShowerPandoraSlidingFitTrackFinder")
123 <<
"Insufficient space points points to build track: " << spacepoints.size();
128 const float wirePitchW(detType->
WirePitchW());
130 const pandora::CartesianVector vertexPosition(
131 ShowerStartPosition.X(), ShowerStartPosition.Y(), ShowerStartPosition.Z());
133 pandora::CartesianPointVector cartesianPointVector;
134 for (
const art::Ptr<recob::SpacePoint> spacePoint : spacepoints)
135 cartesianPointVector.emplace_back(
136 pandora::CartesianVector(spacePoint->XYZ()[0], spacePoint->XYZ()[1], spacePoint->XYZ()[2]));
148 catch (
const pandora::StatusCodeException&) {
150 mf::LogWarning(
"ShowerPandoraSlidingFitTrackFinder")
151 <<
"Unable to extract sliding fit trajectory" << std::endl;
156 mf::LogWarning(
"ShowerPandoraSlidingFitTrackFinder")
157 <<
"Insufficient input trajectory points to build track: " << trackStateVector.size();
161 if (trackStateVector.empty())
162 throw cet::exception(
"ShowerPandoraSlidingFitTrackFinder")
163 <<
"BuildTrack - No input trajectory points provided " << std::endl;
171 trackState.GetPosition().GetY(),
172 trackState.GetPosition().GetZ()));
174 trackState.GetDirection().GetY(),
175 trackState.GetDirection().GetZ()));
178 if (std::fabs(trackState.GetPosition().GetX() -
util::kBogusF) <
179 std::numeric_limits<float>::epsilon() &&
181 std::numeric_limits<float>::epsilon() &&
183 std::numeric_limits<float>::epsilon()) {
204 TVector3 Start = {InitialTrack.
Start().X(), InitialTrack.
Start().Y(), InitialTrack.
Start().Z()};
205 TVector3 End = {InitialTrack.
End().X(), InitialTrack.
End().Y(), InitialTrack.
End().Z()};
206 float tracklength = (Start - End).Mag();
215 const art::Ptr<recob::PFParticle>& pfpPtr,
223 mf::LogError(
"ShowerPandoraSlidingFitTrackFinderAddAssn")
224 <<
"Track not set so the assocation can not be made " << std::endl;
231 const art::Ptr<recob::Track> trackptr = GetProducedElementPtr<recob::Track>(
233 const art::Ptr<recob::Shower> showerptr =
234 GetProducedElementPtr<recob::Shower>(
"shower", ShowerEleHolder);
236 AddSingle<art::Assns<recob::Shower, recob::Track>>(showerptr, trackptr,
"ShowerTrackAssn");
238 std::vector<art::Ptr<recob::Hit>> TrackHits;
241 for (
auto const& TrackHit : TrackHits) {
242 AddSingle<art::Assns<recob::Track, recob::Hit>>(trackptr, TrackHit,
"ShowerTrackHitAssn");
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Header file for the pfo helper class.
static constexpr Flag_t NoPoint
The trajectory point is not defined.
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
Declaration of signal hit object.
Empty interface to map pandora to specifics in the LArSoft geometry.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
static void GetSlidingFitTrajectory(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition, const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector=nullptr)
Apply 3D sliding fit to a set of 3D points and return track trajectory.
constexpr int kBogusI
obviously bogus integer value
std::vector< int > IntVector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space. See recob::tracking::Coord_t for more details on the ...
Point_t const & Start() const
Access to track position at different points.
A trajectory in space reconstructed from hits.
virtual float WirePitchW() const =0
The wire pitch of the mapped W view.
bool CheckElement(const std::string &Name) const
std::vector< Vector_t > Momenta_t
Type of momentum list.
std::vector< PointFlags_t > Flags_t
Type of point flag list.
int GetElement(const std::string &Name, T &Element) const
static constexpr HitIndex_t InvalidHitIndex
Value marking an invalid hit index.
Provides recob::Track data product.
std::vector< Point_t > Positions_t
Type of trajectory point list.
LArPandoraDetectorType * GetDetectorType()
Factory class that returns the correct detector type interface.
constexpr float kBogusF
obviously bogus float value
Point_t const & End() const
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
std::vector< LArTrackState > LArTrackStateVector
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
Helper functions for extracting detector geometry for use in reconsruction.
Set of flags pertaining a point of the track.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: