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

Public Types

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

Public Member Functions

 Track3DKalmanHit (fhicl::ParameterSet const &pset)
 
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
 
void beginJob () override
 Begin job method. More...
 
void endJob () override
 End job method. More...
 
void prepareForInput ()
 
KalmanInputs getInput (const art::Event &evt) const
 
Hits getClusteredHits (const art::Event &evt) const
 Fill a collection using clustered hits. More...
 
KalmanInputs getPFParticleStuff (const art::Event &evt) const
 If UsePFParticles is true use this method to fill in hits. More...
 
Hits getAllHits (const art::Event &evt) const
 If both UseClusteredHits and UsePFParticles is false use this method to fill in hits. More...
 
void createOutputs (const art::Event &evt, detinfo::DetectorPropertiesData const &detProp, const std::vector< KalmanOutput > &outputs, const KalmanInputs &inputs, std::vector< recob::Track > &tracks, std::vector< recob::SpacePoint > &spts, art::Assns< recob::Track, recob::Hit > &th_assn, art::Assns< recob::Track, recob::Hit, recob::TrackHitMeta > &thm_assn, art::Assns< recob::Track, recob::SpacePoint > &tsp_assn, art::Assns< recob::SpacePoint, recob::Hit > &sph_assn, art::Assns< recob::PFParticle, recob::Track > &pfPartTrack_assns)
 
void fillHistograms (std::vector< KalmanOutput > &outputs)
 Fill Histograms method. More...
 

Private Attributes

bool fHist
 Make histograms. More...
 
bool fUseClusterHits
 Use clustered hits as input. More...
 
bool fUsePFParticleHits
 Use PFParticle hits as input. More...
 
bool fUsePFParticleSeeds
 Use PFParticle seeds. More...
 
std::string fHitModuleLabel
 Unclustered Hits. More...
 
std::string fClusterModuleLabel
 Clustered Hits. More...
 
std::string fPFParticleModuleLabel
 PFParticle label. More...
 
Track3DKalmanHitAlg fTKHAlg
 Track3DKalmanHit algorithm. More...
 
SpacePointAlg fSpacePointAlg
 Space point algorithm. More...
 
TH1F * fHIncChisq
 Incremental chisquare. More...
 
TH1F * fHPull
 Hit pull. More...
 
int fNumEvent
 Number of events seen. More...
 

Detailed Description

Definition at line 73 of file Track3DKalmanHit_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::Track3DKalmanHit::Track3DKalmanHit ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Arguments:

p - Fcl parameters.

Definition at line 131 of file Track3DKalmanHit_module.cc.

References fClusterModuleLabel, fHIncChisq, fHist, fHitModuleLabel, fHPull, fNumEvent, fPFParticleModuleLabel, fSpacePointAlg, fTKHAlg, fUseClusterHits, fUsePFParticleHits, fUsePFParticleSeeds, and art::ProductRegistryHelper::produces().

132  : EDProducer{pset}
133  , fHist(false)
134  , fUseClusterHits(false)
135  , fUsePFParticleHits(false)
136  , fUsePFParticleSeeds(false)
137  , fTKHAlg(pset.get<fhicl::ParameterSet>("Track3DKalmanHitAlg"))
138  , fSpacePointAlg(pset.get<fhicl::ParameterSet>("SpacePointAlg"))
139  , fHIncChisq(0)
140  , fHPull(0)
141  , fNumEvent(0)
142 {
143  fHist = pset.get<bool>("Hist");
144  fUseClusterHits = pset.get<bool>("UseClusterHits");
145  fUsePFParticleHits = pset.get<bool>("UsePFParticleHits");
146  fUsePFParticleSeeds = pset.get<bool>("UsePFParticleSeeds");
147  fHitModuleLabel = pset.get<std::string>("HitModuleLabel");
148  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
149  fPFParticleModuleLabel = pset.get<std::string>("PFParticleModuleLabel");
150  if (fUseClusterHits && fUsePFParticleHits) {
151  throw cet::exception("Track3DKalmanHit")
152  << "Using input from both clustered and PFParticle hits.\n";
153  }
154 
155  produces<std::vector<recob::Track>>();
156  produces<std::vector<recob::SpacePoint>>();
158  recob::Hit>>(); // ****** REMEMBER to remove when FindMany improved ******
159  produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
160  produces<art::Assns<recob::Track, recob::SpacePoint>>();
161  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
162  produces<art::Assns<recob::PFParticle, recob::Track>>();
163 
164  // Report.
165 
166  mf::LogInfo("Track3DKalmanHit") << "Track3DKalmanHit configured with the following parameters:\n"
167  << " UseClusterHits = " << fUseClusterHits << "\n"
168  << " HitModuleLabel = " << fHitModuleLabel << "\n"
169  << " ClusterModuleLabel = " << fClusterModuleLabel;
170 }
bool fUseClusterHits
Use clustered hits as input.
std::string fHitModuleLabel
Unclustered Hits.
Track3DKalmanHitAlg fTKHAlg
Track3DKalmanHit algorithm.
bool fUsePFParticleSeeds
Use PFParticle seeds.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::string fPFParticleModuleLabel
PFParticle label.
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
std::string fClusterModuleLabel
Clustered Hits.
SpacePointAlg fSpacePointAlg
Space point algorithm.
int fNumEvent
Number of events seen.
bool fUsePFParticleHits
Use PFParticle hits as input.
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
TH1F * fHIncChisq
Incremental chisquare.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Function Documentation

void trkf::Track3DKalmanHit::beginJob ( )
overrideprivatevirtual

Begin job method.

Reimplemented from art::EDProducer.

Definition at line 174 of file Track3DKalmanHit_module.cc.

References dir, fHIncChisq, fHist, and fHPull.

175 {
176  if (fHist) {
177  // Book histograms.
179  art::TFileDirectory dir = tfs->mkdir("hitkalman", "Track3DKalmanHit histograms");
180 
181  fHIncChisq = dir.make<TH1F>("IncChisq", "Incremental Chisquare", 100, 0., 20.);
182  fHPull = dir.make<TH1F>("Pull", "Hit Pull", 100, -10., 10.);
183  }
184 }
TDirectory * dir
Definition: macro.C:5
TH1F * fHIncChisq
Incremental chisquare.
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 trkf::Track3DKalmanHit::createOutputs ( const art::Event evt,
detinfo::DetectorPropertiesData const &  detProp,
const std::vector< KalmanOutput > &  outputs,
const KalmanInputs inputs,
std::vector< recob::Track > &  tracks,
std::vector< recob::SpacePoint > &  spts,
art::Assns< recob::Track, recob::Hit > &  th_assn,
art::Assns< recob::Track, recob::Hit, recob::TrackHitMeta > &  thm_assn,
art::Assns< recob::Track, recob::SpacePoint > &  tsp_assn,
art::Assns< recob::SpacePoint, recob::Hit > &  sph_assn,
art::Assns< recob::PFParticle, recob::Track > &  pfPartTrack_assns 
)
private

Definition at line 371 of file Track3DKalmanHit_module.cc.

References art::Assns< L, R, D >::addSingle(), trkf::SpacePointAlg::fillSpacePoints(), fSpacePointAlg, fUsePFParticleHits, trkf::SpacePointAlg::getAssociatedHits(), art::ProductRetriever::getProductID(), recob::Track::NumberTrajectoryPoints(), art::ProductRetriever::productGetter(), art::PtrVector< T >::size(), and track.

Referenced by produce().

383 {
384  if (outputs.size() != inputs.size()) return;
385 
386  size_t tracksSize(0);
387  for (auto const& kalman_output : outputs) {
388  tracksSize += kalman_output.tracks.size();
389  }
390  tracks.reserve(tracksSize);
391 
392  auto const tid = evt.getProductID<std::vector<recob::Track>>();
393  auto const tidgetter = evt.productGetter(tid);
394 
395  auto const spacepointId = evt.getProductID<std::vector<recob::SpacePoint>>();
396  auto const getter = evt.productGetter(spacepointId);
397 
398  for (size_t i = 0; i < outputs.size(); ++i) {
399  // Recover the kalman tracks double ended queue
400  const std::deque<KGTrack>& kalman_tracks = outputs[i].tracks;
401 
402  for (auto const& kalman_track : kalman_tracks) {
403 
404  // Add Track object to collection.
406  kalman_track.fillTrack(detProp, track, tracks.size());
407  if (track.NumberTrajectoryPoints() < 2) { continue; }
408  unsigned int numtrajpts = track.NumberTrajectoryPoints();
409  tracks.emplace_back(std::move(track));
410  // SS: tracks->size() does not change after this point in each iteration
411 
412  //fill hits from this track
413  Hits trhits;
414  std::vector<unsigned int> hittpindex; //hit-trajectory point index
415  kalman_track.fillHits(trhits, hittpindex);
416  if (hittpindex.back() >= numtrajpts) { //something is wrong
417  throw cet::exception("Track3DKalmanHit")
418  << "Last hit corresponds to trajectory point index " << hittpindex.back()
419  << " while the number of trajectory points is " << numtrajpts << '\n';
420  }
421 
422  // Make space points from this track.
423  auto nspt = spts.size();
424  fSpacePointAlg.fillSpacePoints(detProp, spts, kalman_track.TrackMap());
425 
426  std::vector<art::Ptr<recob::SpacePoint>> sptvec;
427  for (auto ispt = nspt; ispt < spts.size(); ++ispt) {
428  sptvec.emplace_back(spacepointId, ispt, getter);
429  // Associate newly created space points with hits.
430  // Make space point to hit associations.
431  auto const& sphits = fSpacePointAlg.getAssociatedHits((spts)[ispt]);
432  for (auto const& sphit : sphits) {
433  sph_assn.addSingle(sptvec.back(), sphit);
434  }
435  }
436 
437  art::Ptr<recob::Track> aptr(tid, tracks.size() - 1, tidgetter);
438 
439  // Make Track to Hit associations.
440  for (size_t h = 0; h < trhits.size(); ++h) {
441  th_assn.addSingle(aptr, trhits[h]);
442  recob::TrackHitMeta metadata(hittpindex[h], -1);
443  thm_assn.addSingle(aptr, trhits[h], metadata);
444  }
445 
446  // Make track to space point associations
447  for (auto const& spt : sptvec) {
448  tsp_assn.addSingle(aptr, spt);
449  }
450 
451  // Optionally fill track-to-PFParticle associations.
452  if (fUsePFParticleHits) { pfPartTrack_assns.addSingle(inputs[i].pfPartPtr, aptr); }
453  } // end of loop over a given collection
454  }
455 }
ProductID getProductID(std::string const &instance_name="") const
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:136
Data related to recob::Hit associated with recob::Track.The purpose is to collect several variables t...
Definition: TrackHitMeta.h:43
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
SpacePointAlg fSpacePointAlg
Space point algorithm.
EDProductGetter const * productGetter(ProductID const pid) const
void fillSpacePoints(detinfo::DetectorPropertiesData const &detProp, std::vector< recob::SpacePoint > &spts, std::multimap< double, KHitTrack > const &trackMap) const
Fill a collection of space points.
art::PtrVector< recob::Hit > Hits
bool fUsePFParticleHits
Use PFParticle hits as input.
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
Float_t track
Definition: plot.C:35
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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 trkf::Track3DKalmanHit::endJob ( )
overrideprivatevirtual

End job method.

Reimplemented from art::EDProducer.

Definition at line 235 of file Track3DKalmanHit_module.cc.

References fNumEvent.

236 {
237  mf::LogInfo("Track3DKalmanHit") << "Track3DKalmanHit statistics:\n"
238  << " Number of events = " << fNumEvent << "\n";
239 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fNumEvent
Number of events seen.
void trkf::Track3DKalmanHit::fillHistograms ( std::vector< KalmanOutput > &  outputs)
private

Fill Histograms method.

Definition at line 461 of file Track3DKalmanHit_module.cc.

References fHIncChisq, fHPull, trkf::KHitTrack::getHit(), trkf::KHit< N >::getResError(), trkf::KHit< N >::getResVector(), and trkf::KGTrack::getTrackMap().

Referenced by produce().

462 {
463  for (auto const& output : outputs) {
464  const std::deque<KGTrack>& kalman_tracks = output.tracks;
465  for (size_t i = 0; i < kalman_tracks.size(); ++i) {
466  const KGTrack& trg = kalman_tracks[i];
467  // Loop over measurements in this track.
468  const std::multimap<double, KHitTrack>& trackmap = trg.getTrackMap();
469  for (std::multimap<double, KHitTrack>::const_iterator ih = trackmap.begin();
470  ih != trackmap.end();
471  ++ih) {
472  const KHitTrack& trh = (*ih).second;
473  const std::shared_ptr<const KHitBase>& hit = trh.getHit();
474  double chisq = hit->getChisq();
475  fHIncChisq->Fill(chisq);
476  const KHit<1>* ph1 = dynamic_cast<const KHit<1>*>(&*hit);
477  if (ph1 != 0) {
478  double pull = ph1->getResVector()(0) / std::sqrt(ph1->getResError()(0, 0));
479  fHPull->Fill(pull);
480  }
481  }
482  }
483  }
484 }
intermediate_table::const_iterator const_iterator
Detector simulation of raw signals on wires.
TH1F * fHIncChisq
Incremental chisquare.
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
trkf::Hits trkf::Track3DKalmanHit::getAllHits ( const art::Event evt) const
private

If both UseClusteredHits and UsePFParticles is false use this method to fill in hits.

Definition at line 281 of file Track3DKalmanHit_module.cc.

References fHitModuleLabel, art::ProductRetriever::getByLabel(), hits(), art::Handle< T >::isValid(), art::PtrVector< T >::push_back(), and art::PtrVector< T >::reserve().

Referenced by getInput().

282 {
283  Hits hits;
285  evt.getByLabel(fHitModuleLabel, hith);
286  if (!hith.isValid()) return hits;
287  size_t nhits = hith->size();
288  hits.reserve(nhits);
289 
290  for (size_t i = 0; i < nhits; ++i) {
291  hits.push_back(art::Ptr<recob::Hit>(hith, i));
292  }
293  return hits;
294 }
std::string fHitModuleLabel
Unclustered Hits.
bool isValid() const noexcept
Definition: Handle.h:203
void hits()
Definition: readHits.C:15
art::PtrVector< recob::Hit > Hits
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
trkf::Hits trkf::Track3DKalmanHit::getClusteredHits ( const art::Event evt) const
private

Fill a collection using clustered hits.

Definition at line 262 of file Track3DKalmanHit_module.cc.

References art::PtrVector< T >::end(), fClusterModuleLabel, art::ProductRetriever::getByLabel(), hits(), art::PtrVector< T >::insert(), and art::Handle< T >::isValid().

Referenced by getInput().

263 {
264  Hits hits;
266  evt.getByLabel(fClusterModuleLabel, clusterh);
267 
268  if (!clusterh.isValid()) return hits;
269  // Get hits from all clusters.
270  art::FindManyP<recob::Hit> hitsbycluster(clusterh, evt, fClusterModuleLabel);
271 
272  for (size_t i = 0; i < clusterh->size(); ++i) {
273  std::vector<art::Ptr<recob::Hit>> clushits = hitsbycluster.at(i);
274  hits.insert(hits.end(), clushits.begin(), clushits.end());
275  }
276  return hits;
277 }
std::string fClusterModuleLabel
Clustered Hits.
bool isValid() const noexcept
Definition: Handle.h:203
void hits()
Definition: readHits.C:15
art::PtrVector< recob::Hit > Hits
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
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
trkf::KalmanInputs trkf::Track3DKalmanHit::getInput ( const art::Event evt) const
private

Definition at line 254 of file Track3DKalmanHit_module.cc.

References fUseClusterHits, fUsePFParticleHits, getAllHits(), getClusteredHits(), and getPFParticleStuff().

Referenced by produce().

255 {
256  if (fUsePFParticleHits) return getPFParticleStuff(evt);
257  return KalmanInputs(1, KalmanInput(fUseClusterHits ? getClusteredHits(evt) : getAllHits(evt)));
258 }
bool fUseClusterHits
Use clustered hits as input.
Hits getClusteredHits(const art::Event &evt) const
Fill a collection using clustered hits.
Hits getAllHits(const art::Event &evt) const
If both UseClusteredHits and UsePFParticles is false use this method to fill in hits.
bool fUsePFParticleHits
Use PFParticle hits as input.
std::vector< KalmanInput > KalmanInputs
KalmanInputs getPFParticleStuff(const art::Event &evt) const
If UsePFParticles is true use this method to fill in hits.
trkf::KalmanInputs trkf::Track3DKalmanHit::getPFParticleStuff ( const art::Event evt) const
private

If UsePFParticles is true use this method to fill in hits.

Definition at line 298 of file Track3DKalmanHit_module.cc.

References art::PtrVector< T >::end(), fClusterModuleLabel, fPFParticleModuleLabel, fUsePFParticleSeeds, art::ProductRetriever::getByLabel(), hits(), trkf::KalmanInput::hits, art::PtrVector< T >::insert(), art::Handle< T >::isValid(), trkf::KalmanInput::pfPartPtr, trkf::KalmanInput::seedhits, tca::seeds, and trkf::KalmanInput::seeds.

Referenced by getInput().

299 {
300  KalmanInputs inputs;
301  // Our program is to drive the track creation/fitting off the PFParticles in the data store
302  // We'll use the hits associated to the PFParticles for each track - and only those hits.
303  // Without a valid collection of PFParticles there is nothing to do here
304  // We need a handle to the collection of clusters in the data store so we can
305  // handle associations to hits.
307  evt.getByLabel(fPFParticleModuleLabel, pfParticleHandle);
308  if (!pfParticleHandle.isValid()) return inputs;
309 
311  evt.getByLabel(fClusterModuleLabel, clusterHandle);
312 
313  // If there are no clusters then something is really wrong
314  if (!clusterHandle.isValid()) return inputs;
315 
316  // Recover the collection of associations between PFParticles and clusters, this will
317  // be the mechanism by which we actually deal with clusters
318  art::FindManyP<recob::Cluster> clusterAssns(pfParticleHandle, evt, fPFParticleModuleLabel);
319 
320  // Associations to seeds.
321  art::FindManyP<recob::Seed> seedAssns(pfParticleHandle, evt, fPFParticleModuleLabel);
322 
323  // Likewise, recover the collection of associations to hits
324  art::FindManyP<recob::Hit> clusterHitAssns(clusterHandle, evt, fClusterModuleLabel);
325 
326  inputs.reserve(pfParticleHandle->size());
327 
328  // While PFParticle describes a hierarchal structure, for now we simply loop over the collection
329  for (size_t partIdx = 0; partIdx < pfParticleHandle->size(); partIdx++) {
330 
331  // Add a new empty hit collection.
332  inputs.emplace_back();
333  KalmanInput& kalman_input = inputs.back();
334  kalman_input.pfPartPtr = art::Ptr<recob::PFParticle>(pfParticleHandle, partIdx);
335  Hits& hits = kalman_input.hits;
336 
337  // Fill this hit vector by looping over associated clusters and finding the
338  // hits associated to them
339  std::vector<art::Ptr<recob::Cluster>> clusterVec = clusterAssns.at(partIdx);
340 
341  for (auto const& cluster : clusterVec) {
342  std::vector<art::Ptr<recob::Hit>> hitVec = clusterHitAssns.at(cluster.key());
343  hits.insert(hits.end(), hitVec.begin(), hitVec.end());
344  }
345 
346  // If requested, fill associated seeds.
347  if (!fUsePFParticleSeeds) continue;
348  art::PtrVector<recob::Seed>& seeds = kalman_input.seeds;
349  std::vector<art::Ptr<recob::Seed>> seedVec = seedAssns.at(partIdx);
350  seeds.insert(seeds.end(), seedVec.begin(), seedVec.end());
351  art::FindManyP<recob::Hit> seedHitAssns(seedVec, evt, fPFParticleModuleLabel);
352 
353  for (size_t seedIdx = 0; seedIdx < seedVec.size(); ++seedIdx) {
354  std::vector<art::Ptr<recob::Hit>> seedHitVec;
355  //SS: why seedIdx can have an invalid value?
356  try {
357  seedHitVec = seedHitAssns.at(seedIdx);
358  }
359  catch (art::Exception const&) {
360  seedHitVec.clear();
361  }
362  kalman_input.seedhits.emplace_back();
363  Hits& seedhits = kalman_input.seedhits.back();
364  seedhits.insert(seedhits.end(), seedHitVec.begin(), seedHitVec.end());
365  }
366  }
367  return inputs;
368 }
bool fUsePFParticleSeeds
Use PFParticle seeds.
std::string fPFParticleModuleLabel
PFParticle label.
std::string fClusterModuleLabel
Clustered Hits.
Cluster finding and building.
bool isValid() const noexcept
Definition: Handle.h:203
reference back()
Definition: PtrVector.h:387
void hits()
Definition: readHits.C:15
iterator end()
Definition: PtrVector.h:231
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:14
art::PtrVector< recob::Hit > Hits
iterator insert(iterator position, Ptr< U > const &p)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::vector< KalmanInput > KalmanInputs
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
void trkf::Track3DKalmanHit::prepareForInput ( )
private

Definition at line 243 of file Track3DKalmanHit_module.cc.

References trkf::SpacePointAlg::clearHitMap(), and fSpacePointAlg.

Referenced by produce().

244 {
246 }
SpacePointAlg fSpacePointAlg
Space point algorithm.
void clearHitMap() const
void trkf::Track3DKalmanHit::produce ( art::Event evt)
overrideprivatevirtual

Produce method.

Implements art::EDProducer.

Definition at line 189 of file Track3DKalmanHit_module.cc.

References trkf::SpacePointAlg::clearHitMap(), createOutputs(), fHist, fillHistograms(), fNumEvent, fSpacePointAlg, fTKHAlg, getInput(), trkf::Track3DKalmanHitAlg::makeTracks(), prepareForInput(), and art::Event::put().

190 {
191  ++fNumEvent;
192  auto tracks = std::make_unique<std::vector<recob::Track>>();
193  auto th_assn = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
194  auto thm_assn = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
195  auto tsp_assn = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
196  auto pfPartTrack_assns = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
197  auto spts = std::make_unique<std::vector<recob::SpacePoint>>();
198  auto sph_assn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
199 
200  prepareForInput();
201  auto inputs = getInput(evt);
202 
203  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
204  auto const detProp =
206  auto outputs = fTKHAlg.makeTracks(clockData, detProp, inputs);
207 
208  if (fHist) { fillHistograms(outputs); }
209 
210  createOutputs(evt,
211  detProp,
212  outputs,
213  inputs,
214  *tracks,
215  *spts,
216  *th_assn,
217  *thm_assn,
218  *tsp_assn,
219  *sph_assn,
220  *pfPartTrack_assns);
221 
223 
224  evt.put(std::move(tracks));
225  evt.put(std::move(spts));
226  evt.put(std::move(th_assn));
227  evt.put(std::move(thm_assn));
228  evt.put(std::move(tsp_assn));
229  evt.put(std::move(sph_assn));
230  evt.put(std::move(pfPartTrack_assns));
231 }
Track3DKalmanHitAlg fTKHAlg
Track3DKalmanHit algorithm.
KalmanInputs getInput(const art::Event &evt) const
std::vector< trkf::KalmanOutput > makeTracks(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, KalmanInputs &kalman_inputs)
SpacePointAlg fSpacePointAlg
Space point algorithm.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
void fillHistograms(std::vector< KalmanOutput > &outputs)
Fill Histograms method.
int fNumEvent
Number of events seen.
void clearHitMap() const
void createOutputs(const art::Event &evt, detinfo::DetectorPropertiesData const &detProp, const std::vector< KalmanOutput > &outputs, const KalmanInputs &inputs, std::vector< recob::Track > &tracks, std::vector< recob::SpacePoint > &spts, art::Assns< recob::Track, recob::Hit > &th_assn, art::Assns< recob::Track, recob::Hit, recob::TrackHitMeta > &thm_assn, art::Assns< recob::Track, recob::SpacePoint > &tsp_assn, art::Assns< recob::SpacePoint, recob::Hit > &sph_assn, art::Assns< recob::PFParticle, recob::Track > &pfPartTrack_assns)
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

std::string trkf::Track3DKalmanHit::fClusterModuleLabel
private

Clustered Hits.

Definition at line 109 of file Track3DKalmanHit_module.cc.

Referenced by getClusteredHits(), getPFParticleStuff(), and Track3DKalmanHit().

TH1F* trkf::Track3DKalmanHit::fHIncChisq
private

Incremental chisquare.

Definition at line 115 of file Track3DKalmanHit_module.cc.

Referenced by beginJob(), fillHistograms(), and Track3DKalmanHit().

bool trkf::Track3DKalmanHit::fHist
private

Make histograms.

Definition at line 104 of file Track3DKalmanHit_module.cc.

Referenced by beginJob(), produce(), and Track3DKalmanHit().

std::string trkf::Track3DKalmanHit::fHitModuleLabel
private

Unclustered Hits.

Definition at line 108 of file Track3DKalmanHit_module.cc.

Referenced by getAllHits(), and Track3DKalmanHit().

TH1F* trkf::Track3DKalmanHit::fHPull
private

Hit pull.

Definition at line 116 of file Track3DKalmanHit_module.cc.

Referenced by beginJob(), fillHistograms(), and Track3DKalmanHit().

int trkf::Track3DKalmanHit::fNumEvent
private

Number of events seen.

Definition at line 119 of file Track3DKalmanHit_module.cc.

Referenced by endJob(), produce(), and Track3DKalmanHit().

std::string trkf::Track3DKalmanHit::fPFParticleModuleLabel
private

PFParticle label.

Definition at line 110 of file Track3DKalmanHit_module.cc.

Referenced by getPFParticleStuff(), and Track3DKalmanHit().

SpacePointAlg trkf::Track3DKalmanHit::fSpacePointAlg
private

Space point algorithm.

Definition at line 112 of file Track3DKalmanHit_module.cc.

Referenced by createOutputs(), prepareForInput(), produce(), and Track3DKalmanHit().

Track3DKalmanHitAlg trkf::Track3DKalmanHit::fTKHAlg
private

Track3DKalmanHit algorithm.

Definition at line 111 of file Track3DKalmanHit_module.cc.

Referenced by produce(), and Track3DKalmanHit().

bool trkf::Track3DKalmanHit::fUseClusterHits
private

Use clustered hits as input.

Definition at line 105 of file Track3DKalmanHit_module.cc.

Referenced by getInput(), and Track3DKalmanHit().

bool trkf::Track3DKalmanHit::fUsePFParticleHits
private

Use PFParticle hits as input.

Definition at line 106 of file Track3DKalmanHit_module.cc.

Referenced by createOutputs(), getInput(), and Track3DKalmanHit().

bool trkf::Track3DKalmanHit::fUsePFParticleSeeds
private

Use PFParticle seeds.

Definition at line 107 of file Track3DKalmanHit_module.cc.

Referenced by getPFParticleStuff(), and Track3DKalmanHit().


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