16 const std::vector<raw::ChannelID_t>& xbad,
17 const std::vector<raw::ChannelID_t>& ubad,
18 const std::vector<raw::ChannelID_t>& vbad,
20 double distThreshDrift,
41 std::map<
geo::TPCID, std::vector<HitOrChan>>& out)
54 out[tpc].emplace_back(
hit.get(), xpos);
58 std::sort(it.second.begin(), it.second.end(), [](
auto a,
auto b) {
return a.xpos < b.xpos; });
63 std::map<
geo::TPCID, std::vector<raw::ChannelID_t>>& out)
67 out[tpc].push_back(chan);
81 auto const key = std::make_pair(a, b);
83 auto it = fPtMap.find(key);
84 if (it != fPtMap.end()) {
return it->second; }
86 return fPtMap.try_emplace(key, ISect(a, b)).first->second;
107 using key_t = std::pair<raw::ChannelID_t, raw::ChannelID_t>;
108 std::map<key_t, std::optional<geo::WireIDIntersection>>
fPtMap;
122 const TVector3 pa(ra.
y, ra.
z, 0);
123 const TVector3 pb(rb.
y, rb.
z, 0);
145 std::vector<HitTriplet> ret;
150 std::vector<ChannelDoublet> xus =
DoubletsXU(tpc);
151 std::vector<ChannelDoublet> xvs =
DoubletsXV(tpc);
161 auto xvit_begin = xvs.begin();
169 while (xvit_begin != xvs.end() &&
LessThanXHit(*xvit_begin, xu))
173 for (
auto xvit = xvit_begin; xvit != xvs.end() &&
SameXHit(*xvit, xu); ++xvit) {
178 if (!x.
hit && !u.
hit)
continue;
179 if (!x.
hit && !v.
hit)
continue;
180 if (!u.
hit && !v.
hit)
continue;
184 auto maybe_ptUV = isectUV(u.
chan, v.
chan);
185 if (!maybe_ptUV)
continue;
187 auto const& ptUV = *maybe_ptUV;
209 xavg, (xu.pt.y + xvit->pt.y + ptUV.y) / 3, (xu.pt.z + xvit->pt.z + ptUV.z) / 3};
217 std::cout << tpc <<
" " << xus.size() <<
" XUs and " << xvs.size() <<
" XVs -> " << nxuv
218 <<
" XUVs" << std::endl;
222 std::cout << ret.size() <<
" XUVs total" << std::endl;
230 std::vector<HitTriplet> ret;
235 std::vector<ChannelDoublet> xus =
DoubletsXU(tpc);
241 double xavg = x.
xpos;
249 const XYZ pt{xavg, xu.pt.y, xu.pt.z};
255 std::cout << ret.size() <<
" XUs total" << std::endl;
263 std::vector<ChannelDoublet> ret =
268 ret.push_back({it.b, it.a, it.pt});
277 std::vector<ChannelDoublet> ret =
282 ret.push_back({it.b, it.a, it.pt});
291 const std::vector<HitOrChan>& ahits,
292 const std::vector<HitOrChan>& bhits,
293 const std::vector<raw::ChannelID_t>& bbads)
const 295 std::vector<ChannelDoublet> ret;
299 auto b_begin = bhits.begin();
304 if (
auto pt = isect(a.chan, b)) { ret.emplace_back(a, b, *
pt); }
307 while (b_begin != bhits.end() && b_begin->xpos < a.xpos && !
CloseDrift(b_begin->xpos, a.xpos))
310 for (
auto bit = b_begin; bit != bhits.end(); ++bit) {
315 auto pt = isect(a.chan, b.
chan);
318 ret.emplace_back(a, b, *
pt);
bool CloseSpace(geo::WireIDIntersection ra, geo::WireIDIntersection rb) const
virtual readout::ROPID ChannelToROP(raw::ChannelID_t channel) const =0
Returns the ID of the ROP the channel belongs to.
double z
z position of intersection
std::optional< geo::WireIDIntersection > const & operator()(raw::ChannelID_t a, raw::ChannelID_t b)
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
const geo::WireReadoutGeom * wireReadoutGeom
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
IntersectionCache(geo::WireReadoutGeom const *cmAlg, geo::TPCID tpc)
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
std::map< geo::TPCID, std::vector< HitOrChan > > fV_by_tpc
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fXbad_by_tpc
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::map< geo::TPCID, std::vector< HitOrChan > > fU_by_tpc
Interface for a class providing readout channel mapping to geometry.
const geo::WireReadoutGeom * wireReadoutGeom
static constexpr auto first()
std::optional< geo::WireIDIntersection > ISect(raw::ChannelID_t chanA, raw::ChannelID_t chanB) const
The data type to uniquely identify a TPC.
bool SameXHit(const ChannelDoublet &a, const ChannelDoublet &b)
Detector simulation of raw signals on wires.
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
double ConvertTicksToX(double ticks, int p, int t, int c) const
std::vector< HitTriplet > TripletsTwoView()
Only search for XU intersections.
virtual std::vector< WireID > ChannelToWire(raw::ChannelID_t channel) const =0
std::vector< ChannelDoublet > DoubletsXV(geo::TPCID tpc)
std::vector< ChannelDoublet > DoubletsXU(geo::TPCID tpc)
double y
y position of intersection
bool CloseDrift(double xa, double xb) const
std::vector< HitTriplet > Triplets()
bool LessThanXHit(const ChannelDoublet &a, const ChannelDoublet &b)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
std::map< geo::TPCID, std::vector< raw::ChannelID_t > > fUbad_by_tpc
virtual std::vector< TPCID > ROPtoTPCs(readout::ROPID const &ropid) const =0
Returns a list of ID of TPCs the specified ROP spans.
void FillBadMap(const std::vector< raw::ChannelID_t > &bads, std::map< geo::TPCID, std::vector< raw::ChannelID_t >> &out)
Helper for constructor.
std::map< key_t, std::optional< geo::WireIDIntersection > > fPtMap
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, int maxTriplets=0)
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.
Signal from collection planes.
std::pair< raw::ChannelID_t, raw::ChannelID_t > key_t