14 #include "Math/BinaryOperators.h" 15 #include "Math/Expression.h" 16 #include "Math/GenVector/Cartesian3D.h" 17 #include "Math/GenVector/DisplacementVector3D.h" 18 #include "Math/GenVector/PositionVector3D.h" 19 #include "Math/MatrixRepresentationsStatic.h" 20 #include "Math/SMatrix.h" 44 const bool flipDirection,
49 auto position = traj.
Vertex();
54 std::vector<art::Ptr<recob::Hit>> fwdHits;
71 std::vector<art::Ptr<recob::Hit>> bwdHits;
87 if (okfwd ==
false && okbwd ==
false) {
return false; }
88 else if (okfwd ==
true && okbwd ==
true) {
89 if ((fwdTrack.CountValidPoints() / (fwdTrack.Length() * fwdTrack.Chi2PerNdof())) >=
90 (bwdTrack.CountValidPoints() / (bwdTrack.Length() * bwdTrack.Chi2PerNdof()))) {
93 optionals = std::move(fwdoptionals);
98 optionals = std::move(bwdoptionals);
101 else if (okfwd ==
true) {
104 optionals = std::move(fwdoptionals);
109 optionals = std::move(bwdoptionals);
115 position = traj.
End();
119 auto trackStateCov = (flipDirection ? covEnd : covVtx);
141 const std::vector<recob::TrajectoryPointFlags>& flags,
150 std::cout <<
"Fitting track with tkID=" << tkID <<
" start pos=" << position
151 <<
" dir=" << direction <<
" nHits=" <<
hits.size() <<
" mom=" << pval
152 <<
" pdg=" << pdgid << std::endl;
153 if (
hits.size() < 4) {
154 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
163 std::vector<HitState> hitstatev;
164 std::vector<recob::TrajectoryPointFlags::Mask_t> hitflagsv;
166 if (!inputok)
return false;
169 std::vector<KFTrackState> fwdPrdTkState;
170 std::vector<KFTrackState> fwdUpdTkState;
171 std::vector<unsigned int> hitstateidx;
172 std::vector<unsigned int> rejectedhsidx;
173 std::vector<unsigned int> sortedtksidx;
187 <<
"Trying to recover with skipNegProp = false and cleanZigzag = false\n";
200 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failed for track with ID=" << tkID <<
"\n";
225 const int pdgid)
const 229 trackStateCov(0, 0) = 1000.;
230 trackStateCov(1, 1) = 1000.;
231 trackStateCov(2, 2) = 0.25;
232 trackStateCov(3, 3) = 0.25;
233 trackStateCov(4, 4) = 10.;
236 trackStateCov *= 100.;
238 SVector5 trackStatePar(0., 0., 0., 0., 1. / pval);
241 Plane(position, direction),
249 const std::vector<recob::TrajectoryPointFlags>& flags,
250 std::vector<HitState>& hitstatev,
251 std::vector<recob::TrajectoryPointFlags::Mask_t>& hitflagsv)
const 254 std::cout <<
"flags.size()=" << flags.size() <<
" hits.size()=" <<
hits.size() << std::endl;
258 const size_t fsize = flags.size();
259 for (
size_t ihit = 0; ihit !=
hits.size(); ihit++) {
261 double t =
hit->PeakTime();
266 hitstatev.emplace_back(
269 if (fsize > 0 && ihit < fsize)
270 hitflagsv.push_back(flags[ihit].mask());
284 std::cout <<
"pushed flag mask=" << hitflagsv.back()
297 std::vector<HitState>& hitstatev,
298 std::vector<recob::TrajectoryPointFlags::Mask_t>& hitflagsv,
299 std::vector<KFTrackState>& fwdPrdTkState,
300 std::vector<KFTrackState>& fwdUpdTkState,
301 std::vector<unsigned int>& hitstateidx,
302 std::vector<unsigned int>& rejectedhsidx,
303 std::vector<unsigned int>& sortedtksidx,
304 bool applySkipClean)
const 306 fwdPrdTkState.clear();
307 fwdUpdTkState.clear();
309 rejectedhsidx.clear();
310 sortedtksidx.clear();
312 fwdPrdTkState.reserve(hitstatev.size());
313 fwdUpdTkState.reserve(hitstatev.size());
314 hitstateidx.reserve(hitstatev.size());
322 std::vector<std::vector<unsigned int>> hitsInPlanes(nplanes);
323 for (
unsigned int ihit = 0; ihit < hitstatev.size(); ihit++) {
324 hitsInPlanes[hitstatev[ihit].wireId().Plane].push_back(ihit);
329 auto const iplane = plane.ID().Plane;
330 if (plane.GetIncreasingWireDirection().Dot(trackState.
momentum()) > 0) {
331 std::sort(hitsInPlanes[iplane].
begin(),
332 hitsInPlanes[iplane].
end(),
333 [hitstatev](
const unsigned int& a,
const unsigned int& b) ->
bool {
334 return hitstatev[a].wireId().Wire < hitstatev[b].wireId().Wire;
338 std::sort(hitsInPlanes[iplane].
begin(),
339 hitsInPlanes[iplane].
end(),
340 [hitstatev](
const unsigned int& a,
const unsigned int& b) ->
bool {
341 return hitstatev[a].wireId().Wire > hitstatev[b].wireId().Wire;
350 for (
auto const& p : hitsInPlanes) {
352 std::cout <<
"hit #/Plane/Wire/x/mask: " << ch++ <<
" " << hitstatev[h].wireId().Plane
353 <<
" " << hitstatev[h].wireId().Wire <<
" " << hitstatev[h].hitMeas() <<
" " 354 << hitflagsv[h] << std::endl;
360 std::vector<unsigned int> iterHitsInPlanes(nplanes, 0);
361 for (
unsigned int p = 0; p < hitstatev.size(); ++p) {
362 if (
dumpLevel_ > 1) std::cout << std::endl <<
"processing hit #" << p << std::endl;
364 std::cout <<
"hit sizes: rej=" << rejectedhsidx.size() <<
" good=" << hitstateidx.size()
365 <<
" input=" << hitstatev.size() << std::endl;
367 std::cout <<
"compute distance from state=" << std::endl;
371 double min_dist = DBL_MAX;
373 for (
unsigned int iplane = 0; iplane < nplanes; ++iplane) {
376 std::cout <<
"iplane=" << iplane <<
" nplanes=" << nplanes
377 <<
" iterHitsInPlanes[iplane]=" << iterHitsInPlanes[iplane]
378 <<
" hitsInPlanes[iplane].size()=" << hitsInPlanes[iplane].size() << std::endl;
379 for (
unsigned int& ih = iterHitsInPlanes[iplane]; ih < hitsInPlanes[iplane].size(); ++ih) {
381 unsigned int ihit = hitsInPlanes[iplane][ih];
383 std::cout <<
"ih=" << ih <<
" ihit=" << ihit <<
" size=" << hitsInPlanes[iplane].size()
385 const auto& hitstate = hitstatev[ihit];
386 const auto& hitflags = hitflagsv[ihit];
391 std::cout <<
"rejecting hit flags=" 395 << hitflags << std::endl;
396 rejectedhsidx.push_back(ihit);
404 std::cout <<
"distance to plane " << iplane <<
" wire=" << hitstate.wireId().Wire
405 <<
" = " << dist <<
", min_dist=" << std::min(min_dist, 999.)
406 <<
" min_plane=" << min_plane <<
" success=" << success
407 <<
" wirepo=" << hitstate.plane().position() << std::endl;
409 rejectedhsidx.push_back(ihit);
412 if (applySkipClean &&
skipNegProp_ && fwdUpdTkState.size() > 0 &&
414 rejectedhsidx.push_back(ihit);
417 if (dist < min_dist) {
426 <<
"pick min_dist=" << min_dist <<
" min_plane=" << min_plane <<
" wire=" 429 hitstatev[hitsInPlanes[min_plane][iterHitsInPlanes[min_plane]]].wireId().Wire)
434 if (rejectedhsidx.size() + hitstateidx.size() == hitstatev.size())
439 unsigned int ihit = hitsInPlanes[min_plane][iterHitsInPlanes[min_plane]];
440 const auto* hitstate = &hitstatev[ihit];
441 iterHitsInPlanes[min_plane]++;
452 if (!propok && !(applySkipClean && fwdUpdTkState.size() > 0 &&
skipNegProp_)) {
453 if (
dumpLevel_ > 1) std::cout <<
"attempt backward prop" << std::endl;
463 std::cout <<
"hit state " << std::endl;
465 std::cout <<
"propagation result=" << propok << std::endl;
466 std::cout <<
"propagated state " << std::endl;
468 std::cout <<
"propagated planarity=" 469 << hitstate->plane().direction().Dot(hitstate->plane().position() -
472 std::cout <<
"residual=" << trackState.
residual(*hitstate)
473 <<
" chi2=" << trackState.
chi2(*hitstate) << std::endl;
478 if (applySkipClean && fwdUpdTkState.size() == 0 &&
481 std::cout <<
"rejecting first hit with residual=" << trackState.
residual(*hitstate)
483 rejectedhsidx.push_back(ihit);
484 trackState = startState;
490 auto wire = hitstate->wireId().Wire;
491 float min_chi2_wire = trackState.
chi2(*hitstate);
492 for (
unsigned int jh = iterHitsInPlanes[min_plane]; jh < hitsInPlanes[min_plane].size();
494 const unsigned int jhit = hitsInPlanes[min_plane][jh];
495 const auto& jhitstate = hitstatev[jhit];
496 if (jhitstate.wireId().Wire != wire)
break;
497 if (ihit != jhit) iterHitsInPlanes[min_plane]++;
498 float chi2 = trackState.
chi2(jhitstate);
500 std::cout <<
"additional hit on the same wire with jhit=" << jhit <<
" chi2=" << chi2
501 <<
" ihit=" << ihit <<
" min_chi2_wire=" << min_chi2_wire << std::endl;
502 if (chi2 < min_chi2_wire) {
503 min_chi2_wire = chi2;
505 std::cout <<
"\tnow using ";
508 if (ihit != jhit) rejectedhsidx.push_back(ihit);
512 rejectedhsidx.push_back(jhit);
517 hitstate = &hitstatev[ihit];
518 auto& hitflags = hitflagsv[ihit];
521 if (fwdUpdTkState.size() > 0 && applySkipClean &&
526 std::cout <<
"rejecting hit with res=" <<
std::abs(trackState.
residual(*hitstate))
527 <<
" chi2=" << trackState.
chi2(*hitstate) <<
" dist=" << min_dist
530 if (fwdUpdTkState.size() > 0)
531 trackState = fwdUpdTkState.back();
533 trackState = startState;
534 rejectedhsidx.push_back(ihit);
542 hitstateidx.push_back(ihit);
543 fwdPrdTkState.push_back(trackState);
554 if (fwdUpdTkState.size() > 0)
555 trackState = fwdUpdTkState.back();
557 trackState = startState;
558 fwdUpdTkState.push_back(trackState);
568 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
572 std::cout <<
"updated state " << std::endl;
575 fwdUpdTkState.push_back(trackState);
579 std::cout <<
"WARNING: forward propagation failed. Skip this hit..." << std::endl;
581 if (fwdPrdTkState.size() > 0)
582 trackState = fwdPrdTkState.back();
584 trackState = startState;
585 rejectedhsidx.push_back(ihit);
588 if (rejectedhsidx.size() + hitstateidx.size() == hitstatev.size())
break;
592 for (
unsigned int ihit = 0; ihit < hitstatev.size(); ++ihit) {
593 const auto& hitstate = hitstatev[ihit];
595 std::cout << std::endl <<
"processing hit #" << ihit << std::endl;
598 auto& hitflags = hitflagsv[ihit];
601 rejectedhsidx.push_back(ihit);
607 if (applySkipClean && fwdUpdTkState.size() > 0 &&
skipNegProp_) {
608 if (dist < 0. || success ==
false) {
610 std::cout <<
"WARNING: negative propagation distance. Skip this hit..." << std::endl;
612 rejectedhsidx.push_back(ihit);
634 hitstateidx.push_back(ihit);
635 fwdPrdTkState.push_back(trackState);
643 (fwdUpdTkState.size() > 0 && applySkipClean &&
647 std::cout <<
"rejecting hit with res=" <<
std::abs(trackState.
residual(hitstate))
648 <<
" chi2=" << trackState.
chi2(hitstate) <<
" dist=" << dist << std::endl;
650 if (fwdUpdTkState.size() > 0)
651 trackState = fwdUpdTkState.back();
653 trackState = startState;
654 fwdUpdTkState.push_back(trackState);
664 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
667 fwdUpdTkState.push_back(trackState);
671 std::cout <<
"WARNING: forward propagation failed. Skip this hit..." << std::endl;
674 if (fwdPrdTkState.size() > 0)
675 trackState = fwdPrdTkState.back();
677 trackState = startState;
678 rejectedhsidx.push_back(ihit);
684 if (
dumpLevel_ > 2) assert(rejectedhsidx.size() + hitstateidx.size() == hitstatev.size());
686 std::cout <<
"TRACK AFTER FWD" << std::endl;
687 std::cout <<
"hit sizes=" << rejectedhsidx.size() <<
" " << hitstateidx.size() <<
" " 688 << hitstatev.size() << std::endl;
695 startState = trackState;
699 for (
int itk = fwdPrdTkState.size() - 1; itk >= 0; itk--) {
700 auto& fwdPrdTrackState = fwdPrdTkState[itk];
701 auto& fwdUpdTrackState = fwdUpdTkState[itk];
702 const auto& hitstate = hitstatev[hitstateidx[itk]];
703 auto& hitflags = hitflagsv[hitstateidx[itk]];
705 std::cout << std::endl <<
"processing backward hit #" << itk << std::endl;
726 std::cout <<
"propagation result=" << propok << std::endl;
727 std::cout <<
"propagated state " << std::endl;
729 std::cout <<
"propagated planarity=" 730 << hitstate.plane().direction().Dot(hitstate.plane().position() -
736 bool pcombok = fwdPrdTrackState.combineWithTrackState(trackState.
trackState());
738 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
742 std::cout <<
"combined prd state " << std::endl;
743 fwdPrdTrackState.dump();
747 bool ucombok = fwdUpdTrackState.combineWithTrackState(trackState.
trackState());
749 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
753 std::cout <<
"combined upd state " << std::endl;
754 fwdUpdTrackState.dump();
758 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
762 std::cout <<
"updated state " << std::endl;
766 startState = trackState;
771 fwdUpdTrackState = fwdPrdTrackState;
782 std::cout <<
"WARNING: backward propagation failed. Skip this hit... hitstateidx[itk]=" 783 << hitstateidx[itk] <<
" itk=" << itk << std::endl;
786 trackState = startState;
791 if (nvalidhits < 4) {
792 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__ <<
" ";
796 if (
dumpLevel_ > 1) std::cout <<
"sort output with nvalidhits=" << nvalidhits << std::endl;
800 hitstatev, fwdUpdTkState, hitstateidx, rejectedhsidx, sortedtksidx, hitflagsv, applySkipClean);
801 size_t nsortvalid = 0;
802 for (
auto& idx : sortedtksidx) {
803 auto& hitflags = hitflagsv[hitstateidx[idx]];
806 if (nsortvalid < 4) {
807 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__ <<
" ";
811 if (
dumpLevel_ > 2) assert(rejectedhsidx.size() + sortedtksidx.size() == hitstatev.size());
816 std::vector<HitState>& hitstatev,
817 std::vector<KFTrackState>& fwdUpdTkState,
818 std::vector<unsigned int>& hitstateidx,
819 std::vector<unsigned int>& rejectedhsidx,
820 std::vector<unsigned int>& sortedtksidx,
821 std::vector<recob::TrajectoryPointFlags::Mask_t>& hitflagsv,
822 bool applySkipClean)
const 828 std::vector<std::vector<unsigned int>> tracksInPlanes(nplanes);
829 for (
unsigned int p = 0; p < hitstateidx.size(); ++p) {
830 const auto& hitstate = hitstatev[hitstateidx[p]];
831 tracksInPlanes[hitstate.wireId().Plane].push_back(p);
834 for (
auto s : fwdUpdTkState) {
835 std::cout <<
"state pos=" << s.position() << std::endl;
839 std::vector<unsigned int> iterTracksInPlanes;
840 for (
auto it : tracksInPlanes)
841 iterTracksInPlanes.push_back(0);
842 auto pos = fwdUpdTkState.front().position();
843 auto dir = fwdUpdTkState.front().momentum();
845 for (; p < fwdUpdTkState.size(); ++p) {
847 pos = fwdUpdTkState[p].position();
848 dir = fwdUpdTkState[p].momentum();
850 std::cout <<
"sort output found point not excluded with p=" << p
851 <<
" hitstateidx[p]=" << hitstateidx[p] <<
" pos=" << pos << std::endl;
855 rejectedhsidx.push_back(hitstateidx[p]);
859 std::cout <<
"sort output init with pos=" << pos <<
" dir=" <<
dir << std::endl;
861 for (; p < fwdUpdTkState.size(); ++p) {
863 double min_dotp = DBL_MAX;
864 for (
unsigned int iplane = 0; iplane < iterTracksInPlanes.size(); ++iplane) {
865 for (
unsigned int& itk = iterTracksInPlanes[iplane]; itk < tracksInPlanes[iplane].size();
867 auto& trackstate = fwdUpdTkState[tracksInPlanes[iplane][iterTracksInPlanes[iplane]]];
868 auto& tmppos = trackstate.position();
869 const double dotp =
dir.Dot(tmppos - pos);
871 std::cout <<
"iplane=" << iplane <<
" tmppos=" << tmppos <<
" tmpdir=" << tmppos - pos
872 <<
" dotp=" << dotp << std::endl;
873 if (dotp < min_dotp) {
880 if (min_plane < 0)
continue;
881 const unsigned int ihit = tracksInPlanes[min_plane][iterTracksInPlanes[min_plane]];
883 sortedtksidx.size() > 0) {
885 std::cout <<
"sort output rejecting hit #" << ihit <<
" plane=" << min_plane
886 <<
" with min_dotp=" << min_dotp << std::endl;
887 rejectedhsidx.push_back(hitstateidx[ihit]);
888 iterTracksInPlanes[min_plane]++;
892 std::cout <<
"sort output picking hit #" << ihit <<
" plane=" << min_plane
893 <<
" with min_dotp=" << min_dotp << std::endl;
894 auto& trackstate = fwdUpdTkState[ihit];
895 pos = trackstate.position();
896 dir = trackstate.momentum();
898 sortedtksidx.push_back(ihit);
899 iterTracksInPlanes[min_plane]++;
903 for (
unsigned int p = 0; p < fwdUpdTkState.size(); ++p) {
904 sortedtksidx.push_back(p);
909 std::vector<unsigned int> itoerase;
913 auto pos0 = fwdUpdTkState[sortedtksidx[0]].position();
915 unsigned int end = sortedtksidx.size() - 1;
916 for (; i <
end; ++i) {
917 auto dir0 = fwdUpdTkState[sortedtksidx[i]].position() - pos0;
919 fwdUpdTkState[sortedtksidx[i + 1]].position() - fwdUpdTkState[sortedtksidx[i]].position();
922 if (dir2.Dot(dir0) < 0.) {
928 pos0 = fwdUpdTkState[sortedtksidx[i]].position();
930 if (!broken) { clean =
true; }
932 rejectedhsidx.push_back(hitstateidx[sortedtksidx[i]]);
933 sortedtksidx.erase(sortedtksidx.begin() + i);
944 std::vector<HitState>& hitstatev,
945 std::vector<recob::TrajectoryPointFlags::Mask_t>& hitflagsv,
946 std::vector<KFTrackState>& fwdPrdTkState,
947 std::vector<KFTrackState>& fwdUpdTkState,
948 std::vector<unsigned int>& hitstateidx,
949 std::vector<unsigned int>& rejectedhsidx,
950 std::vector<unsigned int>& sortedtksidx,
958 for (
unsigned int p : sortedtksidx) {
959 const auto& trackstate = fwdUpdTkState[p];
960 const auto& hitflags = hitflagsv[hitstateidx[p]];
961 const unsigned int originalPos = hitstateidx[p];
962 if (
dumpLevel_ > 2) assert(originalPos < hitstatev.size());
964 const auto& prdtrack = fwdPrdTkState[p];
965 const auto& hitstate = hitstatev[hitstateidx[p]];
966 if (
dumpLevel_ > 2) assert(hitstate.wireId().Plane == inHits[originalPos]->WireID().Plane);
970 prdtrack.chi2(hitstate));
976 hitstate.hitMeasErr2(),
977 prdtrack.parameters(),
978 prdtrack.covariance(),
981 tcbk.
addPoint(trackstate.position(),
982 trackstate.momentum(),
988 if (
dumpLevel_ > 0) std::cout <<
"fillResult nvalidhits=" << nvalidhits << std::endl;
992 for (
int i = 0; i < 5; i++)
993 for (
int j = i; j < 5; j++)
995 for (
unsigned int rejidx = 0; rejidx < rejectedhsidx.size(); ++rejidx) {
996 const unsigned int originalPos = rejectedhsidx[rejidx];
997 auto& mask = hitflagsv[rejectedhsidx[rejidx]];
1003 const auto& hitstate = hitstatev[rejectedhsidx[rejidx]];
1004 if (
dumpLevel_ > 2) assert(hitstate.wireId().Plane == inHits[originalPos]->WireID().Plane);
1009 hitstate.hitMeasErr2(),
1012 hitstate.wireId()));
1016 inHits[originalPos],
1023 std::cout <<
"outHits.size()=" << outHits.size() <<
" inHits.size()=" << inHits.size()
1025 if (
dumpLevel_ > 2) assert(outHits.size() == inHits.size());
1030 fwdUpdTkState[sortedtksidx.front()].trackState(),
1031 Plane(fwdUpdTkState[sortedtksidx.front()].position(),
1032 fwdUpdTkState[sortedtksidx.front()].momentum()));
1035 fwdUpdTkState[sortedtksidx.back()].trackState(),
1036 Plane(fwdUpdTkState[sortedtksidx.back()].position(),
1037 fwdUpdTkState[sortedtksidx.back()].momentum()));
1046 mf::LogWarning(
"TrackKalmanFitter") <<
"found point with zero momentum!" << std::endl;
1052 std::cout <<
"outTrack vertex=" << outTrack.
Start() <<
"\ndir=" << outTrack.
StartDirection()
1055 <<
"\nchi2/ndof=" << outTrack.
Chi2PerNdof() << std::endl;
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
static constexpr Flag_t Merged
The hit might have contribution from particles other than this.
void addPoint(const Point_t &point, const Vector_t &vect, art::Ptr< recob::Hit > hit, const PointFlags_t &flag, double chi2)
Add a single point; different version of the functions are provided using const references or rvalue ...
const TrackState & trackState() const
Get the (const reference to the) TrackState.
WireGeo const & WireIDToWireGeo(WireID const &wireid) const
Returns the specified wire.
static constexpr Flag_t Suspicious
The point reconstruction is somehow questionable.
Flags_t const & Flags() const
Returns all flags.
static constexpr Flag_t NoPoint
The trajectory point is not defined.
bool doFitWork(KFTrackState &trackState, detinfo::DetectorPropertiesData const &detProp, std::vector< HitState > &hitstatev, std::vector< recob::TrajectoryPointFlags::Mask_t > &hitflagsv, std::vector< KFTrackState > &fwdPrdTkState, std::vector< KFTrackState > &fwdUpdTkState, std::vector< unsigned int > &hitstateidx, std::vector< unsigned int > &rejectedhsidx, std::vector< unsigned int > &sortedtksidx, bool applySkipClean=true) const
Function where the core of the fit is performed.
double GetXTicksCoefficient(int t, int c) const
recob::tracking::Point_t Point_t
recob::tracking::Vector_t Vector_t
static constexpr Mask_t DefaultFlagsMask()
Flags used in default construction.
const SMatrixSym55 & StartCovariance() const
Access to covariance matrices.
Declaration of signal hit object.
recob::tracking::SMatrixSym55 SMatrixSym55
bool HasValidPoint(size_t i) const
Various functions related to the presence and the number of (valid) points.
constexpr auto abs(T v)
Returns the absolute value of the argument.
Namespace for the trajectory point flags.
bool fitTrack(detinfo::DetectorPropertiesData const &detProp, const recob::TrackTrajectory &traj, int tkID, const SMatrixSym55 &covVtx, const SMatrixSym55 &covEnd, const std::vector< art::Ptr< recob::Hit >> &hits, const double pval, const int pdgid, const bool flipDirection, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit >> &outHits, trkmkr::OptionalOutputs &optionals) const
Fit track starting from TrackTrajectory.
art::ServiceHandle< geo::Geometry const > geom
double chi2(const HitState &hitstate) const
This function calls the homonymous function of the stored TrackState.
TrackState propagateToPlane(bool &success, const detinfo::DetectorPropertiesData &detProp, const TrackState &origin, const Plane &target, bool dodedx, bool domcs, PropDirection dir=FORWARD) const
Main function for propagation of a TrackState to a Plane.
double distanceToPlane(bool &success, const Point_t &origpos, const Vector_t &origdir, const Plane &target) const
Distance of a TrackState (Point and Vector) to a Plane, along the TrackState direction.
double MomentumAtPoint(unsigned int p) const
void setCovariance(const SMatrixSym55 &trackStateCov)
This function calls the homonymous function of the stored TrackState.
void sortOutput(std::vector< HitState > &hitstatev, std::vector< KFTrackState > &fwdUpdTkState, std::vector< unsigned int > &hitstateidx, std::vector< unsigned int > &rejectedhsidx, std::vector< unsigned int > &sortedtksidx, std::vector< recob::TrajectoryPointFlags::Mask_t > &hitflagsv, bool applySkipClean=true) const
Sort the output states.
const Point_t & position() const
This function calls the homonymous function of the stored TrackState.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Vector_t VertexDirection() const
Returns the direction of the trajectory at the first point.
Extension of a TrackState to perform KalmanFilter calculations.
Vector_t StartDirection() const
Access to track direction at different points.
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
double Length(size_t p=0) const
Access to various track properties.
double residual(const HitState &hitstate) const
This function calls the homonymous function of the stored TrackState.
bool rejectHitsNegativeGOF_
recob::tracking::SVector5 SVector5
Point_t const & Start() const
Access to track position at different points.
const SMatrixSym55 & covariance() const
This function calls the homonymous function of the stored TrackState.
bool fillResult(const std::vector< art::Ptr< recob::Hit >> &inHits, const int tkID, const int pdgid, std::vector< HitState > &hitstatev, std::vector< recob::TrajectoryPointFlags::Mask_t > &hitflagsv, std::vector< KFTrackState > &fwdPrdTkState, std::vector< KFTrackState > &fwdUpdTkState, std::vector< unsigned int > &hitstateidx, std::vector< unsigned int > &rejectedhsidx, std::vector< unsigned int > &sortedtksidx, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit >> &outHits, trkmkr::OptionalOutputs &optionals) const
Fill the output objects.
A trajectory in space reconstructed from hits.
Object storing per-hit information from a track fit.
Struct holding point-by-point elements used in OptionalOutputs.
float Chi2PerNdof() const
Access to various track properties.
TrackState rotateToPlane(bool &success, const TrackState &origin, const Plane &target) const
Rotation of a TrackState to a Plane (zero distance propagation)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Provides recob::Track data product.
const TrackStatePropagator * propagator
bool updateWithHitState(const HitState &hitstate)
Update the TrackState given a HitState (they need to be on the same plane)
Data product for reconstructed trajectory in space.
static constexpr Flag_t HitIgnored
Hit was not included for the computation of the trajectory.
The data type to uniquely identify a TPC.
Definition of data types for geometry description.
Point_t const & Vertex() const
Returns the position of the first valid point of the trajectory [cm].
Detector simulation of raw signals on wires.
static constexpr Flag_t Rejected
The hit is extraneous to this track.
static constexpr Flag_t ExcludedFromFit
double ConvertTicksToX(double ticks, int p, int t, int c) const
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
KFTrackState setupInitialTrackState(const Point_t &position, const Vector_t &direction, SMatrixSym55 &trackStateCov, const double pval, const int pdgid) const
Return track state from intial position, direction, and covariance.
size_t NextValidPoint(size_t index) const
Various functions related to the presence and the number of (valid) points.
float maxResidueFirstHit_
Encapsulate the construction of a single detector plane.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
bool sortOutputHitsMinLength_
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Helper class to aid the creation of a recob::Track, keeping data vectors in sync. ...
std::ostream & dump(std::ostream &out=std::cout) const
Printout information.
bool setupInputStates(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit >> &hits, const std::vector< recob::TrajectoryPointFlags > &flags, std::vector< HitState > &hitstatev, std::vector< recob::TrajectoryPointFlags::Mask_t > &hitflagsv) const
Setup vectors of HitState and Masks to be used during the fit.
static constexpr Flag_t DetectorIssue
The hit is associated to a problematic channel.
bool isTrackFitInfosInit()
check initialization of the output vector of TrackFitHitInfos
recob::Track finalizeTrack(const recob::tracking::SMatrixSym55 &covStart, const recob::tracking::SMatrixSym55 &covEnd)
Get the finalized recob::Track; needs the start and end covariance matrices.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
static constexpr Flag_t DeltaRay
The hit might have contribution from a δ ray.
constexpr double kBogusD
obviously bogus double value
const Vector_t & momentum() const
This function calls the homonymous function of the stored TrackState.
std::ostream & dump(std::ostream &out=std::cout) const
Printout information.
void setTrackFitHitInfo(recob::TrackFitHitInfo &&aTrackFitHitInfo)
set the recob::TrackFitHitInfo unique_ptr
Collection of Physical constants used in LArSoft.
const Plane & plane() const
plane where the parameters are defined
recob::tracking::Plane Plane
static constexpr Flag_t Shared
The hit is known to be associated also to another trajectory.
Struct holding optional TrackMaker outputs.
Set of flags pertaining a point of the track.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: