Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrackProducerFromTrackTrajectory Class Reference

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

Inheritance diagram for TrackProducerFromTrackTrajectory:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 TrackProducerFromTrackTrajectory (fhicl::ParameterSet const &p)
 
 TrackProducerFromTrackTrajectory (TrackProducerFromTrackTrajectory const &)=delete
 
 TrackProducerFromTrackTrajectory (TrackProducerFromTrackTrajectory &&)=delete
 
TrackProducerFromTrackTrajectoryoperator= (TrackProducerFromTrackTrajectory const &)=delete
 
TrackProducerFromTrackTrajectoryoperator= (TrackProducerFromTrackTrajectory &&)=delete
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=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)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
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)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &e) override
 

Private Attributes

std::unique_ptr< trkmkr::TrackMakertrackMaker_
 
art::InputTag trajInputTag
 
bool doTrackFitHitInfo_
 
bool doSpacePoints_
 
bool spacePointsFromTrajP_
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
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 ()
 

Detailed Description

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

This producer takes an input an existing recob::TrackTrajectory collection (and the associated hits) and fits it. The mandatory output are: the resulting recob::Track collection, the associated hits, and the association between the input TrackTrajectory 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::TrackTrajectory collection), doTrackFitHitInfo (bool to decide whether to produce recob::TrackFitHitInfo's), doSpacePoints (bool to decide whether to produce recob::SpacePoint's), and spacePointsFromTrajP (bool to decide whether the produced recob::SpacePoint's are taken from the recob::tracking::TrajectoryPoint_t's of the fitted recob::Track).

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

Definition at line 40 of file TrackProducerFromTrackTrajectory_module.cc.

Constructor & Destructor Documentation

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

Definition at line 62 of file TrackProducerFromTrackTrajectory_module.cc.

63  : EDProducer{p}
64  , trackMaker_{art::make_tool<trkmkr::TrackMaker>(p.get<fhicl::ParameterSet>("trackMaker"))}
65  , trajInputTag{p.get<art::InputTag>("inputCollection")}
66  , doTrackFitHitInfo_{p.get<bool>("doTrackFitHitInfo")}
67  , doSpacePoints_{p.get<bool>("doSpacePoints")}
68  , spacePointsFromTrajP_{p.get<bool>("spacePointsFromTrajP")}
69 {
70  produces<std::vector<recob::Track>>();
71  produces<art::Assns<recob::Track, recob::Hit>>();
72  produces<art::Assns<recob::TrackTrajectory, recob::Track>>();
73  if (doTrackFitHitInfo_) produces<std::vector<std::vector<recob::TrackFitHitInfo>>>();
74  if (doSpacePoints_) {
75  produces<std::vector<recob::SpacePoint>>();
76  produces<art::Assns<recob::Hit, recob::SpacePoint>>();
77  }
78 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
p
Definition: test.py:223
TrackProducerFromTrackTrajectory::TrackProducerFromTrackTrajectory ( TrackProducerFromTrackTrajectory const &  )
delete
TrackProducerFromTrackTrajectory::TrackProducerFromTrackTrajectory ( TrackProducerFromTrackTrajectory &&  )
delete

Member Function Documentation

TrackProducerFromTrackTrajectory& TrackProducerFromTrackTrajectory::operator= ( TrackProducerFromTrackTrajectory const &  )
delete
TrackProducerFromTrackTrajectory& TrackProducerFromTrackTrajectory::operator= ( TrackProducerFromTrackTrajectory &&  )
delete
void TrackProducerFromTrackTrajectory::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 81 of file TrackProducerFromTrackTrajectory_module.cc.

82 {
83  // Output collections
84  auto outputTracks = std::make_unique<std::vector<recob::Track>>();
85  auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
86  auto outputTTjTAssn = std::make_unique<art::Assns<recob::TrackTrajectory, recob::Track>>();
87  auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
88  auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
89  auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint>>();
90 
91  // PtrMakers for Assns
92  art::PtrMaker<recob::Track> trackPtrMaker(e);
93  art::PtrMaker<recob::SpacePoint> spacePointPtrMaker(e);
94 
95  // Input from event
97  e.getValidHandle<std::vector<recob::TrackTrajectory>>(trajInputTag);
98  auto const& tjHitsAssn =
100  const auto& trajectoriesWithHits = util::associated_groups(tjHitsAssn);
101 
102  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
103 
104  // Initialize tool for this event
105  trackMaker_->initEvent(e);
106 
107  // Loop over trajectories to fit
108  unsigned int iTraj = 0;
109  for (auto hitsRange : trajectoriesWithHits) {
110 
111  // Get track and its hits
112  art::Ptr<recob::TrackTrajectory> traj(inputTrajs, iTraj++);
113  std::vector<art::Ptr<recob::Hit>> inHits;
114  for (art::Ptr<recob::Hit> const& hit : hitsRange)
115  inHits.push_back(hit);
116 
117  // Declare output objects
118  recob::Track outTrack;
119  std::vector<art::Ptr<recob::Hit>> outHits;
120  trkmkr::OptionalOutputs optionals;
121  if (doTrackFitHitInfo_) optionals.initTrackFitInfos();
123 
124  // Invoke tool to fit track and fill output objects
125  bool fitok = trackMaker_->makeTrack(detProp, traj, inHits, outTrack, outHits, optionals);
126  if (!fitok) continue;
127 
128  // Check that the requirement Nhits == Npoints is satisfied
129  // We also require the hits to the in the same order as the points (this cannot be enforced, can it?)
130  if (outTrack.NumberTrajectoryPoints() != outHits.size()) {
131  throw cet::exception("TrackProducerFromTrackTrajectory")
132  << "Produced recob::Track required to have 1-1 correspondance between hits and points.\n";
133  }
134 
135  // Fill output collections, including Assns
136  outputTracks->emplace_back(std::move(outTrack));
137  const art::Ptr<recob::Track> aptr = trackPtrMaker(outputTracks->size() - 1);
138  outputTTjTAssn->addSingle(traj, aptr);
139  unsigned int ip = 0;
140  for (auto const& trhit : outHits) {
141  outputHits->addSingle(aptr, trhit);
142 
143  if (doSpacePoints_ && spacePointsFromTrajP_ && outputTracks->back().HasValidPoint(ip)) {
144  auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
145  const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
146  const double fErrXYZ[6] = {0};
147  recob::SpacePoint sp(fXYZ, fErrXYZ, -1.);
148  outputSpacePoints->emplace_back(std::move(sp));
149  const art::Ptr<recob::SpacePoint> apsp = spacePointPtrMaker(outputSpacePoints->size() - 1);
150  outputHitSpacePointAssn->addSingle(trhit, apsp);
151  }
152  ip++;
153  }
155  auto osp = optionals.spacePointHitPairs();
156  for (auto it = osp.begin(); it != osp.end(); ++it) {
157  outputSpacePoints->emplace_back(std::move(it->first));
158  const art::Ptr<recob::SpacePoint> apsp = spacePointPtrMaker(outputSpacePoints->size() - 1);
159  outputHitSpacePointAssn->addSingle(it->second, apsp);
160  }
161  }
162  if (doTrackFitHitInfo_) { outputHitInfo->emplace_back(optionals.trackFitHitInfos()); }
163  }
164 
165  // Put collections in the event
166  e.put(std::move(outputTracks));
167  e.put(std::move(outputHits));
168  e.put(std::move(outputTTjTAssn));
169  if (doTrackFitHitInfo_) { e.put(std::move(outputHitInfo)); }
170  if (doSpacePoints_) {
171  e.put(std::move(outputSpacePoints));
172  e.put(std::move(outputHitSpacePointAssn));
173  }
174 }
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
Definition: TrackMaker.h:150
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:98
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:102
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
auto associated_groups(A const &assns)
Helper functions to access associations in order.
T LocationAtPoint(unsigned int p) const
Position at point p. Use e.g. as:
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
Detector simulation of raw signals on wires.
std::vector< SpHitPair > spacePointHitPairs()
get the output vector of SpHitPair by releasing and moving
Definition: TrackMaker.h:184
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
Definition: TrackMaker.h:174
Definition: fwd.h:31
void initSpacePoints()
initialize the output vector of SpHitPair
Definition: TrackMaker.h:156
Struct holding optional TrackMaker outputs.
Definition: TrackMaker.h:114
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

Member Data Documentation

bool TrackProducerFromTrackTrajectory::doSpacePoints_
private

Definition at line 58 of file TrackProducerFromTrackTrajectory_module.cc.

bool TrackProducerFromTrackTrajectory::doTrackFitHitInfo_
private

Definition at line 57 of file TrackProducerFromTrackTrajectory_module.cc.

bool TrackProducerFromTrackTrajectory::spacePointsFromTrajP_
private

Definition at line 59 of file TrackProducerFromTrackTrajectory_module.cc.

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

Definition at line 55 of file TrackProducerFromTrackTrajectory_module.cc.

art::InputTag TrackProducerFromTrackTrajectory::trajInputTag
private

Definition at line 56 of file TrackProducerFromTrackTrajectory_module.cc.


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