BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/TrkReco/include/TrkReco/TMLink.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TMLink.h,v 1.17 2012/05/28 05:16:29 maoh Exp $
3//-----------------------------------------------------------------------------
4// Filename : TMLink.h
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : yoshihito.iwasaki@kek.jp
8//-----------------------------------------------------------------------------
9// Description : A class to relate TMDCWireHit and TTrack objects.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#ifndef TMLink_FLAG_
14#define TMLink_FLAG_
15
16#include <iostream>
17
18#ifdef TRKRECO_DEBUG_DETAIL
19# ifndef TRKRECO_DEBUG
20# define TRKRECO_DEBUG
21# endif
22#endif
23// #define HEP_SHORT_NAMES
24#include <string>
25#ifndef CLHEP_POINT3D_H
26# include "CLHEP/Geometry/Point3D.h"
27#endif
28#ifndef ENABLE_BACKWARDS_COMPATIBILITY
29typedef HepGeom::Point3D<double> HepPoint3D;
30#endif
31
32#include "CLHEP/Alist/AList.h"
33#include "CLHEP/Alist/ConstAList.h"
34#include "TrkReco/TMDCWire.h"
35#include "TrkReco/TMDCWireHit.h"
36// #include "TrkReco/TMDCWire.h"
37// #include "TrkReco/TMDCClust.h"
38
39class TTrackHEP;
40
41class TTrack;
42
43/// A class to relate TMDCWireHit and TTrack objects.
44class TMLink {
45
46public:
47 /// Constructor.
48 /* TMLink(TTrack * track = 0,
49 const TMDCWireHit * hit = 0,
50 const HepPoint3D & position = HepPoint3D());*/
51 TMLink( TTrack* track = 0, const TMDCWireHit* hit = 0,
53 const HepPoint3D& positionD = HepPoint3D(), const double = 0.0 );
54
55 /// Copy constructor.
56 TMLink( const TMLink& );
57
58 /// Destructor
59 virtual ~TMLink();
60
61public: // Selectors
62 /// dumps debug information.
63 void dump( const std::string& message = std::string( "" ),
64 const std::string& prefix = std::string( "" ) ) const;
65
66 /// returns a pointer to a hit.
67 const TMDCWireHit* hit( void ) const;
68
69 /// returns a pointer to a wire.
70 const TMDCWire* const wire( void ) const;
71
72 /// returns a pointer to a track.
73 TTrack* track( void ) const;
74
75 /// returns pull.
76 double pull( void ) const;
77
78 /// returns middle position of a wire. z componet is 0.
79 const HepPoint3D& xyPosition( void ) const;
80
81 /// returns the closest point on wire to a track.
82 const HepPoint3D& positionOnWire( void ) const;
83
84 /// returns the closest point on track to wire.
85 const HepPoint3D& positionOnTrack( void ) const;
86
87 /// returns dPhi to the closest point.
88 double dPhi( void ) const;
89
90 /// returns left-right. 0:left, 1:right, 2:wire
91 unsigned leftRight( void ) const;
92
93 /// returns stauts of stereo hit
94 int zStatus( void ) const;
95
96 /// returns id\# of the pair, if zStatus == 20 (2 consective hits).
97 int zPair( void ) const;
98
99 /// returns position.
100 const HepPoint3D& position( void ) const;
101 const HepPoint3D& positionD( void ) const;
102
103 /// returns distance between point on wire and on track.
104 double distance( void ) const;
105
106 void distance( double );
107
108 double distancenew( void ) const;
109
110 /// returns neighbor TMLink.
111 TMLink* neighbor( unsigned int ) const;
112
113 /// returns a pointer to a TMLink.
114 TMLink* link( void ) const;
115
116 // S.Suzuki added
117 /// returns UseCathode flag
118 // int usecathode(void) const;
119
120 /// returns pointer to the cluster to be fit
121 // TMDCClust * getmclust(void) const;
122 // end S.Suzuki
123
124 /// returns arc and Z for the curl finder.
125 const HepPoint3D& arcZ( const unsigned = 0 ) const;
126
127public: // tmp
128 // const HepPoint3D & conf(void) const;
129 const HepPoint3D& conf( const HepPoint3D& conf );
130
131public: // Modifiers
132 /// sets results of fitting.
133 void update( const HepPoint3D& onTrack, const HepPoint3D& onWire, unsigned leftRight,
134 double pull );
135
136 /// sets a pointer to a hit.
137 const TMDCWireHit* hit( const TMDCWireHit* );
138
139 /// sets a pointer to a track.
141
142 /// sets and returns the closest point on wire to a track.
144 const HepPoint3D& positionOnWire( double p[3] );
145
146 /// sets and returns the closest point on track to wire.
148 const HepPoint3D& positionOnTrack( double p[3] );
149
150 /// sets and returns dPhi to the closest point.
151 double dPhi( double );
152
153 /// sets and returns position.
156
157 /// sets neighbor TMLink.
158 void neighbor( unsigned int, TMLink* );
159
160 /// sets a pointer to a TMLink.
162
163 /// sets left-right. 0:left, 1:right, 2:wire
164 unsigned leftRight( unsigned );
165
166 /// sets pull.
167 double pull( double );
168
169 /// sets stereo Hit status
170 int zStatus( int );
171
172 /// sets id\# of the pair
173 int zPair( int );
174
175 // S.Suzuki added
176
177 /// sets usecathode flag
178 // void setusecathode(int);
179
180 /// sets pointer to the cluster to be fit
181 // void setmclust(TMDCClust *);
182
183 /// sets z(phi) before cathode fit
184 // void setZphiBeforeCathode(float);
185
186 // end S.Suzuki
187
188 /// sets and returns arc and Z for the curl finder.
189 const HepPoint3D& arcZ( const HepPoint3D&, const unsigned = 0 );
190 const unsigned fit2D( const unsigned& );
191 unsigned fit2D( void );
192
193public: // Drift distance
194 /// returns/sets drift distance.
195 float drift( void ) const;
196 float drift( unsigned ) const;
197 float drift( float, unsigned );
198 double cDrift( void ) const;
199 double cDrift( unsigned ) const;
200 double cDrift( double, unsigned );
201
202 /// returns/sets drift distance error.
203 float dDrift( void ) const;
204 float dDrift( unsigned ) const;
205 float dDrift( float, unsigned );
206
207 /// return tsfTag of links
208 unsigned tsfTag( void ) const;
209 unsigned tsfTag( unsigned );
210
211 /// return time of flight
212 double tof( void ) const;
213 double tof( double );
214
215 /// add by jialk returns timeDrift after prop correction
216 void setDriftTime( double );
217 double getDriftTime( void );
218
219 /// returs drift time
220 double DriftTime( double, double ) const;
221
222private:
223 TTrack* _track;
224 const TMDCWireHit* _hit;
225 HepPoint3D _onTrack;
226 HepPoint3D _onWire;
227 HepPoint3D _position;
228 HepPoint3D _positionD;
229 double _dPhi;
230 unsigned _leftRight;
231 float _drift[2];
232 float _dDrift[2];
233
234 double _cDrift[2];
235
236 int _zStatus;
237 int _zPair;
238 double _pull;
239 double _distance;
240 TMLink* _neighbor[6];
241 TMLink* _link;
242
243 //...tmp...
244 HepPoint3D _conf;
245
246 double _tof;
247 double _drifttime;
248
249 //-- S. Suzuki added -------
250 // int _usecathode;
251 // float _ZphiBeforeCathode;
252 // TMDCClust * _mclust;
253 //-- S. Suzuki added end ---
254
255 HepPoint3D _arcZ[4];
256 unsigned _fit2D;
257 unsigned _tsfTag;
258};
259
260// Utility functions
261
262/// returns TTrackHEP
263const TTrackHEP& Links2HEP( const AList<TMLink>& links );
264
265/// returns \# of layers.
266unsigned NSuperLayers( const AList<TMLink>& links );
267
268unsigned NSuperLayers( const AList<TMLink>& links, unsigned minNHits );
269
270unsigned NMissingAxialSuperLayers( const AList<TMLink>& links );
271
272/// returns \# of layers.
273unsigned NLayers( const AList<TMLink>& links );
274
275/// returns \# of hits per layer.
276void NHits( const AList<TMLink>& links, unsigned nHits[50] );
277
278/// returns \# of hits per super layer.
279void NHitsSuperLayer( const AList<TMLink>& links, unsigned nHits[11] );
280
281/// returns axial hits.
283
284/// returns stereo hits.
286
287/// returns \# of axial hits.
288unsigned NAxialHits( const AList<TMLink>& links );
289
290/// returns \# of stereo hits.
291unsigned NStereoHits( const AList<TMLink>& links );
292
293/// returns width(wire cell unit) of given AList<TMLink>. This function assumes that all
294/// TMLink's are in the same super layer.
295unsigned Width( const AList<TMLink>& );
296
297/// returns links which are edges. This function assumes that all TMLink's are in the same
298/// super layer.
300
301/// returns links which are in the same layer as 'a' or 'id'.
302AList<TMLink> SameLayer( const AList<TMLink>& list, const TMLink& a );
303AList<TMLink> SameLayer( const AList<TMLink>& list, unsigned id );
304
305/// returns links which are in the same super layer as 'a' or 'id'.
306AList<TMLink> SameSuperLayer( const AList<TMLink>& list, const TMLink& a );
307AList<TMLink> SameSuperLayer( const AList<TMLink>& list, unsigned id );
308
309/// returns super layer pattern.
310unsigned SuperLayer( const AList<TMLink>& list );
311unsigned SuperLayer( const AList<TMLink>& list, unsigned minNHits );
312
313/// returns the inner(outer)-most link.
314TMLink* InnerMost( const AList<TMLink>& links );
315TMLink* OuterMost( const AList<TMLink>& links );
316
317/// returns links which are in the inner most and outer most layer. This function assumes that
318/// all TMLink's are in the same super layer.
320
321template <class T> class CAList;
322
323/// separate cores and non-cores.
324void SeparateCores( const AList<TMLink>& input, AList<TMLink>& cores,
325 AList<TMLink>& nonCores );
326
327AList<TMLink> Cores( const AList<TMLink>& input );
328
329/// dumps TMLinks.
330void Dump( const CAList<TMLink>& links, const std::string& message = std::string( "" ),
331 const std::string& prefix = std::string( "" ) );
332void Dump( const TMLink& link, const std::string& message = std::string( "" ),
333 const std::string& prefix = std::string( "" ) );
334
335/// Sorter
336#if defined( __GNUG__ )
337int SortByWireId( const TMLink** a, const TMLink** b );
338int SortByX( const TMLink** a, const TMLink** b );
339#else
340extern "C" int SortByWireId( const void* a, const void* b );
341extern "C" int SortByX( const void* a, const void* b );
342#endif
343
344//-----------------------------------------------------------------------------
345
346#ifdef TMLink_NO_INLINE
347# define inline
348#else
349# undef inline
350# define TMLink_INLINE_DEFINE_HERE
351#endif
352
353#ifdef TMLink_INLINE_DEFINE_HERE
354
355inline const TMDCWireHit* TMLink::hit( void ) const { return _hit; }
356
357inline TTrack* TMLink::track( void ) const { return _track; }
358
359inline const TMDCWireHit* TMLink::hit( const TMDCWireHit* a ) { return _hit = a; }
360
361inline TTrack* TMLink::track( TTrack* a ) { return _track = a; }
362
363inline void TMLink::update( const HepPoint3D& onTrack, const HepPoint3D& onWire,
364 unsigned leftRight, double pull ) {
365 _onTrack = onTrack;
366 _onWire = onWire;
367 _leftRight = leftRight;
368 _pull = pull;
369}
370
371inline double TMLink::pull( void ) const { return _pull; }
372
373inline double TMLink::pull( double a ) { return _pull = a; }
374
375inline const HepPoint3D& TMLink::positionOnWire( void ) const { return _onWire; }
376
377inline const HepPoint3D& TMLink::positionOnTrack( void ) const { return _onTrack; }
378
379inline const HepPoint3D& TMLink::positionOnWire( const HepPoint3D& a ) { return _onWire = a; }
380
381inline const HepPoint3D& TMLink::positionOnWire( double p[3] ) {
382 _onWire.setX( p[0] );
383 _onWire.setY( p[1] );
384 _onWire.setZ( p[2] );
385 return _onWire;
386}
387
388inline const HepPoint3D& TMLink::positionOnTrack( const HepPoint3D& a ) {
389 return _onTrack = a;
390}
391
392inline const HepPoint3D& TMLink::positionOnTrack( double p[3] ) {
393 _onTrack.setX( p[0] );
394 _onTrack.setY( p[1] );
395 _onTrack.setZ( p[2] );
396 return _onTrack;
397}
398
399inline unsigned TMLink::leftRight( void ) const { return _leftRight; }
400
401inline unsigned TMLink::leftRight( unsigned a ) { return _leftRight = a; }
402
403inline double TMLink::dPhi( void ) const { return _dPhi; }
404
405inline double TMLink::dPhi( double a ) { return _dPhi = a; }
406
407inline const HepPoint3D& TMLink::position( void ) const { return _position; }
408
409inline const HepPoint3D& TMLink::position( const HepPoint3D& a ) { return _position = a; }
410
411inline const HepPoint3D& TMLink::positionD( void ) const { return _positionD; }
412
413inline const HepPoint3D& TMLink::positionD( const HepPoint3D& a ) { return _positionD = a; }
414
415// inline
416// const HepPoint3D &
417// TMLink::conf(void) const {
418// return _conf;
419// }
420
421inline const HepPoint3D& TMLink::conf( const HepPoint3D& a ) { return _conf = a; }
422
423inline void TMLink::neighbor( unsigned n, TMLink* neighbor ) {
424 if ( n <= 6 ) _neighbor[n] = neighbor;
425}
426
427inline TMLink* TMLink::neighbor( unsigned n ) const {
428 if ( n <= 6 ) return _neighbor[n];
429 return NULL;
430}
431
432inline TMLink* TMLink::link( void ) const { return _link; }
433
434inline TMLink* TMLink::link( TMLink* a ) { return _link = a; }
435
436inline double TMLink::distance( void ) const { return ( _onTrack - _onWire ).mag(); }
437inline double TMLink::distancenew( void ) const { return _distance; }
438
439inline void TMLink::distance( double a ) { _distance = a; }
440// inline
441// const TMDCWire * const
442// TMLink::wire(void) const {
443// if (_hit) return _hit->wire();
444// return NULL;
445// }
446
447// zangsl 040518 move the following two fun. to TMLink.cxx file
448/*
449inline
450const TMDCWire * const
451TMLink::wire(void) const {
452 if (_hit) return _hit->wire();
453 return NULL;
454}
455
456inline
457const HepPoint3D &
458TMLink::xyPosition(void) const {
459 return _hit->wire()->xyPosition();
460}
461*/
462
463inline int TMLink::zStatus( void ) const { return _zStatus; }
464
465inline int TMLink::zStatus( int a ) { return _zStatus = a; }
466
467inline int TMLink::zPair( void ) const { return _zPair; }
468
469inline int TMLink::zPair( int a ) { return _zPair = a; }
470
471/*
472//-- S. Suzuki added -------
473inline
474int
475TMLink::usecathode(void) const {
476 return _usecathode;
477}
478
479inline
480void
481TMLink::setusecathode(int a) {
482 _usecathode = a ;
483}
484
485inline
486TMDCClust *
487TMLink::getmclust(void) const {
488 return _mclust;
489}
490
491inline
492void
493TMLink::setmclust(TMDCClust * a) {
494 _mclust = a ;
495}
496
497//-- S. Suzuki added end ----
498*/
499
500inline const HepPoint3D& TMLink::arcZ( const unsigned i ) const {
501 if ( i < 4 ) return _arcZ[i];
502 std::cerr << "Error!! Please stop!!.....arcZ of TMLink!!! in TrkReco." << std::endl;
503 return _arcZ[0];
504}
505
506inline const HepPoint3D& TMLink::arcZ( const HepPoint3D& az, const unsigned i ) {
507 if ( i < 4 ) return _arcZ[i] = az;
508 std::cerr << "Error!! Please stop!!.....arcZ of TMLink!!! in TrkReco." << std::endl;
509 return _arcZ[0];
510}
511
512// inline
513// void
514// TMLink::setZphiBeforeCathode(float a) {
515// _ZphiBeforeCathode = a;
516// }
517
518inline const unsigned TMLink::fit2D( const unsigned& f ) { return _fit2D = f; }
519
520inline unsigned TMLink::fit2D( void ) { return _fit2D; }
521
522inline float TMLink::drift( unsigned a ) const { return _drift[a]; }
523
524inline float TMLink::drift( float b, unsigned a ) { return _drift[a] = b; }
525
526inline double TMLink::cDrift( unsigned a ) const { return _cDrift[a]; }
527
528inline double TMLink::cDrift( double b, unsigned a ) { return _cDrift[a] = b; }
529
530inline float TMLink::dDrift( unsigned a ) const { return _dDrift[a]; }
531
532inline float TMLink::dDrift( float b, unsigned a ) { return _dDrift[a] = b; }
533
534inline float TMLink::drift( void ) const { return ( _drift[0] + _drift[1] ) / 2.; }
535
536inline double TMLink::cDrift( void ) const { return ( _cDrift[0] + _cDrift[1] ) / 2.; }
537
538inline float TMLink::dDrift( void ) const { return ( _dDrift[0] + _dDrift[1] ) / 2.; }
539
540inline unsigned TMLink::tsfTag( void ) const { return _tsfTag; }
541
542inline unsigned TMLink::tsfTag( unsigned a ) { return _tsfTag = a; }
543
544inline double TMLink::tof( void ) const { return _tof; }
545
546inline double TMLink::tof( double a ) { return _tof = a; }
547
548inline double TMLink::getDriftTime( void ) { return _drifttime; }
549
550inline void TMLink::setDriftTime( double time ) { _drifttime = time; }
551#endif
552
553#undef inline
554
555#endif /* TMLink_FLAG_ */
HepGeom::Point3D< double > HepPoint3D
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
const Int_t n
Double_t time
A class to represent a GEN_HEPEVT particle in tracking.
A class to represent a track in tracking.