StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFwdTrack.cxx
1 #include "StMuFwdTrack.h"
2 #include <vector>
3 
4 #include "StEvent/StFwdTrack.h"
5 
6 StMuFwdTrack::StMuFwdTrack() {
7 
8 }
9 
10 void StMuFwdTrack::set( StFwdTrack * evTrack) {
11  mDidFitConverge = evTrack->didFitConverge();
12  mDidFitConvergeFully = evTrack->didFitConvergeFully();
13  mNumberOfFailedPoints = evTrack->numberOfFailedPoints();
14  mNumberOfSeedPoints = evTrack->numberOfSeedPoints();
15  mNumberOfFitPoints = evTrack->numberOfFitPoints();
16  mChi2 = evTrack->chi2();
17  mNDF = evTrack->ndf();
18  mPval = evTrack->pval();
19  mCharge = evTrack->charge();
20  mPrimaryMomentum = TVector3( evTrack->momentum().x(), evTrack->momentum().y(), evTrack->momentum().z() );
21 
22  //copy the projections
23  for ( auto proj : evTrack->mProjections ){
24  mProjections.push_back(
25  StMuFwdTrackProjection( proj.mDetId, TVector3( proj.mXYZ.x(), proj.mXYZ.y(), proj.mXYZ.z() ), TVector3( proj.mMom.x(), proj.mMom.y(), proj.mMom.z() ), proj.mCov )
26  );
27  }
28 
29  //copy the FTT Seed Points
30  for ( auto sp : evTrack->mFTTPoints ){
31  mFTTPoints.push_back(
32  StMuFwdTrackSeedPoint( TVector3( sp.mXYZ.x(), sp.mXYZ.y(), sp.mXYZ.z() ), sp.mSector, sp.mTrackId, sp.mCov )
33  );
34  }
35 
36  //copy the FST Seed Points
37  for ( auto sp : evTrack->mFSTPoints ){
38  mFSTPoints.push_back(
39  StMuFwdTrackSeedPoint( TVector3( sp.mXYZ.x(), sp.mXYZ.y(), sp.mXYZ.z() ), sp.mSector, sp.mTrackId, sp.mCov )
40  );
41  }
42 }
43 
44 
45 void StMuFwdTrack::addEcalCluster( StMuFcsCluster* clu){
46  int n=mEcalClusters.GetSize();
47  for(int i=0; i<n; i++) if(mEcalClusters[i]==clu) return; //already there, do nothing
48  mEcalClusters.Add(clu);
49 }
50 void StMuFwdTrack::addHcalCluster( StMuFcsCluster* clu){
51  int n=mHcalClusters.GetSize();
52  for(int i=0; i<n; i++) if(mHcalClusters[i]==clu) return; //already there, do nothing
53  mHcalClusters.Add(clu);
54 }
55 
56 /* momentum
57  * get the track momentum at the first point (PV if included)
58  */
59 TVector3 StMuFwdTrack::momentum() const{
60  return mPrimaryMomentum;
61 }
62 
63 /* momentumAt
64  * get the track momentum at the nthh point (if available)
65  */
66 TVector3 StMuFwdTrack::momentumAt(size_t _id) const{
67  if ( _id >= mProjections.size() )
68  return TVector3( 0, 0, 0 );
69 
70  return mProjections[_id].mMom;
71 }
72 
73 char StMuFwdTrack::charge() const{
74  return mCharge;
75 }
76 
77 bool StMuFwdTrack::didFitConverge() const {
78  return mDidFitConverge;
79 }
80 
81 bool StMuFwdTrack::didFitConvergeFully() const {
82  return mDidFitConvergeFully;
83 }
84 
85 short StMuFwdTrack::numberOfFailedPoints() const {
86  return mNumberOfFailedPoints;
87 }
88 
89 double StMuFwdTrack::chi2() const {
90  return mChi2;
91 }
92 
93 double StMuFwdTrack::ndf() const {
94  return mNDF;
95 }
96 
97 double StMuFwdTrack::pval() const {
98  return mPval;
99 }
100 
101 short StMuFwdTrack::numberOfFitPoints() const {
102  return mNumberOfFitPoints;
103 }
104 
105 short StMuFwdTrack::numberOfSeedPoints() const {
106  return mNumberOfSeedPoints;
107 }
108 
109 
110 // StPtrVecFcsCluster& StMuFwdTrack::ecalClusters() { return mEcalClusters; }
111 // const StPtrVecFcsCluster& StMuFwdTrack::ecalClusters() const { return mEcalClusters; }
112 // void StMuFwdTrack::addEcalCluster(StFcsCluster* p){mEcalClusters.push_back(p);}
113 // void StMuFwdTrack::sortEcalClusterByET() {
114 // std::sort(mEcalClusters.begin(), mEcalClusters.end(), [](StFcsCluster* a, StFcsCluster* b) {
115 // return b->fourMomentum().perp() < a->fourMomentum().perp();
116 // });
117 // }
118 
119 // StPtrVecFcsCluster& StMuFwdTrack::hcalClusters() { return mHcalClusters; }
120 // const StPtrVecFcsCluster& StMuFwdTrack::hcalClusters() const { return mHcalClusters; }
121 // void StMuFwdTrack::addHcalCluster(StFcsCluster* p){mHcalClusters.push_back(p);}
122 // void StMuFwdTrack::sortHcalClusterByET() {
123 // std::sort(mHcalClusters.begin(), mHcalClusters.end(), [](StFcsCluster* a, StFcsCluster* b) {
124 // return b->fourMomentum().perp() < a->fourMomentum().perp();
125 // });
126 // }
127 
128 bool StMuFwdTrack::getProjectionFor( int detectorId,
129  StMuFwdTrackProjection &rProj,
130  size_t index ){
131  size_t count = 0;
132  for ( auto proj : mProjections ){
133  if (proj.mDetId == detectorId){
134  rProj.set( proj );
135  if ( count == index )
136  return true;
137  count++;
138  }
139  }
140  return false;
141 }