55 Name(
"ProjectionMatchingAlg")};
62 Name(
"HitModuleLabel"),
63 Comment(
"tag of unclustered hits, which were used to produce PFPs and clusters")};
66 Name(
"PfpModuleLabel"),
67 Comment(
"tag of the input PFParticles and associated clusters")};
70 Name(
"SaveOnlyBranchingVtx"),
71 Comment(
"use true to save only vertices interconnecting many tracks, otherwise vertex is " 72 "added to the front of each track")};
76 Comment(
"save track nodes (only for algorithm development purposes)")};
117 ,
fPmaConfig(config().ProjectionMatchingAlg())
123 produces<std::vector<recob::Track>>();
124 produces<std::vector<recob::SpacePoint>>();
125 produces<std::vector<recob::Vertex>>();
126 produces<std::vector<recob::Vertex>>(
kKinksName);
127 produces<std::vector<recob::Vertex>>(
kNodesName);
131 produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
133 produces<art::Assns<recob::Track, recob::SpacePoint>>();
134 produces<art::Assns<recob::SpacePoint, recob::Hit>>();
138 produces<art::Assns<recob::Track, recob::Vertex>>(
kKinksName);
140 produces<art::Assns<recob::PFParticle, recob::Track>>();
147 auto tracks = std::make_unique<std::vector<recob::Track>>();
148 auto allsp = std::make_unique<std::vector<recob::SpacePoint>>();
149 auto vtxs = std::make_unique<std::vector<recob::Vertex>>();
150 auto kinks = std::make_unique<
151 std::vector<recob::Vertex>>();
152 auto nodes = std::make_unique<std::vector<recob::Vertex>>();
154 auto trk2hit_oldway = std::make_unique<
157 auto trk2hit = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
159 auto trk2sp = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
161 auto sp2hit = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
162 auto vtx2trk = std::make_unique<
166 std::make_unique<art::Assns<recob::Track, recob::Vertex>>();
168 auto pfp2trk = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
174 std::vector<art::Ptr<recob::Hit>> allhitlist;
181 <<
"Not all required data products found in the event." << std::endl;
205 int retCode = pmalgFitter.build(detProp);
214 else if (retCode == 1)
222 auto const& result = pmalgFitter.result();
225 size_t spStart = 0, spEnd = 0;
226 double sp_pos[3], sp_err[6];
227 for (
size_t i = 0; i < 3; i++)
229 for (
size_t i = 0; i < 6; i++)
233 std::map<size_t, std::vector<art::Ptr<recob::Track>>> pfPartToTrackVecMap;
237 tracks->reserve(result.size());
238 for (
size_t trkIndex = 0; trkIndex < result.size(); ++trkIndex) {
244 auto has_plane = [
this, &tpcid](
auto const view) {
253 if (trk->
size() < 2)
continue;
259 size_t trkIdx = tracks->size() - 1;
264 for (
size_t h = 0, cnt = 0; h < trk->
size(); h++) {
269 trk2hit->addSingle(trkPtr, h3d->
Hit2DPtr(), metadata);
270 trk2hit_oldway->addSingle(
275 spStart = allsp->
size();
276 for (
size_t h = 0; h < trk->
size(); ++h) {
280 double hx = h3d->
Point3D().X();
281 double hy = h3d->
Point3D().Y();
282 double hz = h3d->
Point3D().Z();
284 if ((h == 0) || (std::fabs(sp_pos[0] - hx) > 1.0
e-5) ||
285 (std::fabs(sp_pos[1] - hy) > 1.0
e-5) || (std::fabs(sp_pos[2] - hz) > 1.0
e-5)) {
303 spEnd = allsp->size();
305 if (spEnd > spStart)
util::CreateAssn(evt, *tracks, *allsp, *trk2sp, spStart, spEnd);
308 if (result[trkIndex].Key() > -1) {
309 size_t trackIdx = tracks->size() - 1;
312 pfPartToTrackVecMap[result[trkIndex].Key()].push_back(trackPtr);
316 auto vid = evt.
getProductID<std::vector<recob::Vertex>>();
320 auto tid = evt.
getProductID<std::vector<recob::Track>>();
323 auto vsel = pmalgFitter.getVertices(
325 auto ksel = pmalgFitter.getKinks();
326 std::map<size_t, art::Ptr<recob::Vertex>> frontVtxs;
331 for (
auto const& v : vsel) {
332 xyz[0] = v.first.X();
333 xyz[1] = v.first.Y();
334 xyz[2] = v.first.Z();
335 mf::LogVerbatim(
"Summary") <<
" vtx:" << xyz[0] <<
":" << xyz[1] <<
":" << xyz[2]
336 <<
" (" << v.second.size() <<
" tracks)";
338 size_t vidx = vtxs->size();
339 vtxs->push_back(recob::Vertex(xyz, vidx));
342 if (vptr.isNull())
mf::LogWarning(
"PMAlgTrajFitter") <<
"Vertex ptr is null.";
343 if (!v.second.empty()) {
344 for (
const auto& vEntry : v.second) {
345 size_t tidx = vEntry.first;
346 bool isFront = vEntry.second;
348 if (isFront) frontVtxs[tidx] = vptr;
351 vtx2trk->addSingle(vptr, tptr);
355 mf::LogWarning(
"PMAlgTrajFitter") <<
"No tracks found at this vertex.";
359 for (
auto const& k : ksel) {
360 xyz[0] = k.first.X();
361 xyz[1] = k.first.Y();
362 xyz[2] = k.first.Z();
363 mf::LogVerbatim(
"Summary") <<
" kink:" << xyz[0] <<
":" << xyz[1] <<
":" << xyz[2];
365 size_t kidx = kinks->size();
366 size_t tidx = k.second;
369 recob::Vertex(xyz, tidx));
373 trk2kink->addSingle(tptr, kptr);
380 for (
size_t t = 0; t < result.size(); ++t) {
381 auto const&
trk = *(result[t].Track());
382 for (
auto const* node :
trk.Nodes()) {
383 xyz[0] = node->Point3D().X();
384 xyz[1] = node->Point3D().Y();
385 xyz[2] = node->Point3D().Z();
386 nodes->push_back(recob::Vertex(xyz, t));
391 for (
const auto& pfParticleItr : pfPartToTrackVecMap) {
394 <<
"PFParticle key: " << pfParticle.
key() <<
", self: " << pfParticle->
Self()
395 <<
", #tracks: " << pfParticleItr.second.size();
401 <<
"Error in PFParticle lookup, pfparticle index: " << pfParticleItr.first
402 <<
", key: " << pfParticle.
key();
406 evt.
put(std::move(tracks));
407 evt.
put(std::move(allsp));
408 evt.
put(std::move(vtxs));
412 evt.
put(std::move(trk2hit_oldway));
413 evt.
put(std::move(trk2hit));
414 evt.
put(std::move(trk2sp));
416 evt.
put(std::move(sp2hit));
417 evt.
put(std::move(vtx2trk));
420 evt.
put(std::move(pfp2trk));
fhicl::Table< pma::ProjectionMatchingAlg::Config > ProjectionMatchingAlg
bool SelectHits(float fraction=1.0F)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
size_t Self() const
Returns the index of this particle.
recob::Track convertFrom(const pma::Track3D &src, unsigned int tidx, int pdg=0)
ProductID getProductID(std::string const &instance_name="") const
bool fSaveOnlyBranchingVtx
Declaration of signal hit object.
bool IsEnabled() const noexcept
EDProducer(fhicl::ParameterSet const &pset)
The data type to uniquely identify a Plane.
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
fhicl::Atom< bool > SavePmaNodes
TVector3 const & Point3D() const
Planes which measure Z direction.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool HasPlane(PlaneID const &planeid) const
Returns whether we have the specified plane.
void produce(art::Event &e) override
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
EDProductGetter const * productGetter(ProductID const pid) const
fhicl::Table< pma::PMAlgFitter::Config > PMAlgFitting
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
geo::WireReadoutGeom const & wireReadoutGeom
art::InputTag fPfpModuleLabel
fhicl::Atom< bool > SaveOnlyBranchingVtx
Interface for a class providing readout channel mapping to geometry.
fhicl::Atom< bool > RunVertexing
key_type key() const noexcept
bool isNull() const noexcept
fhicl::Table< pma::PMAlgVertexing::Config > PMAlgVertexing
unsigned int FrontTPC() const
unsigned int FrontCryo() const
The data type to uniquely identify a TPC.
Declaration of cluster object.
size_t CompleteMissingWires(detinfo::DetectorPropertiesData const &detProp, unsigned int view)
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
pma::PMAlgVertexing::Config fPmaVtxConfig
static const std::string kNodesName
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
Provides recob::Track data product.
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.
2D representation of charge deposited in the TDC/wire plane
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
PMAlgTrajFitter(Parameters const &config)
static const std::string kKinksName
fhicl::Atom< art::InputTag > HitModuleLabel
PMAlgTrajFitter & operator=(PMAlgTrajFitter const &)=delete
art framework interface to geometry description
pma::PMAlgFitter::Config fPmaFitterConfig
cet::coded_exception< error, detail::translate > exception
Encapsulate the construction of a single detector plane .
fhicl::Atom< art::InputTag > PfpModuleLabel
art::InputTag fHitModuleLabel