LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TrackProducerFromPFParticle Class Reference

Produce a reco::Track collection, as a result of the fit of an existing recob::PFParticle collection. More...

Inheritance diagram for TrackProducerFromPFParticle:
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

 TrackProducerFromPFParticle (fhicl::ParameterSet const &p)
 
 TrackProducerFromPFParticle (TrackProducerFromPFParticle const &)=delete
 
 TrackProducerFromPFParticle (TrackProducerFromPFParticle &&)=delete
 
TrackProducerFromPFParticleoperator= (TrackProducerFromPFParticle const &)=delete
 
TrackProducerFromPFParticleoperator= (TrackProducerFromPFParticle &&)=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

std::unique_ptr< trkmkr::TrackMakertrackMaker_
 
art::InputTag pfpInputTag
 
art::InputTag trkInputTag
 
art::InputTag shwInputTag
 
art::InputTag clsInputTag
 
bool doTrackFitHitInfo_
 
bool doSpacePoints_
 
bool spacePointsFromTrajP_
 
bool trackFromPF_
 
bool showerFromPF_
 
bool seedFromPF_
 

Detailed Description

Produce a reco::Track collection, as a result of the fit of an existing recob::PFParticle collection.

This producer takes an input an existing recob::PFParticle collection and refits the associated tracks; it can make track fits of the associated showers as well, but this is experimental - do it at your own risk. The mandatory outputs are: the resulting recob::Track collection, the associated hits, and the association between the input PFParticle and the output Track. Optional outputs are recob::TrackFitHitInfo and recob::SpacePoint collections, plus the Assns of SpacePoints to Hits. An option is provided to create SpacePoints from the TrajectoryPoints in the Track. The fit is performed by an user-defined tool, which must inherit from larreco/TrackFinder/TrackMaker.

Parameters: trackMaker (fhicl::ParameterSet for the trkmkr::TrackMaker tool used to do the fit), inputCollection (art::InputTag of the input recob::Track collection), doTrackFitHitInfo (bool to decide whether to produce recob::TrackFitHitInfo's), doSpacePoints (bool to decide whether to produce recob::SpacePoint's), spacePointsFromTrajP (bool to decide whether the produced recob::SpacePoint's are taken from the recob::tracking::TrajectoryPoint_t's of the fitted recob::Track), trackFromPF (bool to decide whether to fit the recob::Track associated to the recob::PFParticle), and showerFromPF (bool to decide whether to fit the recob::Shower associated to the recob::PFParticle - this option is intended to mitigate possible problems due to tracks being mis-identified as showers) seedFromPF (bool to decide whether to fit the recob::PFParticle using the associated seed)

Author
G. Cerati (FNAL, MicroBooNE)
Date
2017
Version
1.0

Definition at line 53 of file TrackProducerFromPFParticle_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

TrackProducerFromPFParticle::TrackProducerFromPFParticle ( fhicl::ParameterSet const &  p)
explicit

Definition at line 81 of file TrackProducerFromPFParticle_module.cc.

References clsInputTag, doSpacePoints_, doTrackFitHitInfo_, pfpInputTag, seedFromPF_, showerFromPF_, shwInputTag, spacePointsFromTrajP_, trackFromPF_, trackMaker_, and trkInputTag.

82  : EDProducer{p}
83  , trackMaker_{art::make_tool<trkmkr::TrackMaker>(p.get<fhicl::ParameterSet>("trackMaker"))}
84  , pfpInputTag{p.get<art::InputTag>("inputCollection")}
85  , doTrackFitHitInfo_{p.get<bool>("doTrackFitHitInfo")}
86  , doSpacePoints_{p.get<bool>("doSpacePoints")}
87  , spacePointsFromTrajP_{p.get<bool>("spacePointsFromTrajP")}
88  , trackFromPF_{p.get<bool>("trackFromPF")}
89  , showerFromPF_{p.get<bool>("showerFromPF")}
90  , seedFromPF_{p.get<bool>("seedFromPF")}
91 {
92  //
93  if (p.has_key("trackInputTag"))
94  trkInputTag = p.get<art::InputTag>("trackInputTag");
95  else
97  if (p.has_key("showerInputTag"))
98  shwInputTag = p.get<art::InputTag>("showerInputTag");
99  else
101  if (p.has_key("clusterInputTag"))
102  clsInputTag = p.get<art::InputTag>("clusterInputTag");
103  else
105  produces<std::vector<recob::Track>>();
106  produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
107  produces<art::Assns<recob::PFParticle, recob::Track>>();
108  if (doTrackFitHitInfo_) produces<std::vector<std::vector<recob::TrackFitHitInfo>>>();
109  if (doSpacePoints_) {
110  produces<std::vector<recob::SpacePoint>>();
111  produces<art::Assns<recob::Hit, recob::SpacePoint>>();
112  }
113 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
TrackProducerFromPFParticle::TrackProducerFromPFParticle ( TrackProducerFromPFParticle const &  )
delete
TrackProducerFromPFParticle::TrackProducerFromPFParticle ( TrackProducerFromPFParticle &&  )
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
TrackProducerFromPFParticle& TrackProducerFromPFParticle::operator= ( TrackProducerFromPFParticle const &  )
delete
TrackProducerFromPFParticle& TrackProducerFromPFParticle::operator= ( TrackProducerFromPFParticle &&  )
delete
void TrackProducerFromPFParticle::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 115 of file TrackProducerFromPFParticle_module.cc.

References util::associated_groups(), clsInputTag, d, DEFINE_ART_MODULE, dir, recob::Shower::Direction(), doSpacePoints_, doTrackFitHitInfo_, e, recob::Shower::Energy(), recob::Seed::GetDirection(), recob::Seed::GetPoint(), art::ProductRetriever::getValidHandle(), util::groupByIndex(), trkmkr::OptionalOutputs::initSpacePoints(), trkmkr::OptionalOutputs::initTrackFitInfos(), recob::Track::NumberTrajectoryPoints(), pfpInputTag, seed, seedFromPF_, tca::seeds, showerFromPF_, recob::Shower::ShowerStart(), shwInputTag, trkmkr::OptionalOutputs::spacePointHitPairs(), spacePointsFromTrajP_, track, trkmkr::OptionalOutputs::trackFitHitInfos(), trackFromPF_, trackMaker_, and trkInputTag.

116 {
117  // Output collections
118  auto outputTracks = std::make_unique<std::vector<recob::Track>>();
119  auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
120  auto outputPfpTAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
121  auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
122  auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
123  auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint>>();
124  //
125  // PtrMakers for Assns
126  art::PtrMaker<recob::Track> trackPtrMaker(e);
127  art::PtrMaker<recob::SpacePoint>* spacePointPtrMaker = nullptr;
128  if (doSpacePoints_) spacePointPtrMaker = new art::PtrMaker<recob::SpacePoint>(e);
129  //
130  // Input from event
132  e.getValidHandle<std::vector<recob::PFParticle>>(pfpInputTag);
133  std::unique_ptr<art::FindManyP<recob::Track>> assocTracks;
135  std::unique_ptr<art::FindManyP<recob::Shower>> assocShowers;
136  std::unique_ptr<art::FindManyP<recob::Seed>> assocSeeds;
137  if (trackFromPF_) {
138  assocTracks = std::unique_ptr<art::FindManyP<recob::Track>>(
139  new art::FindManyP<recob::Track>(inputPfps, e, trkInputTag));
141  }
142  if (showerFromPF_)
143  assocShowers = std::unique_ptr<art::FindManyP<recob::Shower>>(
144  new art::FindManyP<recob::Shower>(inputPfps, e, shwInputTag));
145  if (seedFromPF_)
146  assocSeeds = std::unique_ptr<art::FindManyP<recob::Seed>>(
147  new art::FindManyP<recob::Seed>(inputPfps, e, pfpInputTag));
148  const auto& trackHitsGroups = util::associated_groups(tkHitsAssn);
149 
150  std::unique_ptr<art::FindManyP<recob::Cluster>> assocClusters =
151  std::unique_ptr<art::FindManyP<recob::Cluster>>(
152  new art::FindManyP<recob::Cluster>(inputPfps, e, pfpInputTag));
154  const auto& clusterHitsGroups = util::associated_groups(clHitsAssn);
155 
156  // Initialize tool for this event
157  trackMaker_->initEvent(e);
158 
159  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
160 
161  // Loop over pfps to fit
162  for (unsigned int iPfp = 0; iPfp < inputPfps->size(); ++iPfp) {
163  const art::Ptr<recob::PFParticle> pfp(inputPfps, iPfp);
164  if (trackFromPF_) {
165  // Tracks associated to PFParticles
166  const std::vector<art::Ptr<recob::Track>>& tracks = assocTracks->at(iPfp);
167  // Loop over tracks to refit
168  for (art::Ptr<recob::Track> const& track : tracks) {
169 
170  // Get track and its hits
171  std::vector<art::Ptr<recob::Hit>> inHits;
172  decltype(auto) hitsRange = util::groupByIndex(trackHitsGroups, track.key());
173  for (art::Ptr<recob::Hit> const& hit : hitsRange)
174  inHits.push_back(hit);
175 
176  // Declare output objects
177  recob::Track outTrack;
178  std::vector<art::Ptr<recob::Hit>> outHits;
179  trkmkr::OptionalOutputs optionals;
180  if (doTrackFitHitInfo_) optionals.initTrackFitInfos();
181  if (doSpacePoints_ && !spacePointsFromTrajP_) optionals.initSpacePoints();
182 
183  // Invoke tool to fit track and fill output objects
184  bool fitok = trackMaker_->makeTrack(detProp, track, inHits, outTrack, outHits, optionals);
185  if (!fitok) continue;
186 
187  // Check that the requirement Nhits == Npoints is satisfied
188  // We also require the hits to the in the same order as the points (this cannot be enforced, can it?)
189  if (outTrack.NumberTrajectoryPoints() != outHits.size()) {
190  throw cet::exception("TrackProducerFromPFParticle")
191  << "Produced recob::Track required to have 1-1 correspondance between hits and "
192  "points.\n";
193  }
194 
195  // Fill output collections, including Assns
196  outputTracks->emplace_back(std::move(outTrack));
197  const art::Ptr<recob::Track> aptr = trackPtrMaker(outputTracks->size() - 1);
198  outputPfpTAssn->addSingle(pfp, aptr);
199  unsigned int ip = 0;
200  for (auto const& trhit : outHits) {
201  recob::TrackHitMeta metadata(
202  outputTracks->back().HasValidPoint(ip) ? ip : std::numeric_limits<int>::max(),
203  -std::numeric_limits<double>::max());
204  outputHits->addSingle(aptr, trhit, metadata);
205 
206  if (doSpacePoints_ && spacePointsFromTrajP_ && outputTracks->back().HasValidPoint(ip)) {
207  auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
208  const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
209  const double fErrXYZ[6] = {0};
210  recob::SpacePoint sp(fXYZ, fErrXYZ, -1.);
211  outputSpacePoints->emplace_back(std::move(sp));
212  const art::Ptr<recob::SpacePoint> apsp =
213  (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
214  outputHitSpacePointAssn->addSingle(trhit, apsp);
215  }
216  ip++;
217  }
219  auto osp = optionals.spacePointHitPairs();
220  for (auto it = osp.begin(); it != osp.end(); ++it) {
221  outputSpacePoints->emplace_back(std::move(it->first));
222  const art::Ptr<recob::SpacePoint> apsp =
223  (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
224  outputHitSpacePointAssn->addSingle(it->second, apsp);
225  }
226  }
227  if (doTrackFitHitInfo_) { outputHitInfo->emplace_back(optionals.trackFitHitInfos()); }
228  }
229  }
230  //
231  if (showerFromPF_) {
232  //
233  // Showers associated to PFParticles
234  const std::vector<art::Ptr<recob::Shower>>& showers = assocShowers->at(iPfp);
235  // if there is more than one shower the logic below to get the hits does not work! this works, at least for uboone
236  if (showers.size() != 1) continue;
237  //
238  // Get hits for shower (through the chain pfp->clusters->hits)
239  std::vector<art::Ptr<recob::Hit>> inHits;
240  const std::vector<art::Ptr<recob::Cluster>> clustersRange = assocClusters->at(iPfp);
241  for (art::Ptr<recob::Cluster> const& cluster : clustersRange) {
242  // for hits we use groupByIndex since it preserves the order (and we can use it since each cluster must have associated hits)
243  decltype(auto) hitsRange = util::groupByIndex(clusterHitsGroups, cluster.key());
244  for (art::Ptr<recob::Hit> const& hit : hitsRange)
245  inHits.push_back(hit);
246  }
247  // Loop over showers to refit (should be only one)
248  for (unsigned int iShower = 0; iShower < showers.size(); ++iShower) {
249  //
250  // Get the shower and convert/hack it into a trajectory so that the fit is initialized
251  art::Ptr<recob::Shower> shower = showers[iShower];
253  shower->ShowerStart().X(), shower->ShowerStart().Y(), shower->ShowerStart().Z());
255  shower->Direction().X(), shower->Direction().Y(), shower->Direction().Z());
256  float mom = 1.;
257  if (shower->Energy().size() == 3) mom = shower->Energy()[2] * 0.001;
258  std::vector<recob::tracking::Point_t> p;
259  std::vector<recob::tracking::Vector_t> d;
260  for (unsigned int i = 0; i < inHits.size(); ++i) {
261  p.push_back(pos);
262  d.push_back(mom * dir);
263  }
265  std::move(p), std::move(d), recob::TrackTrajectory::Flags_t(p.size()), false);
266  //
267  // Declare output objects
268  recob::Track outTrack;
269  std::vector<art::Ptr<recob::Hit>> outHits;
270  trkmkr::OptionalOutputs optionals;
271  if (doTrackFitHitInfo_) optionals.initTrackFitInfos();
273  //
274  // Invoke tool to fit track and fill output objects
275  bool fitok =
276  trackMaker_->makeTrack(detProp, traj, iPfp, inHits, outTrack, outHits, optionals);
277  if (!fitok) continue;
278  //
279  // Check that the requirement Nhits == Npoints is satisfied
280  // We also require the hits to the in the same order as the points (this cannot be enforced, can it?)
281  if (outTrack.NumberTrajectoryPoints() != outHits.size()) {
282  throw cet::exception("TrackProducerFromPFParticle")
283  << "Produced recob::Track required to have 1-1 correspondance between hits and "
284  "points.\n";
285  }
286  //
287  // Fill output collections, including Assns
288  outputTracks->emplace_back(std::move(outTrack));
289  const art::Ptr<recob::Track> aptr = trackPtrMaker(outputTracks->size() - 1);
290  outputPfpTAssn->addSingle(pfp, aptr);
291  unsigned int ip = 0;
292  for (auto const& trhit : outHits) {
293  recob::TrackHitMeta metadata(
294  outputTracks->back().HasValidPoint(ip) ? ip : std::numeric_limits<int>::max(),
295  -std::numeric_limits<double>::max());
296  outputHits->addSingle(aptr, trhit, metadata);
297  //
298  if (doSpacePoints_ && spacePointsFromTrajP_ && outputTracks->back().HasValidPoint(ip)) {
299  auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
300  const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
301  const double fErrXYZ[6] = {0};
302  recob::SpacePoint sp(fXYZ, fErrXYZ, -1.);
303  outputSpacePoints->emplace_back(std::move(sp));
304  const art::Ptr<recob::SpacePoint> apsp =
305  (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
306  outputHitSpacePointAssn->addSingle(trhit, apsp);
307  }
308  ip++;
309  }
311  auto osp = optionals.spacePointHitPairs();
312  for (auto it = osp.begin(); it != osp.end(); ++it) {
313  outputSpacePoints->emplace_back(std::move(it->first));
314  const art::Ptr<recob::SpacePoint> apsp =
315  (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
316  outputHitSpacePointAssn->addSingle(it->second, apsp);
317  }
318  }
319  if (doTrackFitHitInfo_) { outputHitInfo->emplace_back(optionals.trackFitHitInfos()); }
320  }
321  }
322  //
323  //
324  if (seedFromPF_) {
325  //
326  // Seeds associated to PFParticles
327  const std::vector<art::Ptr<recob::Seed>>& seeds = assocSeeds->at(iPfp);
328  // if there is more than one seed the logic below to get the hits does not work! this works, at least for uboone
329  if (seeds.size() != 1) continue;
330  //
331  // Get hits for pfp (through the chain pfp->clusters->hits)
332  std::vector<art::Ptr<recob::Hit>> inHits;
333  const std::vector<art::Ptr<recob::Cluster>> clustersRange = assocClusters->at(iPfp);
334  for (art::Ptr<recob::Cluster> const& cluster : clustersRange) {
335  // for hits we use groupByIndex since it preserves the order (and we can use it since each cluster must have associated hits)
336  decltype(auto) hitsRange = util::groupByIndex(clusterHitsGroups, cluster.key());
337  for (art::Ptr<recob::Hit> const& hit : hitsRange)
338  inHits.push_back(hit);
339  }
340  if (inHits.size() < 4) continue;
341  // Loop over seeds should be only one)
342  for (unsigned int iS = 0; iS < seeds.size(); ++iS) {
343  //
344  // Get the seed and convert/hack it into a trajectory so that the fit is initialized
345  art::Ptr<recob::Seed> seed = seeds[iS];
346  double p0[3], pe[3];
347  seed->GetPoint(p0, pe);
348  double d0[3], de[3];
349  seed->GetDirection(d0, de);
350  recob::tracking::Point_t pos(p0[0], p0[1], p0[2]);
351  recob::tracking::Vector_t dir(d0[0], d0[1], d0[2]);
352  std::vector<recob::tracking::Point_t> p;
353  std::vector<recob::tracking::Vector_t> d;
354  for (unsigned int i = 0; i < inHits.size(); ++i) {
355  p.push_back(pos);
356  d.push_back(dir);
357  }
359  std::move(p), std::move(d), recob::TrackTrajectory::Flags_t(p.size()), false);
360  //
361  // Declare output objects
362  recob::Track outTrack;
363  std::vector<art::Ptr<recob::Hit>> outHits;
364  trkmkr::OptionalOutputs optionals;
365  if (doTrackFitHitInfo_) optionals.initTrackFitInfos();
367  //
368  // Invoke tool to fit track and fill output objects
369  bool fitok =
370  trackMaker_->makeTrack(detProp, traj, iPfp, inHits, outTrack, outHits, optionals);
371  if (!fitok) continue;
372  //
373  // Check that the requirement Nhits == Npoints is satisfied
374  // We also require the hits to the in the same order as the points (this cannot be enforced, can it?)
375  if (outTrack.NumberTrajectoryPoints() != outHits.size()) {
376  throw cet::exception("TrackProducerFromPFParticle")
377  << "Produced recob::Track required to have 1-1 correspondance between hits and "
378  "points.\n";
379  }
380  //
381  // Fill output collections, including Assns
382  outputTracks->emplace_back(std::move(outTrack));
383  const art::Ptr<recob::Track> aptr = trackPtrMaker(outputTracks->size() - 1);
384  outputPfpTAssn->addSingle(pfp, aptr);
385  unsigned int ip = 0;
386  for (auto const& trhit : outHits) {
387  recob::TrackHitMeta metadata(
388  outputTracks->back().HasValidPoint(ip) ? ip : std::numeric_limits<int>::max(),
389  -std::numeric_limits<double>::max());
390  outputHits->addSingle(aptr, trhit, metadata);
391  //
392  if (doSpacePoints_ && spacePointsFromTrajP_ && outputTracks->back().HasValidPoint(ip)) {
393  auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
394  const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
395  const double fErrXYZ[6] = {0};
396  recob::SpacePoint sp(fXYZ, fErrXYZ, -1.);
397  outputSpacePoints->emplace_back(std::move(sp));
398  const art::Ptr<recob::SpacePoint> apsp =
399  (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
400  outputHitSpacePointAssn->addSingle(trhit, apsp);
401  }
402  ip++;
403  }
405  auto osp = optionals.spacePointHitPairs();
406  for (auto it = osp.begin(); it != osp.end(); ++it) {
407  outputSpacePoints->emplace_back(std::move(it->first));
408  const art::Ptr<recob::SpacePoint> apsp =
409  (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
410  outputHitSpacePointAssn->addSingle(it->second, apsp);
411  }
412  }
413  if (doTrackFitHitInfo_) { outputHitInfo->emplace_back(optionals.trackFitHitInfos()); }
414  }
415  }
416  //
417  }
418  //
419  // Put collections in the event
420  e.put(std::move(outputTracks));
421  e.put(std::move(outputHits));
422  e.put(std::move(outputPfpTAssn));
423  if (doTrackFitHitInfo_) { e.put(std::move(outputHitInfo)); }
424  if (doSpacePoints_) {
425  e.put(std::move(outputSpacePoints));
426  e.put(std::move(outputHitSpacePointAssn));
427  }
428  if (doSpacePoints_) delete spacePointPtrMaker;
429 }
const TVector3 & ShowerStart() const
Definition: Shower.h:197
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
Definition: TrackMaker.h:140
Reconstruction base classes.
void GetPoint(double *Pt, double *Err) const
Definition: Seed.cxx:89
const std::vector< double > & Energy() const
Definition: Shower.h:206
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:136
for(Int_t i=0;i< nentries;i++)
Definition: comparison.C:30
STL namespace.
Data related to recob::Hit associated with recob::Track.The purpose is to collect several variables t...
Definition: TrackHitMeta.h:43
Cluster finding and building.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
auto associated_groups(A const &assns)
Helper functions to access associations in order.
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
Ptr(H, T) -> Ptr< detail::not_map_vector_t< typename H::element_type >>
if(nlines<=0)
long seed
Definition: chem4.cc:67
A trajectory in space reconstructed from hits.
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 ...
Definition: TrackingTypes.h:31
Float_t d
Definition: plot.C:235
const TVector3 & Direction() const
Definition: Shower.h:188
std::vector< PointFlags_t > Flags_t
Type of point flag list.
Detector simulation of raw signals on wires.
std::vector< SpHitPair > spacePointHitPairs()
get the output vector of SpHitPair by releasing and moving
Definition: TrackMaker.h:160
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:14
auto groupByIndex(Groups &&groups, std::size_t index) -> decltype(auto)
Returns the group within groups with the specified index.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
Definition: TrackMaker.h:151
TDirectory * dir
Definition: macro.C:5
Definition: MVAAlg.h:12
Float_t e
Definition: plot.C:35
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...
Definition: TrackingTypes.h:27
Float_t track
Definition: plot.C:35
Definition: Track.hh:42
void GetDirection(double *Dir, double *Err) const
Definition: Seed.cxx:80
void initSpacePoints()
initialize the output vector of SpHitPair
Definition: TrackMaker.h:145
Struct holding optional TrackMaker outputs.
Definition: TrackMaker.h:108
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::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::InputTag TrackProducerFromPFParticle::clsInputTag
private

Definition at line 72 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

bool TrackProducerFromPFParticle::doSpacePoints_
private

Definition at line 74 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

bool TrackProducerFromPFParticle::doTrackFitHitInfo_
private

Definition at line 73 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

art::InputTag TrackProducerFromPFParticle::pfpInputTag
private

Definition at line 69 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

bool TrackProducerFromPFParticle::seedFromPF_
private

Definition at line 78 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

bool TrackProducerFromPFParticle::showerFromPF_
private

Definition at line 77 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

art::InputTag TrackProducerFromPFParticle::shwInputTag
private

Definition at line 71 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

bool TrackProducerFromPFParticle::spacePointsFromTrajP_
private

Definition at line 75 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

bool TrackProducerFromPFParticle::trackFromPF_
private

Definition at line 76 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

std::unique_ptr<trkmkr::TrackMaker> TrackProducerFromPFParticle::trackMaker_
private

Definition at line 68 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().

art::InputTag TrackProducerFromPFParticle::trkInputTag
private

Definition at line 70 of file TrackProducerFromPFParticle_module.cc.

Referenced by produce(), and TrackProducerFromPFParticle().


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