151 auto tracks = std::make_unique<std::vector<recob::Track>>();
152 auto allsp = std::make_unique<std::vector<recob::SpacePoint>>();
153 auto vtxs = std::make_unique<std::vector<recob::Vertex>>();
154 auto kinks = std::make_unique<
155 std::vector<recob::Vertex>>();
156 auto nodes = std::make_unique<std::vector<recob::Vertex>>();
158 auto trk2hit_oldway = std::make_unique<
161 auto trk2hit = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
163 auto trk2sp = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
165 auto sp2hit = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
166 auto vtx2trk = std::make_unique<
170 std::make_unique<art::Assns<recob::Track, recob::Vertex>>();
172 auto pfp2trk = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
178 std::vector<art::Ptr<recob::Hit>> allhitlist;
185 <<
"Not all required data products found in the event." <<
std::endl;
191 art::FindManyP<recob::Cluster> clustersFromPfps(pfparticleHandle,
evt,
fPfpModuleLabel);
209 int retCode = pmalgFitter.build(detProp);
218 else if (retCode == 1)
226 auto const&
result = pmalgFitter.result();
229 size_t spStart = 0, spEnd = 0;
230 double sp_pos[3], sp_err[6];
231 for (
size_t i = 0; i < 3; i++)
233 for (
size_t i = 0; i < 6; i++)
237 std::map<size_t, std::vector<art::Ptr<recob::Track>>> pfPartToTrackVecMap;
242 for (
size_t trkIndex = 0; trkIndex <
result.
size(); ++trkIndex) {
252 if (trk->
size() < 2)
continue;
258 size_t trkIdx =
tracks->size() - 1;
263 for (
size_t h = 0, cnt = 0;
h < trk->
size();
h++) {
269 trk2hit_oldway->addSingle(
274 spStart = allsp->
size();
275 for (
size_t h = 0;
h < trk->
size(); ++
h) {
283 if ((
h == 0) || (std::fabs(sp_pos[0] - hx) > 1.0e-5) ||
284 (std::fabs(sp_pos[1] - hy) > 1.0e-5) || (std::fabs(sp_pos[2] - hz) > 1.0e-5)) {
302 spEnd = allsp->size();
307 if (
result[trkIndex].Key() > -1) {
308 size_t trackIdx =
tracks->size() - 1;
311 pfPartToTrackVecMap[
result[trkIndex].Key()].push_back(trackPtr);
315 auto vid =
evt.getProductID<std::vector<recob::Vertex>>();
316 auto kid =
evt.getProductID<std::vector<recob::Vertex>>(
kKinksName);
317 auto const* kinkGetter =
evt.productGetter(kid);
319 auto tid =
evt.getProductID<std::vector<recob::Track>>();
320 auto const* trkGetter =
evt.productGetter(tid);
322 auto vsel = pmalgFitter.getVertices(
324 auto ksel = pmalgFitter.getKinks();
325 std::map<size_t, art::Ptr<recob::Vertex>> frontVtxs;
330 for (
auto const& v : vsel) {
331 xyz[0] = v.first.X();
332 xyz[1] = v.first.Y();
333 xyz[2] = v.first.Z();
334 mf::LogVerbatim(
"Summary") <<
" vtx:" << xyz[0] <<
":" << xyz[1] <<
":" << xyz[2]
335 <<
" (" << v.second.size() <<
" tracks)";
337 size_t vidx = vtxs->size();
338 vtxs->push_back(recob::Vertex(xyz, vidx));
341 if (vptr.isNull())
mf::LogWarning(
"PMAlgTrajFitter") <<
"Vertex ptr is null.";
342 if (!v.second.empty()) {
343 for (
const auto& vEntry : v.second) {
344 size_t tidx = vEntry.first;
345 bool isFront = vEntry.second;
347 if (isFront) frontVtxs[tidx] = vptr;
350 vtx2trk->addSingle(vptr, tptr);
354 mf::LogWarning(
"PMAlgTrajFitter") <<
"No tracks found at this vertex.";
358 for (
auto const&
k : ksel) {
359 xyz[0] =
k.first.X();
360 xyz[1] =
k.first.Y();
361 xyz[2] =
k.first.Z();
362 mf::LogVerbatim(
"Summary") <<
" kink:" << xyz[0] <<
":" << xyz[1] <<
":" << xyz[2];
364 size_t kidx = kinks->size();
365 size_t tidx =
k.second;
368 recob::Vertex(xyz, tidx));
372 trk2kink->addSingle(tptr, kptr);
380 auto const& trk = *(
result[
t].Track());
381 for (
auto const* node : trk.
Nodes()) {
382 xyz[0] = node->Point3D().X();
383 xyz[1] = node->Point3D().Y();
384 xyz[2] = node->Point3D().Z();
390 for (
const auto& pfParticleItr : pfPartToTrackVecMap) {
393 <<
"PFParticle key: " << pfParticle.key() <<
", self: " << pfParticle->Self()
394 <<
", #tracks: " << pfParticleItr.second.size();
396 if (!pfParticle.isNull())
400 <<
"Error in PFParticle lookup, pfparticle index: " << pfParticleItr.first
401 <<
", key: " << pfParticle.key();
bool SelectHits(float fraction=1.0F)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
bool HasPlane(unsigned int iplane) const
Returns whether a plane with index iplane is present in this TPC.
recob::Track convertFrom(const pma::Track3D &src, unsigned int tidx, int pdg=0)
bool fSaveOnlyBranchingVtx
bool IsEnabled() const noexcept
TVector3 const & Point3D() const
Planes which measure Z direction.
art::ServiceHandle< geo::Geometry const > fGeom
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void push_back(Ptr< U > const &p)
art::InputTag fPfpModuleLabel
fhicl::Atom< bool > RunVertexing
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.
unsigned int FrontTPC() const
unsigned int FrontCryo() const
size_t CompleteMissingWires(detinfo::DetectorPropertiesData const &detProp, unsigned int view)
void push_back(pma::Hit3D *hit)
pma::PMAlgVertexing::Config fPmaVtxConfig
static const std::string kNodesName
double Dx() const noexcept
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
pma::ProjectionMatchingAlg::Config fPmaConfig
art::Ptr< recob::Hit > const & Hit2DPtr() const
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
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::vector< pma::Node3D * > const & Nodes() const noexcept
2D representation of charge deposited in the TDC/wire plane
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
static const std::string kKinksName
pma::PMAlgFitter::Config fPmaFitterConfig
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
art::InputTag fHitModuleLabel