20 #include "range/v3/view.hpp" 26 constexpr
double step{0.3};
35 ,
fGeom{lar::providerFrom<geo::Geometry>()}
50 float const thr)
const 52 unsigned int nAll = 0, nPassed = 0;
53 unsigned int testPlane = adcImage.
Plane();
55 std::vector<unsigned int> trkTPCs = trk.
TPCs();
56 std::vector<unsigned int> trkCryos = trk.
Cryos();
62 for (
auto const* seg : trk.
Segments()) {
73 unsigned tpc = seg->
TPC();
74 unsigned cryo = seg->Cryo();
79 while ((f < 1.0) && node->
SameTPC(
p)) {
81 geo::WireID wireID(cryo, tpc, testPlane, (
int)p2d.X());
83 int widx = (
int)p2d.X();
88 if (channelStatus.
IsGood(ch)) {
89 float max_adc = adcImage.
poolMax(widx, didx, 2);
90 if (max_adc > thr) nPassed++;
105 double v = nPassed / (double)nAll;
114 struct hits_on_plane {
120 unsigned int const plane_;
133 TH1F* histoRejected)
const 136 double d2, max_d2 = max_d * max_d;
137 unsigned int nAll = 0, nPassed = 0;
138 unsigned int testPlane = adcImage.
Plane();
140 std::vector<unsigned int> trkTPCs = trk.
TPCs();
141 std::vector<unsigned int> trkCryos = trk.
Cryos();
142 std::map<std::pair<unsigned int, unsigned int>, std::pair<TVector2, TVector2>>
ranges;
143 std::map<std::pair<unsigned int, unsigned int>,
double> wirePitch;
144 for (
auto const& [
t,
c] : views::cartesian_product(trkTPCs, trkCryos)) {
149 unsigned int tpc, cryo;
150 std::map<std::pair<unsigned int, unsigned int>, std::vector<pma::Vector2D>> all_close_points;
154 tpc =
h.WireID().TPC;
155 cryo =
h.WireID().Cryostat;
156 std::pair<unsigned int, unsigned int> tpc_cryo(tpc, cryo);
157 std::pair<TVector2, TVector2> rect = ranges[tpc_cryo];
159 if ((
h.WireID().Wire > rect.first.X() - 10) &&
160 (
h.WireID().Wire < rect.second.X() + 10) &&
161 (
h.PeakTime() > rect.first.Y() - 100) &&
162 (
h.PeakTime() < rect.second.Y() + 100)) {
163 TVector2 p2d(wirePitch[tpc_cryo] *
h.WireID().Wire,
166 d2 = trk.
Dist2(p2d, testPlane, tpc, cryo);
168 if (d2 < max_d2) { all_close_points[tpc_cryo].emplace_back(p2d.X(), p2d.Y()); }
177 for (
auto const* seg : trk.
Segments()) {
193 auto const& points = all_close_points[{tpc, cryo}];
198 while ((f < 1.0) && node->
SameTPC(
p)) {
200 geo::WireID wireID(cryo, tpc, testPlane, (
int)p2d.X());
202 int widx = (
int)p2d.X();
207 if (channelStatus.
IsGood(ch)) {
208 bool is_close =
false;
209 float max_adc = adcImage.
poolMax(widx, didx, 2);
212 p2d.SetX(wirepitch * p2d.X());
213 for (
const auto&
h : points) {
226 if (histoPassing) histoPassing->Fill(max_adc);
229 if (histoRejected) histoRejected->Fill(max_adc);
243 double v = nPassed / (double)nAll;
259 if (hits.empty()) {
return 0; }
262 double d2, max_d2 = max_d * max_d;
263 unsigned int nAll = 0, nPassed = 0;
264 unsigned int testPlane = hits.front()->WireID().Plane;
266 std::vector<unsigned int> trkTPCs = trk.
TPCs();
267 std::vector<unsigned int> trkCryos = trk.
Cryos();
268 std::map<std::pair<unsigned int, unsigned int>, std::pair<TVector2, TVector2>>
ranges;
269 std::map<std::pair<unsigned int, unsigned int>,
double> wirePitch;
270 for (
auto const& [
t,
c] : views::cartesian_product(trkTPCs, trkCryos)) {
275 unsigned int tpc, cryo;
276 std::map<std::pair<unsigned int, unsigned int>, std::vector<pma::Vector2D>> all_close_points;
280 tpc =
h.WireID().TPC;
281 cryo =
h.WireID().Cryostat;
282 std::pair<unsigned int, unsigned int> tpc_cryo(tpc, cryo);
283 std::pair<TVector2, TVector2> rect = ranges[tpc_cryo];
285 if ((
h.WireID().Wire > rect.first.X() - 10) &&
286 (
h.WireID().Wire < rect.second.X() + 10) &&
287 (
h.PeakTime() > rect.first.Y() - 100) &&
288 (
h.PeakTime() < rect.second.Y() + 100)) {
289 TVector2 p2d(wirePitch[tpc_cryo] *
h.WireID().Wire,
292 d2 = trk.
Dist2(p2d, testPlane, tpc, cryo);
294 if (d2 < max_d2) all_close_points[tpc_cryo].emplace_back(p2d.X(), p2d.Y());
303 for (
auto const* seg : trk.
Segments()) {
319 auto const& points = all_close_points[{tpc, cryo}];
324 while ((f < 1.0) && node->
SameTPC(
p)) {
326 geo::WireID wireID(cryo, tpc, testPlane, (
int)p2d.X());
329 if (channelStatus.
IsGood(ch)) {
331 p2d.SetX(wirepitch * p2d.X());
332 for (
const auto&
h : points) {
353 double v = nPassed / (double)nAll;
368 unsigned int testPlane,
370 unsigned int cryo)
const 373 double d2, max_d2 = max_d * max_d;
374 unsigned int nAll = 0, nPassed = 0;
379 dc *=
step / dc.Mag();
385 geo::WireID wireID(cryo, tpc, testPlane, (
int)p2d.X());
388 if (channelStatus.
IsGood(ch)) {
389 p2d.Set(wirepitch * p2d.X(), p2d.Y());
390 for (
const auto&
h : hits)
391 if ((
h->WireID().Plane == testPlane) && (
h->WireID().TPC == tpc) &&
392 (
h->WireID().Cryostat == cryo)) {
411 double v = nPassed / (double)nAll;
412 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" segment fraction ok: " << v;
427 while ((idx < trk.
size() - 1) && !trk[idx]->IsEnabled())
429 double l0 = trk.
Length(0, idx + 1);
431 idx = trk.
size() - 1;
432 while ((idx > 1) && !trk[idx]->IsEnabled())
438 return 1.0 - (l0 +
l1) / trk.
Length();
445 int const nSegments = 0.8 * trk_size / sqrt(trk_size);
446 return std::max(
size_t{1},
static_cast<size_t>(nSegments));
460 std::vector<unsigned int> tpcs = trk->
TPCs();
461 for (
size_t t = 0;
t < tpcs.size(); ++
t) {
469 size_t nNodes = (size_t)(nSegments - 1);
473 mf::LogWarning(
"ProjectionMatchingAlg") <<
" initialization failed, delete trk";
481 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" optimize trk (" << nSegments <<
" seg)";
496 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" clusters do not match, f = " <<
f;
507 std::map<unsigned int, std::vector<art::Ptr<recob::Hit>>> hits_by_tpc;
508 for (
auto const&
h : hits) {
509 hits_by_tpc[
h->WireID().TPC].push_back(
h);
512 std::vector<pma::Track3D*>
tracks;
513 for (
auto const& hsel : hits_by_tpc) {
515 if (trk) tracks.push_back(trk);
518 bool need_reopt =
false;
519 while (tracks.size() > 1) {
524 double d, dmin = 1.0e12;
525 size_t t_best = 0, cfg = 0;
526 for (
size_t t = 1;
t < tracks.size(); ++
t) {
577 tracks.erase(tracks.begin() + t_best);
584 if (!tracks.empty()) {
585 trk = tracks.front();
589 <<
" reopt after merging initial tpc segments: done, g = " <<
g;
596 size_t nNodes = (size_t)(nSegments - 1);
598 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" optimize trk (add " << nSegments <<
" seg)";
620 double vtxarray[3]{vtx.X(), vtx.Y(), vtx.Z()};
624 TVector3 vtxv3(vtx.X(), vtx.Y(), vtx.Z());
631 std::vector<art::Ptr<recob::Hit>> hitstpc;
632 for (
size_t h = 0;
h < hits.size(); ++
h)
633 if (hits[
h]->
WireID().TPC == tpc) hitstpc.push_back(hits[
h]);
635 if (!hitstpc.size())
return 0;
637 std::vector<art::Ptr<recob::Hit>> hitstrk;
639 size_t countviews = 0;
641 mf::LogVerbatim(
"ProjectionMatchinAlg") <<
"collecting hits from view: " << view;
648 std::vector<art::Ptr<recob::Hit>> hitsview;
649 for (
size_t h = 0; h < hitstpc.size(); ++
h)
650 if (hitstpc[h]->
WireID().Plane == view) hitsview.push_back(hitstpc[h]);
651 if (!hitsview.size()) {
657 std::vector<art::Ptr<recob::Hit>> hitsfilter;
664 for (
size_t h = 0; h < hitsfilter.size(); ++
h)
665 hitstrk.push_back(hitsfilter[h]);
667 if (hitsfilter.size() >= 5) countviews++;
672 if (!hitstrk.size() || (countviews < 2)) {
673 mf::LogWarning(
"ProjectionMatchinAlg") <<
"too few hits, segment not built";
685 if (trk->
size() < 10) {
686 mf::LogWarning(
"ProjectionMatchingAlg") <<
"too short segment, delete segment";
701 const TVector2& vtx2d)
const 703 size_t min_size = hits_in.size() / 5;
704 if (min_size < 3) min_size = 3;
706 std::vector<size_t> used;
707 std::vector<std::vector<art::Ptr<recob::Hit>>> sub_groups;
708 std::vector<art::Ptr<recob::Hit>> close_hits;
710 float mindist2 = 99999.99;
711 size_t id_sub_groups_save = 0;
713 while (
GetCloseHits_(detProp, r2d, hits_in, used, close_hits)) {
715 sub_groups.emplace_back(close_hits);
717 for (
size_t h = 0;
h < close_hits.size(); ++
h) {
720 close_hits[
h]->PeakTime(),
723 close_hits[
h]->
WireID().Cryostat);
726 if (dist2 < mindist2) {
727 id_sub_groups_save = id;
735 for (
size_t i = 0; i < sub_groups.size(); ++i) {
736 if (i == id_sub_groups_save) {
737 for (
auto h : sub_groups[i])
738 hits_out.push_back(
h);
742 for (
size_t i = 0; i < sub_groups.size(); ++i) {
743 if ((i != id_sub_groups_save) && (hits_out.size() < 10) && (sub_groups[i].
size() > min_size))
744 for (
auto h : sub_groups[i])
745 hits_out.push_back(
h);
755 std::vector<size_t>& used,
760 const double gapMargin = 5.0;
763 while ((idx < hits_in.size()) &&
Has_(used, idx))
766 if (idx < hits_in.size()) {
767 hits_out.push_back(hits_in[idx]);
770 unsigned int tpc = hits_in[idx]->WireID().TPC;
771 unsigned int cryo = hits_in[idx]->WireID().Cryostat;
772 unsigned int view = hits_in[idx]->WireID().Plane;
776 double r2d2 = r2d * r2d;
777 double gapMargin2 = sqrt(2 * gapMargin * gapMargin);
778 gapMargin2 = (gapMargin2 + r2d) * (gapMargin2 + r2d);
783 for (
size_t i = 0; i < hits_in.size(); i++)
784 if (!
Has_(used, i)) {
790 for (
auto const& ho : hits_out) {
792 TVector2 ho_cm(wirePitch * ho->WireID().Wire, driftPitch * ho->PeakTime());
802 hits_out.push_back(hi);
820 double mse = trk.
GetMse();
821 mf::LogWarning(
"ProjectionMatchingAlg") <<
"initial value of mse: " << mse;
822 while ((mse > 0.5) &&
TestTrk_(trk, tpcgeom)) {
824 for (
size_t h = 0;
h < trk.
size(); ++
h)
826 trk[
h]->SetEnabled(
false);
831 trk.
Optimize(detProp, 0, 0.0001,
false);
835 if (mse == trk.
GetMse())
break;
861 for (
size_t h = 0;
h < trk.
size(); ++
h) {
862 if (!trk[
h]->IsEnabled())
break;
866 mf::LogWarning(
"ProjectionMatchingAlg") <<
"length of segment: " << length;
867 if (length < 3.0) test =
false;
878 if (
c == idx)
return true;
888 while (h < trk.
size()) {
889 if (trk[h]->IsEnabled())
911 mf::LogWarning(
"ProjectionMatchingAlg") <<
"initialization failed, delete segment";
921 mf::LogWarning(
"ProjectionMatchingAlg") <<
"need at least two views in single tpc";
932 const TVector3& point)
const 939 if (dfront > dback) trk->
Flip();
941 trk->
Nodes().front()->SetPoint3D(point);
942 trk->
Nodes().front()->SetFrozen(
true);
954 const TVector3& point)
const 961 if (dfront > dback) trk->
Flip();
963 trk->
Nodes().front()->SetPoint3D(point);
964 trk->
Nodes().front()->SetFrozen(
true);
977 bool add_nodes)
const 988 int nNodes = nSegments - copy->
Nodes().size() + 1;
989 if (nNodes < 0) nNodes = 0;
992 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" add " << nNodes <<
" nodes";
1014 size_t nCloseHits = 0;
1015 int forwWires = 3, backWires = -1;
1016 double xMargin = 0.4;
1018 if ((view == (
int)
h->WireID().Plane) && (tpc ==
h->WireID().TPC) &&
1019 (cryo ==
h->WireID().Cryostat)) {
1021 for (
size_t ht = 0; ht < trk.
size(); ht++)
1022 if (trk[ht]->Hit2DPtr().key() ==
h.key()) {
1026 if (found)
continue;
1028 int dw = wdir * (
h->WireID().Wire - wire);
1029 if ((dw <= forwWires) && (dw >= backWires)) {
1031 if (fabs(x - drift_x) < xMargin) nCloseHits++;
1045 std::pair<int, int>
const* wires,
1048 unsigned int cryo)
const 1050 double x = 0.0,
y = 0.0,
z = 0.0;
1051 std::vector<std::pair<int, unsigned int>> wire_view;
1052 for (
unsigned int i = 0; i < 3; i++)
1053 if (wires[i].first >= 0) {
1054 const auto hiter = hits.find(i);
1055 if (hiter != hits.end()) {
1066 wire_view.emplace_back(wires[i].first, i);
1070 if (wire_view.size() > 1) {
1071 x /= wire_view.size();
1075 wire_view[1].second,
1082 <<
"trk tpc:" << tpc <<
" size:" << trk.
size() <<
" add ref.point (" << x <<
"; " <<
y <<
"; " 1088 <<
"trk tpc:" << tpc <<
" size:" << trk.
size()
1089 <<
" wire-plane-parallel track, but need two clean views of endpoint";
1102 mf::LogWarning(
"ProjectionMatchingAlg") <<
"Please, apply before TPC stitching.";
1106 const double maxCosXZ = 0.992546;
1111 if ((segFront->
Length() < 0.8) && (segFront1->
Length() > 5.0)) segFront = segFront1;
1115 dirFrontXZ *= 1.0 / dirFrontXZ.R();
1120 if ((segBack->
Length() < 0.8) && (segBack1->
Length() > 5.0)) segBack = segBack1;
1124 dirBackXZ *= 1.0 / dirBackXZ.R();
1126 if ((fabs(dirFrontXZ.Z()) < maxCosXZ) && (fabs(dirBackXZ.Z()) < maxCosXZ)) {
1130 unsigned int nPlanesFront = 0, nPlanesBack = 0;
1131 std::pair<int, int> wiresFront[3], wiresBack[3];
1132 double xFront[3], xBack[3];
1134 for (
unsigned int i = 0; i < 3; i++) {
1135 bool frontPresent =
false, backPresent =
false;
1137 int idxFront0 = trk.
NextHit(-1, i);
1139 if ((idxFront0 >= 0) && (idxFront0 < (
int)trk.
size()) && (idxBack0 >= 0) &&
1140 (idxBack0 < (
int)trk.
size())) {
1141 int idxFront1 = trk.
NextHit(idxFront0, i);
1142 int idxBack1 = trk.
PrevHit(idxBack0, i);
1143 if ((idxFront1 >= 0) && (idxFront1 < (
int)trk.
size()) && (idxBack1 >= 0) &&
1144 (idxBack1 < (
int)trk.
size())) {
1145 int wFront0 = trk[idxFront0]->Wire();
1146 int wBack0 = trk[idxBack0]->Wire();
1148 int wFront1 = trk[idxFront1]->Wire();
1149 int wBack1 = trk[idxBack1]->Wire();
1151 wiresFront[i].first = wFront0;
1152 wiresFront[i].second = wFront0 - wFront1;
1153 xFront[i] = detProp.
ConvertTicksToX(trk[idxFront0]->PeakTime(), i, tpc, cryo);
1155 wiresBack[i].first = wBack0;
1156 wiresBack[i].second = wBack0 - wBack1;
1157 xBack[i] = detProp.
ConvertTicksToX(trk[idxBack0]->PeakTime(), i, tpc, cryo);
1159 if (wiresFront[i].
second) {
1160 if (wiresFront[i].second > 0)
1161 wiresFront[i].second = 1;
1163 wiresFront[i].second = -1;
1165 frontPresent =
true;
1169 if (wiresBack[i].second) {
1170 if (wiresBack[i].second > 0)
1171 wiresBack[i].second = 1;
1173 wiresBack[i].second = -1;
1181 if (!frontPresent) { wiresFront[i].first = -1; }
1182 if (!backPresent) { wiresBack[i].first = -1; }
1185 bool refAdded =
false;
1186 if ((nPlanesFront > 1) && (fabs(dirFrontXZ.Z()) >= maxCosXZ)) {
1187 refAdded |=
addEndpointRef_(detProp, trk, hits, wiresFront, xFront, tpc, cryo);
1190 if ((nPlanesBack > 1) && (fabs(dirBackXZ.Z()) >= maxCosXZ)) {
1191 refAdded |=
addEndpointRef_(detProp, trk, hits, wiresBack, xBack, tpc, cryo);
1194 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
"guide wire-plane-parallel track endpoints";
1208 const double maxCosXZ = 0.992546;
1210 unsigned int tpc, cryo;
1224 if (seg1 && (seg0->
Length() < 0.8) && (seg1->
Length() > 5.0)) { seg0 = seg1; }
1227 dir0XZ *= 1.0 / dir0XZ.R();
1229 if (fabs(dir0XZ.Z()) < maxCosXZ) {
return; }
1231 unsigned int nPlanes = 0;
1232 std::pair<int, int> wires[3];
1235 for (
unsigned int i = 0; i < 3; i++) {
1238 int idx0 = -1, idx1 = -1;
1244 if ((idx0 >= 0) && (idx0 < (
int)trk.
size()) && (trk[idx0]->
TPC() == tpc) &&
1245 (trk[idx0]->Cryo() == cryo)) {
1251 if ((idx1 >= 0) && (idx1 < (
int)trk.
size()) && (trk[idx1]->
TPC() == tpc) &&
1252 (trk[idx1]->Cryo() == cryo)) {
1253 int w0 = trk[idx0]->Wire();
1254 int w1 = trk[idx1]->Wire();
1256 wires[i].first = w0;
1257 wires[i].second = w0 - w1;
1261 if (wires[i].second > 0)
1262 wires[i].second = 1;
1264 wires[i].second = -1;
1272 if (!present) { wires[i].first = -1; }
1275 if ((nPlanes > 1) && (fabs(dir0XZ.Z()) >= maxCosXZ) &&
1277 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
"guide wire-plane-parallel track endpoint";
1284 std::vector<pma::Hit3D*>
1296 double dist = distFF;
1299 if (distFB < dist) {
1305 if (distBF < dist) {
1311 if (distBB < dist) {
1321 case 1:
mf::LogError(
"PMAlgTrackMaker") <<
"Tracks in reversed order.";
return false;
1328 <<
"alignTracks: should never happen." <<
std::endl;
1337 bool const reopt)
const 1343 double lmean = dst.
Length() / (dst.
Nodes().size() - 1);
1344 if ((
pma::Dist2(dst.
Nodes().back()->Point3D(), src.
Nodes().front()->Point3D()) > 0.5 * lmean) ||
1346 dst.
AddNode(detProp, src.
Nodes().front()->Point3D(), tpc, cryo);
1347 if (src.
Nodes().front()->IsFrozen()) dst.
Nodes().back()->SetFrozen(
true);
1349 for (
size_t n = 1;
n < src.
Nodes().size();
n++) {
1356 for (
size_t h = 0;
h < src.
size();
h++) {
1361 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" reopt after merging done, g = " <<
g;
1378 unsigned int* nused)
const 1380 for (
size_t i = 0; i < trk.
size(); i++) {
1382 if (hit->
View2D() == view) {
1391 unsigned int nhits = 0;
1392 double last_x, dx = 0.0, last_q, dq = 0.0, dqdx = 0.0;
1398 if ((ih >= 0) && (ih < (
int)trk.
size())) {
1402 while ((dx < 2.5) && (ih >= 0) && (ih < (
int)trk.
size())) {
1409 if (dx + last_x < 3.0) {
1420 while ((ih >= 0) && (ih < (
int)trk.
size())) {
1427 mf::LogError(
"ProjectionMatchingAlg") <<
"Initial part selection failed.";
1431 mf::LogError(
"ProjectionMatchingAlg") <<
"Initial part too short to select useful hits.";
1434 if (dx > 0.0) dqdx = dq / dx;
1436 if (nused) (*nused) = nhits;
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
bool SelectHits(float fraction=1.0F)
void AddHits(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit >> &hits)
pma::Track3D * buildTrack(const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &hits_1, const std::vector< art::Ptr< recob::Hit >> &hits_2={}) const
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
bool HasPlane(unsigned int iplane) const
Returns whether a plane with index iplane is present in this TPC.
bool addEndpointRef_(const detinfo::DetectorPropertiesData &detProp, pma::Track3D &trk, const std::map< unsigned int, std::vector< art::Ptr< recob::Hit >>> &hits, std::pair< int, int > const *wires, double const *xPos, unsigned int tpc, unsigned int cryo) const
Functions to help with numbers.
double GetMse(unsigned int view=geo::kUnknown) const
MSE of hits weighted with hit amplidudes and wire plane coefficients.
constexpr to_element_t to_element
static constexpr double g
bool Has_(const std::vector< size_t > &v, size_t idx) const
double Dist2(const TVector2 &p2d, unsigned int view, unsigned int tpc, unsigned int cryo) const
double Dist2(const TVector2 &v1, const TVector2 &v2)
double const fMinTwoViewFraction
int PrevHit(int index, unsigned int view=geo::kZ, bool inclDisabled=false) const
double GetXTicksCoefficient(int t, int c) const
pma::Track3D * extendTrack(const detinfo::DetectorPropertiesData &clockData, const pma::Track3D &trk, const std::vector< art::Ptr< recob::Hit >> &hits, bool add_nodes) const
Add more hits to an existing track, reoptimize, optionally add more nodes.
static void SetOptFactor(unsigned int view, float value)
geo::GeometryCore const * fGeom
geo::WireID WireID() const
pma::Hit3D const * front() const
Implementation of the Projection Matching Algorithm.
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
Geometry information for a single TPC.
fhicl::Atom< double > NodeMargin3D
TVector3 const & Point3D() const
bool Initialize(detinfo::DetectorPropertiesData const &detProp, float initEndSegW=0.05F)
Planes which measure Z direction.
void TagOutlier(bool state) noexcept
TVector2 WireDriftToCm(detinfo::DetectorPropertiesData const &detProp, unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
std::vector< unsigned int > TPCs() const
WireID_t Wire
Index of the wire within its plane.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
static void SetMargin(double m)
Set allowed node position margin around TPC.
static size_t getSegCount_(size_t trk_size)
unsigned int Plane() const
fhicl::Atom< double > TrkValidationDist2D
unsigned int Wire() const noexcept
unsigned int BackTPC() const
fhicl::Atom< double > HitWeightU
recob::tracking::Vector_t Vector3D
double Optimize(const detinfo::DetectorPropertiesData &detProp, int nNodes=-1, double eps=0.01, bool selAllHits=true, bool setAllNodes=true, size_t selSegHits=0, size_t selVtxHits=0)
Main optimization method.
art framework interface to geometry description
double const fFineTuningEps
void AddRefPoint(const TVector3 &p)
bool GetCloseHits_(const detinfo::DetectorPropertiesData &detProp, double r2d, const std::vector< art::Ptr< recob::Hit >> &hits_in, std::vector< size_t > &used, std::vector< art::Ptr< recob::Hit >> &hits_out) const
unsigned int NEnabledHits(unsigned int view=geo::kUnknown) const
int TPC(void) const
TPC index or -1 if out of any TPC.
std::vector< unsigned int > Cryos() const
unsigned int BackCryo() const
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
fhicl::Atom< double > HitWeightV
double selectInitialHits(pma::Track3D &trk, unsigned int view=geo::kZ, unsigned int *nused=0) const
void AddNode(pma::Node3D *node)
pma::Hit3D * release_at(size_t index)
unsigned int NHits(unsigned int view) const
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
bool alignTracks(pma::Track3D &first, pma::Track3D &second) const
fhicl::Atom< double > HitWeightZ
double const fTrkValidationDist2D
void SetEndSegWeight(float value) noexcept
fhicl::Atom< double > HitTestingDist2D
std::vector< pma::Segment3D * > const & Segments() const noexcept
double validate_on_adc_test(const detinfo::DetectorPropertiesData &detProp, const lariov::ChannelStatusProvider &channelStatus, const pma::Track3D &trk, const img::DataProviderAlg &adcImage, const std::vector< art::Ptr< recob::Hit >> &hits, TH1F *histoPassing, TH1F *histoRejected) const
void FilterOutSmallParts(const detinfo::DetectorPropertiesData &detProp, double r2d, const std::vector< art::Ptr< recob::Hit >> &hits_in, std::vector< art::Ptr< recob::Hit >> &hits_out, const TVector2 &vtx2d) const
double ConvertXToTicks(double X, int p, int t, int c) const
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
virtual bool IsGood(raw::ChannelID_t channel) const
Returns whether the specified channel is physical and good.
float SummedADC() const noexcept
double const fHitTestingDist2D
double const fOptimizationEps
Class providing information about the quality of channels.
bool SameTPC(const TVector3 &p3d, float margin=0.0F) const
Check if p3d is in the same TPC as the node.
unsigned int FrontTPC() const
unsigned int FrontCryo() const
static int max(int a, int b)
pma::Track3D * buildSegment(const detinfo::DetectorPropertiesData &clockData, const std::vector< art::Ptr< recob::Hit >> &hits_1, const std::vector< art::Ptr< recob::Hit >> &hits_2={}) const
PlaneID_t Plane
Index of the plane within its TPC.
unsigned int DisableSingleViewEnds()
fhicl::Atom< double > FineTuningEps
bool IntersectionPoint(geo::WireID const &wid1, geo::WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
float GetSegFraction() const noexcept
yes & test(std::ostream &)
Detector simulation of raw signals on wires.
constexpr auto absDiff(A const &a, B const &b)
Returns the absolute value of the difference between two values.
double ConvertTicksToX(double ticks, int p, int t, int c) const
void push_back(pma::Hit3D *hit)
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether we have the specified TPC.
unsigned int View2D() const noexcept
bool HasTwoViews(size_t nmin=1) const
int Cryo(void) const
Cryostat index or -1 if out of any cryostat.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
float PeakTime() const
Time of the signal peak, in tick units.
double Length(size_t step=1) const
bool IsFrozen(void) const
Check if the vertex 3D position is fixed.
double validate(const detinfo::DetectorPropertiesData &detProp, const lariov::ChannelStatusProvider &channelStatus, const pma::Track3D &trk, const std::vector< art::Ptr< recob::Hit >> &hits) const
void ShortenSeg_(const detinfo::DetectorPropertiesData &detProp, pma::Track3D &trk, const geo::TPCGeo &tpcgeom) const
bool chkEndpointHits_(const detinfo::DetectorPropertiesData &detProp, int wire, int wdir, double drift_x, int view, unsigned int tpc, unsigned int cryo, const pma::Track3D &trk, const std::vector< art::Ptr< recob::Hit >> &hits) const
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
pma::Track3D * buildShowerSeg(const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &hits, const pma::Vector3D &vtx) const
double GetSegmentProjVector(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
void mergeTracks(const detinfo::DetectorPropertiesData &detProp, pma::Track3D &dst, pma::Track3D &src, bool reopt) const
pma::Vector3D GetDirection3D(void) const override
Get 3D direction cosines of this segment.
double GetDistToProj() const
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
ProjectionMatchingAlg(const Config &config)
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double > > Vector2D
int NextHit(int index, unsigned int view=geo::kZ, bool inclDisabled=false) const
void guideEndpoints(const detinfo::DetectorPropertiesData &clockData, pma::Track3D &trk, const std::map< unsigned int, std::vector< art::Ptr< recob::Hit >>> &hits) const
Interface for experiment-specific channel quality info provider.
pma::Hit3D const * back() const
std::vector< pma::Hit3D * > trimTrackToVolume(pma::Track3D &trk, TVector3 p0, TVector3 p1) const
double validate_on_adc(const detinfo::DetectorPropertiesData &detProp, const lariov::ChannelStatusProvider &channelStatus, const pma::Track3D &trk, const img::DataProviderAlg &adcImage, float thr) const
double HitDxByView(size_t index, unsigned int view) const
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
std::vector< pma::Node3D * > const & Nodes() const noexcept
static unsigned filter(unsigned char *out, const unsigned char *in, unsigned w, unsigned h, const LodePNG_InfoColor *info)
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
2D representation of charge deposited in the TDC/wire plane
fhicl::Atom< double > OptimizationEps
fhicl::Atom< double > MinTwoViewFraction
unsigned int ChannelID_t
Type representing the ID of a readout channel.
bool Flip(const detinfo::DetectorPropertiesData &detProp, std::vector< pma::Track3D * > &allTracks)
float poolMax(int wire, int drift, size_t r=0) const
Pool max value in a patch around the wire/drift pixel.
TPCID_t TPC
Index of the TPC within its cryostat.
Interface for experiment-specific service for channel quality info.
second_as<> second
Type of time stored in seconds, in double precision.
recob::tracking::Plane Plane
void RemoveNotEnabledHits(pma::Track3D &trk) const
double twoViewFraction(pma::Track3D &trk) const
geo::CryostatID::CryostatID_t FindCryostatAtPosition(geo::Point_t const &worldLoc) const
Returns the index of the cryostat at specified location.
constexpr ProductStatus present() noexcept
double Length(void) const
bool TestTrk_(pma::Track3D &trk, const geo::TPCGeo &tpcgeom) const
cet::coded_exception< error, detail::translate > exception
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
std::pair< TVector2, TVector2 > WireDriftRange(detinfo::DetectorPropertiesData const &detProp, unsigned int view, unsigned int tpc, unsigned int cryo) const
pma::Track3D * buildMultiTPCTrack(const detinfo::DetectorPropertiesData &clockData, const std::vector< art::Ptr< recob::Hit >> &hits) const
QTextStream & endl(QTextStream &s)
bool HasWire(geo::WireID const &wireid) const
Returns whether we have the specified wire.