93 produces< std::vector<recob::Track> >();
94 produces< art::Assns<recob::PFParticle, recob::Track> >();
95 produces< art::Assns<recob::Track, recob::Hit> >();
96 produces< art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta> >();
106 std::unique_ptr< std::vector<recob::Track> > outputTracks(
new std::vector<recob::Track> );
114 const unsigned int nWirePlanes(theGeometry->
MaxPlanes());
117 throw cet::exception(
"LArPandoraTrackCreation") <<
" LArPandoraTrackCreation::produce --- More than three wire planes present ";
119 if ((0 == theGeometry->
Ncryostats()) || (0 == theGeometry->
NTPC(0)))
120 throw cet::exception(
"LArPandoraTrackCreation") <<
" LArPandoraTrackCreation::produce --- unable to access first tpc in first cryostat ";
122 std::unordered_set<geo::_plane_proj> planeSet;
123 for (
unsigned int iPlane = 0; iPlane < nWirePlanes; ++iPlane)
124 (
void) planeSet.insert(theGeometry->
TPC(0, 0).
Plane(iPlane).
View());
126 if ((nWirePlanes != planeSet.size()) || !planeSet.count(
geo::kU) || !planeSet.count(
geo::kV) || (planeSet.count(
geo::kW) && planeSet.count(
geo::kY)))
127 throw cet::exception(
"LArPandoraTrackCreation") <<
" LArPandoraTrackCreation::produce --- expect to find u and v views; if there is one further view, it must be w or y ";
129 const bool useYPlane((nWirePlanes > 2) && planeSet.count(
geo::kY));
158 if (pfParticlesToSpacePoints.end() == particleToSpacePointIter)
160 mf::LogDebug(
"LArPandoraTrackCreation") <<
"No spacepoints associated to particle ";
167 if (pfParticlesToClusters.end() == particleToClustersIter)
169 mf::LogDebug(
"LArPandoraShowerCreation") <<
"No clusters associated to particle ";
176 if ((pfParticlesToVertices.end() == particleToVertexIter) || (1 != particleToVertexIter->second.size()))
178 mf::LogDebug(
"LArPandoraTrackCreation") <<
"Unexpected number of vertices for particle ";
183 pandora::CartesianPointVector cartesianPointVector;
185 cartesianPointVector.emplace_back(pandora::CartesianVector(spacePoint->
XYZ()[0], spacePoint->
XYZ()[1], spacePoint->
XYZ()[2]));
187 double vertexXYZ[3] = {0., 0., 0.};
188 particleToVertexIter->second.front()->XYZ(vertexXYZ);
189 const pandora::CartesianVector vertexPosition(vertexXYZ[0], vertexXYZ[1], vertexXYZ[2]);
198 catch (
const pandora::StatusCodeException &)
200 mf::LogDebug(
"LArPandoraTrackCreation") <<
"Unable to extract sliding fit trajectory";
206 mf::LogDebug(
"LArPandoraTrackCreation") <<
"Insufficient input trajectory points to build track: " << trackStateVector.size();
210 HitVector hitsFromSpacePoints, hitsFromClusters, hitsInParticle;
216 for (
unsigned int hitIndex = 0; hitIndex < hitsFromSpacePoints.size(); hitIndex++)
218 hitsInParticle.push_back(hitsFromSpacePoints.at(hitIndex));
219 (void) hitsInParticleSet.insert(hitsFromSpacePoints.at(hitIndex));
222 for (
unsigned int hitIndex = 0; hitIndex < hitsFromClusters.size(); hitIndex++)
224 if (hitsInParticleSet.count(hitsFromClusters.at(hitIndex)) == 0)
225 hitsInParticle.push_back(hitsFromClusters.at(hitIndex));
229 if (trackStateVector.size()>hitsFromSpacePoints.size())
231 throw cet::exception(
"LArPandoraTrackCreation") <<
"trackStateVector.size() is greater than hitsFromSpacePoints.size()";
233 const unsigned int nInvalidPoints = hitsInParticle.size()-trackStateVector.size();
234 for (
unsigned int i=0;i<nInvalidPoints;++i) {
244 util::CreateAssn(*
this, evt, pTrack, pPFParticle, *(outputParticlesToTracks.get()));
245 util::CreateAssn(*
this, evt, *(outputTracks.get()), hitsInParticle, *(outputTracksToHits.get()));
248 for (
unsigned int hitIndex = 0; hitIndex < hitsInParticle.size(); hitIndex++)
253 outputTracksToHitsWithMeta->addSingle(pTrack, pHit, metadata);
257 mf::LogDebug(
"LArPandoraTrackCreation") <<
"Number of new tracks: " << outputTracks->size() << std::endl;
259 evt.
put(std::move(outputTracks));
260 evt.
put(std::move(outputTracksToHits));
261 evt.
put(std::move(outputTracksToHitsWithMeta));
262 evt.
put(std::move(outputParticlesToTracks));
269 if (trackStateVector.empty())
270 throw cet::exception(
"LArPandoraTrackCreation") <<
"BuildTrack - No input trajectory points provided ";
278 xyz.emplace_back(
recob::tracking::Point_t(trackState.GetPosition().GetX(), trackState.GetPosition().GetY(), trackState.GetPosition().GetZ()));
279 pxpypz.emplace_back(
recob::tracking::Vector_t(trackState.GetDirection().GetX(), trackState.GetDirection().GetY(), trackState.GetDirection().GetZ()));
281 if (std::fabs(trackState.GetPosition().GetX()-
util::kBogusF)<std::numeric_limits<float>::epsilon() &&
282 std::fabs(trackState.GetPosition().GetY()-
util::kBogusF)<std::numeric_limits<float>::epsilon() &&
283 std::fabs(trackState.GetPosition().GetZ()-
util::kBogusF)<std::numeric_limits<float>::epsilon())
Header file for the pfo helper class.
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
LArPandoraTrackCreation & operator=(LArPandoraTrackCreation const &)=delete
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
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
Header file for lar pfo objects.
Declaration of signal hit object.
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.
void produce(art::Event &evt) override
constexpr int kBogusI
obviously bogus integer value
std::vector< int > IntVector
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
Planes which measure Y direction.
unsigned int m_slidingFitHalfWindow
The sliding fit half window.
ProductID put(std::unique_ptr< PROD > &&product)
std::unordered_set< art::Ptr< recob::Hit > > HitSet
View_t View() const
Which coordinate does this plane measure.
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 ...
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
#define DEFINE_ART_MODULE(klass)
Provides recob::Track data product.
static void GetAssociatedHits(const art::Event &evt, const std::string &label, const std::vector< art::Ptr< T > > &inputVector, HitVector &associatedHits, const pandora::IntVector *const indexVector=nullptr)
Get all hits associated with input clusters.
A trajectory in space reconstructed from hits.
bool m_useAllParticles
Build a recob::Track for every recob::PFParticle.
std::string m_pfParticleLabel
The pf particle label.
static void CollectVertices(const art::Event &evt, const std::string &label, VertexVector &vertexVector, PFParticlesToVertices &particlesToVertices)
Collect the reconstructed PFParticles and associated Vertices from the ART event record.
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
std::vector< Vector_t > Momenta_t
Type of momentum list.
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
const Double32_t * XYZ() const
std::vector< PointFlags_t > Flags_t
Type of point flag list.
static constexpr HitIndex_t InvalidHitIndex
Value marking an invalid hit index.
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
std::vector< art::Ptr< recob::Hit > > HitVector
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
Utility object to perform functions of association.
std::vector< Point_t > Positions_t
Type of trajectory point list.
constexpr float kBogusF
obviously bogus float value
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
static bool IsTrack(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as track-like.
recob::Track BuildTrack(const int id, const lar_content::LArTrackStateVector &trackStateVector) const
Build a recob::Track object.
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
std::vector< LArTrackState > LArTrackStateVector
unsigned int m_minTrajectoryPoints
The minimum number of trajectory points.
Planes which measure W (third view for Bo, MicroBooNE, etc).
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
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 function for LArPandoraInterface producer module
Set of flags pertaining a point of the track.
LArPandoraTrackCreation(fhicl::ParameterSet const &pset)
art framework interface to geometry description
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
cet::coded_exception< error, detail::translate > exception
std::vector< art::Ptr< recob::Vertex > > VertexVector