LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trkf::PMAlgTrajFitter Class Reference
Inheritance diagram for trkf::PMAlgTrajFitter:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  Config
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 
using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 PMAlgTrajFitter (Parameters const &config)
 
 PMAlgTrajFitter (PMAlgTrajFitter const &)=delete
 
 PMAlgTrajFitter (PMAlgTrajFitter &&)=delete
 
PMAlgTrajFitteroperator= (PMAlgTrajFitter const &)=delete
 
PMAlgTrajFitteroperator= (PMAlgTrajFitter &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void produce (art::Event &e) override
 

Private Attributes

art::InputTag fHitModuleLabel
 
art::InputTag fPfpModuleLabel
 
pma::ProjectionMatchingAlg::Config fPmaConfig
 
pma::PMAlgFitter::Config fPmaFitterConfig
 
pma::PMAlgVertexing::Config fPmaVtxConfig
 
bool fSaveOnlyBranchingVtx
 
bool fSavePmaNodes
 
art::ServiceHandle< geo::Geometry const > fGeom
 

Static Private Attributes

static const std::string kKinksName = "kink"
 
static const std::string kNodesName = "node"
 

Detailed Description

Definition at line 47 of file PMAlgTrajFitter_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

trkf::PMAlgTrajFitter::PMAlgTrajFitter ( PMAlgTrajFitter::Parameters const &  config)
explicit

Definition at line 112 of file PMAlgTrajFitter_module.cc.

References fHitModuleLabel, fPfpModuleLabel, fPmaConfig, fPmaFitterConfig, fPmaVtxConfig, fSaveOnlyBranchingVtx, fSavePmaNodes, kKinksName, kNodesName, and art::ProductRegistryHelper::produces().

113  : EDProducer{config}
114  , fHitModuleLabel(config().HitModuleLabel())
115  , fPfpModuleLabel(config().PfpModuleLabel())
116  ,
117 
118  fPmaConfig(config().ProjectionMatchingAlg())
119  , fPmaFitterConfig(config().PMAlgFitting())
120  , fPmaVtxConfig(config().PMAlgVertexing())
121  ,
122 
123  fSaveOnlyBranchingVtx(config().SaveOnlyBranchingVtx())
124  , fSavePmaNodes(config().SavePmaNodes())
125  {
126  produces<std::vector<recob::Track>>();
127  produces<std::vector<recob::SpacePoint>>();
128  produces<std::vector<recob::Vertex>>(); // no instance name for interaction vertices
129  produces<std::vector<recob::Vertex>>(kKinksName); // collection of kinks on tracks
130  produces<std::vector<recob::Vertex>>(kNodesName); // collection of pma nodes
131 
133  recob::Hit>>(); // ****** REMEMBER to remove when FindMany improved ******
134  produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
135 
136  produces<art::Assns<recob::Track, recob::SpacePoint>>();
137  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
138  produces<
140  recob::Track>>(); // no instance name for assns of tracks to interaction vertices
141  produces<art::Assns<recob::Track, recob::Vertex>>(kKinksName); // assns of kinks to tracks
142 
143  produces<art::Assns<recob::PFParticle, recob::Track>>();
144  }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
pma::PMAlgVertexing::Config fPmaVtxConfig
static const std::string kNodesName
pma::ProjectionMatchingAlg::Config fPmaConfig
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:992
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
static const std::string kKinksName
pma::PMAlgFitter::Config fPmaFitterConfig
trkf::PMAlgTrajFitter::PMAlgTrajFitter ( PMAlgTrajFitter const &  )
delete
trkf::PMAlgTrajFitter::PMAlgTrajFitter ( PMAlgTrajFitter &&  )
delete

Member Function Documentation

template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
PMAlgTrajFitter& trkf::PMAlgTrajFitter::operator= ( PMAlgTrajFitter const &  )
delete
PMAlgTrajFitter& trkf::PMAlgTrajFitter::operator= ( PMAlgTrajFitter &&  )
delete
void trkf::PMAlgTrajFitter::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 147 of file PMAlgTrajFitter_module.cc.

References art::PtrVector< T >::clear(), pma::Track3D::CompleteMissingWires(), pma::convertFrom(), util::CreateAssn(), DEFINE_ART_MODULE, pma::Hit3D::Dx(), e, fGeom, fHitModuleLabel, art::fill_ptr_vector(), fPfpModuleLabel, fPmaConfig, fPmaFitterConfig, fPmaVtxConfig, pma::Track3D::FrontCryo(), pma::Track3D::FrontTPC(), fSaveOnlyBranchingVtx, fSavePmaNodes, art::ProductRetriever::getByLabel(), art::ProductRetriever::getProductID(), pma::Hit3D::Hit2DPtr(), pma::Hit3D::IsEnabled(), art::Ptr< T >::isNull(), art::Ptr< T >::key(), kKinksName, kNodesName, geo::kU, geo::kV, geo::kZ, pma::Hit3D::Point3D(), art::ProductRetriever::productGetter(), art::PtrVector< T >::push_back(), art::Event::put(), pma::PMAlgFitter::Config::RunVertexing, pma::Track3D::SelectHits(), recob::PFParticle::Self(), pma::Track3D::size(), art::PtrVector< T >::size(), and geo::GeometryCore::TPC().

148  {
149  // ---------------- Create data products ------------------
150  auto tracks = std::make_unique<std::vector<recob::Track>>();
151  auto allsp = std::make_unique<std::vector<recob::SpacePoint>>();
152  auto vtxs = std::make_unique<std::vector<recob::Vertex>>(); // interaction vertices
153  auto kinks = std::make_unique<
154  std::vector<recob::Vertex>>(); // kinks on tracks (no new particles start in kinks)
155  auto nodes = std::make_unique<std::vector<recob::Vertex>>(); // pma nodes
156 
157  auto trk2hit_oldway = std::make_unique<
159  recob::Hit>>(); // ****** REMEMBER to remove when FindMany improved ******
160  auto trk2hit = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
161 
162  auto trk2sp = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
163 
164  auto sp2hit = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
165  auto vtx2trk = std::make_unique<
167  recob::Track>>(); // one or more tracks (particles) start in the vertex
168  auto trk2kink =
169  std::make_unique<art::Assns<recob::Track, recob::Vertex>>(); // one or more kinks on the track
170 
171  auto pfp2trk = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
172 
173  // ------------------- Collect inputs ---------------------
174  art::Handle<std::vector<recob::Hit>> allHitListHandle;
177  std::vector<art::Ptr<recob::Hit>> allhitlist;
178  if (!(evt.getByLabel(fHitModuleLabel,
179  allHitListHandle) && // all hits used to make clusters and PFParticles
180  evt.getByLabel(fPfpModuleLabel, cluListHandle) && // clusters associated to PFParticles
181  evt.getByLabel(fPfpModuleLabel, pfparticleHandle))) // and finally PFParticles
182  {
183  throw cet::exception("PMAlgTrajFitter")
184  << "Not all required data products found in the event." << std::endl;
185  }
186 
187  art::fill_ptr_vector(allhitlist, allHitListHandle);
188 
189  art::FindManyP<recob::Hit> hitsFromClusters(cluListHandle, evt, fPfpModuleLabel);
190  art::FindManyP<recob::Cluster> clustersFromPfps(pfparticleHandle, evt, fPfpModuleLabel);
191  art::FindManyP<recob::Vertex> vtxFromPfps(pfparticleHandle, evt, fPfpModuleLabel);
192 
193  auto const detProp =
195 
196  // -------------- PMA Fitter for this event ---------------
197  auto pmalgFitter = pma::PMAlgFitter(allhitlist,
198  *cluListHandle,
199  *pfparticleHandle,
200  hitsFromClusters,
201  clustersFromPfps,
202  vtxFromPfps,
203  fPmaConfig,
205  fPmaVtxConfig);
206 
207  // ------------------ Do the job here: --------------------
208  int retCode = pmalgFitter.build(detProp);
209  // --------------------------------------------------------
210  switch (retCode) {
211  case -2: mf::LogError("Summary") << "problem"; break;
212  case -1: mf::LogWarning("Summary") << "no input"; break;
213  case 0: mf::LogVerbatim("Summary") << "no tracks done"; break;
214  default:
215  if (retCode < 0)
216  mf::LogVerbatim("Summary") << "unknown result";
217  else if (retCode == 1)
218  mf::LogVerbatim("Summary") << retCode << " track ready";
219  else
220  mf::LogVerbatim("Summary") << retCode << " tracks ready";
221  break;
222  }
223 
224  // ---------- Translate output to data products: ----------
225  auto const& result = pmalgFitter.result();
226  if (!result.empty()) // ok, there is something to save
227  {
228  size_t spStart = 0, spEnd = 0;
229  double sp_pos[3], sp_err[6];
230  for (size_t i = 0; i < 3; i++)
231  sp_pos[i] = 1.0;
232  for (size_t i = 0; i < 6; i++)
233  sp_err[i] = 1.0;
234 
235  // use the following to create PFParticle <--> Track associations;
236  std::map<size_t, std::vector<art::Ptr<recob::Track>>> pfPartToTrackVecMap;
237 
238  //auto const make_trkptr = art::PtrMaker<recob::Track>(evt, *this); // PtrMaker Step #1
239 
240  tracks->reserve(result.size());
241  for (size_t trkIndex = 0; trkIndex < result.size(); ++trkIndex) {
242  pma::Track3D* trk = result[trkIndex].Track();
243 
244  trk->SelectHits(); // just in case, set all to enabled
245  unsigned int itpc = trk->FrontTPC(), icryo = trk->FrontCryo();
246  auto const& tpc = fGeom->TPC(geo::TPCID(icryo, itpc));
247  if (tpc.HasPlane(geo::kU)) trk->CompleteMissingWires(detProp, geo::kU);
248  if (tpc.HasPlane(geo::kV)) trk->CompleteMissingWires(detProp, geo::kV);
249  if (tpc.HasPlane(geo::kZ)) trk->CompleteMissingWires(detProp, geo::kZ);
250 
251  // gc: make sure no tracks are created with less than 2 points
252  if (trk->size() < 2) continue;
253 
254  tracks->push_back(pma::convertFrom(*trk, trkIndex));
255 
256  //auto const trkPtr = make_trkptr(tracks->size() - 1); // PtrMaker Step #2
257 
258  size_t trkIdx = tracks->size() - 1; // stuff for assns:
259  art::ProductID trkId = evt.getProductID<std::vector<recob::Track>>();
260  art::Ptr<recob::Track> trkPtr(trkId, trkIdx, evt.productGetter(trkId));
261 
262  //gc: save associated hits in the same order as trajectory points
263  for (size_t h = 0, cnt = 0; h < trk->size(); h++) {
264  pma::Hit3D* h3d = (*trk)[h];
265  if (!h3d->IsEnabled()) continue;
266 
267  recob::TrackHitMeta metadata(cnt++, h3d->Dx());
268  trk2hit->addSingle(trkPtr, h3d->Hit2DPtr(), metadata);
269  trk2hit_oldway->addSingle(
270  trkPtr, h3d->Hit2DPtr()); // ****** REMEMBER to remove when FindMany improved ******
271  }
272 
274  spStart = allsp->size();
275  for (size_t h = 0; h < trk->size(); ++h) {
276  pma::Hit3D* h3d = (*trk)[h];
277  if (!h3d->IsEnabled()) continue;
278 
279  double hx = h3d->Point3D().X();
280  double hy = h3d->Point3D().Y();
281  double hz = h3d->Point3D().Z();
282 
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)) {
285  if (sp_hits.size()) // hits assigned to the previous sp
286  {
287  util::CreateAssn(evt, *allsp, sp_hits, *sp2hit);
288  sp_hits.clear();
289  }
290  sp_pos[0] = hx;
291  sp_pos[1] = hy;
292  sp_pos[2] = hz;
293  allsp->push_back(recob::SpacePoint(sp_pos, sp_err, 1.0));
294  }
295  sp_hits.push_back(h3d->Hit2DPtr());
296  }
297 
298  if (sp_hits.size()) // hits assigned to the last sp
299  {
300  util::CreateAssn(evt, *allsp, sp_hits, *sp2hit);
301  }
302  spEnd = allsp->size();
303 
304  if (spEnd > spStart) util::CreateAssn(evt, *tracks, *allsp, *trk2sp, spStart, spEnd);
305 
306  // if there is a PFParticle collection then recover PFParticle and add info to map
307  if (result[trkIndex].Key() > -1) {
308  size_t trackIdx = tracks->size() - 1;
309  art::ProductID trackId = evt.getProductID<std::vector<recob::Track>>();
310  art::Ptr<recob::Track> trackPtr(trackId, trackIdx, evt.productGetter(trackId));
311  pfPartToTrackVecMap[result[trkIndex].Key()].push_back(trackPtr);
312  }
313  }
314 
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);
318 
319  auto tid = evt.getProductID<std::vector<recob::Track>>();
320  auto const* trkGetter = evt.productGetter(tid);
321 
322  auto vsel = pmalgFitter.getVertices(
323  fSaveOnlyBranchingVtx); // vtx pos's with vector of connected track idxs
324  auto ksel = pmalgFitter.getKinks(); // pairs of kink position - associated track idx
325  std::map<size_t, art::Ptr<recob::Vertex>> frontVtxs; // front vertex ptr for each track index
326 
327  if (fPmaFitterConfig.RunVertexing()) // save vertices and vtx-trk assns
328  {
329  double xyz[3];
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)";
336 
337  size_t vidx = vtxs->size();
338  vtxs->push_back(recob::Vertex(xyz, vidx));
339 
340  art::Ptr<recob::Vertex> vptr(vid, vidx, evt.productGetter(vid));
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;
346 
347  if (isFront) frontVtxs[tidx] = vptr; // keep ptr of the front vtx
348 
349  art::Ptr<recob::Track> tptr(tid, tidx, trkGetter);
350  vtx2trk->addSingle(vptr, tptr);
351  }
352  }
353  else
354  mf::LogWarning("PMAlgTrajFitter") << "No tracks found at this vertex.";
355  }
356  mf::LogVerbatim("Summary") << vtxs->size() << " vertices ready";
357 
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];
363 
364  size_t kidx = kinks->size();
365  size_t tidx = k.second; // track idx on which this kink was found
366 
367  kinks->push_back(
368  recob::Vertex(xyz, tidx)); // save index of track (will have color of trk in evd)
369 
370  art::Ptr<recob::Track> tptr(tid, tidx, trkGetter);
371  art::Ptr<recob::Vertex> kptr(kid, kidx, kinkGetter);
372  trk2kink->addSingle(tptr, kptr);
373  }
374  mf::LogVerbatim("Summary") << ksel.size() << " kinks ready";
375  }
376 
377  if (fSavePmaNodes) {
378  double xyz[3];
379  for (size_t t = 0; t < result.size(); ++t) {
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();
385  nodes->push_back(recob::Vertex(xyz, t));
386  }
387  }
388  }
389 
390  for (const auto& pfParticleItr : pfPartToTrackVecMap) {
391  art::Ptr<recob::PFParticle> pfParticle(pfparticleHandle, pfParticleItr.first);
392  mf::LogVerbatim("PMAlgTrajFitter")
393  << "PFParticle key: " << pfParticle.key() << ", self: " << pfParticle->Self()
394  << ", #tracks: " << pfParticleItr.second.size();
395 
396  if (!pfParticle.isNull())
397  util::CreateAssn(evt, pfParticle, pfParticleItr.second, *pfp2trk);
398  else
399  mf::LogError("PMAlgTrajFitter")
400  << "Error in PFParticle lookup, pfparticle index: " << pfParticleItr.first
401  << ", key: " << pfParticle.key();
402  }
403  }
404 
405  evt.put(std::move(tracks));
406  evt.put(std::move(allsp));
407  evt.put(std::move(vtxs));
408  evt.put(std::move(kinks), kKinksName);
409  evt.put(std::move(nodes), kNodesName);
410 
411  evt.put(std::move(trk2hit_oldway)); // ****** REMEMBER to remove when FindMany improved ******
412  evt.put(std::move(trk2hit));
413  evt.put(std::move(trk2sp));
414 
415  evt.put(std::move(sp2hit));
416  evt.put(std::move(vtx2trk));
417  evt.put(std::move(trk2kink), kKinksName);
418 
419  evt.put(std::move(pfp2trk));
420  }
bool SelectHits(float fraction=1.0F)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
recob::Track convertFrom(const pma::Track3D &src, unsigned int tidx, int pdg=0)
Planes which measure V.
Definition: geo_types.h:136
bool IsEnabled() const noexcept
Definition: PmaHit3D.h:86
TVector3 const & Point3D() const
Definition: PmaHit3D.h:50
Planes which measure Z direction.
Definition: geo_types.h:138
Data related to recob::Hit associated with recob::Track.The purpose is to collect several variables t...
Definition: TrackHitMeta.h:43
art::ServiceHandle< geo::Geometry const > fGeom
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TPCGeo const & TPC(TPCID const &tpcid=tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:722
Planes which measure U.
Definition: geo_types.h:135
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
fhicl::Atom< bool > RunVertexing
unsigned int FrontTPC() const
Definition: PmaTrack3D.h:118
unsigned int FrontCryo() const
Definition: PmaTrack3D.h:119
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
size_type size() const
Definition: PtrVector.h:302
size_t CompleteMissingWires(detinfo::DetectorPropertiesData const &detProp, unsigned int view)
void push_back(pma::Hit3D *hit)
Definition: PmaTrack3D.h:77
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
double Dx() const noexcept
Definition: PmaHit3D.h:69
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
pma::ProjectionMatchingAlg::Config fPmaConfig
art::Ptr< recob::Hit > const & Hit2DPtr() const
Definition: PmaHit3D.h:48
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:992
std::vector< pma::Node3D * > const & Nodes() const noexcept
Definition: PmaTrack3D.h:274
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
TCEvent evt
Definition: DataStructs.cxx:8
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
size_t size() const
Definition: PmaTrack3D.h:89
static const std::string kKinksName
void clear()
Definition: PtrVector.h:533
pma::PMAlgFitter::Config fPmaFitterConfig
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

art::ServiceHandle<geo::Geometry const> trkf::PMAlgTrajFitter::fGeom
private

Definition at line 105 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

art::InputTag trkf::PMAlgTrajFitter::fHitModuleLabel
private

Definition at line 90 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

art::InputTag trkf::PMAlgTrajFitter::fPfpModuleLabel
private

Definition at line 91 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

pma::ProjectionMatchingAlg::Config trkf::PMAlgTrajFitter::fPmaConfig
private

Definition at line 93 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

pma::PMAlgFitter::Config trkf::PMAlgTrajFitter::fPmaFitterConfig
private

Definition at line 94 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

pma::PMAlgVertexing::Config trkf::PMAlgTrajFitter::fPmaVtxConfig
private

Definition at line 95 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

bool trkf::PMAlgTrajFitter::fSaveOnlyBranchingVtx
private

Definition at line 97 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

bool trkf::PMAlgTrajFitter::fSavePmaNodes
private

Definition at line 98 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

const std::string trkf::PMAlgTrajFitter::kKinksName = "kink"
staticprivate

Definition at line 101 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

const std::string trkf::PMAlgTrajFitter::kNodesName = "node"
staticprivate

Definition at line 102 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().


The documentation for this class was generated from the following file: