BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TFastFinder.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TFastFinder.cxx,v 1.7 2010/03/31 09:58:59 liucy Exp $
3//-----------------------------------------------------------------------------
4// Filename : TFastFinder.cc
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : yoshihito.iwasaki@kek.jp
8//-----------------------------------------------------------------------------
9// Description : A class to find tracks with the conformal method.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#include "TrkReco/TFastFinder.h"
14#include "TrkReco/TConformalFinder0.h"
15#include "TrkReco/THistogram.h"
16#include "TrkReco/TMDCUtil.h"
17#include "TrkReco/TMLink.h"
18#include "TrkReco/TTrack.h"
19
20TFastFinder::TFastFinder() : _builder( "fast find builder", 30 ) {
21 _selector.nLinks( 4 );
22 _selector.nSuperLayers( 2 );
23 _selector.minPt( 0.05 );
24 _selector.maxImpact( 100. );
25 _selector.maxSigma( 30. );
26 _selector.nLinksStereo( 3 );
27 _selector.maxDistance( 30. );
28 _builder.trackSelector( _selector );
29}
30
32
33std::string TFastFinder::version( void ) const { return "0.00"; }
34
35void TFastFinder::dump( const std::string& msg, const std::string& pre ) const {
36 std::cout << pre;
37 TFinderBase::dump( msg );
38}
39
40void TFastFinder::clear( void ) {
41 _axialHits.removeAll();
42 _stereoHits.removeAll();
43 HepAListDeleteAll( _axialLinks );
44 HepAListDeleteAll( _stereoLinks );
45}
46
48 const AList<TMDCWireHit>& stereoHits, AList<TTrack>& tracks ) {
49
50 //...Select good hits...
51 selectHits2( axialHits, stereoHits );
52
53 //...Conformal transformation with IP constraint...
55 TConformalFinder0::conformalTransformationRphi( ORIGIN, _stereoHits, _stereoLinks );
56
57 //...Make a histogram...
58 THistogram hist( 288 );
59 hist.fillX( _axialLinks );
60 AList<TSegment0> clusters = hist.clusters0();
61
62 //...Cluster loop...
63 unsigned n = clusters.length();
64 for ( unsigned i = 0; i < n; i++ )
65 {
66
67 //...2D track...
68 TTrack* t = _builder.buildRphi( clusters[i]->links() );
69 if ( t == NULL ) continue;
70#ifdef TRKRECO_DEBUG_DETAIL
71 std::cout << "TFastFinder::doit ... 2D track found" << std::endl;
72#endif
73
74 //...Make it 3D...
75 TTrack* ts = t;
76 ts = _builder.buildStereo( *t, findCloseHits( _stereoLinks, *t ) );
77 if ( ts == NULL ) continue;
78#ifdef TRKRECO_DEBUG_DETAIL
79 std::cout << "TFastFinder::doit ... 3D track found" << std::endl;
80#endif
81
82 //...OK...
83 t->assign( WireHitFastFinder );
84 t->finder( TrackFastFinder );
85 // t->assign(WireHitFastFinder, TrackFastFinder);
86 tracks.append( t );
87 _stereoLinks.remove( t->links() );
88 }
89
90 //...Termination...
91 HepAListDeleteAll( clusters );
92 return 0;
93}
94
95void TFastFinder::selectHits( const AList<TMDCWireHit>& axialHits,
96 const AList<TMDCWireHit>& stereoHits ) {
97 unsigned n = axialHits.length();
98 for ( unsigned i = 0; i < n; i++ )
99 {
100 const TMDCWireHit& h = *axialHits[i];
101 if ( ( h.state() & WireHitIsolated ) && ( h.state() & WireHitContinuous ) )
102 _axialHits.append( (TMDCWireHit&)h );
103 }
104 n = stereoHits.length();
105 for ( unsigned i = 0; i < n; i++ )
106 {
107 const TMDCWireHit& h = *stereoHits[i];
108 if ( ( h.state() & WireHitIsolated ) && ( h.state() & WireHitContinuous ) )
109 _stereoHits.append( (TMDCWireHit&)h );
110 }
111}
112
113void TFastFinder::selectHits2( const AList<TMDCWireHit>& axialHits,
114 const AList<TMDCWireHit>& stereoHits ) {
115 selectSimpleSegments( axialHits, _axialHits );
116 selectSimpleSegments( stereoHits, _stereoHits );
117}
118
119AList<TMLink> TFastFinder::findCloseHits( const AList<TMLink>& links,
120 const TTrack& track ) const {
121 //
122 // Coded by J.Suzuki
123 //
124 AList<TMLink> list;
125
126 //...Check condition...
127 if ( track.links().length() == 0 )
128 {
129#ifdef TRKRECO_DEBUG_DETAIL
130 std::cout << "TConformalFinder::findCloseHits !!! ";
131 std::cout << " no links found in a track : This should not be happened";
132 std::cout << std::endl;
133#endif
134
135 return list;
136 }
137
138 //...Parameters...
139 // float dRcut[11] = {0, 3.5, 0., 5.5, 0., 6.5, 0., 7.5, 0., 9.5, 0.};
140 float dRcut[11] = { 0., 4.3, 0., 6.5, 0., 7.5, 0., 8.0, 0., 9.5, 0. };
141
142 //...Select Stereo hits associated to the current r-phi curve...
143 double R0 = track.helix().curv();
144 double xInnerWire = track.links()[0]->wire()->xyPosition().x();
145 double yInnerWire = track.links()[0]->wire()->xyPosition().y();
146 unsigned nall = links.length();
147 for ( unsigned j = 0; j < nall; j++ )
148 {
149 TMLink& t = *links[j];
150 const TMDCWire& w = *t.wire();
151 HepVector3D X = w.xyPosition() - track.helix().center();
152 double Rmag2 = X.mag2();
153 double DR = fabs( sqrt( Rmag2 ) - fabs( R0 ) );
154 t.zStatus( -10 );
155 t.zPair( 0 );
156 if ( DR < dRcut[w.superLayerId()] &&
157 ( xInnerWire * w.xyPosition().x() + yInnerWire * w.xyPosition().y() ) > 0. )
158 { list.append( t ); }
159 }
160
161 return list;
162}
163
164void TFastFinder::selectSimpleSegments( const AList<TMDCWireHit>& in,
165 AList<TMDCWireHit>& out ) const {
166 AList<TMDCWireHit> hits = in;
167 while ( hits.last() )
168 {
169 TMDCWireHit& h = *hits.last();
170
171 //...Start clustering...
172 // AList<TMDCWireHit> & cluster = * new AList<TMDCWireHit>();
173 AList<TMDCWireHit> cluster;
174 AList<TMDCWireHit> toBeChecked;
175 bool ok = true;
176 toBeChecked.append( h );
177 while ( toBeChecked.length() )
178 {
179 TMDCWireHit& a = *toBeChecked.last();
180 toBeChecked.remove( a );
181 if ( cluster.hasMember( a ) ) continue;
182
183 //...Check hit...
184 unsigned state = a.state();
185 if ( !( state & WireHitIsolated ) ) ok = false;
186 if ( !( state & WireHitContinuous ) ) ok = false;
187
188 //...Append...
189 cluster.append( a );
190
191 //...Neighbor hit...
192 unsigned ptn = ( state & WireHitNeighborPattern ) >> 12;
193 for ( unsigned i = 0; i < 6; i++ )
194 {
195 if ( ( ptn >> i ) % 2 )
196 {
197 const TMDCWireHit& b = *a.wire()->neighbor( i )->hit();
198 toBeChecked.append( (TMDCWireHit&)b );
199 }
200 }
201 }
202
203 //...Check cluster size...
204 if ( ( cluster.length() < 4 ) || ( cluster.length() > 8 ) ) ok = false;
205
206 //...OK. Good hits...
207 if ( ok ) out.append( cluster );
208
209 //...Remove cluster...
210 hits.remove( cluster );
211
212 //...For debug...
213#ifdef TRKRECO_DEBUG_DETAIL
214 std::cout << "TFastFinder::selectSimpleSegment ... cluster : ok = ";
215 std::cout << ok << " : ";
216#endif
217 for ( unsigned i = 0; i < cluster.length(); i++ )
218 {
219 TMDCWireHit& h = *cluster[i];
220#ifdef TRKRECO_DEBUG_DETAIL
221 std::cout << h.wire()->name() << ",";
222#endif
223 if ( !ok )
224 {
225 unsigned state = h.state();
226 if ( state & WireHitIsolated ) state ^= WireHitIsolated;
227 if ( state & WireHitContinuous ) state ^= WireHitContinuous;
228 h.state( state );
229 }
230 }
231#ifdef TRKRECO_DEBUG_DETAIL
232 std::cout << std::endl;
233#endif
234
235 remove:
236 hits.remove( h );
237 }
238}
HepGeom::Vector3D< double > HepVector3D
const Int_t n
double w
const HepPoint3D ORIGIN
Constants.
Definition TMDCUtil.cxx:47
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
static void conformalTransformationRphi(const HepPoint3D &center, const AList< TMDCWireHit > &hits, AList< TMLink > &links)
std::string version(void) const
returns version.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
void clear(void)
clear internal information.
int doit(const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks)
finds tracks.
virtual ~TFastFinder()
Destructor.
TFastFinder()
Constructor.
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
A class for a histogram used in tracking.
AList< TSegment0 > clusters0(void) const
returns an AList<TSegment0> of clusters.
void fillX(const AList< TMLink > &links)
fills with hits.
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
const TMDCWireHit *const hit(void) const
returns a pointer to a TMDCWireHit.
const TMDCWire *const neighbor(unsigned) const
returns a pointer to a neighbor wire.
Definition TMDCWire.cxx:94
std::string name(void) const
returns name.
const AList< TMLink > & links(unsigned mask=0) const
A class to represent a track in tracking.
const Helix & helix(void) const
returns helix parameter.
int t()
Definition t.c:1