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