All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrackProducerFromTrack Class Reference

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

Inheritance diagram for TrackProducerFromTrack:

Public Member Functions

 TrackProducerFromTrack (fhicl::ParameterSet const &p)
 
 TrackProducerFromTrack (TrackProducerFromTrack const &)=delete
 
 TrackProducerFromTrack (TrackProducerFromTrack &&)=delete
 
TrackProducerFromTrackoperator= (TrackProducerFromTrack const &)=delete
 
TrackProducerFromTrackoperator= (TrackProducerFromTrack &&)=delete
 

Private Member Functions

void produce (art::Event &e) override
 

Private Attributes

std::unique_ptr
< trkmkr::TrackMaker
trackMaker_
 
art::InputTag trackInputTag
 
bool doTrackFitHitInfo_
 
bool doSpacePoints_
 
bool spacePointsFromTrajP_
 

Detailed Description

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

This producer takes an input an existing recob::Track collection (and the associated hits) and re-fits them. The mandatory output are: the resulting recob::Track collection and the associated hits. 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), 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 42 of file TrackProducerFromTrack_module.cc.

Constructor & Destructor Documentation

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

Definition at line 61 of file TrackProducerFromTrack_module.cc.

62  : EDProducer{p}
63  , trackMaker_{art::make_tool<trkmkr::TrackMaker>(p.get<fhicl::ParameterSet>("trackMaker"))}
64  , trackInputTag{p.get<art::InputTag>("inputCollection")}
65  , doTrackFitHitInfo_{p.get<bool>("doTrackFitHitInfo")}
66  , doSpacePoints_{p.get<bool>("doSpacePoints")}
67  , spacePointsFromTrajP_{p.get<bool>("spacePointsFromTrajP")}
68 {
69  produces<std::vector<recob::Track>>();
70  produces<art::Assns<recob::Track, recob::Hit>>();
71  if (doTrackFitHitInfo_) produces<std::vector<std::vector<recob::TrackFitHitInfo>>>();
72  if (doSpacePoints_) {
73  produces<std::vector<recob::SpacePoint>>();
74  produces<art::Assns<recob::Hit, recob::SpacePoint>>();
75  }
76 }
pdgs p
Definition: selectors.fcl:22
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
TrackProducerFromTrack::TrackProducerFromTrack ( TrackProducerFromTrack const &  )
delete
TrackProducerFromTrack::TrackProducerFromTrack ( TrackProducerFromTrack &&  )
delete

Member Function Documentation

TrackProducerFromTrack& TrackProducerFromTrack::operator= ( TrackProducerFromTrack const &  )
delete
TrackProducerFromTrack& TrackProducerFromTrack::operator= ( TrackProducerFromTrack &&  )
delete
void TrackProducerFromTrack::produce ( art::Event &  e)
overrideprivate

Definition at line 79 of file TrackProducerFromTrack_module.cc.

80 {
81  // Output collections
82  auto outputTracks = std::make_unique<std::vector<recob::Track>>();
83  auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
84  auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
85  auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
86  auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint>>();
87 
88  // PtrMakers for Assns
89  art::PtrMaker<recob::Track> trackPtrMaker(e);
90  art::PtrMaker<recob::SpacePoint> spacePointPtrMaker(e);
91 
92  // Input from event
93  auto const inputTracks = e.getValidHandle<std::vector<recob::Track>>(trackInputTag);
94  auto const& tkHitsAssn = *e.getValidHandle<art::Assns<recob::Track, recob::Hit>>(trackInputTag);
95  const auto& tracksWithHits = util::associated_groups(tkHitsAssn);
96 
97  // Initialize tool for this event
98  trackMaker_->initEvent(e);
99 
100  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
101 
102  // Loop over tracks to refit
103  unsigned int iTrack = 0;
104  for (auto hitsRange : tracksWithHits) {
105 
106  // Get track and its hits
107  art::Ptr<recob::Track> track(inputTracks, iTrack++);
108  std::vector<art::Ptr<recob::Hit>> inHits;
109  for (art::Ptr<recob::Hit> const& hit : hitsRange)
110  inHits.push_back(hit);
111 
112  // Declare output objects
113  recob::Track outTrack;
114  std::vector<art::Ptr<recob::Hit>> outHits;
115  trkmkr::OptionalOutputs optionals;
116  if (doTrackFitHitInfo_) optionals.initTrackFitInfos();
118 
119  // Invoke tool to fit track and fill output objects
120  bool fitok = trackMaker_->makeTrack(detProp, track, inHits, outTrack, outHits, optionals);
121  if (!fitok) continue;
122 
123  // Check that the requirement Nhits == Npoints is satisfied
124  // We also require the hits to the in the same order as the points (this cannot be enforced, can it?)
125  if (outTrack.NumberTrajectoryPoints() != outHits.size()) {
126  throw cet::exception("TrackProducerFromTrack")
127  << "Produced recob::Track required to have 1-1 correspondance between hits and "
128  "points.\noutTrack.NumberTrajectoryPoints()="
129  << outTrack.NumberTrajectoryPoints() << " outHits.size()=" << outHits.size() << "\n";
130  }
131 
132  // Fill output collections, including Assns
133  outputTracks->emplace_back(std::move(outTrack));
134  const art::Ptr<recob::Track> aptr = trackPtrMaker(outputTracks->size() - 1);
135  unsigned int ip = 0;
136  for (auto const& trhit : outHits) {
137  outputHits->addSingle(aptr, trhit);
138 
139  if (doSpacePoints_ && spacePointsFromTrajP_ && outputTracks->back().HasValidPoint(ip)) {
140  auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
141  const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
142  const double fErrXYZ[6] = {0};
143  recob::SpacePoint sp(fXYZ, fErrXYZ, -1.);
144  outputSpacePoints->emplace_back(std::move(sp));
145  const art::Ptr<recob::SpacePoint> apsp = spacePointPtrMaker(outputSpacePoints->size() - 1);
146  outputHitSpacePointAssn->addSingle(trhit, apsp);
147  }
148  ip++;
149  }
151  auto osp = optionals.spacePointHitPairs();
152  for (auto it = osp.begin(); it != osp.end(); ++it) {
153  outputSpacePoints->emplace_back(std::move(it->first));
154  const art::Ptr<recob::SpacePoint> apsp = spacePointPtrMaker(outputSpacePoints->size() - 1);
155  outputHitSpacePointAssn->addSingle(it->second, apsp);
156  }
157  }
158  if (doTrackFitHitInfo_) { outputHitInfo->emplace_back(optionals.trackFitHitInfos()); }
159  }
160 
161  // Put collections in the event
162  e.put(std::move(outputTracks));
163  e.put(std::move(outputHits));
164  if (doTrackFitHitInfo_) { e.put(std::move(outputHitInfo)); }
165  if (doSpacePoints_) {
166  e.put(std::move(outputSpacePoints));
167  e.put(std::move(outputHitSpacePointAssn));
168  }
169 }
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
Definition: TrackMaker.h:161
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
process_name use argoneut_mc_hitfinder track
process_name hit
Definition: cheaterreco.fcl:51
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
auto associated_groups(A const &assns)
Helper functions to access associations in order.
std::vector< SpHitPair > spacePointHitPairs()
get the output vector of SpHitPair by releasing and moving
Definition: TrackMaker.h:195
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
Definition: TrackMaker.h:185
do i e
void initSpacePoints()
initialize the output vector of SpHitPair
Definition: TrackMaker.h:167
Struct holding optional TrackMaker outputs.
Definition: TrackMaker.h:125
auto const detProp
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:

Member Data Documentation

bool TrackProducerFromTrack::doSpacePoints_
private

Definition at line 57 of file TrackProducerFromTrack_module.cc.

bool TrackProducerFromTrack::doTrackFitHitInfo_
private

Definition at line 56 of file TrackProducerFromTrack_module.cc.

bool TrackProducerFromTrack::spacePointsFromTrajP_
private

Definition at line 58 of file TrackProducerFromTrack_module.cc.

art::InputTag TrackProducerFromTrack::trackInputTag
private

Definition at line 55 of file TrackProducerFromTrack_module.cc.

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

Definition at line 54 of file TrackProducerFromTrack_module.cc.


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