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" 45 const bool flipDirection,
55 std::vector<art::Ptr<recob::Hit>> fwdHits;
72 std::vector<art::Ptr<recob::Hit>> bwdHits;
88 if (okfwd ==
false && okbwd ==
false) {
return false; }
89 else if (okfwd ==
true && okbwd ==
true) {
90 if ((fwdTrack.CountValidPoints() / (fwdTrack.Length() * fwdTrack.Chi2PerNdof())) >=
91 (bwdTrack.CountValidPoints() / (bwdTrack.Length() * bwdTrack.Chi2PerNdof()))) {
102 else if (okfwd ==
true) {
120 auto trackStateCov = (flipDirection ? covEnd : covVtx);
143 const std::vector<recob::TrajectoryPointFlags>& flags,
152 std::cout <<
"Fitting track with tkID=" << tkID <<
" start pos=" << position
153 <<
" dir=" << direction <<
" nHits=" << hits.size() <<
" mom=" << pval
155 if (hits.size() < 4) {
156 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
165 std::vector<HitState> hitstatev;
166 std::vector<recob::TrajectoryPointFlags::Mask_t> hitflagsv;
167 bool inputok =
setupInputStates(detProp, hits, flags, trackState, hitstatev, hitflagsv);
168 if (!inputok)
return false;
171 std::vector<KFTrackState> fwdPrdTkState;
172 std::vector<KFTrackState> fwdUpdTkState;
173 std::vector<unsigned int> hitstateidx;
174 std::vector<unsigned int> rejectedhsidx;
175 std::vector<unsigned int> sortedtksidx;
189 <<
"Trying to recover with skipNegProp = false and cleanZigzag = false\n";
202 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failed for track with ID=" << tkID <<
"\n";
228 const int pdgid)
const 232 trackStateCov(0, 0) = 1000.;
233 trackStateCov(1, 1) = 1000.;
234 trackStateCov(2, 2) = 0.25;
235 trackStateCov(3, 3) = 0.25;
236 trackStateCov(4, 4) = 10.;
239 trackStateCov *= 100.;
241 SVector5 trackStatePar(0., 0., 0., 0., 1. / pval);
244 Plane(position, direction),
253 const std::vector<recob::TrajectoryPointFlags>& flags,
255 std::vector<HitState>& hitstatev,
256 std::vector<recob::TrajectoryPointFlags::Mask_t>& hitflagsv)
const 259 std::cout <<
"flags.size()=" << flags.size() <<
" hits.size()=" << hits.size() <<
std::endl;
263 const size_t fsize = flags.size();
264 for (
size_t ihit = 0; ihit != hits.size(); ihit++) {
265 const auto&
hit = hits[ihit];
266 double t =
hit->PeakTime();
271 hitstatev.emplace_back(
274 if (fsize > 0 && ihit < fsize)
275 hitflagsv.push_back(flags[ihit].
mask());
289 std::cout <<
"pushed flag mask=" << hitflagsv.back()
296 if (
dumpLevel_ > 2) assert(hits.size() == hitstatev.size());
303 std::vector<HitState>& hitstatev,
304 std::vector<recob::TrajectoryPointFlags::Mask_t>& hitflagsv,
305 std::vector<KFTrackState>& fwdPrdTkState,
306 std::vector<KFTrackState>& fwdUpdTkState,
307 std::vector<unsigned int>& hitstateidx,
308 std::vector<unsigned int>& rejectedhsidx,
309 std::vector<unsigned int>& sortedtksidx,
310 bool applySkipClean)
const 312 fwdPrdTkState.clear();
313 fwdUpdTkState.clear();
315 rejectedhsidx.clear();
316 sortedtksidx.clear();
318 fwdPrdTkState.reserve(hitstatev.size());
319 fwdUpdTkState.reserve(hitstatev.size());
320 hitstateidx.reserve(hitstatev.size());
328 std::vector<std::vector<unsigned int>> hitsInPlanes(nplanes);
329 for (
unsigned int ihit = 0; ihit < hitstatev.size(); ihit++) {
330 hitsInPlanes[hitstatev[ihit].wireId().Plane].push_back(ihit);
333 for (
unsigned int iplane = 0; iplane < nplanes; ++iplane) {
336 std::sort(hitsInPlanes[iplane].
begin(),
337 hitsInPlanes[iplane].
end(),
338 [hitstatev](
const unsigned int&
a,
const unsigned int&
b) ->
bool {
339 return hitstatev[
a].wireId().Wire < hitstatev[
b].wireId().Wire;
343 std::sort(hitsInPlanes[iplane].
begin(),
344 hitsInPlanes[iplane].
end(),
345 [hitstatev](
const unsigned int&
a,
const unsigned int&
b) ->
bool {
346 return hitstatev[
a].wireId().Wire > hitstatev[
b].wireId().Wire;
355 for (
auto p : hitsInPlanes) {
357 std::cout <<
"hit #/Plane/Wire/x/mask: " << ch++ <<
" " << hitstatev[
h].wireId().Plane
358 <<
" " << hitstatev[
h].wireId().Wire <<
" " << hitstatev[
h].hitMeas() <<
" " 365 std::vector<unsigned int> iterHitsInPlanes(nplanes, 0);
366 for (
unsigned int p = 0;
p < hitstatev.size(); ++
p) {
369 std::cout <<
"hit sizes: rej=" << rejectedhsidx.size() <<
" good=" << hitstateidx.size()
370 <<
" input=" << hitstatev.size() <<
std::endl;
372 std::cout <<
"compute distance from state=" <<
std::endl;
376 double min_dist = DBL_MAX;
378 for (
unsigned int iplane = 0; iplane < nplanes; ++iplane) {
381 std::cout <<
"iplane=" << iplane <<
" nplanes=" << nplanes
382 <<
" iterHitsInPlanes[iplane]=" << iterHitsInPlanes[iplane]
383 <<
" hitsInPlanes[iplane].size()=" << hitsInPlanes[iplane].size() <<
std::endl;
384 for (
unsigned int&
ih = iterHitsInPlanes[iplane];
ih < hitsInPlanes[iplane].size(); ++
ih) {
386 unsigned int ihit = hitsInPlanes[iplane][
ih];
388 std::cout <<
"ih=" <<
ih <<
" ihit=" << ihit <<
" size=" << hitsInPlanes[iplane].size()
390 const auto& hitstate = hitstatev[ihit];
391 const auto& hitflags = hitflagsv[ihit];
396 std::cout <<
"rejecting hit flags=" 401 rejectedhsidx.push_back(ihit);
409 std::cout <<
"distance to plane " << iplane <<
" wire=" << hitstate.wireId().Wire
410 <<
" = " << dist <<
", min_dist=" <<
std::min(min_dist, 999.)
411 <<
" min_plane=" << min_plane <<
" success=" << success
412 <<
" wirepo=" << hitstate.plane().position() <<
std::endl;
414 rejectedhsidx.push_back(ihit);
417 if (applySkipClean &&
skipNegProp_ && fwdUpdTkState.size() > 0 &&
419 rejectedhsidx.push_back(ihit);
422 if (dist < min_dist) {
431 <<
"pick min_dist=" << min_dist <<
" min_plane=" << min_plane <<
" wire=" 434 hitstatev[hitsInPlanes[min_plane][iterHitsInPlanes[min_plane]]].wireId().Wire)
439 if (rejectedhsidx.size() + hitstateidx.size() == hitstatev.size())
444 unsigned int ihit = hitsInPlanes[min_plane][iterHitsInPlanes[min_plane]];
445 const auto* hitstate = &hitstatev[ihit];
446 iterHitsInPlanes[min_plane]++;
457 if (!propok && !(applySkipClean && fwdUpdTkState.size() > 0 &&
skipNegProp_)) {
470 std::cout <<
"propagation result=" << propok <<
std::endl;
471 std::cout <<
"propagated state " <<
std::endl;
473 std::cout <<
"propagated planarity=" 474 << hitstate->plane().direction().Dot(hitstate->plane().position() -
477 std::cout <<
"residual=" << trackState.
residual(*hitstate)
483 if (applySkipClean && fwdUpdTkState.size() == 0 &&
486 std::cout <<
"rejecting first hit with residual=" << trackState.
residual(*hitstate)
488 rejectedhsidx.push_back(ihit);
489 trackState = startState;
495 auto wire = hitstate->wireId().Wire;
496 float min_chi2_wire = trackState.
chi2(*hitstate);
497 for (
unsigned int jh = iterHitsInPlanes[min_plane]; jh < hitsInPlanes[min_plane].size();
499 const unsigned int jhit = hitsInPlanes[min_plane][jh];
500 const auto& jhitstate = hitstatev[jhit];
501 if (jhitstate.wireId().Wire != wire)
break;
502 if (ihit != jhit) iterHitsInPlanes[min_plane]++;
503 float chi2 = trackState.
chi2(jhitstate);
505 std::cout <<
"additional hit on the same wire with jhit=" << jhit <<
" chi2=" << chi2
506 <<
" ihit=" << ihit <<
" min_chi2_wire=" << min_chi2_wire <<
std::endl;
507 if (chi2 < min_chi2_wire) {
508 min_chi2_wire = chi2;
510 std::cout <<
"\tnow using ";
513 if (ihit != jhit) rejectedhsidx.push_back(ihit);
517 rejectedhsidx.push_back(jhit);
522 hitstate = &hitstatev[ihit];
523 auto& hitflags = hitflagsv[ihit];
526 if (fwdUpdTkState.size() > 0 && applySkipClean &&
531 std::cout <<
"rejecting hit with res=" <<
std::abs(trackState.
residual(*hitstate))
532 <<
" chi2=" << trackState.
chi2(*hitstate) <<
" dist=" << min_dist
535 if (fwdUpdTkState.size() > 0)
536 trackState = fwdUpdTkState.back();
538 trackState = startState;
539 rejectedhsidx.push_back(ihit);
547 hitstateidx.push_back(ihit);
548 fwdPrdTkState.push_back(trackState);
559 if (fwdUpdTkState.size() > 0)
560 trackState = fwdUpdTkState.back();
562 trackState = startState;
563 fwdUpdTkState.push_back(trackState);
573 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
577 std::cout <<
"updated state " <<
std::endl;
580 fwdUpdTkState.push_back(trackState);
584 std::cout <<
"WARNING: forward propagation failed. Skip this hit..." <<
std::endl;
586 if (fwdPrdTkState.size() > 0)
587 trackState = fwdPrdTkState.back();
589 trackState = startState;
590 rejectedhsidx.push_back(ihit);
593 if (rejectedhsidx.size() + hitstateidx.size() == hitstatev.size())
break;
597 for (
unsigned int ihit = 0; ihit < hitstatev.size(); ++ihit) {
598 const auto& hitstate = hitstatev[ihit];
603 auto& hitflags = hitflagsv[ihit];
606 rejectedhsidx.push_back(ihit);
612 if (applySkipClean && fwdUpdTkState.size() > 0 &&
skipNegProp_) {
613 if (dist < 0. || success ==
false) {
615 std::cout <<
"WARNING: negative propagation distance. Skip this hit..." <<
std::endl;
617 rejectedhsidx.push_back(ihit);
639 hitstateidx.push_back(ihit);
640 fwdPrdTkState.push_back(trackState);
648 (fwdUpdTkState.size() > 0 && applySkipClean &&
652 std::cout <<
"rejecting hit with res=" <<
std::abs(trackState.
residual(hitstate))
653 <<
" chi2=" << trackState.
chi2(hitstate) <<
" dist=" << dist <<
std::endl;
655 if (fwdUpdTkState.size() > 0)
656 trackState = fwdUpdTkState.back();
658 trackState = startState;
659 fwdUpdTkState.push_back(trackState);
669 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
672 fwdUpdTkState.push_back(trackState);
676 std::cout <<
"WARNING: forward propagation failed. Skip this hit..." <<
std::endl;
679 if (fwdPrdTkState.size() > 0)
680 trackState = fwdPrdTkState.back();
682 trackState = startState;
683 rejectedhsidx.push_back(ihit);
689 if (
dumpLevel_ > 2) assert(rejectedhsidx.size() + hitstateidx.size() == hitstatev.size());
691 std::cout <<
"TRACK AFTER FWD" <<
std::endl;
692 std::cout <<
"hit sizes=" << rejectedhsidx.size() <<
" " << hitstateidx.size() <<
" " 700 startState = trackState;
704 for (
int itk = fwdPrdTkState.size() - 1; itk >= 0; itk--) {
705 auto& fwdPrdTrackState = fwdPrdTkState[itk];
706 auto& fwdUpdTrackState = fwdUpdTkState[itk];
707 const auto& hitstate = hitstatev[hitstateidx[itk]];
708 auto& hitflags = hitflagsv[hitstateidx[itk]];
731 std::cout <<
"propagation result=" << propok <<
std::endl;
732 std::cout <<
"propagated state " <<
std::endl;
734 std::cout <<
"propagated planarity=" 735 << hitstate.plane().direction().Dot(hitstate.plane().position() -
741 bool pcombok = fwdPrdTrackState.combineWithTrackState(trackState.
trackState());
743 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
747 std::cout <<
"combined prd state " <<
std::endl;
748 fwdPrdTrackState.dump();
752 bool ucombok = fwdUpdTrackState.combineWithTrackState(trackState.
trackState());
754 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
758 std::cout <<
"combined upd state " <<
std::endl;
759 fwdUpdTrackState.dump();
763 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__;
767 std::cout <<
"updated state " <<
std::endl;
771 startState = trackState;
776 fwdUpdTrackState = fwdPrdTrackState;
787 std::cout <<
"WARNING: backward propagation failed. Skip this hit... hitstateidx[itk]=" 788 << hitstateidx[itk] <<
" itk=" << itk <<
std::endl;
791 trackState = startState;
796 if (nvalidhits < 4) {
797 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__ <<
" ";
801 if (
dumpLevel_ > 1) std::cout <<
"sort output with nvalidhits=" << nvalidhits <<
std::endl;
805 hitstatev, fwdUpdTkState, hitstateidx, rejectedhsidx, sortedtksidx, hitflagsv, applySkipClean);
806 size_t nsortvalid = 0;
807 for (
auto& idx : sortedtksidx) {
808 auto& hitflags = hitflagsv[hitstateidx[idx]];
811 if (nsortvalid < 4) {
812 mf::LogWarning(
"TrackKalmanFitter") <<
"Fit failure at " << __FILE__ <<
" " << __LINE__ <<
" ";
816 if (
dumpLevel_ > 2) assert(rejectedhsidx.size() + sortedtksidx.size() == hitstatev.size());
822 std::vector<KFTrackState>& fwdUpdTkState,
823 std::vector<unsigned int>& hitstateidx,
824 std::vector<unsigned int>& rejectedhsidx,
825 std::vector<unsigned int>& sortedtksidx,
826 std::vector<recob::TrajectoryPointFlags::Mask_t>& hitflagsv,
827 bool applySkipClean)
const 833 std::vector<std::vector<unsigned int>> tracksInPlanes(nplanes);
834 for (
unsigned int p = 0;
p < hitstateidx.size(); ++
p) {
835 const auto& hitstate = hitstatev[hitstateidx[
p]];
836 tracksInPlanes[hitstate.wireId().Plane].push_back(
p);
839 for (
auto s : fwdUpdTkState) {
840 std::cout <<
"state pos=" <<
s.position() <<
std::endl;
844 std::vector<unsigned int> iterTracksInPlanes;
845 for (
auto it : tracksInPlanes)
846 iterTracksInPlanes.push_back(0);
847 auto pos = fwdUpdTkState.front().position();
848 auto dir = fwdUpdTkState.front().momentum();
850 for (; p < fwdUpdTkState.size(); ++
p) {
852 pos = fwdUpdTkState[
p].position();
853 dir = fwdUpdTkState[
p].momentum();
855 std::cout <<
"sort output found point not excluded with p=" << p
856 <<
" hitstateidx[p]=" << hitstateidx[
p] <<
" pos=" <<
pos <<
std::endl;
860 rejectedhsidx.push_back(hitstateidx[p]);
864 std::cout <<
"sort output init with pos=" <<
pos <<
" dir=" <<
dir <<
std::endl;
866 for (; p < fwdUpdTkState.size(); ++
p) {
868 double min_dotp = DBL_MAX;
869 for (
unsigned int iplane = 0; iplane < iterTracksInPlanes.size(); ++iplane) {
870 for (
unsigned int& itk = iterTracksInPlanes[iplane]; itk < tracksInPlanes[iplane].size();
872 auto& trackstate = fwdUpdTkState[tracksInPlanes[iplane][iterTracksInPlanes[iplane]]];
873 auto& tmppos = trackstate.position();
874 const double dotp =
dir.Dot(tmppos -
pos);
876 std::cout <<
"iplane=" << iplane <<
" tmppos=" << tmppos <<
" tmpdir=" << tmppos -
pos 878 if (dotp < min_dotp) {
885 if (min_plane < 0)
continue;
886 const unsigned int ihit = tracksInPlanes[min_plane][iterTracksInPlanes[min_plane]];
888 sortedtksidx.size() > 0) {
890 std::cout <<
"sort output rejecting hit #" << ihit <<
" plane=" << min_plane
891 <<
" with min_dotp=" << min_dotp <<
std::endl;
892 rejectedhsidx.push_back(hitstateidx[ihit]);
893 iterTracksInPlanes[min_plane]++;
897 std::cout <<
"sort output picking hit #" << ihit <<
" plane=" << min_plane
898 <<
" with min_dotp=" << min_dotp <<
std::endl;
899 auto& trackstate = fwdUpdTkState[ihit];
900 pos = trackstate.position();
901 dir = trackstate.momentum();
903 sortedtksidx.push_back(ihit);
904 iterTracksInPlanes[min_plane]++;
908 for (
unsigned int p = 0;
p < fwdUpdTkState.size(); ++
p) {
909 sortedtksidx.push_back(
p);
914 std::vector<unsigned int> itoerase;
918 auto pos0 = fwdUpdTkState[sortedtksidx[0]].position();
920 unsigned int end = sortedtksidx.size() - 1;
921 for (; i <
end; ++i) {
922 auto dir0 = fwdUpdTkState[sortedtksidx[i]].position() - pos0;
924 fwdUpdTkState[sortedtksidx[i + 1]].position() - fwdUpdTkState[sortedtksidx[i]].position();
927 if (dir2.Dot(dir0) < 0.) {
933 pos0 = fwdUpdTkState[sortedtksidx[i]].position();
935 if (!broken) { clean =
true; }
937 rejectedhsidx.push_back(hitstateidx[sortedtksidx[i]]);
938 sortedtksidx.erase(sortedtksidx.begin() + i);
949 std::vector<HitState>& hitstatev,
950 std::vector<recob::TrajectoryPointFlags::Mask_t>& hitflagsv,
951 std::vector<KFTrackState>& fwdPrdTkState,
952 std::vector<KFTrackState>& fwdUpdTkState,
953 std::vector<unsigned int>& hitstateidx,
954 std::vector<unsigned int>& rejectedhsidx,
955 std::vector<unsigned int>& sortedtksidx,
963 for (
unsigned int p : sortedtksidx) {
964 const auto& trackstate = fwdUpdTkState[
p];
965 const auto& hitflags = hitflagsv[hitstateidx[
p]];
966 const unsigned int originalPos = hitstateidx[
p];
967 if (
dumpLevel_ > 2) assert(originalPos >= 0 && originalPos < hitstatev.size());
969 const auto& prdtrack = fwdPrdTkState[
p];
970 const auto& hitstate = hitstatev[hitstateidx[
p]];
971 if (
dumpLevel_ > 2) assert(hitstate.wireId().Plane == inHits[originalPos]->WireID().Plane);
975 prdtrack.chi2(hitstate));
981 hitstate.hitMeasErr2(),
982 prdtrack.parameters(),
983 prdtrack.covariance(),
986 tcbk.
addPoint(trackstate.position(),
987 trackstate.momentum(),
997 for (
int i = 0; i < 5; i++)
998 for (
int j = i; j < 5; j++)
1000 for (
unsigned int rejidx = 0; rejidx < rejectedhsidx.size(); ++rejidx) {
1001 const unsigned int originalPos = rejectedhsidx[rejidx];
1002 auto&
mask = hitflagsv[rejectedhsidx[rejidx]];
1008 const auto& hitstate = hitstatev[rejectedhsidx[rejidx]];
1009 if (
dumpLevel_ > 2) assert(hitstate.wireId().Plane == inHits[originalPos]->WireID().Plane);
1014 hitstate.hitMeasErr2(),
1017 hitstate.wireId()));
1021 inHits[originalPos],
1028 std::cout <<
"outHits.size()=" << outHits.size() <<
" inHits.size()=" << inHits.size()
1030 if (
dumpLevel_ > 2) assert(outHits.size() == inHits.size());
1035 fwdUpdTkState[sortedtksidx.front()].trackState(),
1036 Plane(fwdUpdTkState[sortedtksidx.front()].position(),
1037 fwdUpdTkState[sortedtksidx.front()].momentum()));
1040 fwdUpdTkState[sortedtksidx.back()].trackState(),
1041 Plane(fwdUpdTkState[sortedtksidx.back()].position(),
1042 fwdUpdTkState[sortedtksidx.back()].momentum()));
1057 std::cout <<
"outTrack vertex=" << outTrack.
Start() <<
"\ndir=" << outTrack.
StartDirection()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
static constexpr Flag_t Merged
The hit might have contribution from particles other than this.
const TrackState & trackState() const
Get the (const reference to the) TrackState.
static constexpr Flag_t Suspicious
The point reconstruction is somehow questionable.
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
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.
recob::tracking::SMatrixSym55 SMatrixSym55
bool HasValidPoint(size_t i) const
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
bool setupInputStates(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit >> &hits, const std::vector< recob::TrajectoryPointFlags > &flags, const KFTrackState &trackState, std::vector< HitState > &hitstatev, std::vector< recob::TrajectoryPointFlags::Mask_t > &hitflagsv) const
Setup vectors of HitState and Masks to be used during the fit.
double chi2(const HitState &hitstate) const
Vector GetIncreasingWireDirection() const
Returns the direction of increasing wires.
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)
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
void addPoint(const Point_t &point, const Vector_t &vect, art::Ptr< Hit > hit, const PointFlags_t &flag, double chi2)
Add a single point; different version of the functions are provided using const references or rvalue ...
Vector_t VertexDirection() const
Returns the direction of the trajectory at the first point.
Track finalizeTrack(const tracking::SMatrixSym55 &covStart, const tracking::SMatrixSym55 &covEnd)
Get the finalized recob::Track; needs the start and end covariance matrices.
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
bool rejectHitsNegativeGOF_
recob::tracking::SVector5 SVector5
Point_t const & Start() const
Access to track position at different points.
const SMatrixSym55 & covariance() const
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
TrackState rotateToPlane(bool &success, const TrackState &origin, const Plane &target) const
Rotation of a TrackState to a Plane (zero distance propagation)
const TrackStatePropagator * propagator
bool updateWithHitState(const HitState &hitstate)
Update the TrackState given a HitState (they need to be on the same plane)
static constexpr Flag_t HitIgnored
Hit was not included for the computation of the trajectory.
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.
Declaration of signal hit object.
size_t NextValidPoint(size_t index) const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
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
Provides recob::Track data product.
Helper class to aid the creation of a recob::Track, keeping data vectors in sync. ...
static constexpr Flag_t DetectorIssue
The hit is associated to a problematic channel.
bool isTrackFitInfosInit()
check initialization of the output vector of TrackFitHitInfos
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
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:
QTextStream & endl(QTextStream &s)
WireGeo const & WireIDToWireGeo(geo::WireID const &wireid) const