28 #include "StFgtLHTracking.h"
29 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
33 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
34 #include "StMuDSTMaker/COMMON/StMuDst.h"
35 #include "StMuDSTMaker/COMMON/StMuEvent.h"
36 #include "StarClassLibrary/StThreeVectorF.hh"
40 StFgtLHTracking::StFgtLHTracking(
const Char_t* name ) :
StFgtTracking( name ), mPoints( 3 ), mFitThres( 1 ), mIncludeThres( 0.5 ), mNumAgreeThres( mPoints-1 ), mUseVertex(0) { };
43 StFgtLHTracking::~StFgtLHTracking(){ };
45 void StFgtLHTracking::Clear(
const Option_t *opt ){
46 StFgtTracking::Clear();
52 Int_t StFgtLHTracking::findTracks(){
55 StFgtTrPointVec tempPoints;
56 Int_t startDiscIdx = 0;
57 UShort_t discBitArray = 0;
59 Bool_t vertexValid = 0;
68 tempPoints.push_back(
StFgtTrPoint( v.x(), v.y(), v.z() ) );
69 vertex.SetXYZ( v.x(), v.y(), v.z() );
72 LOG_ERROR <<
"ERROR finding vertex from StMuEvent" << endl;
77 makePointTuples( tempPoints, startDiscIdx, discBitArray );
79 Int_t nLines = mLineVec.size();
83 LOG_INFO <<
"------------------------------------------------" << endm;
84 LOG_INFO <<
"Event number " << GetEventNumber() <<
" has " << mPointsTot <<
" points and " << nLines <<
" line(s)" << endm;
99 StFgtLHLineVec::iterator lineIter;
100 for( lineIter = mLineVec.begin(); lineIter != mLineVec.end(); ++lineIter )
104 Double_t includeThresSq = mIncludeThres * mIncludeThres;
105 StFgtLHTrackVec::iterator trackIter1, trackIter2;
106 StFgtTrPointVec::const_iterator pointIter;
110 for( trackIter1 = mTrackVec.begin(); trackIter1 != mTrackVec.end(); ++trackIter1, ++trackIdx ){
111 for( Int_t disc = 0; disc < kFgtNumDiscs; ++disc ){
112 StFgtTrPointVec &pointVec = mPointVecPerDisc[ disc ];
115 for( pointIter = pointVec.begin(); pointIter != pointVec.end(); ++pointIter, ++pointIdx ){
116 Double_t thisResSq = perpDistSqLineToPoint( trackIter1->line, pointIter->pos );
118 if( thisResSq < includeThresSq && thisResSq < trackIter1->resSqPerDisc[disc] ){
119 trackIter1->resSqPerDisc[disc] = thisResSq;
120 trackIter1->pointPerDisc[disc] = pointIdx;
127 Int_t nTracks = mTrackVec.size();
128 LOG_INFO <<
"Before prunning, event number " << GetEventNumber() <<
" has " << nTracks <<
" tracks" << endm;
131 for( trackIter1 = mTrackVec.begin(); trackIter1 != mTrackVec.end(); ++trackIter1, ++trackIdx ){
132 cout <<
"\tPoints on track " << trackIdx <<
": ";
133 for( Int_t i = 0; i<kFgtNumDiscs; ++i )
134 cout << trackIter1->pointPerDisc[i] <<
' ';
138 cout <<
"mInclude Thres is " << mIncludeThres << endl;
142 for( trackIter1 = mTrackVec.begin(); trackIter1 != mTrackVec.end(); ++trackIter1 ){
143 if( trackIter1->pointPerDisc[0] > -2 ){
144 trackIter1->effResSq = 0;
149 trackIter1->effResSq += perpDistSqLineToPoint( trackIter1->line, vertex );
152 for( Int_t disc = 0; disc < kFgtNumDiscs; ++disc )
153 if( trackIter1->pointPerDisc[disc] > -1 ){
154 trackIter1->effResSq += trackIter1->resSqPerDisc[disc];
157 trackIter1->effResSq /= (nDiscs*nDiscs);
159 if( nDiscs < mPoints ){
160 trackIter1->pointPerDisc[0] = -10;
164 for( trackIter2 = mTrackVec.begin(); trackIter2 != trackIter1; ++trackIter2 ){
165 if( trackIter2->pointPerDisc[0] > -2 ){
167 for( Int_t i = 0; i<kFgtNumDiscs; ++i )
168 nAgree += ( trackIter1->pointPerDisc[i] == trackIter2->pointPerDisc[i] && trackIter1->pointPerDisc[i] > -1 ) ;
171 if( nAgree >= mNumAgreeThres ){
172 ( trackIter1->effResSq < trackIter2->effResSq ? trackIter2 : trackIter1 )->pointPerDisc[0] = -10;
180 StFgtLHTrackVec copyVec;
181 for( trackIter1 = mTrackVec.begin(); trackIter1 != mTrackVec.end(); ++trackIter1 )
182 if( trackIter1->pointPerDisc[0] > -2 )
183 copyVec.push_back( *trackIter1 );
184 copyVec.swap( mTrackVec );
187 Int_t nTracks = mTrackVec.size();
188 LOG_INFO <<
"After prunning, event number " << GetEventNumber() <<
" has " << nTracks <<
" tracks" << endm;
191 for( trackIter1 = mTrackVec.begin(); trackIter1 != mTrackVec.end(); ++trackIter1, ++trackIdx ){
192 cout <<
"\tPoints on track " << trackIdx <<
": ";
193 for( Int_t i = 0; i<kFgtNumDiscs; ++i )
194 cout << trackIter1->pointPerDisc[i] <<
' ';
195 cout <<
", old vertZ " << trackIter1->line.vertZ <<
", effRes " << sqrt( trackIter1->effResSq ) << endl;
201 StFgtTrPointVec points;
202 StFgtTrPoint vertex2( vertex.X(), vertex.Y(), vertex.Z() );
204 for( trackIter1 = mTrackVec.begin(); trackIter1 != mTrackVec.end(); ++trackIter1, ++trackIdx ){
206 UShort_t bitArray = 0;
209 points.push_back( vertex2 );
211 for( Int_t i = 0; i<kFgtNumDiscs; ++i )
212 if( trackIter1->pointPerDisc[i] > -1 ){
213 points.push_back( mPointVecPerDisc[i][trackIter1->pointPerDisc[i]] );
218 makeLine( points, bitArray, &trackIter1->line );
221 trackIter1->effResSq = trackIter1->line.res / points.size();
222 trackIter1->effResSq *= trackIter1->effResSq;
225 Double_t perp2 = trackIter1->line.bx*trackIter1->line.bx + trackIter1->line.by*trackIter1->line.by;
226 Double_t x = trackIter1->line.bx + trackIter1->line.mx*120;
227 Double_t y = trackIter1->line.by + trackIter1->line.my*120;
228 Double_t perpB = sqrt(x*x+y*y);
229 cout <<
"\tEvent " << GetEventNumber() <<
" Track new vertZ " << trackIter1->line.vertZ <<
", effRes " << sqrt( trackIter1->effResSq )
230 <<
", bitVec 0x" << std::hex << bitArray << std::dec <<
", perp at z=0 " << sqrt(perp2) <<
" perp at z=120 " << perpB;
239 cout <<
" delta vertZ = " << trackIter1->line.vertZ - v.z();
254 cout <<
"-----> Real vertex at " << v.x() <<
' ' << v.y() <<
' ' << v.z() << endl;
272 void StFgtLHTracking::makePointTuples( StFgtTrPointVec& points, Int_t startDiscIdx, UShort_t discBitArray ){
273 if( startDiscIdx < kFgtNumDiscs ){
274 StFgtTrPointVec::const_iterator iter;
278 for( Int_t disc = startDiscIdx; disc < kFgtNumDiscs; ++disc ){
279 StFgtTrPointVec &pointVec = mPointVecPerDisc[ disc ];
280 UShort_t discBit = (1<<disc);
282 for( iter = pointVec.begin(); iter != pointVec.end(); ++iter ){
283 points.push_back( *iter );
285 ( (Int_t)points.size() < mPoints ) ? makePointTuples( points, disc+1, discBitArray | discBit ) : makeLine( points, discBitArray | discBit );
292 void StFgtLHTracking::makeLine( StFgtTrPointVec& points, UShort_t discBitArray,
StFgtLHLine *linePtr ){
293 StFgtTrPointVec::const_iterator iter = points.begin();
294 Double_t A = 0, B = 0, Cx = 0, Cy = 0, D = 0, Ex = 0, Ey = 0;
298 for( ; iter != points.end(); ++iter ){
299 Double_t x = iter->pos.X();
300 Double_t y = iter->pos.Y();
301 Double_t z = iter->pos.Z();
315 Double_t denom = D*A - B*B;
317 Double_t bx = (-B*Cx + A*Ex)/denom;
318 Double_t by = (-B*Cy + A*Ey)/denom;
319 Double_t mx = ( D*Cx - B*Ex)/denom;
320 Double_t my = ( D*Cy - B*Ey)/denom;
322 mLineVec.push_back(
StFgtLHLine( discBitArray, mx, my, bx, by ) );
335 for( iter = points.begin(); iter != points.end(); ++iter ){
336 line.pointIdx.push_back( iter->ptIdx );
337 dist += perpDistSqLineToPoint( line, iter->pos );
340 line.res = sqrt(dist);
351 if( line.res > mFitThres )
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)