00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TMLine_FLAG_
00014 #define TMLine_FLAG_
00015
00016 #ifdef TRKRECO_DEBUG_DETAIL
00017 #ifndef TRKRECO_DEBUG
00018 #define TRKRECO_DEBUG
00019 #endif
00020 #endif
00021
00022 #include <string>
00023
00024 #define HEP_SHORT_NAMES
00025
00026 #include "TrkReco/TTrackBase.h"
00027 #include "TrkReco/TMLink.h"
00028 #include "TrkReco/TLineFitter.h"
00029
00030 #ifndef CLHEP_POINT3D_H
00031 #include "CLHEP/Geometry/Point3D.h"
00032 #endif
00033 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00034 typedef HepGeom::Point3D<double> HepPoint3D;
00035 #endif
00036
00037
00038
00040 class TMLine : public TTrackBase {
00041
00042 public:
00044 TMLine();
00045
00047 TMLine(const AList<TMLink> &);
00048
00050 virtual ~TMLine();
00051
00052 public:
00054 virtual unsigned objectType(void) const;
00055
00057 void dump(const std::string & message = std::string(""),
00058 const std::string & prefix = std::string("")) const;
00059
00061 double a(void) const;
00062
00064 double b(void) const;
00065
00067 double chi2(void) const;
00068
00070 double reducedChi2(void) const;
00071
00072 public:
00074 double distance(const TMLink &) const;
00075 double distance(const HepPoint3D &) const;
00076
00077 public:
00079
00080
00082 int fit2();
00083
00085 int fit2s();
00086
00088 int fit2p();
00089
00091 int fit2sp();
00092
00094 void removeChits();
00095
00097 void refine(AList<TMLink> & list, float maxSigma);
00098
00100 void removeSLY(AList<TMLink> & list);
00101
00103 void appendSLY(AList<TMLink> & list);
00104
00106 void appendByszdistance(AList<TMLink> & list, unsigned isl, float maxSigma);
00107
00109 void property(double a, double b, double det);
00110
00111 private:
00112 mutable bool _fittedUpdated;
00113
00114 private:
00115 double _a;
00116 double _b;
00117 double _det;
00118 static const TLineFitter _fitter;
00119
00120 private:
00121 mutable double _chi2;
00122 mutable double _reducedChi2;
00123 };
00124
00126 #if defined(__GNUG__)
00127 int
00128 SortByB(const TMLine ** a, const TMLine ** b);
00129 #else
00130 extern "C" int
00131 SortByB(const void* a, const void* b);
00132 #endif
00133
00134
00135
00136 #ifdef TMLine_NO_INLINE
00137 #define inline
00138 #else
00139 #undef inline
00140 #define TMLine_INLINE_DEFINE_HERE
00141 #endif
00142
00143 #ifdef TMLine_INLINE_DEFINE_HERE
00144
00145 inline
00146 double
00147 TMLine::a(void) const {
00148 #ifdef TRKRECO_DEBUG
00149 if (! _fitted) std::cout << "TMLine::a !!! fit not performed" << std::endl;
00150 #endif
00151 return _a;
00152 }
00153
00154 inline
00155 double
00156 TMLine::b(void) const {
00157 #ifdef TRKRECO_DEBUG
00158 if (! _fitted) std::cout << "TMLine::b !!! fit not performed" << std::endl;
00159 #endif
00160 return _b;
00161 }
00162
00163 inline
00164 double
00165 TMLine::distance(const TMLink & l) const {
00166 #ifdef TRKRECO_DEBUG
00167 if (! _fitted) std::cout << "TMLine::distance !!! fit not performed" << std::endl;
00168 #endif
00169 double dy = fabs(_a * l.position().x() + _b - l.position().y());
00170 double invCos = sqrt(1. + _a * _a);
00171 return dy / invCos;
00172 }
00173
00174 inline
00175 double
00176 TMLine::distance(const HepPoint3D & p) const {
00177 #ifdef TRKRECO_DEBUG
00178 if (! _fitted) std::cout << "TMLine::distance !!! fit not performed" << std::endl;
00179 #endif
00180 double dy = fabs(_a * p.x() + _b - p.y());
00181 double invCos = sqrt(1. + _a * _a);
00182 return dy / invCos;
00183 }
00184
00185 inline
00186 void
00187 TMLine::property(double a, double b, double det) {
00188 _a = a;
00189 _b = b;
00190 _det = det;
00191 }
00192
00193 inline
00194 unsigned
00195 TMLine::objectType(void) const {
00196 return Line;
00197 }
00198
00199 #endif
00200
00201 #undef inline
00202
00203 #endif