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

#include "TripletFinder.h"

Public Member Functions

 TripletFinder (const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &xhits, const std::vector< art::Ptr< recob::Hit >> &uhits, const std::vector< art::Ptr< recob::Hit >> &vhits, const std::vector< raw::ChannelID_t > &xbad, const std::vector< raw::ChannelID_t > &ubad, const std::vector< raw::ChannelID_t > &vbad, double distThresh, double distThreshDrift, double xhitOffset)
 
std::vector< HitTripletTriplets ()
 
std::vector< HitTripletTripletsTwoView ()
 Only search for XU intersections. More...
 

Protected Member Functions

void FillHitMap (const detinfo::DetectorPropertiesData &clockData, const std::vector< art::Ptr< recob::Hit >> &hits, std::map< geo::TPCID, std::vector< HitOrChan >> &out)
 Helper for constructor. More...
 
void FillBadMap (const std::vector< raw::ChannelID_t > &bads, std::map< geo::TPCID, std::vector< raw::ChannelID_t >> &out)
 Helper for constructor. More...
 
bool CloseDrift (double xa, double xb) const
 
bool CloseSpace (geo::WireIDIntersection ra, geo::WireIDIntersection rb) const
 
std::vector< ChannelDoubletDoubletsXU (geo::TPCID tpc)
 
std::vector< ChannelDoubletDoubletsXV (geo::TPCID tpc)
 
std::vector< ChannelDoubletDoubletHelper (geo::TPCID tpc, const std::vector< HitOrChan > &ahits, const std::vector< HitOrChan > &bhits, const std::vector< raw::ChannelID_t > &bbads) const
 

Protected Attributes

const geo::GeometryCoregeom
 
double fDistThresh
 
double fDistThreshDrift
 
double fXHitOffset
 
std::map< geo::TPCID, std::vector< HitOrChan > > fX_by_tpc
 
std::map< geo::TPCID, std::vector< HitOrChan > > fU_by_tpc
 
std::map< geo::TPCID, std::vector< HitOrChan > > fV_by_tpc
 
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fXbad_by_tpc
 
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fUbad_by_tpc
 
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fVbad_by_tpc
 

Detailed Description

Definition at line 51 of file TripletFinder.h.

Constructor & Destructor Documentation

reco3d::TripletFinder::TripletFinder ( const detinfo::DetectorPropertiesData detProp,
const std::vector< art::Ptr< recob::Hit >> &  xhits,
const std::vector< art::Ptr< recob::Hit >> &  uhits,
const std::vector< art::Ptr< recob::Hit >> &  vhits,
const std::vector< raw::ChannelID_t > &  xbad,
const std::vector< raw::ChannelID_t > &  ubad,
const std::vector< raw::ChannelID_t > &  vbad,
double  distThresh,
double  distThreshDrift,
double  xhitOffset 
)

Definition at line 13 of file TripletFinder.cxx.

References FillBadMap(), FillHitMap(), fU_by_tpc, fUbad_by_tpc, fV_by_tpc, fVbad_by_tpc, fX_by_tpc, and fXbad_by_tpc.

24  , fDistThresh(distThresh)
25  , fDistThreshDrift(distThreshDrift)
26  , fXHitOffset(xhitOffset)
27  {
28  FillHitMap(detProp, xhits, fX_by_tpc);
29  FillHitMap(detProp, uhits, fU_by_tpc);
30  FillHitMap(detProp, vhits, fV_by_tpc);
31 
32  FillBadMap(xbad, fXbad_by_tpc);
33  FillBadMap(ubad, fUbad_by_tpc);
34  FillBadMap(vbad, fVbad_by_tpc);
35  }
std::map< geo::TPCID, std::vector< HitOrChan > > fX_by_tpc
Definition: TripletFinder.h:94
std::map< geo::TPCID, std::vector< HitOrChan > > fV_by_tpc
Definition: TripletFinder.h:96
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fXbad_by_tpc
Definition: TripletFinder.h:99
std::map< geo::TPCID, std::vector< HitOrChan > > fU_by_tpc
Definition: TripletFinder.h:95
const geo::GeometryCore * geom
Definition: TripletFinder.h:69
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fUbad_by_tpc
void FillBadMap(const std::vector< raw::ChannelID_t > &bads, std::map< geo::TPCID, std::vector< raw::ChannelID_t >> &out)
Helper for constructor.
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fVbad_by_tpc
void FillHitMap(const detinfo::DetectorPropertiesData &clockData, const std::vector< art::Ptr< recob::Hit >> &hits, std::map< geo::TPCID, std::vector< HitOrChan >> &out)
Helper for constructor.

Member Function Documentation

bool reco3d::TripletFinder::CloseDrift ( double  xa,
double  xb 
) const
protected

Definition at line 117 of file TripletFinder.cxx.

References fDistThreshDrift.

Referenced by DoubletHelper(), and Triplets().

118  {
119  return fabs(xa - xb) < fDistThreshDrift;
120  }
bool reco3d::TripletFinder::CloseSpace ( geo::WireIDIntersection  ra,
geo::WireIDIntersection  rb 
) const
protected

Definition at line 123 of file TripletFinder.cxx.

References fDistThresh, geo::WireIDIntersection::y, and geo::WireIDIntersection::z.

Referenced by Triplets().

124  {
125  const TVector3 pa(ra.y, ra.z, 0);
126  const TVector3 pb(rb.y, rb.z, 0);
127 
128  return (pa - pb).Mag() < fDistThresh;
129  }
double z
z position of intersection
Definition: geo_types.h:792
double y
y position of intersection
Definition: geo_types.h:791
std::vector< ChannelDoublet > reco3d::TripletFinder::DoubletHelper ( geo::TPCID  tpc,
const std::vector< HitOrChan > &  ahits,
const std::vector< HitOrChan > &  bhits,
const std::vector< raw::ChannelID_t > &  bbads 
) const
protected

Definition at line 289 of file TripletFinder.cxx.

References reco3d::HitOrChan::chan, CloseDrift(), pt, and reco3d::HitOrChan::xpos.

Referenced by DoubletsXU(), and DoubletsXV().

294  {
295  std::vector<ChannelDoublet> ret;
296 
297  IntersectionCache isect(tpc);
298 
299  auto b_begin = bhits.begin();
300 
301  for (const HitOrChan& a : ahits) {
302  // Bad channels are easy because there's no timing constraint
303  for (raw::ChannelID_t b : bbads) {
305  if (isect(a.chan, b, pt)) { ret.emplace_back(a, b, pt); }
306  }
307 
308  while (b_begin != bhits.end() && b_begin->xpos < a.xpos && !CloseDrift(b_begin->xpos, a.xpos))
309  ++b_begin;
310 
311  for (auto bit = b_begin; bit != bhits.end(); ++bit) {
312  const HitOrChan& b = *bit;
313 
314  if (b.xpos > a.xpos && !CloseDrift(b.xpos, a.xpos)) break;
315 
317  if (!isect(a.chan, b.chan, pt)) continue;
318 
319  ret.emplace_back(a, b, pt);
320  } // end for b
321  } // end for a
322 
323  return ret;
324  }
TMarker * pt
Definition: egs.C:25
bool CloseDrift(double xa, double xb) const
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
std::vector< ChannelDoublet > reco3d::TripletFinder::DoubletsXU ( geo::TPCID  tpc)
protected

Definition at line 261 of file TripletFinder.cxx.

References DoubletHelper(), fU_by_tpc, fUbad_by_tpc, fX_by_tpc, and fXbad_by_tpc.

Referenced by Triplets(), and TripletsTwoView().

262  {
263  std::vector<ChannelDoublet> ret =
264  DoubletHelper(tpc, fX_by_tpc[tpc], fU_by_tpc[tpc], fUbad_by_tpc[tpc]);
265 
266  // Find X(bad)+U(good) doublets, have to flip them for the final result
267  for (auto it : DoubletHelper(tpc, fU_by_tpc[tpc], {}, fXbad_by_tpc[tpc])) {
268  ret.push_back({it.b, it.a, it.pt});
269  }
270 
271  return ret;
272  }
std::vector< ChannelDoublet > DoubletHelper(geo::TPCID tpc, const std::vector< HitOrChan > &ahits, const std::vector< HitOrChan > &bhits, const std::vector< raw::ChannelID_t > &bbads) const
std::map< geo::TPCID, std::vector< HitOrChan > > fX_by_tpc
Definition: TripletFinder.h:94
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fXbad_by_tpc
Definition: TripletFinder.h:99
std::map< geo::TPCID, std::vector< HitOrChan > > fU_by_tpc
Definition: TripletFinder.h:95
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fUbad_by_tpc
std::vector< ChannelDoublet > reco3d::TripletFinder::DoubletsXV ( geo::TPCID  tpc)
protected

Definition at line 275 of file TripletFinder.cxx.

References DoubletHelper(), fV_by_tpc, fVbad_by_tpc, fX_by_tpc, and fXbad_by_tpc.

Referenced by Triplets().

276  {
277  std::vector<ChannelDoublet> ret =
278  DoubletHelper(tpc, fX_by_tpc[tpc], fV_by_tpc[tpc], fVbad_by_tpc[tpc]);
279 
280  // Find X(bad)+V(good) doublets, have to flip them for the final result
281  for (auto it : DoubletHelper(tpc, fV_by_tpc[tpc], {}, fXbad_by_tpc[tpc])) {
282  ret.push_back({it.b, it.a, it.pt});
283  }
284 
285  return ret;
286  }
std::vector< ChannelDoublet > DoubletHelper(geo::TPCID tpc, const std::vector< HitOrChan > &ahits, const std::vector< HitOrChan > &bhits, const std::vector< raw::ChannelID_t > &bbads) const
std::map< geo::TPCID, std::vector< HitOrChan > > fX_by_tpc
Definition: TripletFinder.h:94
std::map< geo::TPCID, std::vector< HitOrChan > > fV_by_tpc
Definition: TripletFinder.h:96
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fXbad_by_tpc
Definition: TripletFinder.h:99
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fVbad_by_tpc
void reco3d::TripletFinder::FillBadMap ( const std::vector< raw::ChannelID_t > &  bads,
std::map< geo::TPCID, std::vector< raw::ChannelID_t >> &  out 
)
protected

Helper for constructor.

Definition at line 60 of file TripletFinder.cxx.

References geo::GeometryCore::ChannelToROP(), geom, and geo::GeometryCore::ROPtoTPCs().

Referenced by TripletFinder().

62  {
63  for (raw::ChannelID_t chan : bads) {
64  for (geo::TPCID tpc : geom->ROPtoTPCs(geom->ChannelToROP(chan))) {
65  out[tpc].push_back(chan);
66  }
67  }
68  }
std::vector< TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
const geo::GeometryCore * geom
Definition: TripletFinder.h:69
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void reco3d::TripletFinder::FillHitMap ( const detinfo::DetectorPropertiesData clockData,
const std::vector< art::Ptr< recob::Hit >> &  hits,
std::map< geo::TPCID, std::vector< HitOrChan >> &  out 
)
protected

Helper for constructor.

Definition at line 38 of file TripletFinder.cxx.

References geo::GeometryCore::ChannelToROP(), geo::GeometryCore::ChannelToWire(), detinfo::DetectorPropertiesData::ConvertTicksToX(), fXHitOffset, geom, hits(), geo::kCollection, geo::GeometryCore::ROPtoTPCs(), and geo::GeometryCore::SignalType().

Referenced by TripletFinder().

41  {
42  for (const art::Ptr<recob::Hit>& hit : hits) {
43  for (geo::TPCID tpc : geom->ROPtoTPCs(geom->ChannelToROP(hit->Channel()))) {
44  double xpos = 0;
45  for (geo::WireID wire : geom->ChannelToWire(hit->Channel())) {
46  if (geo::TPCID(wire) == tpc) {
47  xpos = detProp.ConvertTicksToX(hit->PeakTime(), wire);
48  if (geom->SignalType(wire) == geo::kCollection) xpos += fXHitOffset;
49  }
50  }
51 
52  out[tpc].emplace_back(hit.get(), xpos);
53  }
54  }
55  for (auto& it : out)
56  std::sort(it.second.begin(), it.second.end(), [](auto a, auto b) { return a.xpos < b.xpos; });
57  }
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
std::vector< TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
const geo::GeometryCore * geom
Definition: TripletFinder.h:69
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
Detector simulation of raw signals on wires.
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
Signal from collection planes.
Definition: geo_types.h:152
std::vector< HitTriplet > reco3d::TripletFinder::Triplets ( )

Definition at line 146 of file TripletFinder.cxx.

References reco3d::HitOrChan::chan, CloseDrift(), CloseSpace(), DoubletsXU(), DoubletsXV(), fX_by_tpc, reco3d::HitOrChan::hit, reco3d::LessThanXHit(), pt, reco3d::SameXHit(), x, reco3d::HitOrChan::xpos, geo::WireIDIntersection::y, and geo::WireIDIntersection::z.

Referenced by reco3d::SpacePointSolver::produce().

147  {
148  std::vector<HitTriplet> ret;
149 
150  for (const auto& it : fX_by_tpc) {
151  const geo::TPCID& tpc = it.first;
152 
153  std::vector<ChannelDoublet> xus = DoubletsXU(tpc);
154  std::vector<ChannelDoublet> xvs = DoubletsXV(tpc);
155 
156  // Cache to prevent repeating the same questions
157  IntersectionCache isectUV(tpc);
158 
159  // For the efficient looping below to work we need to sort the doublet
160  // lists so the X hits occur in the same order.
161  std::sort(xus.begin(), xus.end(), LessThanXHit);
162  std::sort(xvs.begin(), xvs.end(), LessThanXHit);
163 
164  auto xvit_begin = xvs.begin();
165 
166  int nxuv = 0;
167  for (const ChannelDoublet& xu : xus) {
168  const HitOrChan& x = xu.a;
169  const HitOrChan& u = xu.b;
170 
171  // Catch up until we're looking at the same X hit in XV
172  while (xvit_begin != xvs.end() && LessThanXHit(*xvit_begin, xu))
173  ++xvit_begin;
174 
175  // Loop through all those matching hits
176  for (auto xvit = xvit_begin; xvit != xvs.end() && SameXHit(*xvit, xu); ++xvit) {
177  const HitOrChan& v = xvit->b;
178 
179  // Only allow one bad channel per triplet
180  if (!x.hit && !u.hit) continue;
181  if (!x.hit && !v.hit) continue;
182  if (!u.hit && !v.hit) continue;
183 
184  if (u.hit && v.hit && !CloseDrift(u.xpos, v.xpos)) continue;
185 
187  if (!isectUV(u.chan, v.chan, ptUV)) continue;
188 
189  if (!CloseSpace(xu.pt, xvit->pt) || !CloseSpace(xu.pt, ptUV) ||
190  !CloseSpace(xvit->pt, ptUV))
191  continue;
192 
193  double xavg = 0;
194  int nx = 0;
195  if (x.hit) {
196  xavg += x.xpos;
197  ++nx;
198  }
199  if (u.hit) {
200  xavg += u.xpos;
201  ++nx;
202  }
203  if (v.hit) {
204  xavg += v.xpos;
205  ++nx;
206  }
207  xavg /= nx;
208 
209  const XYZ pt{
210  xavg, (xu.pt.y + xvit->pt.y + ptUV.y) / 3, (xu.pt.z + xvit->pt.z + ptUV.z) / 3};
211 
212  ret.emplace_back(HitTriplet{x.hit, u.hit, v.hit, pt});
213  ++nxuv;
214  } // end for xv
215  } // end for xu
216 
217  std::cout << tpc << " " << xus.size() << " XUs and " << xvs.size() << " XVs -> " << nxuv
218  << " XUVs" << std::endl;
219 
220  } // end for tpc
221 
222  std::cout << ret.size() << " XUVs total" << std::endl;
223 
224  return ret;
225  }
Float_t x
Definition: compare.C:6
bool CloseSpace(geo::WireIDIntersection ra, geo::WireIDIntersection rb) const
double z
z position of intersection
Definition: geo_types.h:792
std::map< geo::TPCID, std::vector< HitOrChan > > fX_by_tpc
Definition: TripletFinder.h:94
TMarker * pt
Definition: egs.C:25
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
bool SameXHit(const ChannelDoublet &a, const ChannelDoublet &b)
std::vector< ChannelDoublet > DoubletsXV(geo::TPCID tpc)
std::vector< ChannelDoublet > DoubletsXU(geo::TPCID tpc)
double y
y position of intersection
Definition: geo_types.h:791
bool CloseDrift(double xa, double xb) const
bool LessThanXHit(const ChannelDoublet &a, const ChannelDoublet &b)
std::vector< HitTriplet > reco3d::TripletFinder::TripletsTwoView ( )

Only search for XU intersections.

Definition at line 228 of file TripletFinder.cxx.

References DoubletsXU(), fX_by_tpc, reco3d::HitOrChan::hit, pt, x, and reco3d::HitOrChan::xpos.

229  {
230  std::vector<HitTriplet> ret;
231 
232  for (const auto& it : fX_by_tpc) {
233  const geo::TPCID& tpc = it.first;
234 
235  std::vector<ChannelDoublet> xus = DoubletsXU(tpc);
236 
237  for (const ChannelDoublet& xu : xus) {
238  const HitOrChan& x = xu.a;
239  const HitOrChan& u = xu.b;
240 
241  double xavg = x.xpos;
242  int nx = 1;
243  if (u.hit) {
244  xavg += u.xpos;
245  ++nx;
246  }
247  xavg /= nx;
248 
249  const XYZ pt{xavg, xu.pt.y, xu.pt.z};
250 
251  ret.emplace_back(HitTriplet{x.hit, u.hit, 0, pt});
252  } // end for xu
253  } // end for tpc
254 
255  std::cout << ret.size() << " XUs total" << std::endl;
256 
257  return ret;
258  }
Float_t x
Definition: compare.C:6
std::map< geo::TPCID, std::vector< HitOrChan > > fX_by_tpc
Definition: TripletFinder.h:94
TMarker * pt
Definition: egs.C:25
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
std::vector< ChannelDoublet > DoubletsXU(geo::TPCID tpc)

Member Data Documentation

double reco3d::TripletFinder::fDistThresh
protected

Definition at line 90 of file TripletFinder.h.

Referenced by CloseSpace().

double reco3d::TripletFinder::fDistThreshDrift
protected

Definition at line 91 of file TripletFinder.h.

Referenced by CloseDrift().

std::map<geo::TPCID, std::vector<HitOrChan> > reco3d::TripletFinder::fU_by_tpc
protected

Definition at line 95 of file TripletFinder.h.

Referenced by DoubletsXU(), and TripletFinder().

std::map<geo::TPCID, std::vector<raw::ChannelID_t> > reco3d::TripletFinder::fUbad_by_tpc
protected

Definition at line 100 of file TripletFinder.h.

Referenced by DoubletsXU(), and TripletFinder().

std::map<geo::TPCID, std::vector<HitOrChan> > reco3d::TripletFinder::fV_by_tpc
protected

Definition at line 96 of file TripletFinder.h.

Referenced by DoubletsXV(), and TripletFinder().

std::map<geo::TPCID, std::vector<raw::ChannelID_t> > reco3d::TripletFinder::fVbad_by_tpc
protected

Definition at line 101 of file TripletFinder.h.

Referenced by DoubletsXV(), and TripletFinder().

std::map<geo::TPCID, std::vector<HitOrChan> > reco3d::TripletFinder::fX_by_tpc
protected

Definition at line 94 of file TripletFinder.h.

Referenced by DoubletsXU(), DoubletsXV(), TripletFinder(), Triplets(), and TripletsTwoView().

std::map<geo::TPCID, std::vector<raw::ChannelID_t> > reco3d::TripletFinder::fXbad_by_tpc
protected

Definition at line 99 of file TripletFinder.h.

Referenced by DoubletsXU(), DoubletsXV(), and TripletFinder().

double reco3d::TripletFinder::fXHitOffset
protected

Definition at line 92 of file TripletFinder.h.

Referenced by FillHitMap().

const geo::GeometryCore* reco3d::TripletFinder::geom
protected

Definition at line 69 of file TripletFinder.h.

Referenced by FillBadMap(), FillHitMap(), and reco3d::IntersectionCache::ISect().


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