BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/TrkReco/include/TrkReco/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 : yoshihito.iwasaki@kek.jp
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
25typedef HepGeom::Point3D<double> HepPoint3D;
26#endif
27#include "CLHEP/Geometry/Vector3D.h"
28#ifndef ENABLE_BACKWARDS_COMPATIBILITY
29typedef HepGeom::Vector3D<double> HepVector3D;
30#endif
31
32#include "TrkReco/TMDCUtil.h"
33#include "TrkReco/TMLink.h"
34#include "TrkReco/TTrackBase.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
45public:
46 /// Constructor.
49
50 /// Destructor
51 virtual ~TSegment();
52
53public: // 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
105 /// shape, 5:X shape, 6:parallel, 7:complicated.
106 unsigned clusterType( void ) const;
107
108 /// returns a list of sub TSegments in this cluster. If cluster type is 1, 2, or 7, no
109 /// cluster is returned.
110 AList<TSegment> split( void ) const;
111
112 // split in Tsf model.
114
115 int solveDualHits( void );
116 double duality( void ) const;
117
118 /// solve LR of hit in TSF.
119 void solveLR( void );
120 void solveThreeHits( void );
121
122public: // TTrack relations
124
125public: // Segment links
127 const AList<TSegment>& innerLinks( void ) const;
129 const AList<TSegment>& outerLinks( void ) const;
130 unsigned state( void ) const;
131 unsigned state( unsigned );
132
133private:
134 AList<TSegment> splitAV( void ) const;
135 AList<TSegment> splitParallel( void ) const;
136 AList<TSegment> splitComplicated( void ) const;
137 AList<TSegment> splitDual( void ) const;
138
139private:
140 /// updates cache.
141 void update( void ) const;
142
143 /// updates type.
144 void updateType( void ) const;
145
146 /// updates duality.
147 void updateDuality( void ) const;
148
149private:
150 // for Tsf
151 void fitLine( TMLink* seed, TMLink* outer, HepPoint3D line[4] ) const;
152 AList<TSegment> appendByLine( TMLink* seed, TMLink* outer, AList<TMLink>& seedNeighbors,
153 AList<TMLink>& restHits, const HepPoint3D line[4] );
154 double distance2( TMLink*, HepPoint3D ) const;
155 double maxdDistance( TMLink* ) const;
156
157 HepPoint3D leastSquaresFitting1( const AList<TMLink>& links,
158 const HepPoint3D tsfLine ) const;
159 HepPoint3D leastSquaresFitting( const AList<TMLink>& links, const HepPoint3D tsfLine ) const;
160 HepPoint3D positionTsf( const AList<TMLink>& links, const HepPoint3D line ) const;
161 void segSalvage( AList<TMLink>& );
162 void expandSeg( const int, AList<TMLink>& );
163 HepPoint3D closestPoint( const HepPoint3D& p, const HepPoint3D line ) const;
164
165private:
166 // always updated.
167 AList<TTrack> _tracks;
168 AList<TSegment> _innerLinks;
169 AList<TSegment> _outerLinks;
170 unsigned _state;
171
172private:
173 mutable HepPoint3D _position;
174 mutable HepPoint3D _outerPosition;
175 mutable HepVector3D _direction;
176 mutable unsigned _innerWidth;
177 mutable unsigned _outerWidth;
178 mutable unsigned _innerMostLayer;
179 mutable unsigned _outerMostLayer;
180 mutable AList<TMLink> _inners;
181 mutable AList<TMLink> _outers;
182 mutable unsigned _nLayer;
183 mutable unsigned _clusterType;
184 mutable double _duality;
185 mutable unsigned _nDual;
186 mutable double _angle;
187
188 //----tsf----//
189 double _times[11]; // times of sigma
190 mutable HepPoint3D _lineTsf;
191
192 static TMDC* _cdc;
193
194private:
195 // for Tsf
196 AList<TMLink> _usedHitsOfSecond; // for the (23) layers;
197};
198
199// Utility functions
200/// returns \# of core links in segments.
201unsigned NCoreLinks( const CAList<TSegment>& list );
202
203/// returns AList of TMLink used for a track.
204AList<TMLink> Links( const TSegment&, const TTrack& );
205
206/// returns AList of TMLink.
207AList<TMLink> Links( const AList<TSegment>& list );
208
209/// checks property of segments.
210// void
211// CheckSegments(const CAList<TSegment> & segmentList);
212//
213/// checks to link segments.
214// void
215// CheckSegmentLink(const TSegment & base,
216// const TSegment & next,
217// float distance,
218// float dirAngle);
219
220/// returns \# of unique segment links.
221unsigned NUniqueLinks( const TSegment& a );
222
223/// returns a list of unique segments in links.
225
226/// returns a segment to the outer-most unique segment.
228
229/// returns \# of links in the major link.
230unsigned NMajorLinks( const TSegment& a );
231
232/// returns a list of segments in major links.
234
235/// returns \# of link branches in the major link.
236unsigned NLinkBranches( const TSegment& a );
237
238/// returns isolated and crowded list.
239void SeparateCrowded( const AList<TSegment>& input, AList<TSegment>& isolated,
240 AList<TSegment>& crowded );
241
242/// returns super layer pattern.
243unsigned SuperLayer( const AList<TSegment>& list );
244
245//-----------------------------------------------------------------------------
246
247#ifdef TSegment_NO_INLINE
248# define inline
249#else
250# undef inline
251# define TSegment_INLINE_DEFINE_HERE
252#endif
253
254#ifdef TSegment_INLINE_DEFINE_HERE
255
256inline const AList<TMLink>& TSegment::inners( void ) const {
257 if ( !_fitted ) update();
258 return _inners;
259}
260
261inline const AList<TMLink>& TSegment::outers( void ) const {
262 if ( !_fitted ) update();
263 return _outers;
264}
265
266inline const HepPoint3D& TSegment::position( void ) const {
267 if ( !_fitted ) update();
268 return _position;
269}
270
271inline const HepVector3D& TSegment::direction( void ) const {
272 if ( !_fitted ) update();
273 return _direction;
274}
275
276inline unsigned TSegment::innerWidth( void ) const {
277 if ( !_fitted ) update();
278 return _innerWidth;
279}
280
281inline unsigned TSegment::outerWidth( void ) const {
282 if ( !_fitted ) update();
283 return _outerWidth;
284}
285
286inline unsigned TSegment::innerMostLayer( void ) const {
287 if ( !_fitted ) update();
288 return _innerMostLayer;
289}
290
291inline unsigned TSegment::outerMostLayer( void ) const {
292 if ( !_fitted ) update();
293 return _outerMostLayer;
294}
295
296inline unsigned TSegment::clusterType( void ) const {
297 if ( !nLinks() ) return 0;
298 if ( _clusterType == 0 ) updateType();
299 return _clusterType;
300}
301
302inline double TSegment::duality( void ) const { return _duality; }
303
304inline unsigned TSegment::objectType( void ) const { return Segment; }
305
306inline unsigned TSegment::superLayerId( void ) const {
307 unsigned id = ( links() )[0]->wire()->superLayerId();
308# ifdef TRKRECO_DEBUG
309 {
310 const AList<TMLink>& list = links();
311 unsigned n = list.length();
312 for ( unsigned i = 1; i < n; i++ )
313 {
314 if ( list[i]->hit()->wire()->superLayerId() != id )
315 {
316 std::cout << "TSegment::superLayerId !!! strange segment found";
317 std::cout << std::endl;
318 dump();
319 break;
320 }
321 }
322 }
323# endif
324 return id;
325}
326
327inline AList<TTrack>& TSegment::tracks( void ) { return _tracks; }
328
329inline AList<TSegment>& TSegment::innerLinks( void ) { return _innerLinks; }
330
331inline const AList<TSegment>& TSegment::innerLinks( void ) const { return _innerLinks; }
332
333inline AList<TSegment>& TSegment::outerLinks( void ) { return _outerLinks; }
334
335inline const AList<TSegment>& TSegment::outerLinks( void ) const { return _outerLinks; }
336
337inline unsigned TSegment::state( void ) const { return _state; }
338
339inline unsigned TSegment::state( unsigned a ) { return _state = a; }
340
341//-----tsf----//
342inline const HepPoint3D& TSegment::lineTsf( void ) const { return _lineTsf; }
343
344inline const HepPoint3D& TSegment::lineTsf( const HepPoint3D& a ) { return _lineTsf = a; }
345#endif
346
347#undef inline
348
349#endif /* TSegment_FLAG_ */
HepGeom::Vector3D< double > HepVector3D
HepGeom::Point3D< double > HepPoint3D
const Int_t n
#define min(a, b)
#define max(a, b)
HepGeom::Point3D< double > HepPoint3D
unsigned NMajorLinks(const TSegment &a)
returns # of links in the major link.
AList< TMLink > Links(const TSegment &, const TTrack &)
returns AList of TMLink used for a track.
unsigned NUniqueLinks(const TSegment &a)
checks property of segments.
HepGeom::Vector3D< double > HepVector3D
void SeparateCrowded(const AList< TSegment > &input, AList< TSegment > &isolated, AList< TSegment > &crowded)
returns isolated and crowded list.
TSegment * OuterMostUniqueLink(const TSegment &a)
returns a segment to the outer-most unique segment.
unsigned NLinkBranches(const TSegment &a)
returns # of link branches in the major link.
unsigned NCoreLinks(const CAList< TSegment > &list)
returns # of core links in segments.
Definition TSegment.cxx:987
AList< TSegment > UniqueLinks(const TSegment &a)
returns a list of unique segments in links.
AList< TSegment > MajorLinks(const TSegment &a)
returns a list of segments in major links.
unsigned SuperLayer(const AList< TSegment > &list)
returns super layer pattern.
to specify 1-dim region or range by two floats
A class to relate TMDCWireHit and TTrack objects.
unsigned outerWidth(void) const
returns outer width.
double duality(void) const
const AList< TMLink > & inners(void) const
returns TMLinks in inner/outer-most layer.
const HepVector3D & direction(void) const
returns direction.
virtual ~TSegment()
Destructor.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
const TMLink & center(void) const
returns a TMLink which is the closest to the center.
TSegment(const AList< TMLink > &)
const AList< TMLink > & outers(void) const
unsigned superLayerId() const
returns super layer id.
void solveThreeHits(void)
TSegment()
Constructor.
Range rangeX(double min, double max) const
returns Range of x-coordinate of TMLinks.
const AList< TSegment > & outerLinks(void) const
const HepPoint3D & lineTsf(const HepPoint3D &)
AList< TSegment > split(void) const
AList< TSegment > splitTsf(AList< TMLink > &)
virtual unsigned objectType(void) const
returns type.
unsigned state(void) const
double distance(const HepPoint3D &, const HepVector3D &) const
unsigned innerWidth(void) const
returns inner width.
const AList< TSegment > & innerLinks(void) const
unsigned innerMostLayer(void) const
returns inner most layer.
unsigned clusterType(void) const
void solveLR(void)
solve LR of hit in TSF.
unsigned state(unsigned)
int solveDualHits(void)
AList< TSegment > & outerLinks(void)
const HepPoint3D & position(void) const
returns position.
unsigned width(void) const
returns width.
double distance(const TSegment &) const
calculates distance between two clusters. Smaller value indicates closer.
const HepPoint3D & outerPosition(void) const
unsigned outerMostLayer(void) const
returns outer most layer.
AList< TSegment > & innerLinks(void)
virtual unsigned objectType(void) const
returns type.
const HepPoint3D & lineTsf(void) const
return line of Tsf for pos and dir
AList< TTrack > & tracks(void)
A virtual class for a track class in tracking.
const AList< TMLink > & links(unsigned mask=0) const
unsigned nLinks(unsigned mask=0) const
returns # of masked TMLinks assigned to this track object.
void update(void) const
update cache.
A class to represent a track in tracking.