LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
KFitTrack.cxx
Go to the documentation of this file.
1 
12 #include "cetlib_except/exception.h"
13 
14 namespace trkf {
15 
17  KFitTrack::KFitTrack() : fPath(0.), fChisq(0.), fStat(INVALID) {}
18 
28  KFitTrack::KFitTrack(const KETrack& tre, double s, double chisq, FitStatus stat)
29  : KETrack(tre), fPath(s), fChisq(chisq), fStat(stat)
30  {}
31 
34 
66  {
67  // Make sure that the two track surfaces are the same.
68  // Throw an exception if they are not.
69 
70  if (!getSurface()->isEqual(*trf.getSurface()))
71  throw cet::exception("KFitTrack") << "Track combination surfaces are not the same.\n";
72 
73  // Default result failure.
74 
75  bool result = false;
76 
77  // Make sure input statuses are compatible and figure out the
78  // updated status.
79 
80  FitStatus stat1 = getStat();
81  FitStatus stat2 = trf.getStat();
82  FitStatus statu = UNKNOWN;
83  if ((stat1 == FORWARD && stat2 == BACKWARD_PREDICTED) ||
84  (stat1 == FORWARD_PREDICTED && stat2 == BACKWARD) ||
85  (stat1 == BACKWARD && stat2 == FORWARD_PREDICTED) ||
86  (stat1 == BACKWARD_PREDICTED && stat2 == FORWARD))
87  statu = OPTIMAL;
88  else if (stat1 == FORWARD_PREDICTED && stat2 == BACKWARD_PREDICTED)
89  statu = OPTIMAL_PREDICTED;
90  else
91  statu = UNKNOWN;
92  if (statu != UNKNOWN) {
93 
94  // Update track parameters and error matrix.
95 
96  std::optional<double> chisq = combineTrack(trf);
97 
98  // Update status and chisquare.
99 
100  if (!!chisq) {
101  result = true;
102  fStat = statu;
103  fChisq = fChisq + trf.getChisq() + *chisq;
104  }
105  }
106 
107  // Done.
108 
109  return result;
110  }
111 
113  std::ostream& KFitTrack::Print(std::ostream& out, bool doTitle) const
114  {
115  if (doTitle) out << "KFitTrack:\n";
116 
117  // Print information specific to this class.
118 
119  out << " Distance = " << fPath << "\n";
120  out << " Chisquare = " << fChisq << "\n";
121  out << " Status = "
122  << (fStat == INVALID ?
123  "INVALID" :
124  (fStat == UNKNOWN ?
125  "UNKNOWN" :
126  (fStat == FORWARD ?
127  "FORWARD" :
128  (fStat == FORWARD_PREDICTED ?
129  "FORWARD_PREDICTED" :
130  (fStat == BACKWARD ?
131  "BACKWARD" :
132  (fStat == BACKWARD_PREDICTED ?
133  "BACKWARD_PREDICTED" :
134  (fStat == OPTIMAL ? "OPTIMAL" : "OPTIMAL_PREDICTED")))))))
135  << "\n";
136 
137  // Print base class.
138 
139  KETrack::Print(out, false);
140  return out;
141  }
142 
143 } // end namespace trkf
const std::shared_ptr< const Surface > & getSurface() const
Surface.
Definition: KTrack.h:53
FitStatus
Fit status enum.
Definition: KFitTrack.h:39
FitStatus fStat
Fit status.
Definition: KFitTrack.h:82
virtual std::ostream & Print(std::ostream &out, bool doTitle=true) const
Printout.
Definition: KFitTrack.cxx:113
std::optional< double > combineTrack(const KETrack &tre)
Combine two tracks.
Definition: KETrack.cxx:87
double fChisq
Fit chisquare.
Definition: KFitTrack.h:81
KFitTrack()
Default constructor.
Definition: KFitTrack.cxx:17
virtual ~KFitTrack()
Destructor.
Definition: KFitTrack.cxx:33
bool combineFit(const KFitTrack &trf)
Combine two tracks.
Definition: KFitTrack.cxx:65
virtual std::ostream & Print(std::ostream &out, bool doTitle=true) const
Printout.
Definition: KETrack.cxx:179
double fPath
Propagation distance.
Definition: KFitTrack.h:80
Basic Kalman filter track class, with fit information.
double getChisq() const
Fit chisquare.
Definition: KFitTrack.h:62
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
FitStatus getStat() const
Fit status.
Definition: KFitTrack.h:63