14 , _superLayer( super )
15 , _innerBoundHits( 0 )
16 , _outerBoundHits( 0 )
17 , _firstCallUpdate3D( true )
20 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc", m_pmgnIMF );
21 if ( scmgn != StatusCode::SUCCESS )
22 { std::cout <<
"Unable to open Magnetic field service" << std::endl; }
27 _wireHits.insert( _wireHits.end(), outerHits.begin(), outerHits.end() );
28 _outerBoundHits.clear();
29 _outerBoundHits.insert( _outerBoundHits.end(), outerBound.begin(), outerBound.end() );
34 _wireHits.insert( _wireHits.end(), innerHits.begin(), innerHits.end() );
35 _innerBoundHits.clear();
36 _innerBoundHits.insert( _innerBoundHits.end(), innerBound.begin(), innerBound.end() );
40 _wireHits.push_back( h );
41 _outerBoundHits.clear();
42 _outerBoundHits.push_back( h );
46 _wireHits.push_back( h );
47 _innerBoundHits.clear();
48 _innerBoundHits.push_back( h );
62 if ( _sList.size() )
return _sList[0];
65 std::cout <<
"FTSegment::s() _sList.size() = 0 ! this = " <<
this << std::endl;
71 if ( _zList.size() )
return _zList[0];
74 std::cout <<
"FTSegment::s() _zList.size() = 0 ! this = " <<
this << std::endl;
82 if ( _trackList.size() )
return _trackList.front();
87 if ( _trackList.size() ) _trackList.front() = src;
88 else _trackList.push_back( src );
89 return _trackList.front();
93 if ( _innerBoundHits.size() > 1 )
95 auto it = _innerBoundHits.begin();
96 float phi_1st = ( *it )->phi();
98 float phi_2nd = ( *it )->phi();
99 float phi = 0.5 * ( phi_1st + phi_2nd );
100 if ( fabs( phi_1st - phi_2nd ) >
M_PI )
101 {
return ( phi >
M_PI ) ? ( phi -
M_PI ) : ( phi +
M_PI ); }
104 else return _innerBoundHits.front()->phi();
108 if ( _outerBoundHits.size() > 1 )
110 auto it = _outerBoundHits.begin();
111 float phi_1st = ( *it )->phi();
113 float phi_2nd = ( *it )->phi();
114 float phi = 0.5 * ( phi_1st + phi_2nd );
115 if ( fabs( phi_1st - phi_2nd ) >
M_PI )
116 {
return ( phi >
M_PI ) ? ( phi -
M_PI ) : ( phi +
M_PI ); }
119 else return _outerBoundHits.front()->phi();
123 float x_len = _outgoing_x - _incoming_x;
124 float y_len = _outgoing_y - _incoming_y;
126 return sin( phi_l ) / sqrt( x_len * x_len + y_len * y_len );
134 array<FTList<FTWire*>, 4> wireHitsByLocalLayer;
136 for (
auto& hptr : _wireHits )
137 { wireHitsByLocalLayer[hptr->layer()->localLayerId()].push_back( hptr ); }
139 float length_phi = 0;
140 int innerBoundId = 0;
141 int outerBoundId = 0;
142 int AlreadyFound = 0;
144 const int nLayer = _superLayer->nLayer();
147 for (
int i = 0; i != nLayer; i++ )
149 int N_wireHits = wireHitsByLocalLayer[i].size();
152 float localPhi_max = 0.;
153 float localPhi_min = 7.;
155 for (
int j = 0; j != N_wireHits; j++ )
157 float localPhi = wireHitsByLocalLayer[i][j]->phi();
158 if ( localPhi > localPhi_max ) localPhi_max = localPhi;
159 if ( localPhi < localPhi_min ) localPhi_min = localPhi;
162 float local_length_phi = localPhi_max - localPhi_min;
163 if ( local_length_phi >
M_PI ) local_length_phi = 2 *
M_PI - local_length_phi;
164 if ( local_length_phi > length_phi ) length_phi = local_length_phi;
168 else if ( !AlreadyFound ) { innerBoundId++; }
179 if ( innerBoundId > 0 )
185 if ( outerBoundId < nLayer - 1 )
195 _innerBoundHits.insert( _innerBoundHits.end(), wireHitsByLocalLayer[innerBoundId].begin(),
196 wireHitsByLocalLayer[innerBoundId].end() );
197 _outerBoundHits.insert( _outerBoundHits.end(), wireHitsByLocalLayer[outerBoundId].begin(),
198 wireHitsByLocalLayer[outerBoundId].end() );
206 float in_r = _innerBoundHits.front()->layer()->r();
207 float out_r = _outerBoundHits.front()->layer()->r();
208 float sbX = _incoming_x - _outgoing_x;
209 float sbY = _incoming_y - _outgoing_y;
211 _kappa = 2. * ( -1. / 2.99792458 / m_pmgnIMF->getReferField() ) *
212 ( _outgoing_x * _incoming_y - _outgoing_y * _incoming_x ) /
213 ( in_r * out_r * sqrt( sbX * sbX + sbY * sbY ) );
215 _r = 0.5 * ( in_r + out_r );
220 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc ).ignore();
222 MsgStream log(
msgSvc,
"FTFinder" );
224 if ( _firstCallUpdate3D )
227 _firstCallUpdate3D =
false;
234 const FTLayer* bound = _innerBoundHits.front()->layer();
236 log << MSG::DEBUG <<
"started inS calculation with layer limit " << bound->
limit() << endmsg;
237 if ( !( la.
sd( (
double)bound->
r(), (
double)_incoming_x, (
double)_incoming_y,
238 (
double)bound->
limit(),
242 double inZ = bound->
z( d );
245 bound = _outerBoundHits.front()->layer();
246 log << MSG::DEBUG <<
"started outS calculation with layer limit " << bound->
limit()
248 if ( !( la.
sd( (
double)bound->
r(), (
double)_outgoing_x, (
double)_outgoing_y,
249 (
double)bound->
limit(),
253 double outZ = bound->
z( d );
254 _sList.push_back( inS + outS );
255 _zList.push_back( inZ + outZ );
256 _trackList.push_back(
track );
257 log << MSG::DEBUG <<
"-----> coupled! DONE! " << endmsg;
263 float min_D_z = 9999.;
269 for (
auto t : _trackList )
271 float z_tmp = _zList[j];
272 float s_tmp = _sList[j];
273 float D_z = fabs(
t->d_z( s_tmp, z_tmp ) );
290 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc );
292 MsgStream log(
msgSvc,
"FTSegment" );
293 log << MSG::DEBUG <<
"pintout of one segment:" << endmsg;
295 for (
auto h : _wireHits )
297 log << MSG::DEBUG <<
"hit: layer " << h->layer()->layerId() <<
" phi " << h->phi()
303void FTSegment::updateInOutXY() {
304 int n = _innerBoundHits.size();
305 int m = _outerBoundHits.size();
310 auto it = _innerBoundHits.begin();
311 float x0 = ( *it )->x(), y0 = ( *it )->y();
313 float x1 = ( *it )->x(), y1 = ( *it )->y();
315 _incoming_x = 0.5 * ( x0 + x1 );
316 _incoming_y = 0.5 * ( y0 + y1 );
320 _incoming_x = _innerBoundHits.front()->x();
321 _incoming_y = _innerBoundHits.front()->y();
327 auto it = _outerBoundHits.begin();
328 float x0 = ( *it )->x(), y0 = ( *it )->y();
330 float x1 = ( *it )->x(), y1 = ( *it )->y();
332 _outgoing_x = 0.5 * ( x0 + x1 );
333 _outgoing_y = 0.5 * ( y0 + y1 );
337 _outgoing_x = _outerBoundHits.front()->x();
338 _outgoing_y = _outerBoundHits.front()->y();
double sin(const BesAngle a)
const float r() const
returns r form origin
double z(const double d) const
returns z for "d" in r-phi plane
const double limit() const
returns limit of "d" for stereo layer
FTSuperLayer * superLayer() const
returns super-layer
float incomingPhi() const
returns phi of incoming position
int examine()
examine segment
FTList< FTWire * > & wireHits()
returns wire-hit FTList
float r() const
returns r from origin
float outgoingY() const
returns y of outgoing position
float kappa() const
returns kappa(axial)
void linkStereoSegments()
link stereo segments by tanLambda
float outgoingX() const
returns x of outgoing position
float incomingX() const
returns x of incoming position
const FTList< FTWire * > & innerBoundHits()
returns innerBoundHits
void update()
update information for axial segment
const FTList< FTWire * > & outerBoundHits()
returns outerBoundHits
void connect_inner(const FTList< FTWire * > &, const FTList< FTWire * > &)
float outgoingPhi() const
returns phi of outgoing position
FTSegment(FTSuperLayer *super, FTList< FTWire * > &hits)
FTTrack * track() const
returns track
float z() const
returns z for matched 2D track
float attr_const() const
returns the sin(dphi)/MOD(r_out-r_in)
float incomingY() const
returns y of incoming position
float s() const
returns s for matched 2D track
static MdcParameter * param
int update3D(FTTrack *track)
update information for stereo segment
void connect_outer(const FTList< FTWire * > &, const FTList< FTWire * > &)
connect short segments
static const std::array< float, 11 > _maxDphi
int sd(double r, double x, double y, double limit, double &s, double &d) const
static MdcParameter * instance()