BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
TSegment.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TSegment.h,v 1.12 2010/03/31 09:58:59 liucy Exp $
3//-----------------------------------------------------------------------------
4// Filename : TSegment.h
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : [email protected]
8//-----------------------------------------------------------------------------
9// Description : A class to manage a group of TMLink's.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#ifndef TSegment_FLAG_
14#define TSegment_FLAG_
15
16#ifdef TRKRECO_DEBUG_DETAIL
17#ifndef TRKRECO_DEBUG
18#define TRKRECO_DEBUG
19#endif
20#endif
21#ifndef CLHEP_POINT3D_H
22#include "CLHEP/Geometry/Point3D.h"
23#endif
24#ifndef ENABLE_BACKWARDS_COMPATIBILITY
26#endif
27#include "CLHEP/Geometry/Vector3D.h"
28#ifndef ENABLE_BACKWARDS_COMPATIBILITY
30#endif
31
32#include "TrkReco/TTrackBase.h"
33#include "TrkReco/TMDCUtil.h"
34#include "TrkReco/TMLink.h"
35
36class TTrack;
37class Range;
38template <class T> class CAList;
39
40#define TSegmentCrowd 8
41
42/// A class to relate TMDCWireHit and TTrack objects.
43class TSegment : public TTrackBase {
44
45 public:
46 /// Constructor.
47 TSegment();
48 TSegment(const AList<TMLink> &);
49
50 /// Destructor
51 virtual ~TSegment();
52
53 public:// Selectors
54 /// returns type.
55 virtual unsigned objectType(void) const;
56
57 /// dumps debug information.
58 void dump(const std::string & message = std::string(""),
59 const std::string & prefix = std::string("")) const;
60
61 /// returns super layer id.
62 unsigned superLayerId() const;
63
64 /// returns position.
65 const HepPoint3D & position(void) const;
66 const HepPoint3D & outerPosition(void) const;
67
68 /// return line of Tsf for pos and dir
69 const HepPoint3D & lineTsf(void) const;
70 const HepPoint3D & lineTsf(const HepPoint3D &);
71
72 /// returns direction.
73 const HepVector3D & direction(void) const;
74
75 /// calculates distance between two clusters. Smaller value indicates closer.
76 double distance(const TSegment &) const;
77 double distance(const HepPoint3D &, const HepVector3D &) const;
78
79 /// returns Range of x-coordinate of TMLinks.
80 Range rangeX(double min, double max) const;
81
82 /// returns TMLinks in inner/outer-most layer.
83 const AList<TMLink> & inners(void) const;
84 const AList<TMLink> & outers(void) const;
85
86 /// returns a TMLink which is the closest to the center.
87 const TMLink & center(void) const;
88
89 /// returns width.
90 unsigned width(void) const;
91
92 /// returns inner width.
93 unsigned innerWidth(void) const;
94
95 /// returns outer width.
96 unsigned outerWidth(void) const;
97
98 /// returns inner most layer.
99 unsigned innerMostLayer(void) const;
100
101 /// returns outer most layer.
102 unsigned outerMostLayer(void) const;
103
104 /// returns cluster type. 0:empty, 1:short line, 2:long line, 3:V shage(from outside), 4:A shape, 5:X shape, 6:parallel, 7:complicated.
105 unsigned clusterType(void) const;
106
107 /// returns a list of sub TSegments in this cluster. If cluster type is 1, 2, or 7, no cluster is returned.
108 AList<TSegment> split(void) const;
109
110 //split in Tsf model.
112
113 int solveDualHits(void);
114 double duality(void) const;
115
116 ///solve LR of hit in TSF.
117 void solveLR(void);
118 void solveThreeHits(void);
119
120 public:// TTrack relations
121 AList<TTrack> & tracks(void);
122
123 public:// Segment links
125 const AList<TSegment> & innerLinks(void) const;
127 const AList<TSegment> & outerLinks(void) const;
128 unsigned state(void) const;
129 unsigned state(unsigned);
130
131 private:
132 AList<TSegment> splitAV(void) const;
133 AList<TSegment> splitParallel(void) const;
134 AList<TSegment> splitComplicated(void) const;
135 AList<TSegment> splitDual(void) const;
136
137 private:
138 /// updates cache.
139 void update(void) const;
140
141 /// updates type.
142 void updateType(void) const;
143
144 /// updates duality.
145 void updateDuality(void) const;
146
147 private:
148 //for Tsf
149 void fitLine(TMLink *seed, TMLink *outer, HepPoint3D line[4]) const;
150 AList<TSegment> appendByLine(TMLink *seed, TMLink *outer, AList<TMLink> & seedNeighbors, AList<TMLink> & restHits, const HepPoint3D line[4]);
151 double distance2(TMLink *, HepPoint3D) const;
152 double maxdDistance(TMLink *) const;
153
154 HepPoint3D leastSquaresFitting1(const AList<TMLink> & links, const HepPoint3D tsfLine) const;
155 HepPoint3D leastSquaresFitting(const AList<TMLink> & links, const HepPoint3D tsfLine) const;
156 HepPoint3D positionTsf(const AList<TMLink> & links, const HepPoint3D line) const;
157 void segSalvage(AList<TMLink> &);
158 void expandSeg(const int, AList<TMLink> &);
159 HepPoint3D closestPoint(const HepPoint3D & p, const HepPoint3D line) const;
160
161 private:
162 // always updated.
163 AList<TTrack> _tracks;
164 AList<TSegment> _innerLinks;
165 AList<TSegment> _outerLinks;
166 unsigned _state;
167
168 private:
169 mutable HepPoint3D _position;
170 mutable HepPoint3D _outerPosition;
171 mutable HepVector3D _direction;
172 mutable unsigned _innerWidth;
173 mutable unsigned _outerWidth;
174 mutable unsigned _innerMostLayer;
175 mutable unsigned _outerMostLayer;
176 mutable AList<TMLink> _inners;
177 mutable AList<TMLink> _outers;
178 mutable unsigned _nLayer;
179 mutable unsigned _clusterType;
180 mutable double _duality;
181 mutable unsigned _nDual;
182 mutable double _angle;
183
184 //----tsf----//
185 double _times[11]; //times of sigma
186 mutable HepPoint3D _lineTsf;
187
188 static TMDC * _cdc;
189
190 private:
191 //for Tsf
192 AList<TMLink> _usedHitsOfSecond; //for the (23) layers;
193};
194
195// Utility functions
196/// returns \# of core links in segments.
197unsigned NCoreLinks(const CAList<TSegment> & list);
198
199/// returns AList of TMLink used for a track.
200AList<TMLink> Links(const TSegment &, const TTrack &);
201
202/// returns AList of TMLink.
204
205/// checks property of segments.
206//void
207//CheckSegments(const CAList<TSegment> & segmentList);
208//
209/// checks to link segments.
210//void
211//CheckSegmentLink(const TSegment & base,
212// const TSegment & next,
213// float distance,
214// float dirAngle);
215
216/// returns \# of unique segment links.
217unsigned
218NUniqueLinks(const TSegment & a);
219
220/// returns a list of unique segments in links.
222UniqueLinks(const TSegment & a);
223
224/// returns a segment to the outer-most unique segment.
225TSegment *
227
228/// returns \# of links in the major link.
229unsigned
230NMajorLinks(const TSegment & a);
231
232/// returns a list of segments in major links.
234MajorLinks(const TSegment & a);
235
236/// returns \# of link branches in the major link.
237unsigned
238NLinkBranches(const TSegment & a);
239
240/// returns isolated and crowded list.
241void
242SeparateCrowded(const AList<TSegment> & input,
243 AList<TSegment> & isolated,
244 AList<TSegment> & crowded);
245
246/// returns super layer pattern.
247unsigned
248SuperLayer(const AList<TSegment> & list);
249
250//-----------------------------------------------------------------------------
251
252#ifdef TSegment_NO_INLINE
253#define inline
254#else
255#undef inline
256#define TSegment_INLINE_DEFINE_HERE
257#endif
258
259#ifdef TSegment_INLINE_DEFINE_HERE
260
261inline
262const AList<TMLink> &
263TSegment::inners(void) const {
264 if (! _fitted) update();
265 return _inners;
266}
267
268inline
269const AList<TMLink> &
270TSegment::outers(void) const {
271 if (! _fitted) update();
272 return _outers;
273}
274
275inline
276const HepPoint3D &
278 if (! _fitted) update();
279 return _position;
280}
281
282inline
283const HepVector3D &
285 if (! _fitted) update();
286 return _direction;
287}
288
289inline
290unsigned
292 if (! _fitted) update();
293 return _innerWidth;
294}
295
296inline
297unsigned
299 if (! _fitted) update();
300 return _outerWidth;
301}
302
303inline
304unsigned
306 if (! _fitted) update();
307 return _innerMostLayer;
308}
309
310inline
311unsigned
313 if (! _fitted) update();
314 return _outerMostLayer;
315}
316
317inline
318unsigned
320 if (! nLinks()) return 0;
321 if (_clusterType == 0) updateType();
322 return _clusterType;
323}
324
325inline
326double
327TSegment::duality(void) const {
328 return _duality;
329}
330
331inline
332unsigned
334 return Segment;
335}
336
337inline
338unsigned
340 unsigned id = (links())[0]->wire()->superLayerId();
341#ifdef TRKRECO_DEBUG
342 {
343 const AList<TMLink> & list = links();
344 unsigned n = list.length();
345 for (unsigned i = 1; i < n; i++) {
346 if (list[i]->hit()->wire()->superLayerId() != id) {
347 std::cout << "TSegment::superLayerId !!! strange segment found";
348 std::cout << std::endl;
349 dump();
350 break;
351 }
352 }
353 }
354#endif
355 return id;
356}
357
358inline
361 return _tracks;
362}
363
364inline
367 return _innerLinks;
368}
369
370inline
371const AList<TSegment> &
373 return _innerLinks;
374}
375
376inline
379 return _outerLinks;
380}
381
382inline
383const AList<TSegment> &
385 return _outerLinks;
386}
387
388inline
389unsigned
390TSegment::state(void) const {
391 return _state;
392}
393
394inline
395unsigned
396TSegment::state(unsigned a) {
397 return _state = a;
398}
399
400//-----tsf----//
401inline
402const HepPoint3D &
403TSegment::lineTsf(void) const {
404 return _lineTsf;
405}
406
407inline
408const HepPoint3D &
410 return _lineTsf = a;
411}
412#endif
413
414#undef inline
415
416#endif /* TSegment_FLAG_ */
417
const Int_t n
HepGeom::Point3D< double > HepPoint3D
Definition: TSegment.h:25
unsigned NMajorLinks(const TSegment &a)
returns # of links in the major link.
Definition: TSegment.cxx:1005
AList< TMLink > Links(const TSegment &, const TTrack &)
returns AList of TMLink used for a track.
Definition: TSegment.cxx:963
unsigned NUniqueLinks(const TSegment &a)
checks property of segments.
Definition: TSegment.cxx:978
HepGeom::Vector3D< double > HepVector3D
Definition: TSegment.h:29
void SeparateCrowded(const AList< TSegment > &input, AList< TSegment > &isolated, AList< TSegment > &crowded)
returns isolated and crowded list.
Definition: TSegment.cxx:1061
TSegment * OuterMostUniqueLink(const TSegment &a)
returns a segment to the outer-most unique segment.
Definition: TSegment.cxx:1084
unsigned NLinkBranches(const TSegment &a)
returns # of link branches in the major link.
Definition: TSegment.cxx:1048
unsigned NCoreLinks(const CAList< TSegment > &list)
returns # of core links in segments.
Definition: TSegment.cxx:947
AList< TSegment > UniqueLinks(const TSegment &a)
returns a list of unique segments in links.
Definition: TSegment.cxx:991
AList< TSegment > MajorLinks(const TSegment &a)
returns a list of segments in major links.
Definition: TSegment.cxx:1026
unsigned SuperLayer(const AList< TSegment > &list)
returns super layer pattern.
Definition: TSegment.cxx:1075
#define Segment
Definition: TTrackBase.h:31
Definition: TLine2D.h:22
to specify 1-dim region or range by two floats
Definition: Range.h:19
Definition: TMDC.h:61
A class to relate TMDCWireHit and TTrack objects.
Definition: TSegment.h:43
unsigned outerWidth(void) const
returns outer width.
Definition: TSegment.h:298
double duality(void) const
Definition: TSegment.h:327
const AList< TMLink > & inners(void) const
returns TMLinks in inner/outer-most layer.
Definition: TSegment.h:263
const HepVector3D & direction(void) const
returns direction.
Definition: TSegment.h:284
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TSegment.cxx:116
const TMLink & center(void) const
returns a TMLink which is the closest to the center.
const AList< TMLink > & outers(void) const
Definition: TSegment.h:270
unsigned superLayerId() const
returns super layer id.
Definition: TSegment.h:339
void solveThreeHits(void)
Definition: TSegment.cxx:1658
TSegment()
Constructor.
Definition: TSegment.cxx:30
Range rangeX(double min, double max) const
returns Range of x-coordinate of TMLinks.
Definition: TSegment.cxx:261
virtual ~TSegment()
Destructor.
Definition: TSegment.cxx:112
AList< TSegment > split(void) const
returns a list of sub TSegments in this cluster. If cluster type is 1, 2, or 7, no cluster is returne...
Definition: TSegment.cxx:388
AList< TSegment > splitTsf(AList< TMLink > &)
Definition: TSegment.cxx:1134
virtual unsigned objectType(void) const
returns type.
Definition: TSegment.h:333
unsigned state(void) const
Definition: TSegment.h:390
unsigned innerWidth(void) const
returns inner width.
Definition: TSegment.h:291
unsigned innerMostLayer(void) const
returns inner most layer.
Definition: TSegment.h:305
unsigned clusterType(void) const
returns cluster type. 0:empty, 1:short line, 2:long line, 3:V shage(from outside),...
Definition: TSegment.h:319
void solveLR(void)
solve LR of hit in TSF.
Definition: TSegment.cxx:1604
int solveDualHits(void)
Definition: TSegment.cxx:736
AList< TSegment > & outerLinks(void)
Definition: TSegment.h:378
const HepPoint3D & position(void) const
returns position.
Definition: TSegment.h:277
unsigned width(void) const
returns width.
Definition: TSegment.cxx:1101
double distance(const TSegment &) const
calculates distance between two clusters. Smaller value indicates closer.
Definition: TSegment.cxx:237
const HepPoint3D & outerPosition(void) const
unsigned outerMostLayer(void) const
returns outer most layer.
Definition: TSegment.h:312
AList< TSegment > & innerLinks(void)
Definition: TSegment.h:366
const HepPoint3D & lineTsf(void) const
return line of Tsf for pos and dir
Definition: TSegment.h:403
AList< TTrack > & tracks(void)
Definition: TSegment.h:360
A virtual class for a track class in tracking.
Definition: TTrackBase.h:46
bool _fitted
Definition: TTrackBase.h:162
const AList< TMLink > & links(unsigned mask=0) const
returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
Definition: TTrackBase.cxx:297
unsigned nLinks(unsigned mask=0) const
returns # of masked TMLinks assigned to this track object.
Definition: TTrackBase.cxx:305
A class to represent a track in tracking.
Definition: TTrack.h:129