14# include "AIDA/IAxis.h"
15# include "AIDA/IHistogram1D.h"
16# include "AIDA/IHistogram2D.h"
17# include "AIDA/IHistogram3D.h"
18# include "AIDA/IHistogramFactory.h"
42 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc", m_pmgnIMF );
43 if ( scmgn != StatusCode::SUCCESS )
44 { std::cout <<
"Unable to open MagneticField service" << std::endl; }
86 return ( Dz < 10 * ( 7 -
n ) ) ? Dz : 9999.;
96 if (
d_z( s_tmp, z_tmp ) < 9998. )
122 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc ).ignore();
124 MsgStream log(
msgSvc,
"FTFinder" );
127 if ( fabs(
_kappa ) > 1.2 /
param->_minPt )
return 0;
131 for (
int i = 0; i !=
n; i++ )
135 for (
auto it = hits.begin();
141 it = hits.
erase( it );
146 _la->add_point( (
double)h.
x(), (
double)h.
y(),
exp( -par * par ) );
152 double chi2 =
_la->fit();
153 HepVector a =
_la->Hpar( m_ftFinder->pivot );
155 log << MSG::DEBUG <<
" chi2/_la cut(1): " << chi2 <<
" / " <<
_la->nc() <<
" a1("
156 <<
param->_minDr <<
"): " << a( 1 ) <<
" a3(" << 1.05 /
param->_minPt <<
"):" << a( 3 )
159 if ( chi2 /
_la->nc() > 1. )
return 0;
160 if ( fabs( a( 3 ) ) > ( 1.05 /
param->_minPt ) )
return 0;
161 if ( fabs( a( 1 ) ) >
param->_minDr )
return 0;
165 log << MSG::DEBUG <<
" passed chi2/_la, a(3) and a(1) cut" << endmsg;
168 for (
int i = 0; i !=
n; i++ )
174 for (
auto it = hits.begin(); it != hits.end(); it++ )
177 const float x = h.
x();
178 const float y = h.
y();
179 double d0 =
_la->d( (
double)x, (
double)y );
181 if ( fabs( d0 ) > 0.7 * h.
layer()->
csize() )
continue;
186 else { delta = -delta; }
187 _la->add_point( x - delta * y, y + delta * x, 1 );
194 HepVector center =
_la->center();
195 const float xc = center( 1 );
196 const float yc = center( 2 );
197 const float rc = a( 1 ) + ( -1. / 2.99792458 / m_pmgnIMF->getReferField() ) /
199 int nn = salvage.size();
201 for (
int i = 0; i != nn; i++ )
206 for (
auto it = hits.begin(); it != hits.end(); it++ )
212 if ( ( y * xc - x * yc ) / ( r * rc ) < 0.707 )
break;
213 double d0 =
_la->d( (
double)x, (
double)y );
215 if ( fabs( d0 ) > 0.7 * h.
layer()->
csize() )
continue;
226 _la->add_point( x - delta * y, y + delta * x, 1 );
252 if ( vtx_flag )
_la->fit( vx, vy, 20 *
_la->chisq() /
_la->nc() );
257 for (
int i = 0; i !=
n; i++ )
261 for (
auto it = hits.begin(); it != hits.end(); it++ )
264 const float x = h.
x();
265 const float y = h.
y();
266 double d0 =
_la->d( (
double)x, (
double)y );
268 if ( m_ftFinder->evtTiming )
270 float time = h.
time() + m_ftFinder->evtTiming;
271 if (
time < -100 )
continue;
276 if ( fabs( d0 ) > 0.5 * cellsize )
continue;
294 _la->add_point( x - delta * y, y + delta * x, 1 );
298 HepVector b =
_la->Hpar( m_ftFinder->pivot );
299 double chi2 =
_la->fit();
309 if ( vtx_flag )
_la->fit( vx, vy, 20 *
_la->chisq() /
_la->nc() );
316 for (
int i = 0; i !=
n; i++ )
320 for (
auto it = hits.begin(); it != hits.end(); it++ )
325 const float x = h.
x();
326 const float y = h.
y();
327 double d0 =
_la->d( (
double)x, (
double)y );
329 if ( m_ftFinder->evtTiming )
331 float time = h.
time() + m_ftFinder->evtTiming;
332 if (
time < -100 )
continue;
336 if ( fabs( d0 ) > 0.5 * cellsize )
continue;
350 _la->add_point( x - delta * y, y + delta * x, 1 );
352 if ( temp < fabs( h.
distance() + d0 ) )
359 HepVector b =
_la->Hpar( m_ftFinder->pivot );
360 double chi2 =
_la->fit();
362 if ( k > 5 ) {
return l; }
367 if ( vtx_flag )
_la->fit( vx, vy, 20 *
_la->chisq() /
_la->nc() );
371 for (
int i = 0; i ^
n; i++ )
375 for (
auto it = hits.begin();
381 const float x = h.
x();
382 const float y = h.
y();
383 double d0 =
_la->d( (
double)x, (
double)y );
385 if ( m_ftFinder->evtTiming )
387 float time = h.
time() + m_ftFinder->evtTiming;
388 if (
time < -100 )
continue;
393 if ( fabs( d0 ) > 0.5 * cellsize )
continue;
406 it = hits.
erase( it );
409 _la->add_point( x - delta * y, y + delta * x, 1 );
414 HepVector b =
_la->Hpar( m_ftFinder->pivot );
415 double chi2 =
_la->fit();
420 if ( vtx_flag )
_la->fit( vx, vy, 20 *
_la->chisq() /
_la->nc() );
425 for (
int i = 0; i !=
n; i++ )
429 for (
auto it = hits.begin(); it != hits.end(); it++ )
433 const float x = h->
x();
434 const float y = h->
y();
435 double d0 =
_la->d( (
double)x, (
double)y );
437 if ( m_ftFinder->evtTiming )
439 float time = h->
time() + m_ftFinder->evtTiming;
440 if (
time < -100 )
continue;
444 if ( fabs( d0 ) > 0.5 * cellsize )
continue;
456 _la->add_point( x - delta * y, y + delta * x, 1 );
460 HepVector b =
_la->Hpar( m_ftFinder->pivot );
461 double chi2 =
_la->fit();
469 for (
int i = 0; i !=
n; i++ )
473 int m = segments.size();
474 float min_D_z = 9998.;
478 for (
int j = 0; j != m; j++ )
481 float s_tmp =
s->s();
482 float z_tmp =
s->z();
483 double D_z = fabs(
d_z( s_tmp, z_tmp ) );
512 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc ).ignore();
514 MsgStream log(
msgSvc,
"FTFinder" );
516 HepVector a =
_la->Hpar( m_ftFinder->pivot );
519 log << MSG::DEBUG <<
"number of stereo segments: " <<
n << endmsg;
520 if (
n < (
param->_nseg ) )
525 log << MSG::DEBUG <<
"cut by _nseg" <<
param->_nseg << endmsg;
532 for (
int i = 0; i !=
n; i++ )
536 for (
auto it = hits.begin(); it != hits.end(); it++ )
541 if ( !( h.
z( *
_la, z ) ) )
continue;
545 log << MSG::DEBUG <<
"cellsize: " << cellsize << endmsg;
547 if ( m_ftFinder->evtTiming )
549 float time = h.
time() + m_ftFinder->evtTiming;
550 if (
time < -100 )
continue;
551 double distance = m_ftFinder->t2x( h.
layer(),
time );
553 log << MSG::DEBUG <<
"m_ftFinder->evtTiming: " << m_ftFinder->evtTiming
554 <<
" TDC time: " << h.
time() <<
" distance: " << distance << endmsg;
557 double par = h.
distance() / ( 0.25 * cellsize );
558 _za->add(
s, z,
exp( -par * par ) );
559 sList.push_back(
s );
560 zList.push_back( z );
561 hList.push_back( &h );
565 if ( hList.size() < (
param->_nlength ) )
570 log << MSG::DEBUG <<
"cut by _nlength: " <<
param->_nlength << endmsg;
574 double chi2 =
_za->calculate();
578 for (
auto it = std::make_tuple( zList.begin(), sList.begin(), hList.begin() );
579 it != std::make_tuple( zList.end(), sList.end(), hList.end() ); )
581 auto itz = std::get<0>( it );
582 auto its = std::get<1>( it );
583 auto ith = std::get<2>( it );
585 double d =
_za->d( *its, *itz );
586 float z_distance = ( *ith )->distance_z();
588 if ( fabs( fabs( d ) - z_distance ) > (
param->_z_cut1 ) )
590 log << MSG::DEBUG <<
"cut by _z_cut1: " <<
param->_z_cut1 << endmsg;
592 itz = zList.
erase( itz );
593 its = sList.
erase( its );
594 ith = hList.
erase( ith );
595 it = std::make_tuple( itz, its, ith );
599 _za->add( *its, ( d > 0 ) ? *itz - z_distance : *itz + z_distance, 1. );
601 it = std::make_tuple( ++itz, ++its, ++ith );
609 log << MSG::DEBUG <<
"cut by _nc: " <<
param->_nc << endmsg;
613 chi2 =
_za->calculate();
616 for (
auto it = std::make_tuple( zList.begin(), sList.begin(), hList.begin() );
617 it != std::make_tuple( zList.end(), sList.end(), hList.end() );
618 it = std::make_tuple( ++std::get<0>( it ), ++std::get<1>( it ), ++std::get<2>( it ) ) )
620 auto itz = std::get<0>( it );
621 auto its = std::get<1>( it );
622 auto ith = std::get<2>( it );
624 double d =
_za->d( *its, *itz );
625 float z_distance = ( *ith )->distance_z();
626 ( *ith )->setChi2( fabs( d ) - z_distance );
630 g_sigmaz->fill( fabs( d ) - z_distance, 1.0 );
633 if ( fabs( fabs( d ) - z_distance ) > (
param->_z_cut2 ) )
continue;
634 _za->add( *its, ( d > 0 ) ? *itz - z_distance : *itz + z_distance, 1. );
642 log << MSG::DEBUG <<
"cut by _nc" <<
param->_nc << endmsg;
646 chi2 =
_za->calculate();
EvtComplex exp(const EvtComplex &c)
AIDA::IHistogram1D * g_sigmaz
AIDA::IHistogram1D * g_chi2xy
AIDA::IHistogram1D * g_sigmaxy
AIDA::IHistogram1D * g_chi2sz
#define FTWireFittingInvalid
const float r() const
returns r form origin
double csize() const
returns cell size
std::vector< T >::iterator erase(typename std::vector< T >::iterator it)
float kappa_tmp() const
returns kappa at linking
const Lpav & lpav() const
returns lpav
int r_phiReFit(float vx, float xy, int vtx_flag)
do r-phi refit
void append_stereo_cache(FTSegment *)
append stereo segment to the cache
FTTrack(FTList< FTSegment * > &axial_segments, float kappa, float chi2_kappa)
constructor
int linkStereoSegments()
link stereo segments by tanLambda
float SigmaZ(float z)
add z for culculation of tanLambda
int get_nhits()
calculate the wire hits number
const FTList< FTSegment * > & stereo_segments()
returns stereo_segments
int r_phi4Fit(float vx, float xy, int vtx_flag)
void setFTFinder(FTFinder *)
float chi2_kappa_tmp() const
returns sigmaKappa at linking
FTList< FTSegment * > _stereo_segments
static MdcParameter * param
const FTList< FTSegment * > & axial_segments()
returns axial segments
Helix * helix() const
returns helix parameters
int r_phiFit()
do r-phi circle fit
float SigmaSZ(float sz)
add s for culculation of dz, tanLambda
int s_zFit()
do s-z linear fit
float SigmaS(float s)
add s for culculation of tanLambda
void updateSZ()
update s and z information for linking
void append_stereo(FTSegment *, float s, float z)
append stereo segment to the stereo segment list
FTList< FTSegment * > _stereo_segments_cache
int r_phi3Fit(int l, float vx, float xy, int vtx_flag)
float SigmaSS(float ss)
add s for culculation of dz, tanLambda
FTList< FTList< FTSegment * > > _stereo_segments_by_superLayer
int r_phi2Fit(float vx, float xy, int vtx_flag)
float d_z(float s, float z) const
const zav & Zav() const
returns zav
FTList< FTSegment * > _axial_segments
int z(const Lpav &la, double &z) const
returns z for track la
float time() const
rerurns TDC time(after t0 subtraction)
unsigned stateAND(const unsigned mask) const
returns state bit
FTLayer * layer() const
returns layer
void stateOR(const unsigned mask)
set state bit
const float x() const
returns position x
float distance() const
returns drift distance
void setChi2(float chi2)
set residual fit chi2
const float y() const
returns position y
static MdcParameter * instance()