LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
reco3d::TripletFinder Class Reference

#include "TripletFinder.h"

Public Member Functions

 TripletFinder (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 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
 
const detinfo::DetectorPropertiesdetprop
 
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 53 of file TripletFinder.h.

Constructor & Destructor Documentation

reco3d::TripletFinder::TripletFinder ( 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 8 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.

16  : geom(art::ServiceHandle<geo::Geometry>()->provider()),
18  fDistThresh(distThresh),
19  fDistThreshDrift(distThreshDrift),
20  fXHitOffset(xhitOffset)
21  {
22  FillHitMap(xhits, fX_by_tpc);
23  FillHitMap(uhits, fU_by_tpc);
24  FillHitMap(vhits, fV_by_tpc);
25 
26  FillBadMap(xbad, fXbad_by_tpc);
27  FillBadMap(ubad, fUbad_by_tpc);
28  FillBadMap(vbad, fVbad_by_tpc);
29  }
std::map< geo::TPCID, std::vector< HitOrChan > > fX_by_tpc
Definition: TripletFinder.h:97
const detinfo::DetectorProperties * detprop
Definition: TripletFinder.h:71
std::map< geo::TPCID, std::vector< HitOrChan > > fV_by_tpc
Definition: TripletFinder.h:99
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fXbad_by_tpc
void FillHitMap(const std::vector< art::Ptr< recob::Hit >> &hits, std::map< geo::TPCID, std::vector< HitOrChan >> &out)
Helper for constructor.
std::map< geo::TPCID, std::vector< HitOrChan > > fU_by_tpc
Definition: TripletFinder.h:98
const geo::GeometryCore * geom
Definition: TripletFinder.h:70
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

Member Function Documentation

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

Definition at line 118 of file TripletFinder.cxx.

References fDistThreshDrift.

Referenced by DoubletHelper(), and Triplets().

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

Definition at line 124 of file TripletFinder.cxx.

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

Referenced by Triplets().

126  {
127  const TVector3 pa(ra.y, ra.z, 0);
128  const TVector3 pb(rb.y, rb.z, 0);
129 
130  return (pa-pb).Mag() < fDistThresh;
131  }
double z
z position of intersection
Definition: geo_types.h:494
double y
y position of intersection
Definition: geo_types.h:493
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 277 of file TripletFinder.cxx.

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

Referenced by DoubletsXU(), and DoubletsXV().

281  {
282  std::vector<ChannelDoublet> ret;
283 
284  IntersectionCache isect(tpc);
285 
286  auto b_begin = bhits.begin();
287 
288  for(const HitOrChan& a: ahits){
289  // Bad channels are easy because there's no timing constraint
290  for(raw::ChannelID_t b: bbads){
292  if(isect(a.chan, b, pt)){
293  ret.emplace_back(a, b, pt);
294  }
295  }
296 
297  while(b_begin != bhits.end() &&
298  b_begin->xpos < a.xpos &&
299  !CloseDrift(b_begin->xpos, a.xpos)) ++b_begin;
300 
301  for(auto bit = b_begin; bit != bhits.end(); ++bit){
302  const HitOrChan& b = *bit;
303 
304  if(b.xpos > a.xpos && !CloseDrift(b.xpos, a.xpos)) break;
305 
307  if(!isect(a.chan, b.chan, pt)) continue;
308 
309  ret.emplace_back(a, b, pt);
310  } // end for b
311  } // end for a
312 
313  return ret;
314  }
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:27
std::vector< ChannelDoublet > reco3d::TripletFinder::DoubletsXU ( geo::TPCID  tpc)
protected

Definition at line 250 of file TripletFinder.cxx.

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

Referenced by Triplets(), and TripletsTwoView().

251  {
252  std::vector<ChannelDoublet> ret = DoubletHelper(tpc, fX_by_tpc[tpc], fU_by_tpc[tpc], fUbad_by_tpc[tpc]);
253 
254  // Find X(bad)+U(good) doublets, have to flip them for the final result
255  for(auto it: DoubletHelper(tpc, fU_by_tpc[tpc], {}, fXbad_by_tpc[tpc])){
256  ret.push_back({it.b, it.a, it.pt});
257  }
258 
259  return ret;
260  }
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:97
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fXbad_by_tpc
std::map< geo::TPCID, std::vector< HitOrChan > > fU_by_tpc
Definition: TripletFinder.h:98
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 263 of file TripletFinder.cxx.

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

Referenced by Triplets().

264  {
265  std::vector<ChannelDoublet> ret = DoubletHelper(tpc, fX_by_tpc[tpc], fV_by_tpc[tpc], fVbad_by_tpc[tpc]);
266 
267  // Find X(bad)+V(good) doublets, have to flip them for the final result
268  for(auto it: DoubletHelper(tpc, fV_by_tpc[tpc], {}, fXbad_by_tpc[tpc])){
269  ret.push_back({it.b, it.a, it.pt});
270  }
271 
272  return ret;
273  }
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:97
std::map< geo::TPCID, std::vector< HitOrChan > > fV_by_tpc
Definition: TripletFinder.h:99
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fXbad_by_tpc
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 56 of file TripletFinder.cxx.

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

Referenced by FillHitMap(), and TripletFinder().

58  {
59  for(raw::ChannelID_t chan: bads){
60  for(geo::TPCID tpc: geom->ROPtoTPCs(geom->ChannelToROP(chan))){
61  out[tpc].push_back(chan);
62  }
63  }
64  }
std::vector< geo::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:70
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:27
void reco3d::TripletFinder::FillHitMap ( const std::vector< art::Ptr< recob::Hit >> &  hits,
std::map< geo::TPCID, std::vector< HitOrChan >> &  out 
)
protected

Helper for constructor.

Definition at line 33 of file TripletFinder.cxx.

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

Referenced by TripletFinder().

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

Definition at line 148 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().

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

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

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

Member Data Documentation

const detinfo::DetectorProperties* reco3d::TripletFinder::detprop
protected

Definition at line 71 of file TripletFinder.h.

Referenced by FillHitMap().

double reco3d::TripletFinder::fDistThresh
protected

Definition at line 93 of file TripletFinder.h.

Referenced by CloseSpace().

double reco3d::TripletFinder::fDistThreshDrift
protected

Definition at line 94 of file TripletFinder.h.

Referenced by CloseDrift().

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

Definition at line 98 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 103 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 99 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 104 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 97 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 102 of file TripletFinder.h.

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

double reco3d::TripletFinder::fXHitOffset
protected

Definition at line 95 of file TripletFinder.h.

Referenced by FillHitMap().

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

Definition at line 70 of file TripletFinder.h.

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


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