11 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" 12 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" 18 fGeom( &*(
art::ServiceHandle<
geo::Geometry>()) ),
35 fDetProp = lar::providerFrom<detinfo::DetectorPropertiesService>();
42 unsigned int nAll = 0, nPassed = 0;
43 unsigned int testPlane = adcImage.
Plane();
45 std::vector< unsigned int > trkTPCs = trk.
TPCs();
46 std::vector< unsigned int > trkCryos = trk.
Cryos();
48 unsigned int tpc, cryo;
56 for (
auto const * seg : trk.
Segments())
60 p = seg->End();
continue;
67 tpc = seg->
TPC(); cryo = seg->Cryo();
72 while ((f < 1.0) && node->
SameTPC(p))
75 geo::WireID wireID(cryo, tpc, testPlane, (
int)p2d.X());
77 int widx = (int)p2d.X();
83 if (channelStatus.IsGood(ch))
85 float max_adc = adcImage.
poolMax(widx, didx, 2);
86 if (max_adc > thr) nPassed++;
102 double v = nPassed / (double)nAll;
113 TH1F * histoPassing, TH1F * histoRejected)
const 116 double d2, max_d2 = max_d * max_d;
117 unsigned int nAll = 0, nPassed = 0;
118 unsigned int testPlane = adcImage.
Plane();
120 std::vector< unsigned int > trkTPCs = trk.
TPCs();
121 std::vector< unsigned int > trkCryos = trk.
Cryos();
122 std::map< std::pair< unsigned int, unsigned int >, std::pair< TVector2, TVector2 > > ranges;
123 std::map< std::pair< unsigned int, unsigned int >,
double > wirePitch;
124 for (
auto c : trkCryos)
125 for (
auto t : trkTPCs)
127 ranges[std::pair< unsigned int, unsigned int >(t, c)] = trk.
WireDriftRange(testPlane, t, c);
131 unsigned int tpc, cryo;
132 std::map< std::pair< unsigned int, unsigned int >, std::vector< pma::Vector2D > > all_close_points;
134 for (
const auto h :
hits)
135 if (h->WireID().Plane == testPlane)
137 tpc = h->WireID().TPC;
138 cryo = h->WireID().Cryostat;
139 std::pair< unsigned int, unsigned int > tpc_cryo(tpc, cryo);
140 std::pair< TVector2, TVector2 > rect = ranges[tpc_cryo];
142 if ((h->WireID().Wire > rect.first.X() - 10) &&
143 (h->WireID().Wire < rect.second.X() + 10) &&
144 (h->PeakTime() > rect.first.Y() - 100) &&
145 (h->PeakTime() < rect.second.Y() + 100))
147 TVector2 p2d(wirePitch[tpc_cryo] * h->WireID().Wire,
fDetProp->
ConvertTicksToX(h->PeakTime(), testPlane, tpc, cryo));
149 d2 = trk.
Dist2(p2d, testPlane, tpc, cryo);
151 if (d2 < max_d2) { all_close_points[tpc_cryo].emplace_back(p2d.X(), p2d.Y()); }
161 for (
auto const * seg : trk.
Segments())
165 p = seg->End();
continue;
172 tpc = seg->
TPC(); cryo = seg->Cryo();
176 auto const & points = all_close_points[std::pair< unsigned int, unsigned int >(tpc, cryo)];
181 while ((f < 1.0) && node->
SameTPC(p))
184 geo::WireID wireID(cryo, tpc, testPlane, (
int)p2d.X());
186 int widx = (int)p2d.X();
192 if (channelStatus.IsGood(ch))
194 bool is_close =
false;
195 float max_adc = adcImage.
poolMax(widx, didx, 2);
199 p2d.SetX(wirepitch * p2d.X());
200 for (
const auto & h : points)
203 if (d2 < max_d2) { is_close =
true; nPassed++;
break; }
209 if (is_close) {
if (histoPassing) histoPassing->Fill(max_adc); }
210 else {
if (histoRejected) histoRejected->Fill(max_adc); }
223 double v = nPassed / (double)nAll;
234 if (
hits.empty()) {
return 0; }
237 double d2, max_d2 = max_d * max_d;
238 unsigned int nAll = 0, nPassed = 0;
239 unsigned int testPlane =
hits.front()->WireID().Plane;
241 std::vector< unsigned int > trkTPCs = trk.
TPCs();
242 std::vector< unsigned int > trkCryos = trk.
Cryos();
243 std::map< std::pair< unsigned int, unsigned int >, std::pair< TVector2, TVector2 > > ranges;
244 std::map< std::pair< unsigned int, unsigned int >,
double > wirePitch;
245 for (
auto c : trkCryos)
246 for (
auto t : trkTPCs)
248 ranges[std::pair< unsigned int, unsigned int >(t, c)] = trk.
WireDriftRange(testPlane, t, c);
252 unsigned int tpc, cryo;
253 std::map< std::pair< unsigned int, unsigned int >, std::vector< pma::Vector2D > > all_close_points;
255 for (
const auto h :
hits)
256 if (h->WireID().Plane == testPlane)
258 tpc = h->WireID().TPC;
259 cryo = h->WireID().Cryostat;
260 std::pair< unsigned int, unsigned int > tpc_cryo(tpc, cryo);
261 std::pair< TVector2, TVector2 > rect = ranges[tpc_cryo];
263 if ((h->WireID().Wire > rect.first.X() - 10) &&
264 (h->WireID().Wire < rect.second.X() + 10) &&
265 (h->PeakTime() > rect.first.Y() - 100) &&
266 (h->PeakTime() < rect.second.Y() + 100))
268 TVector2 p2d(wirePitch[tpc_cryo] * h->WireID().Wire,
fDetProp->
ConvertTicksToX(h->PeakTime(), testPlane, tpc, cryo));
270 d2 = trk.
Dist2(p2d, testPlane, tpc, cryo);
272 if (d2 < max_d2) all_close_points[tpc_cryo].emplace_back(p2d.X(), p2d.Y());
282 for (
auto const * seg : trk.
Segments())
286 p = seg->End();
continue;
293 tpc = seg->
TPC(); cryo = seg->Cryo();
297 auto const & points = all_close_points[std::pair< unsigned int, unsigned int >(tpc, cryo)];
302 while ((f < 1.0) && node->
SameTPC(p))
305 geo::WireID wireID(cryo, tpc, testPlane, (
int)p2d.X());
309 if (channelStatus.IsGood(ch))
313 p2d.SetX(wirepitch * p2d.X());
314 for (
const auto & h : points)
317 if (d2 < max_d2) { nPassed++;
break; }
333 double v = nPassed / (double)nAll;
342 const TVector3& p0,
const TVector3& p1,
344 unsigned int testPlane,
unsigned int tpc,
unsigned int cryo)
const 348 double d2, max_d2 = max_d * max_d;
349 unsigned int nAll = 0, nPassed = 0;
352 TVector3 dc(p1); dc -= p;
353 dc *= step / dc.Mag();
362 geo::WireID wireID(cryo, tpc, testPlane, (
int)p2d.X());
366 if (channelStatus.IsGood(ch))
368 p2d.Set(wirepitch * p2d.X(), p2d.Y());
369 for (
const auto & h :
hits)
370 if ((h->WireID().Plane == testPlane) &&
371 (h->WireID().TPC == tpc) &&
372 (h->WireID().Cryostat == cryo))
375 if (d2 < max_d2) { nPassed++;
break; }
388 double v = nPassed / (double)nAll;
389 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" segment fraction ok: " << v;
402 while ((idx < trk.
size() - 1) && !trk[idx]->IsEnabled()) idx++;
403 double l0 = trk.
Length(0, idx + 1);
405 idx = trk.
size() - 1;
406 while ((idx > 1) && !trk[idx]->IsEnabled()) idx--;
407 double l1 = trk.
Length(idx - 1, trk.
size() - 1);
411 return 1.0 - (l0 + l1) / trk.
Length();
417 int nSegments = (int)( 0.8 * trk_size / sqrt(trk_size) );
419 if (nSegments > 1)
return (
size_t)nSegments;
433 std::vector< unsigned int > tpcs = trk->
TPCs();
434 for (
size_t t = 0; t < tpcs.size(); ++t)
444 size_t nNodes = (size_t)( nSegments - 1 );
449 mf::LogWarning(
"ProjectionMatchingAlg") <<
" initialization failed, delete trk";
458 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" optimize trk (" << nSegments <<
" seg)";
474 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" clusters do not match, f = " <<
f;
484 std::map< unsigned int, std::vector< art::Ptr<recob::Hit> > > hits_by_tpc;
485 for (
auto const & h :
hits)
487 hits_by_tpc[h->WireID().TPC].push_back(h);
490 std::vector< pma::Track3D* > tracks;
491 for(
auto const & hsel : hits_by_tpc)
495 if (trk) tracks.push_back(trk);
498 bool need_reopt =
false;
499 while (tracks.size() > 1)
505 double d, dmin = 1.0e12;
506 size_t t_best = 0, cfg = 0;
507 for (
size_t t = 1; t < tracks.size(); ++t)
512 if (d < dmin) { dmin =
d; best = second; t_best = t; cfg = 0; }
515 if (d < dmin) { dmin =
d; best = second; t_best = t; cfg = 1; }
518 if (d < dmin) { dmin =
d; best = second; t_best = t; cfg = 2; }
521 if (d < dmin) { dmin =
d; best = second; t_best = t; cfg = 3; }
531 tracks[0] = best;
delete first;
break;
538 tracks.erase(tracks.begin() + t_best);
546 trk = tracks.front();
550 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" reopt after merging initial tpc segments: done, g = " << g;
557 size_t nNodes = (size_t)( nSegments - 1 );
560 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" optimize trk (add " << nSegments <<
" seg)";
580 double vtxarray[3] {vtx.X(), vtx.Y(), vtx.Z()};
584 TVector3 vtxv3(vtx.X(), vtx.Y(), vtx.Z());
591 std::vector<art::Ptr<recob::Hit> > hitstpc;
592 for (
size_t h = 0; h <
hits.size(); ++h)
593 if (
hits[h]->WireID().TPC == tpc)
594 hitstpc.push_back(
hits[h]);
596 if (!hitstpc.size())
return 0;
598 std::vector<art::Ptr<recob::Hit> > hitstrk;
599 size_t view = 0;
size_t countviews = 0;
602 mf::LogVerbatim(
"ProjectionMatchinAlg") <<
"collecting hits from view: " << view;
603 if (!tpcgeom.
HasPlane(view)) {++view;
continue;}
606 std::vector<art::Ptr<recob::Hit> > hitsview;
607 for (
size_t h = 0; h < hitstpc.size(); ++h)
608 if (hitstpc[h]->WireID().Plane == view)
609 hitsview.push_back(hitstpc[h]);
610 if (!hitsview.size()) {++view;
continue;}
613 std::vector<art::Ptr<recob::Hit> > hitsfilter;
620 for (
size_t h = 0; h < hitsfilter.size(); ++h)
621 hitstrk.push_back(hitsfilter[h]);
623 if (hitsfilter.size() >= 5) countviews++;
628 if (!hitstrk.size() || (countviews < 2))
630 mf::LogWarning(
"ProjectionMatchinAlg") <<
"too few hits, segment not built";
642 if (trk->
size() < 10)
644 mf::LogWarning(
"ProjectionMatchingAlg") <<
"too short segment, delete segment";
658 const TVector2& vtx2d)
const 660 size_t min_size = hits_in.size() / 5;
661 if (min_size < 3) min_size = 3;
663 std::vector<size_t> used;
664 std::vector< std::vector< art::Ptr<recob::Hit> > > sub_groups;
665 std::vector< art::Ptr<recob::Hit> > close_hits;
667 float mindist2 = 99999.99;
size_t id_sub_groups_save = 0;
size_t id = 0;
671 sub_groups.emplace_back(close_hits);
673 for (
size_t h = 0; h < close_hits.size(); ++h)
676 close_hits[h]->PeakTime(),
677 close_hits[h]->WireID().
Plane,
678 close_hits[h]->WireID().TPC,
679 close_hits[h]->WireID().Cryostat);
682 if (dist2 < mindist2)
684 id_sub_groups_save = id;
692 for (
size_t i = 0; i < sub_groups.size(); ++i)
694 if (i == id_sub_groups_save)
696 for (
auto h : sub_groups[i]) hits_out.push_back(h);
700 for (
size_t i = 0; i < sub_groups.size(); ++i)
702 if ((i != id_sub_groups_save) && (hits_out.size() < 10) && (sub_groups[i].size() > min_size))
703 for (
auto h : sub_groups[i]) hits_out.push_back(h);
712 std::vector<size_t>& used,
717 const double gapMargin = 5.0;
720 while ((idx < hits_in.size()) &&
Has(used, idx)) idx++;
722 if (idx < hits_in.size())
724 hits_out.push_back(hits_in[idx]);
727 unsigned int tpc = hits_in[idx]->WireID().TPC;
728 unsigned int cryo = hits_in[idx]->WireID().Cryostat;
729 unsigned int view = hits_in[idx]->WireID().Plane;
733 double r2d2 = r2d*r2d;
734 double gapMargin2 = sqrt(2 * gapMargin*gapMargin);
735 gapMargin2 = (gapMargin2 + r2d)*(gapMargin2 + r2d);
741 for (
size_t i = 0; i < hits_in.size(); i++)
749 for (
auto const & ho : hits_out)
752 TVector2 ho_cm(wirePitch * ho->WireID().Wire, driftPitch * ho->PeakTime());
755 if (d2 < r2d2) { accept =
true;
break; }
760 hits_out.push_back(hi);
774 double mse = trk.
GetMse();
775 mf::LogWarning(
"ProjectionMatchingAlg") <<
"initial value of mse: " << mse;
776 while ((mse > 0.5) &&
TestTrk(trk, tpcgeom))
779 for (
size_t h = 0; h < trk.
size(); ++h)
781 > 0.8*trk.
Length()) trk[h]->SetEnabled(
false);
790 if (mse == trk.
GetMse())
break;
820 for (
size_t h = 0; h < trk.
size(); ++h)
822 if (!trk[h]->IsEnabled())
break;
826 mf::LogWarning(
"ProjectionMatchingAlg") <<
"length of segment: " << length;
827 if (length < 3.0) test =
false;
836 for (
auto c : v)
if (c == idx)
return true;
845 while (h < trk.
size())
847 if (trk[h]->IsEnabled()) ++h;
864 (trk->
TPCs().size() == 1))
868 mf::LogWarning(
"ProjectionMatchingAlg") <<
"initialization failed, delete segment";
879 mf::LogWarning(
"ProjectionMatchingAlg") <<
"need at least two views in single tpc";
889 const TVector3& point)
const 897 if (dfront > dback) trk->
Flip();
899 trk->
Nodes().front()->SetPoint3D(point);
900 trk->
Nodes().front()->SetFrozen(
true);
911 const TVector3& point)
const 919 if (dfront > dback) trk->
Flip();
921 trk->
Nodes().front()->SetPoint3D(point);
922 trk->
Nodes().front()->SetFrozen(
true);
934 bool add_nodes)
const 947 int nNodes = nSegments - copy->
Nodes().size() + 1;
948 if (nNodes < 0) nNodes = 0;
952 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" add " << nNodes <<
" nodes";
964 int wire,
int wdir,
double drift_x,
int view,
965 unsigned int tpc,
unsigned int cryo,
969 size_t nCloseHits = 0;
970 int forwWires = 3, backWires = -1;
971 double xMargin = 0.4;
973 if ((view == (
int)h->WireID().Plane) &&
974 (tpc == h->WireID().TPC) &&
975 (cryo == h->WireID().Cryostat))
978 for (
size_t ht = 0; ht < trk.
size(); ht++)
979 if (trk[ht]->Hit2DPtr().key() == h.key())
985 int dw = wdir * (h->WireID().Wire - wire);
986 if ((dw <= forwWires) && (dw >= backWires))
989 if (fabs(x - drift_x) < xMargin) nCloseHits++;
992 if (nCloseHits > 1)
return false;
998 std::pair<int, int>
const * wires,
double const * xPos,
999 unsigned int tpc,
unsigned int cryo)
const 1001 double x = 0.0,
y = 0.0,
z = 0.0;
1002 std::vector< std::pair<int, unsigned int> > wire_view;
1003 for (
unsigned int i = 0; i < 3; i++)
1004 if (wires[i].first >= 0)
1006 const auto hiter =
hits.find(i);
1007 if (hiter !=
hits.end())
1009 if (
chkEndpointHits(wires[i].first, wires[i].second, xPos[i], i, tpc, cryo, trk, hiter->second))
1012 wire_view.push_back(std::pair<int, unsigned int>(wires[i].first, i));
1016 if (wire_view.size() > 1)
1018 x /= wire_view.size();
1020 wire_view[0].first, wire_view[1].first,
1021 wire_view[0].second, wire_view[1].second,
1025 <<
" add ref.point (" << x <<
"; " <<
y <<
"; " <<
z <<
")";
1031 <<
" wire-plane-parallel track, but need two clean views of endpoint";
1042 mf::LogWarning(
"ProjectionMatchingAlg") <<
"Please, apply before TPC stitching.";
1046 const double maxCosXZ = 0.992546;
1052 if ((segFront->
Length() < 0.8) && (segFront1->
Length() > 5.0))
1053 segFront = segFront1;
1057 dirFrontXZ *= 1.0 / dirFrontXZ.R();
1063 if ((segBack->
Length() < 0.8) && (segBack1->
Length() > 5.0))
1068 dirBackXZ *= 1.0 / dirBackXZ.R();
1070 if ((fabs(dirFrontXZ.Z()) < maxCosXZ) && (fabs(dirBackXZ.Z()) < maxCosXZ))
1075 unsigned int nPlanesFront = 0, nPlanesBack = 0;
1076 std::pair<int, int> wiresFront[3], wiresBack[3];
1077 double xFront[3], xBack[3];
1079 for (
unsigned int i = 0; i < 3; i++)
1081 bool frontPresent =
false, backPresent =
false;
1084 int idxFront0 = trk.
NextHit(-1, i);
1086 if ((idxFront0 >= 0) && (idxFront0 < (int)trk.
size()) &&
1087 (idxBack0 >= 0) && (idxBack0 < (int)trk.
size()))
1089 int idxFront1 = trk.
NextHit(idxFront0, i);
1090 int idxBack1 = trk.
PrevHit(idxBack0, i);
1091 if ((idxFront1 >= 0) && (idxFront1 < (
int)trk.
size()) &&
1092 (idxBack1 >= 0) && (idxBack1 < (int)trk.
size()))
1094 int wFront0 = trk[idxFront0]->Wire();
1095 int wBack0 = trk[idxBack0]->Wire();
1097 int wFront1 = trk[idxFront1]->Wire();
1098 int wBack1 = trk[idxBack1]->Wire();
1100 wiresFront[i].first = wFront0;
1101 wiresFront[i].second = wFront0 - wFront1;
1104 wiresBack[i].first = wBack0;
1105 wiresBack[i].second = wBack0 - wBack1;
1108 if (wiresFront[i].second)
1110 if (wiresFront[i].second > 0) wiresFront[i].second = 1;
1111 else wiresFront[i].second = -1;
1113 frontPresent =
true;
1117 if (wiresBack[i].second)
1119 if (wiresBack[i].second > 0) wiresBack[i].second = 1;
1120 else wiresBack[i].second = -1;
1128 if (!frontPresent) { wiresFront[i].first = -1; }
1129 if (!backPresent) { wiresBack[i].first = -1; }
1132 bool refAdded =
false;
1133 if ((nPlanesFront > 1) && (fabs(dirFrontXZ.Z()) >= maxCosXZ))
1138 if ((nPlanesBack > 1) && (fabs(dirBackXZ.Z()) >= maxCosXZ))
1144 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
"guide wire-plane-parallel track endpoints";
1155 const double maxCosXZ = 0.992546;
1157 unsigned int tpc, cryo;
1179 if (seg1 && (seg0->
Length() < 0.8) && (seg1->
Length() > 5.0))
1185 dir0XZ *= 1.0 / dir0XZ.R();
1187 if (fabs(dir0XZ.Z()) < maxCosXZ) {
return; }
1189 unsigned int nPlanes = 0;
1190 std::pair<int, int> wires[3];
1193 for (
unsigned int i = 0; i < 3; i++)
1198 int idx0 = -1, idx1 = -1;
1208 if ((idx0 >= 0) && (idx0 < (int)trk.
size()) &&
1209 (trk[idx0]->TPC() == tpc) && (trk[idx0]->Cryo() == cryo))
1220 if ((idx1 >= 0) && (idx1 < (
int)trk.
size()) &&
1221 (trk[idx1]->TPC() == tpc) && (trk[idx1]->Cryo() == cryo))
1223 int w0 = trk[idx0]->Wire();
1224 int w1 = trk[idx1]->Wire();
1226 wires[i].first = w0;
1227 wires[i].second = w0 - w1;
1230 if (wires[i].second)
1232 if (wires[i].second > 0) wires[i].second = 1;
1233 else wires[i].second = -1;
1241 if (!present) { wires[i].first = -1; }
1244 if ((nPlanes > 1) && (fabs(dir0XZ.Z()) >= maxCosXZ) &&
1247 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
"guide wire-plane-parallel track endpoint";
1257 std::vector< pma::Hit3D* > trimmedHits;
1269 double dist = distFF;
1272 if (distFB < dist) { k = 1; dist = distFB; }
1275 if (distBF < dist) { k = 2; dist = distBF; }
1278 if (distBB < dist) { k = 3; dist = distBB; }
1282 case 0: first.
Flip();
break;
1283 case 1:
mf::LogError(
"PMAlgTrackMaker") <<
"Tracks in reversed order.";
return false;
1285 case 3: second.
Flip();
break;
1286 default:
throw cet::exception(
"pma::ProjectionMatchingAlg") <<
"alignTracks: should never happen." << std::endl;
1297 double lmean = dst.
Length() / (dst.
Nodes().size() - 1);
1299 dst.
Nodes().back()->Point3D(),
1300 src.
Nodes().front()->Point3D()) > 0.5 * lmean) ||
1303 dst.
AddNode(src.
Nodes().front()->Point3D(), tpc, cryo);
1304 if (src.
Nodes().front()->IsFrozen())
1305 dst.
Nodes().back()->SetFrozen(
true);
1307 for (
size_t n = 1;
n < src.
Nodes().size();
n++)
1315 dst.
Nodes().back()->SetFrozen(
true);
1317 for (
size_t h = 0; h < src.
size(); h++)
1324 mf::LogVerbatim(
"ProjectionMatchingAlg") <<
" reopt after merging done, g = " << g;
1341 for (
size_t i = 0; i < trk.
size(); i++)
1344 if (hit->
View2D() == view)
1353 unsigned int nhits = 0;
1354 double last_x, dx = 0.0, last_q, dq = 0.0, dqdx = 0.0;
1355 int ih = trk.
NextHit(-1, view);
1360 if ((ih >= 0) && (ih < (
int)trk.
size()))
1365 while ((dx < 2.5) && (ih >= 0) && (ih < (
int)trk.
size()))
1374 if (dx + last_x < 3.0)
1385 while ((ih >= 0) && (ih < (
int)trk.
size()))
1392 else {
mf::LogError(
"ProjectionMatchingAlg") <<
"Initial part selection failed."; }
1394 if (!nhits) {
mf::LogError(
"ProjectionMatchingAlg") <<
"Initial part too short to select useful hits."; }
1396 if (dx > 0.0) dqdx = dq / dx;
1398 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)
pma::Track3D * buildShowerSeg(const std::vector< art::Ptr< recob::Hit > > &hits, const pma::Vector3D &vtx) const
Build a shower segment from sets of hits and attached to the provided vertex.
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
bool HasPlane(unsigned int iplane) const
Returns whether a plane with index iplane is present in this TPC.
double fTrkValidationDist2D
std::vector< unsigned int > TPCs(void) const
Functions to help with numbers.
detinfo::DetectorProperties const * fDetProp
double GetDistToProj(void) const
Utilities related to art service access.
double GetMse(unsigned int view=geo::kUnknown) const
MSE of hits weighted with hit amplidudes and wire plane coefficients.
yes & test(std::ostream &)
double Dist2(const TVector2 &p2d, unsigned int view, unsigned int tpc, unsigned int cryo) const
void guideEndpoints(pma::Track3D &trk, const std::map< unsigned int, std::vector< art::Ptr< recob::Hit > > > &hits) const
Add 3D reference points to clean endpoints of a track (both need to be in the same TPC)...
unsigned int View2D(void) const
double Dist2(const TVector2 &v1, const TVector2 &v2)
unsigned int FrontTPC(void) const
unsigned int BackTPC(void) const
int PrevHit(int index, unsigned int view=geo::kZ, bool inclDisabled=false) const
bool Flip(std::vector< pma::Track3D * > &allTracks)
static void SetOptFactor(unsigned int view, float value)
bool addEndpointRef(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
T::provider_type const * providerFrom()
Returns a constant pointer to the provider of specified service.
geo::GeometryCore const * fGeom
geo::WireID WireID() const
Initial tdc tick for hit.
double fMinTwoViewFraction
::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.
std::vector< pma::Node3D * > const & Nodes(void) const
fhicl::Atom< double > NodeMargin3D
Planes which measure Z direction.
bool GetCloseHits(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
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.
fhicl::Atom< double > TrkValidationDist2D
fhicl::Atom< double > HitWeightU
std::vector< pma::Segment3D * > const & Segments(void) const
unsigned int Wire(void) const
recob::tracking::Vector_t Vector3D
pma::Track3D * buildMultiTPCTrack(const std::vector< art::Ptr< recob::Hit > > &hits) const
as far as hits origin from at least two wire planes.
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
void AddRefPoint(const TVector3 &p)
unsigned int NEnabledHits(unsigned int view=geo::kUnknown) const
int TPC(void) const
TPC index or -1 if out of any TPC.
bool ShiftEndsToHits(void)
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
fhicl::Atom< double > HitWeightV
std::pair< TVector2, TVector2 > WireDriftRange(unsigned int view, unsigned int tpc, unsigned int cryo) const
double selectInitialHits(pma::Track3D &trk, unsigned int view=geo::kZ, unsigned int *nused=0) const
float GetSegFraction() const
void AddNode(pma::Node3D *node)
pma::Hit3D * release_at(size_t index)
unsigned int NHits(unsigned int view) const
bool alignTracks(pma::Track3D &first, pma::Track3D &second) const
fhicl::Atom< double > HitWeightZ
virtual double GetXTicksCoefficient(int t, int c) const =0
fhicl::Atom< double > HitTestingDist2D
unsigned int BackCryo(void) const
pma::Track3D * buildSegment(const std::vector< art::Ptr< recob::Hit > > &hits_1, const std::vector< art::Ptr< recob::Hit > > &hits_2=std::vector< art::Ptr< recob::Hit > >()) const
bool chkEndpointHits(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
void SetEndSegWeight(float value)
pma::Track3D * buildTrack(const std::vector< art::Ptr< recob::Hit > > &hits_1, const std::vector< art::Ptr< recob::Hit > > &hits_2=std::vector< art::Ptr< recob::Hit > >()) const
wire planes; number of segments used to create the track depends on the number of hits...
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double > > Vector2D
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
double Optimize(int nNodes=-1, double eps=0.01, bool selAllHits=true, bool setAllNodes=true, size_t selSegHits=0, size_t selVtxHits=0)
Main optimization method.
bool SameTPC(const TVector3 &p3d, float margin=0.0F) const
Check if p3d is in the same TPC as the node.
float SummedADC(void) const
General LArSoft Utilities.
unsigned int Plane(void) const
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.
void ShortenSeg(pma::Track3D &trk, const geo::TPCGeo &tpcgeom) const
unsigned int FrontCryo(void) const
std::vector< unsigned int > Cryos(void) const
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.
unsigned int DisableSingleViewEnds(void)
bool Has(const std::vector< size_t > &v, size_t idx) const
void push_back(pma::Hit3D *hit)
double validate_on_adc_test(const pma::Track3D &trk, const img::DataProviderAlg &adcImage, const std::vector< art::Ptr< recob::Hit > > &hits, TH1F *histoPassing, TH1F *histoRejected) const
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether we have the specified TPC.
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
TVector3 const & Point3D(void) const
double validate_on_adc(const pma::Track3D &trk, const img::DataProviderAlg &adcImage, float thr) const
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
static size_t getSegCount(size_t trk_size)
bool IsFrozen(void) const
Check if the vertex 3D position is fixed.
virtual void TagOutlier(bool state)
LArSoft-specific namespace.
void FilterOutSmallParts(double r2d, const std::vector< art::Ptr< recob::Hit > > &hits_in, std::vector< art::Ptr< recob::Hit > > &hits_out, const TVector2 &vtx2d) const
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
double GetSegmentProjVector(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
pma::Vector3D GetDirection3D(void) const override
Get 3D direction cosines of this segment.
TVector2 WireDriftToCm(unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
bool Initialize(float initEndSegW=0.05F)
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
pma::Track3D * extendTrack(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.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
ProjectionMatchingAlg(const Config &config)
int NextHit(int index, unsigned int view=geo::kZ, bool inclDisabled=false) const
void MakeProjection(void)
std::vector< pma::Hit3D * > trimTrackToVolume(pma::Track3D &trk, TVector3 p0, TVector3 p1) 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.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
fhicl::Atom< double > OptimizationEps
fhicl::Atom< double > MinTwoViewFraction
unsigned int ChannelID_t
Type representing the ID of a readout channel.
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.
recob::tracking::Plane Plane
void RemoveNotEnabledHits(pma::Track3D &trk) const
Namespace collecting geometry-related classes utilities.
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.
double validate(const pma::Track3D &trk, const std::vector< art::Ptr< recob::Hit > > &hits) const
bool TestTrk(pma::Track3D &trk, const geo::TPCGeo &tpcgeom) const
double Length(void) const
cet::coded_exception< error, detail::translate > exception
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
bool HasWire(geo::WireID const &wireid) const
Returns whether we have the specified wire.
void mergeTracks(pma::Track3D &dst, pma::Track3D &src, bool reopt) const
void AddHits(const std::vector< art::Ptr< recob::Hit > > &hits)