Public Member Functions | Private Member Functions | Private Attributes | List of all members
trkf::FeatureTracker Class Reference
Inheritance diagram for trkf::FeatureTracker:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 FeatureTracker (fhicl::ParameterSet const &pset)
 
- 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 &evt) override
 
void GetProjectedEnds (detinfo::DetectorPropertiesData const &detProp, TVector3 xyz, std::vector< double > &uvw, std::vector< double > &t, int tpc=0, int cryo=0)
 
std::map< int, std::vector< double > > ExtractEndPointTimes (std::vector< recob::EndPoint2D > EndPoints)
 
std::vector< recob::SpacePointGet3DFeaturePoints (detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< recob::EndPoint2D > const &EndPoints, art::PtrVector< recob::Hit > const &Hits)
 
std::vector< recob::SeedGetValidLines (detinfo::DetectorPropertiesData const &detProp, std::vector< recob::SpacePoint > &sps, bool ApplyFilter=true)
 
void RemoveDuplicatePaths (std::vector< recob::Seed > &Seeds, std::vector< int > &ConnectionPoint1, std::vector< int > &ConnectionPoint2)
 

Private Attributes

trkf::SpacePointAlg fSP
 
corner::CornerFinderAlg fCorner
 
std::string fHitModuleLabel
 
std::string fCalDataModuleLabel
 
double fLineIntFraction
 
double fLineIntThreshold
 
std::map< int, std::vector< double > > fEndPointTimes
 
art::ServiceHandle< geo::Geometry const > fGeometryHandle
 

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

Definition at line 34 of file FeatureTracker_module.cc.

Constructor & Destructor Documentation

trkf::FeatureTracker::FeatureTracker ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 78 of file FeatureTracker_module.cc.

79  : EDProducer{pset}
80  , fSP(pset.get<fhicl::ParameterSet>("SpacepointPset"))
81  , fCorner(pset.get<fhicl::ParameterSet>("CornerPset"))
82  , fHitModuleLabel{pset.get<std::string>("HitModuleLabel")}
83  , fCalDataModuleLabel{pset.get<std::string>("CornerPset.CalDataModuleLabel")}
84  , fLineIntFraction{pset.get<double>("LineIntFraction")}
85  , fLineIntThreshold{pset.get<double>("LineIntThreshold")}
86  {
87  produces<std::vector<recob::Seed>>();
88  }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
trkf::SpacePointAlg fSP
corner::CornerFinderAlg fCorner

Member Function Documentation

std::map< int, std::vector< double > > trkf::FeatureTracker::ExtractEndPointTimes ( std::vector< recob::EndPoint2D EndPoints)
private

Definition at line 134 of file FeatureTracker_module.cc.

135  {
136  std::map<int, std::vector<double>> EndPointTimesInPlane;
137  for (size_t i = 0; i != EndPoints.size(); ++i) {
138  EndPointTimesInPlane[EndPoints.at(i).View()].push_back(EndPoints.at(i).DriftTime());
139  }
140 
141  for (std::map<int, std::vector<double>>::iterator itEpTime = EndPointTimesInPlane.begin();
142  itEpTime != EndPointTimesInPlane.end();
143  ++itEpTime) {
144  std::sort(itEpTime->second.begin(), itEpTime->second.end());
145  }
146  return EndPointTimesInPlane;
147  }
std::vector< recob::SpacePoint > trkf::FeatureTracker::Get3DFeaturePoints ( detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
std::vector< recob::EndPoint2D > const &  EndPoints,
art::PtrVector< recob::Hit > const &  Hits 
)
private

Definition at line 312 of file FeatureTracker_module.cc.

316  {
317 
318  art::PtrVector<recob::Hit> HitsForEndPoints;
319 
320  // Loop through the hits looking for the ones which match corners
321  for (std::vector<recob::EndPoint2D>::const_iterator itEP = EndPoints.begin();
322  itEP != EndPoints.end();
323  ++itEP) {
324  int EPMatchCount = 0;
325 
326  for (art::PtrVector<recob::Hit>::const_iterator itHit = Hits.begin(); itHit != Hits.end();
327  ++itHit) {
328 
329  if ((itEP->View() == (*itHit)->View()) &&
330  (itEP->WireID().Wire == (*itHit)->WireID().Wire)) {
331  HitsForEndPoints.push_back(*itHit);
332  EPMatchCount++;
333  }
334  }
335  }
336  std::vector<recob::SpacePoint> spts;
337  fSP.makeSpacePoints(clockData, detProp, HitsForEndPoints, spts);
338 
339  for (size_t i = 0; i != spts.size(); ++i) {
340  for (size_t p = 0; p != 3; ++p) {
341  double Closest = 100000;
342  double spt_t = detProp.ConvertXToTicks(spts.at(i).XYZ()[0], p, 0, 0);
343  for (size_t epTime = 0; epTime != fEndPointTimes[p].size(); ++epTime) {
344  if (fabs(fEndPointTimes[p].at(epTime) - spt_t) < Closest) {
345  Closest = fabs(fEndPointTimes[p].at(epTime) - spt_t);
346  }
347  }
348  }
349  }
350  return spts;
351  }
iterator begin()
Definition: PtrVector.h:217
trkf::SpacePointAlg fSP
intermediate_table::const_iterator const_iterator
typename data_t::const_iterator const_iterator
Definition: PtrVector.h:55
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
iterator end()
Definition: PtrVector.h:231
p
Definition: test.py:223
std::map< int, std::vector< double > > fEndPointTimes
void trkf::FeatureTracker::GetProjectedEnds ( detinfo::DetectorPropertiesData const &  detProp,
TVector3  xyz,
std::vector< double > &  uvw,
std::vector< double > &  t,
int  tpc = 0,
int  cryo = 0 
)
private

Definition at line 289 of file FeatureTracker_module.cc.

295  {
297 
298  int NPlanes = geo->Cryostat(cryo).TPC(tpc).Nplanes();
299 
300  uvw.resize(NPlanes);
301  t.resize(NPlanes);
302 
303  for (int plane = 0; plane != NPlanes; plane++) {
304  uvw[plane] = geo->NearestWire(xyz, plane, tpc, cryo);
305  t[plane] = detProp.ConvertXToTicks(xyz[0], plane, tpc, cryo);
306  }
307  }
unsigned int Nplanes() const
Number of planes in this tpc.
Definition: TPCGeo.h:165
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:93
LArSoft geometry interface.
Definition: ChannelGeo.h:16
std::vector< recob::Seed > trkf::FeatureTracker::GetValidLines ( detinfo::DetectorPropertiesData const &  detProp,
std::vector< recob::SpacePoint > &  sps,
bool  ApplyFilter = true 
)
private

Definition at line 152 of file FeatureTracker_module.cc.

155  {
156  std::vector<recob::Seed> SeedsToReturn;
157 
158  std::vector<int> ConnectionPoint1;
159  std::vector<int> ConnectionPoint2;
160  std::map<int, std::vector<int>> SeedConnections;
161 
162  for (size_t i = 0; i != spts.size(); ++i) {
163  for (size_t j = 0; j != i; ++j) {
164 
165  TVector3 xyz_i;
166  TVector3 xyz_j;
167 
168  std::vector<double> t_i, t_j;
169 
170  std::vector<double> uvw_i;
171  std::vector<double> uvw_j;
172 
173  for (size_t d = 0; d != 3; ++d) {
174  xyz_i[d] = spts.at(i).XYZ()[d];
175  xyz_j[d] = spts.at(j).XYZ()[d];
176  }
177 
178  GetProjectedEnds(detProp, xyz_i, uvw_i, t_i, 0, 0);
179  GetProjectedEnds(detProp, xyz_j, uvw_j, t_j, 0, 0);
180 
181  bool ThisLineGood = true;
182 
183  for (size_t p = 0; p != uvw_i.size(); ++p) {
184  TH2F const& RawHist = fCorner.GetWireDataHist(p);
185 
186  double lineint = fCorner.line_integral(
187  RawHist, uvw_i.at(p), t_i.at(p), uvw_j.at(p), t_j.at(p), fLineIntThreshold);
188 
189  if (lineint < fLineIntFraction) { ThisLineGood = false; }
190  }
191  if (ThisLineGood) {
192  double Err[3];
193  double Pos[3];
194  double Dir[3];
195 
196  for (size_t d = 0; d != 3; ++d) {
197  Pos[d] = 0.5 * (xyz_i[d] + xyz_j[d]);
198  Dir[d] = 0.5 * (xyz_i[d] - xyz_j[d]);
199  Err[d] = 0;
200  }
201 
202  ConnectionPoint1.push_back(i);
203  ConnectionPoint2.push_back(j);
204 
205  SeedsToReturn.push_back(recob::Seed(Pos, Dir, Err, Err));
206  }
207  }
208  }
209 
210  if (ApplyFilter) {
211  RemoveDuplicatePaths(SeedsToReturn, ConnectionPoint1, ConnectionPoint2);
212  mf::LogInfo("FeatureTracker")
213  << "Seeds after filter " << SeedsToReturn.size() << " seeds" << std::endl;
214  }
215 
216  return SeedsToReturn;
217  }
void RemoveDuplicatePaths(std::vector< recob::Seed > &Seeds, std::vector< int > &ConnectionPoint1, std::vector< int > &ConnectionPoint2)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void GetProjectedEnds(detinfo::DetectorPropertiesData const &detProp, TVector3 xyz, std::vector< double > &uvw, std::vector< double > &t, int tpc=0, int cryo=0)
TH2F const & GetWireDataHist(unsigned int) const
float line_integral(TH2F const &hist, int x1, float y1, int x2, float y2, float threshold) const
p
Definition: test.py:223
QTextStream & endl(QTextStream &s)
corner::CornerFinderAlg fCorner
void trkf::FeatureTracker::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 91 of file FeatureTracker_module.cc.

92  {
93 
94  // Extract hits PtrVector from event
96  evt.getByLabel(fHitModuleLabel, hith);
97 
99  for (unsigned int i = 0; i < hith->size(); ++i) {
100  art::Ptr<recob::Hit> prod(hith, i);
101  hitvec.push_back(prod);
102  }
103 
104  //We need to grab out the wires.
106  evt.getByLabel(fCalDataModuleLabel, wireHandle);
107  std::vector<recob::Wire> const& wireVec(*wireHandle);
108 
109  //First, have it process the wires.
110  fCorner.GrabWires(wireVec, *fGeometryHandle);
111 
112  std::vector<recob::EndPoint2D> EndPoints;
114 
116 
117  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
118  auto const detProp =
120  std::vector<recob::SpacePoint> sps = Get3DFeaturePoints(clockData, detProp, EndPoints, hitvec);
121  std::vector<recob::Seed> SeedsToStore = GetValidLines(detProp, sps, true);
122 
123  std::unique_ptr<std::vector<recob::Seed>> seeds(new std::vector<recob::Seed>);
124 
125  for (size_t i = 0; i != SeedsToStore.size(); ++i)
126  seeds->push_back(SeedsToStore.at(i));
127 
128  evt.put(std::move(seeds));
129  }
std::vector< recob::SpacePoint > Get3DFeaturePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< recob::EndPoint2D > const &EndPoints, art::PtrVector< recob::Hit > const &Hits)
void get_feature_points(std::vector< recob::EndPoint2D > &, geo::Geometry const &)
std::map< int, std::vector< double > > ExtractEndPointTimes(std::vector< recob::EndPoint2D > EndPoints)
art::ServiceHandle< geo::Geometry const > fGeometryHandle
void GrabWires(std::vector< recob::Wire > const &wireVec, geo::Geometry const &)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
std::map< int, std::vector< double > > fEndPointTimes
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:13
std::vector< recob::Seed > GetValidLines(detinfo::DetectorPropertiesData const &detProp, std::vector< recob::SpacePoint > &sps, bool ApplyFilter=true)
corner::CornerFinderAlg fCorner
void trkf::FeatureTracker::RemoveDuplicatePaths ( std::vector< recob::Seed > &  Seeds,
std::vector< int > &  ConnectionPoint1,
std::vector< int > &  ConnectionPoint2 
)
private

Definition at line 222 of file FeatureTracker_module.cc.

225  {
226 
227  std::map<int, bool> MarkedForRemoval;
228 
229  std::map<int, std::vector<int>> SeedsSharingPoint;
230  for (size_t i = 0; i != Seeds.size(); ++i) {
231  SeedsSharingPoint[ConnectionPoint1[i]].push_back(i);
232  SeedsSharingPoint[ConnectionPoint2[i]].push_back(i);
233  }
234 
235  for (size_t s = 0; s != Seeds.size(); ++s) {
236 
237  int StartPt = ConnectionPoint1.at(s);
238  int EndPt = ConnectionPoint2.at(s);
239  int MidPt = -1;
240 
241  for (size_t SeedsWithThisStart = 0; SeedsWithThisStart != SeedsSharingPoint[StartPt].size();
242  SeedsWithThisStart++) {
243  int i = SeedsSharingPoint[StartPt].at(SeedsWithThisStart);
244  if (ConnectionPoint1.at(i) == StartPt)
245  MidPt = ConnectionPoint2.at(i);
246  else if (ConnectionPoint2.at(i) == StartPt)
247  MidPt = ConnectionPoint1.at(i);
248 
249  for (size_t SeedsWithThisMid = 0; SeedsWithThisMid != SeedsSharingPoint[MidPt].size();
250  SeedsWithThisMid++) {
251  int j = SeedsSharingPoint[MidPt].at(SeedsWithThisMid);
252  if ((ConnectionPoint1.at(j) == EndPt) || (ConnectionPoint2.at(j) == EndPt)) {
253 
254  double Lengthi = Seeds.at(i).GetLength();
255  double Lengthj = Seeds.at(j).GetLength();
256  double Lengths = Seeds.at(s).GetLength();
257 
258  if ((Lengths > Lengthi) && (Lengths > Lengthj)) {
259  MarkedForRemoval[i] = true;
260  MarkedForRemoval[j] = true;
261  }
262 
263  if ((Lengthi > Lengths) && (Lengthi > Lengthj)) {
264  MarkedForRemoval[s] = true;
265  MarkedForRemoval[j] = true;
266  }
267  if ((Lengthj > Lengthi) && (Lengthj > Lengths)) {
268  MarkedForRemoval[s] = true;
269  MarkedForRemoval[i] = true;
270  }
271  }
272  }
273  }
274  }
275  for (std::map<int, bool>::reverse_iterator itrem = MarkedForRemoval.rbegin();
276  itrem != MarkedForRemoval.rend();
277  ++itrem) {
278  if (itrem->second == true) {
279  Seeds.erase(Seeds.begin() + itrem->first);
280  ConnectionPoint1.erase(ConnectionPoint1.begin() + itrem->first);
281  ConnectionPoint2.erase(ConnectionPoint2.begin() + itrem->first);
282  }
283  }
284  }
static QCString * s
Definition: config.cpp:1042

Member Data Documentation

std::string trkf::FeatureTracker::fCalDataModuleLabel
private

Definition at line 69 of file FeatureTracker_module.cc.

corner::CornerFinderAlg trkf::FeatureTracker::fCorner
private

Definition at line 66 of file FeatureTracker_module.cc.

std::map<int, std::vector<double> > trkf::FeatureTracker::fEndPointTimes
private

Definition at line 74 of file FeatureTracker_module.cc.

art::ServiceHandle<geo::Geometry const> trkf::FeatureTracker::fGeometryHandle
private

Definition at line 75 of file FeatureTracker_module.cc.

std::string trkf::FeatureTracker::fHitModuleLabel
private

Definition at line 68 of file FeatureTracker_module.cc.

double trkf::FeatureTracker::fLineIntFraction
private

Definition at line 71 of file FeatureTracker_module.cc.

double trkf::FeatureTracker::fLineIntThreshold
private

Definition at line 72 of file FeatureTracker_module.cc.

trkf::SpacePointAlg trkf::FeatureTracker::fSP
private

Definition at line 65 of file FeatureTracker_module.cc.


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