00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TSegment_FLAG_
00014 #define TSegment_FLAG_
00015
00016 #ifdef TRKRECO_DEBUG_DETAIL
00017 #ifndef TRKRECO_DEBUG
00018 #define TRKRECO_DEBUG
00019 #endif
00020 #endif
00021 #ifndef CLHEP_POINT3D_H
00022 #include "CLHEP/Geometry/Point3D.h"
00023 #endif
00024 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00025 typedef HepGeom::Point3D<double> HepPoint3D;
00026 #endif
00027 #include "CLHEP/Geometry/Vector3D.h"
00028 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00029 typedef HepGeom::Vector3D<double> HepVector3D;
00030 #endif
00031
00032 #include "TrkReco/TTrackBase.h"
00033 #include "TrkReco/TMDCUtil.h"
00034 #include "TrkReco/TMLink.h"
00035
00036 class TTrack;
00037 class Range;
00038 template <class T> class CAList;
00039
00040 #define TSegmentCrowd 8
00041
00043 class TSegment : public TTrackBase {
00044
00045 public:
00047 TSegment();
00048 TSegment(const AList<TMLink> &);
00049
00051 virtual ~TSegment();
00052
00053 public:
00055 virtual unsigned objectType(void) const;
00056
00058 void dump(const std::string & message = std::string(""),
00059 const std::string & prefix = std::string("")) const;
00060
00062 unsigned superLayerId() const;
00063
00065 const HepPoint3D & position(void) const;
00066 const HepPoint3D & outerPosition(void) const;
00067
00069 const HepPoint3D & lineTsf(void) const;
00070 const HepPoint3D & lineTsf(const HepPoint3D &);
00071
00073 const HepVector3D & direction(void) const;
00074
00076 double distance(const TSegment &) const;
00077 double distance(const HepPoint3D &, const HepVector3D &) const;
00078
00080 Range rangeX(double min, double max) const;
00081
00083 const AList<TMLink> & inners(void) const;
00084 const AList<TMLink> & outers(void) const;
00085
00087 const TMLink & center(void) const;
00088
00090 unsigned width(void) const;
00091
00093 unsigned innerWidth(void) const;
00094
00096 unsigned outerWidth(void) const;
00097
00099 unsigned innerMostLayer(void) const;
00100
00102 unsigned outerMostLayer(void) const;
00103
00105 unsigned clusterType(void) const;
00106
00108 AList<TSegment> split(void) const;
00109
00110
00111 AList<TSegment> splitTsf(AList<TMLink> &);
00112
00113 int solveDualHits(void);
00114 double duality(void) const;
00115
00117 void solveLR(void);
00118 void solveThreeHits(void);
00119
00120 public:
00121 AList<TTrack> & tracks(void);
00122
00123 public:
00124 AList<TSegment> & innerLinks(void);
00125 const AList<TSegment> & innerLinks(void) const;
00126 AList<TSegment> & outerLinks(void);
00127 const AList<TSegment> & outerLinks(void) const;
00128 unsigned state(void) const;
00129 unsigned state(unsigned);
00130
00131 private:
00132 AList<TSegment> splitAV(void) const;
00133 AList<TSegment> splitParallel(void) const;
00134 AList<TSegment> splitComplicated(void) const;
00135 AList<TSegment> splitDual(void) const;
00136
00137 private:
00139 void update(void) const;
00140
00142 void updateType(void) const;
00143
00145 void updateDuality(void) const;
00146
00147 private:
00148
00149 void fitLine(TMLink *seed, TMLink *outer, HepPoint3D line[4]) const;
00150 AList<TSegment> appendByLine(TMLink *seed, TMLink *outer, AList<TMLink> & seedNeighbors, AList<TMLink> & restHits, const HepPoint3D line[4]);
00151 double distance2(TMLink *, HepPoint3D) const;
00152 double maxdDistance(TMLink *) const;
00153
00154 HepPoint3D leastSquaresFitting1(const AList<TMLink> & links, const HepPoint3D tsfLine) const;
00155 HepPoint3D leastSquaresFitting(const AList<TMLink> & links, const HepPoint3D tsfLine) const;
00156 HepPoint3D positionTsf(const AList<TMLink> & links, const HepPoint3D line) const;
00157 void segSalvage(AList<TMLink> &);
00158 void expandSeg(const int, AList<TMLink> &);
00159 HepPoint3D closestPoint(const HepPoint3D & p, const HepPoint3D line) const;
00160
00161 private:
00162
00163 AList<TTrack> _tracks;
00164 AList<TSegment> _innerLinks;
00165 AList<TSegment> _outerLinks;
00166 unsigned _state;
00167
00168 private:
00169 mutable HepPoint3D _position;
00170 mutable HepPoint3D _outerPosition;
00171 mutable HepVector3D _direction;
00172 mutable unsigned _innerWidth;
00173 mutable unsigned _outerWidth;
00174 mutable unsigned _innerMostLayer;
00175 mutable unsigned _outerMostLayer;
00176 mutable AList<TMLink> _inners;
00177 mutable AList<TMLink> _outers;
00178 mutable unsigned _nLayer;
00179 mutable unsigned _clusterType;
00180 mutable double _duality;
00181 mutable unsigned _nDual;
00182 mutable double _angle;
00183
00184
00185 double _times[11];
00186 mutable HepPoint3D _lineTsf;
00187
00188 static TMDC * _cdc;
00189
00190 private:
00191
00192 AList<TMLink> _usedHitsOfSecond;
00193 };
00194
00195
00197 unsigned NCoreLinks(const CAList<TSegment> & list);
00198
00200 AList<TMLink> Links(const TSegment &, const TTrack &);
00201
00203 AList<TMLink> Links(const AList<TSegment> & list);
00204
00206
00207
00208
00210
00211
00212
00213
00214
00215
00217 unsigned
00218 NUniqueLinks(const TSegment & a);
00219
00221 AList<TSegment>
00222 UniqueLinks(const TSegment & a);
00223
00225 TSegment *
00226 OuterMostUniqueLink(const TSegment & a);
00227
00229 unsigned
00230 NMajorLinks(const TSegment & a);
00231
00233 AList<TSegment>
00234 MajorLinks(const TSegment & a);
00235
00237 unsigned
00238 NLinkBranches(const TSegment & a);
00239
00241 void
00242 SeparateCrowded(const AList<TSegment> & input,
00243 AList<TSegment> & isolated,
00244 AList<TSegment> & crowded);
00245
00247 unsigned
00248 SuperLayer(const AList<TSegment> & list);
00249
00250
00251
00252 #ifdef TSegment_NO_INLINE
00253 #define inline
00254 #else
00255 #undef inline
00256 #define TSegment_INLINE_DEFINE_HERE
00257 #endif
00258
00259 #ifdef TSegment_INLINE_DEFINE_HERE
00260
00261 inline
00262 const AList<TMLink> &
00263 TSegment::inners(void) const {
00264 if (! _fitted) update();
00265 return _inners;
00266 }
00267
00268 inline
00269 const AList<TMLink> &
00270 TSegment::outers(void) const {
00271 if (! _fitted) update();
00272 return _outers;
00273 }
00274
00275 inline
00276 const HepPoint3D &
00277 TSegment::position(void) const {
00278 if (! _fitted) update();
00279 return _position;
00280 }
00281
00282 inline
00283 const HepVector3D &
00284 TSegment::direction(void) const {
00285 if (! _fitted) update();
00286 return _direction;
00287 }
00288
00289 inline
00290 unsigned
00291 TSegment::innerWidth(void) const {
00292 if (! _fitted) update();
00293 return _innerWidth;
00294 }
00295
00296 inline
00297 unsigned
00298 TSegment::outerWidth(void) const {
00299 if (! _fitted) update();
00300 return _outerWidth;
00301 }
00302
00303 inline
00304 unsigned
00305 TSegment::innerMostLayer(void) const {
00306 if (! _fitted) update();
00307 return _innerMostLayer;
00308 }
00309
00310 inline
00311 unsigned
00312 TSegment::outerMostLayer(void) const {
00313 if (! _fitted) update();
00314 return _outerMostLayer;
00315 }
00316
00317 inline
00318 unsigned
00319 TSegment::clusterType(void) const {
00320 if (! nLinks()) return 0;
00321 if (_clusterType == 0) updateType();
00322 return _clusterType;
00323 }
00324
00325 inline
00326 double
00327 TSegment::duality(void) const {
00328 return _duality;
00329 }
00330
00331 inline
00332 unsigned
00333 TSegment::objectType(void) const {
00334 return Segment;
00335 }
00336
00337 inline
00338 unsigned
00339 TSegment::superLayerId(void) const {
00340 unsigned id = (links())[0]->wire()->superLayerId();
00341 #ifdef TRKRECO_DEBUG
00342 {
00343 const AList<TMLink> & list = links();
00344 unsigned n = list.length();
00345 for (unsigned i = 1; i < n; i++) {
00346 if (list[i]->hit()->wire()->superLayerId() != id) {
00347 std::cout << "TSegment::superLayerId !!! strange segment found";
00348 std::cout << std::endl;
00349 dump();
00350 break;
00351 }
00352 }
00353 }
00354 #endif
00355 return id;
00356 }
00357
00358 inline
00359 AList<TTrack> &
00360 TSegment::tracks(void) {
00361 return _tracks;
00362 }
00363
00364 inline
00365 AList<TSegment> &
00366 TSegment::innerLinks(void) {
00367 return _innerLinks;
00368 }
00369
00370 inline
00371 const AList<TSegment> &
00372 TSegment::innerLinks(void) const {
00373 return _innerLinks;
00374 }
00375
00376 inline
00377 AList<TSegment> &
00378 TSegment::outerLinks(void) {
00379 return _outerLinks;
00380 }
00381
00382 inline
00383 const AList<TSegment> &
00384 TSegment::outerLinks(void) const {
00385 return _outerLinks;
00386 }
00387
00388 inline
00389 unsigned
00390 TSegment::state(void) const {
00391 return _state;
00392 }
00393
00394 inline
00395 unsigned
00396 TSegment::state(unsigned a) {
00397 return _state = a;
00398 }
00399
00400
00401 inline
00402 const HepPoint3D &
00403 TSegment::lineTsf(void) const {
00404 return _lineTsf;
00405 }
00406
00407 inline
00408 const HepPoint3D &
00409 TSegment::lineTsf(const HepPoint3D & a){
00410 return _lineTsf = a;
00411 }
00412 #endif
00413
00414 #undef inline
00415
00416 #endif
00417