158 #include "StParticleDefinition.hh"
159 #include "StVertex.h"
160 #include "StTrackGeometry.h"
161 #include "StTrackDetectorInfo.h"
162 #include "StTrackPidTraits.h"
163 #include "StTrackNode.h"
164 #include "StThreeVectorD.hh"
166 #include "StG2TrackVertexMap.h"
167 #include "StExtGeometry.h"
170 static const
char rcsid[] = "$Id:
StTrack.cxx,v 2.47 2017/05/04 01:00:30 perev Exp $";
174 memset(mBeg, 0, mEnd-mBeg+1);
179 for (
int bit = 14; bit < 23; bit++)
if (track.TestBit(BIT(bit))) SetBit(BIT(bit));
180 memcpy (mBeg, track.mBeg, mEnd-mBeg+1);
181 mTopologyMap = track.mTopologyMap;
182 mFitTraits = track.mFitTraits;
184 mGeometry = track.mGeometry->copy();
187 if (track.mOuterGeometry)
188 mOuterGeometry = track.mOuterGeometry->copy();
191 mDetectorInfo = track.mDetectorInfo;
192 mPidTraitsVec = track.mPidTraitsVec;
197 StTrack::operator=(
const StTrack& track) {
198 if (
this != &track) {
199 for (
int bit = 14; bit < 23; bit++)
if (track.TestBit(BIT(bit))) SetBit(BIT(bit));
200 memcpy (mBeg, track.mBeg, mEnd-mBeg+1);
201 mTopologyMap = track.mTopologyMap;
202 mFitTraits = track.mFitTraits;
203 if (mGeometry)
delete mGeometry;
205 mGeometry = track.mGeometry->copy();
208 if (mOuterGeometry)
delete mOuterGeometry;
209 if (track.mOuterGeometry)
210 mOuterGeometry = track.mOuterGeometry->copy();
213 mDetectorInfo = track.mDetectorInfo;
214 mPidTraitsVec = track.mPidTraitsVec;
222 delete mOuterGeometry;
226 StTrack::flag()
const {
return mFlag; }
230 StTrack::encodedMethod()
const {
return mEncodedMethod; }
233 StTrack::finderMethod(StTrackFinderMethod bit)
const
235 return mEncodedMethod & (1<<bit);
239 StTrack::fittingMethod()
const
241 int method = mEncodedMethod & 0xf;
244 return kHelix2StepId;
262 return kITKalmanFitId;
265 case kUndefinedFitterId:
266 return kUndefinedFitterId;
272 StTrack::impactParameter()
const {
return mImpactParameter; }
275 StTrack::length()
const {
return mLength; }
278 StTrack::numberOfPossiblePoints()
const
280 unsigned short result;
281 result = numberOfPossiblePoints(kTpcId) +
282 numberOfPossiblePoints(kFtpcWestId) +
283 numberOfPossiblePoints(kFtpcEastId) +
284 numberOfPossiblePoints(kSvtId) +
285 numberOfPossiblePoints(kSsdId) +
286 numberOfPossiblePoints(kSstId) +
287 numberOfPossiblePoints(kPxlId) +
288 numberOfPossiblePoints(kIstId) +
289 numberOfPossiblePoints(kFtsId);
290 if (type() == primary || type() == estPrimary) result++;
295 StTrack::numberOfPossiblePoints(StDetectorId det)
const
299 return mNumberOfPossiblePointsFtpcWest;
301 return mNumberOfPossiblePointsFtpcEast;
303 return mNumberOfPossiblePointsTpc;
305 return mNumberOfPossiblePointsSvt;
307 return mNumberOfPossiblePointsSsd;
309 return mNumberOfPossiblePointsSst;
311 return mNumberOfPossiblePointsPxl;
313 return mNumberOfPossiblePointsIst;
315 return mNumberOfPossiblePointsFts;
322 StTrack::topologyMap()
const {
return mTopologyMap; }
325 StTrack::geometry()
const {
return mGeometry; }
328 StTrack::geometry() {
return mGeometry; }
331 StTrack::outerGeometry()
const {
return mOuterGeometry; }
334 StTrack::outerGeometry() {
return mOuterGeometry; }
337 StTrack::fitTraits() {
return mFitTraits; }
340 StTrack::fitTraits()
const {
return mFitTraits; }
343 StTrack::detectorInfo() {
return mDetectorInfo; }
346 StTrack::detectorInfo()
const {
return mDetectorInfo; }
348 const StSPtrVecTrackPidTraits&
349 StTrack::pidTraits()
const {
return mPidTraitsVec; }
351 StSPtrVecTrackPidTraits&
352 StTrack::pidTraits() {
return mPidTraitsVec; }
354 StPtrVecTrackPidTraits
355 StTrack::pidTraits(StDetectorId det)
const
357 StPtrVecTrackPidTraits vec;
358 for (
unsigned int i=0; i<mPidTraitsVec.size(); i++)
359 if (mPidTraitsVec[i]->detector() == det)
360 vec.push_back(mPidTraitsVec[i]);
367 return pid(*
this, mPidTraitsVec);
371 StTrack::node()
const {
return mNode; }
374 StTrack::node() {
return mNode; }
377 StTrack::setFlag(
short val) { mFlag = val; }
381 StTrack::setEncodedMethod(
unsigned short val) { mEncodedMethod = val; }
384 StTrack::setImpactParameter(
float val) { mImpactParameter = val; }
387 StTrack::setLength(
float val) { mLength = val; }
395 if (mGeometry)
delete mGeometry;
402 if (mOuterGeometry)
delete mOuterGeometry;
403 mOuterGeometry = val;
410 StTrack::addPidTraits(
StTrackPidTraits* val) { mPidTraitsVec.push_back(val); }
417 StTrack::setNumberOfPossiblePoints(
unsigned char val, StDetectorId det)
421 mNumberOfPossiblePointsFtpcWest = val;
424 mNumberOfPossiblePointsFtpcEast = val;
427 mNumberOfPossiblePointsTpc = val;
430 mNumberOfPossiblePointsSvt = val;
433 mNumberOfPossiblePointsSsd = val;
436 mNumberOfPossiblePointsSst = val;
439 mNumberOfPossiblePointsPxl = val;
442 mNumberOfPossiblePointsIst = val;
445 mNumberOfPossiblePointsFts = val;
453 StTrack::setNode(
StTrackNode* val) { mNode = val; }
455 #include "StHelixModel.h"
456 int StTrack::bad()
const
458 static const double world = 1.e+5;
460 if (!StMath::Finite(mImpactParameter))
return 12;
461 if (!StMath::Finite(mLength) )
return 13;
462 if (mFlag <0 )
return 21;
463 if (mFlag ==0 )
return 31;
464 if (::fabs(mImpactParameter)>world )
return 22;
465 if (::fabs(mLength) >world )
return 23;
466 if (mLength <1./world )
return 33;
467 if (mLength > world )
return 34;
468 if (!mGeometry )
return 24;
469 ierr = mGeometry->bad();
470 if (ierr )
return 4+100*ierr;
471 if (!mOuterGeometry )
return 25;
472 ierr = mOuterGeometry->bad();
473 if (ierr )
return 5+100*ierr;
478 if (ierr )
return 6+100*ierr;
479 if ((flag()/100)%10 == 9)
return 0;
483 double per = hlx1.
period();
484 while (len12< 0) len12+=per;
485 while (len12>per) len12-=per;
486 double tol = (len12)*0.2;
if (tol<1) tol =1;
489 if (fabs(hlx1.z(mLength))>kStarMaxTrackRangeZ)
return 53;
490 double qwe = pow(hlx1.
x(mLength),2)+pow(hlx1.y(mLength),2);
491 if (sqrt(qwe)>kStarMaxTrackRangeR)
return 63;
495 void StTrack::Streamer(TBuffer &R__b)
499 if (R__b.IsReading()) {
500 unsigned int R__s, R__c;
501 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
503 Class()->ReadBuffer(R__b,
this, R__v, R__s, R__c);
507 StObject::Streamer(R__b);
512 UChar_t oldEncodedMethod;
513 R__b >> oldEncodedMethod;
514 mEncodedMethod=oldEncodedMethod;
516 R__b >> mImpactParameter;
518 R__b >> mSeedQuality;
519 mTopologyMap.Streamer(R__b);
520 mFitTraits.Streamer(R__b);
530 mPidTraitsVec.Streamer(R__b);
532 R__b.CheckByteCount(R__s, R__c, Class());
536 Class()->WriteBuffer(R__b,
this);
541 void StTrack::setIdTruth()
546 const StPtrVecHit& vh = di->hits();
548 typedef std::map< int,float> myMap_t;
549 typedef std::pair<int,float> myPair_t;
550 typedef myMap_t::const_iterator myIter_t;
554 int nHits = vh.size(),
id=0,qa=0;
555 for (
int hi=0;hi<nHits; hi++) {
556 const StHit* rHit = vh[hi];
557 id = rHit->idTruth();
if (!
id)
continue;
558 qa = rHit->qaTruth();
if (!qa) qa = 1;
561 if (! idTruths.size())
return;
562 int tkBest=-1;
float qaBest=0,qaSum=0;
563 for (myIter_t it=idTruths.begin(); it!=idTruths.end();++it) {
565 if ((*it).second<qaBest)
continue;
566 tkBest=(*it).first; qaBest=(*it).second;
568 if (tkBest < 0 || tkBest> 0xffff)
return;
569 int avgQua= 100*qaBest/(qaSum+1e-10)+0.5;
570 setIdTruth(tkBest,avgQua);
571 int IdVx = StG2TrackVertexMap::instance()->IdVertex(tkBest);
575 ostream& operator<<(ostream& os,
const StTrack& track) {
576 os << Form(
"%4i ",track.key());
577 if (track.type() == global) os <<
"global";
578 else os <<
"primary";
579 os << Form(
" %4i",track.flag());
580 if (track.isPostXTrack()) os <<
"C";
581 else if (track.isPromptTrack()) os <<
"P";
583 if (track.isCtbMatched() || track.isToFMatched()) os <<
"T";
585 if (track.isBemcMatched() || track.isEemcMatched()) {
586 if (track.isBemcMatched()) os <<
"b";
588 unsigned int fext = track.flagExtension() & 07;
590 case 0: os <<
" ";
break;
591 case 1: os <<
"M";
break;
592 case 2: os <<
"H";
break;
593 case 3: os <<
"E";
break;
594 case 4: os <<
"T";
break;
595 case 5: os <<
"W";
break;
596 case 6: os <<
"Z";
break;
597 default: os <<
"?";
break;
600 if (track.isMembraneCrossingTrack()) os <<
"X";
601 else if (track.isWestTpcOnly()) os <<
"W";
602 else if (track.isEastTpcOnly()) os <<
"E";
604 if (track.isShortTrack2EMC()) os <<
"S";
606 if (track.isRejected()) os <<
"R";
608 double length = track.length();
609 if (length > 9999.) length = 9999.;
610 os << Form(
" NP %2d L %8.3f", track.numberOfPossiblePoints(),length);
611 os << Form(
" IdT: %4i Q:%3i", track.idTruth(), track.qaTruth());
618 for (; *kexg; kexg = &((*kexg)->mNext)) {}
double x(double s) const
coordinates of helix at point s
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
double period() const
returns period length of helix