5 #include "StThreeVectorF.hh"
6 #include "StThreeVectorD.hh"
7 #include "StThreeVector.hh"
9 #include "StiHitContainer.h"
11 #include "StiDetector.h"
12 #include "StiPlacement.h"
13 #include "StiDetectorContainer.h"
14 #include "StiLocalTrackSeedFinder.h"
15 #include "StiSortedHitIterator.h"
16 #include "StiMasterDetectorBuilder.h"
21 StiLocalTrackSeedFinder::StiLocalTrackSeedFinder(
const string& name,
22 const string& description,
28 _trackFactory(trackFactory),
29 _hitContainer(hitContainer),
30 _detectorContainer(detectorContainer)
37 StiLocalTrackSeedFinder::~StiLocalTrackSeedFinder()
56 _hitIter =
StiSortedHitIterator(_hitContainer,_detectorContainer->begin(),_detectorContainer->end());
64 if (fRxyMin && pow(hit->
x(),2)+pow(hit->y(),2)<fRxyMin*fRxyMin)
continue;
67 catch(runtime_error & rte )
86 if ( _detectorContainer->
moveIn()==false )
return false;
87 const StiDetector* d = _detectorContainer->getCurrentDetector();
89 if (p->getLayerRadius() < fRxyMin)
return false;
90 StiHit* closestHit = _hitContainer->getNearestHit(p->getLayerRadius(),
93 StiLocalTrackSeedFinderParameters::instance()->deltaY(),
94 StiLocalTrackSeedFinderParameters::instance()->deltaZ());
96 if (!closestHit )
return false;
97 _seedHits.push_back(closestHit);
109 _seedHits.push_back(hit);
113 int iSeedLength = seedPars->seedLength();
114 int iExtrapMaxLength = seedPars->extrapMaxLength();
115 int iExtrapMinLength = seedPars->extrapMinLength();
116 int iMaxSkipped = seedPars->maxSkipped();
118 while ( go && (
int)_seedHits.size()<iSeedLength)
124 if ( (
int)_seedHits.size()<iSeedLength )
131 while ( go && _skipped<=iMaxSkipped &&
132 (
int)_seedHits.size()<=( iSeedLength+iExtrapMaxLength))
139 if ( (
int)_seedHits.size()<( iSeedLength+iExtrapMinLength) )
182 const StiHit* hit1 = *( _seedHits.begin()+_seedHits.size() -2 );
183 const StiHit* hit2 = _seedHits.back();
187 double r1 = hit1->
x();
188 double y1 = hit1->y();
189 double z1 = hit1->z();
190 double r2 = hit2->
x();
191 double y2 = hit2->y();
192 double z2 = hit2->z();
197 if (fabs(dr) <=1.e-3)
return false;
198 assert (fabs(dr) >1.e-3);
202 for (
int i=0; i<=_skipped; ++i)
204 if ( _detectorContainer->
moveIn()==
false)
211 const StiDetector* newLayer = **_detectorContainer;
212 double r3 = newLayer->getPlacement()->getNormalRadius();
216 if (r3<=25.) {
return false; }
222 double y3 = y1 + dy/dr*(r3-r1);
225 double beta_ry = atan2(dr, dy);
226 double rho_ry = ::sqrt(dr*dr + dy*dy);
227 double alpha_ry = atan2(StiLocalTrackSeedFinderParameters::instance()->extrapDeltaY(), 2.*rho_ry);
228 double tanplus_ry = tan(beta_ry+alpha_ry);
229 double tanminus_ry = tan(beta_ry-alpha_ry);
230 if (tanplus_ry==0. || tanminus_ry==0.)
231 cout<<
"StiLocalTrackSeedFidner::extrapolate(). -W- tanplus_ry==0. || tanminus_ry==0."<<endl;
233 double y3_minus = (r3-r1)/tanplus_ry + y1;
234 double y3_plus = (r3-r1)/tanminus_ry + y1;
236 double z3 = z1 + dz/dr*(r3-r1);
238 double beta_rz = atan2(dr, dz);
239 double rho_rz = ::sqrt(dr*dr + dz*dz);
240 double alpha_rz = atan2(StiLocalTrackSeedFinderParameters::instance()->extrapDeltaZ(), 2.*rho_rz);
241 double tanplus_rz = tan(beta_rz+alpha_rz);
242 double tanminus_rz = tan(beta_rz-alpha_rz);
243 if (tanplus_rz==0. || tanminus_rz==0.)
244 cout<<
"StiLocalTrackSeedFidner::extrapolate(). -W- tanplus_rz==0. || tanminus_rz==0."<<endl;
245 double z3_minus = (r3-r1)/tanplus_rz + z1;
246 double z3_plus = (r3-r1)/tanminus_rz + z1;
255 StiHit* closestHit = _hitContainer->getNearestHit(p->getLayerRadius(),
258 fabs(y3_plus-y3_minus) /2.,
259 fabs(z3_plus-z3_minus) /2.);
267 _seedHits.push_back(closestHit);
277 bool status = fit(track);
278 if (!status) track = 0;
290 void StiLocalTrackSeedFinder::print()
const
292 cout <<
"StiLocalTrackSeedFinder::print() -I- ";
293 for (vector<StiDetector*>::const_iterator it=_detectorContainer->begin();
294 it!=_detectorContainer->end();
299 cout <<
"\n Search Window in Y:\t"<<StiLocalTrackSeedFinderParameters::instance()->deltaY()<<endl;
300 cout <<
"\n Search Window in Z:\t"<<StiLocalTrackSeedFinderParameters::instance()->deltaZ()<<endl;
306 return os <<
" StiLocalTrackSeedFinder " << endl;
Definition of Kalman Track.
Abstract definition of a Track.
bool moveIn(double phiCut=-1.0, double zCut=-1.0, double rMin=-1.0)
Step in radially in STAR TPC global coordinates.
StiKalmanTrack * initializeTrack(StiKalmanTrack *)
StiKalmanTrack * makeTrack(StiHit *hit)
void setToDetector(const StiDetector *layer)
Set iterators to the detector nearest to the passed StiDetector pointer.
const Float_t & x() const
Return the local x, y, z values.
const StiDetector * detector() const
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
Definition of Kalman Track.
virtual int initialize(const vector< StiHit * > &)
Convenience method to initialize a track based on seed information.
StiTrack * findTrack(double rMin=0)
bool extendHit(StiHit &hit)
Extend hit looking for closest neighbor in z.
UInt_t timesUsed() const
Return the number of times this hit was assigned to a track.
An abstract class defining the interface to the track finder.
bool extrapolate()
Extrapolate to next layer using straight line, add hit closest in z.