BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
ExtMdcTrack Class Reference

#include <ExtMdcTrack.h>

Public Member Functions

 ExtMdcTrack (void)
 ~ExtMdcTrack (void)
void SetMsgFlag (bool aFlag)
bool SetMdcRecTrkCol (RecMdcTrackCol *aPointer)
bool SetMdcKalTrkCol (RecMdcKalTrackCol *aPointer)
bool SetParId (int pid)
bool GetOneGoodTrk ()
bool ReadTrk (int pid)
int GetTrackID ()
RecMdcTrackGetMdcRecTrkPtr () const
const Hep3Vector GetPosition () const
const Hep3Vector GetMomentum () const
const HepSymMatrix GetErrorMatrix () const
double GetTrackLength () const
double GetTrkTof () const
double GetPt () const
double GetParticleCharge () const

Detailed Description

Definition at line 36 of file ExtMdcTrack.h.

Constructor & Destructor Documentation

◆ ExtMdcTrack()

ExtMdcTrack::ExtMdcTrack ( void )

Definition at line 29 of file ExtMdcTrack.cxx.

30 : myMsgFlag( true )
31 , myInputTrk( "Kal" )
32 , myParID( 2 )
33 , myHelixPar( NumHelixPar )
34 , myMdcErr( NdimMdcErr, 0 )
35 , myPhiTerm( 0. ) {}

◆ ~ExtMdcTrack()

ExtMdcTrack::~ExtMdcTrack ( void )

Definition at line 37 of file ExtMdcTrack.cxx.

37{}

Member Function Documentation

◆ GetErrorMatrix()

const HepSymMatrix ExtMdcTrack::GetErrorMatrix ( ) const

Definition at line 251 of file ExtMdcTrack.cxx.

251 {
252 Ext_Helix aHelix( myPivot, myHelixPar, myMdcErr );
253 // aHelix.pivot(aHelix.x(myPhiTerm));//Move the pivot to the PhiTerm position.
254
255 Hep3Vector aPoint = aHelix.x( myPhiTerm );
256 double phi0 = aHelix.phi0();
257 double kappaInv = 1.0 / aHelix.kappa();
258 double cosPhi0 = cos( phi0 );
259 double sinPhi0 = sin( phi0 );
260 // 0 -> myPhiTerm, 2009-5-29, by wangll
261 // double px = aHelix.momentum(0).x();
262 // double py = aHelix.momentum(0).y();
263 // double pz = aHelix.momentum(0).z();
264 double px = aHelix.momentum( myPhiTerm ).x();
265 double py = aHelix.momentum( myPhiTerm ).y();
266 double pz = aHelix.momentum( myPhiTerm ).z();
267
268 // Calculate the Jacobian: d(xp)/d(helix).
269 HepMatrix Helix2XpJcb( NdimExtErr, NdimMdcErr, 0 );
270
271 Helix2XpJcb( 1, 1 ) = cosPhi0;
272 Helix2XpJcb( 1, 2 ) = myPivot.y() - aPoint.y();
273 Helix2XpJcb( 1, 3 ) = ( myPivot.x() - aPoint.x() + myHelixPar( 1 ) * cosPhi0 ) * kappaInv;
274 Helix2XpJcb( 2, 1 ) = sinPhi0;
275 Helix2XpJcb( 2, 2 ) = aPoint.x() - myPivot.x();
276 Helix2XpJcb( 2, 2 ) = ( myPivot.y() - aPoint.y() + myHelixPar( 1 ) * sinPhi0 ) * kappaInv;
277 Helix2XpJcb( 3, 3 ) = ( myPivot.z() - aPoint.z() + myHelixPar( 4 ) ) * kappaInv;
278 Helix2XpJcb( 3, 4 ) = 1.0;
279 Helix2XpJcb( 3, 5 ) = ( aPoint.z() - myPivot.z() - myHelixPar( 4 ) ) / myHelixPar( 5 );
280 Helix2XpJcb( 4, 2 ) = -py;
281 Helix2XpJcb( 4, 3 ) = -px * kappaInv;
282 Helix2XpJcb( 5, 2 ) = px;
283 Helix2XpJcb( 5, 3 ) = -py * kappaInv;
284 Helix2XpJcb( 6, 3 ) = -pz * kappaInv;
285 Helix2XpJcb( 6, 5 ) = fabs( kappaInv );
286
287 // Calculate the Ext error matrix(6x6) in (x,p).
288 // if(myMsgFlag) cout<<"Error matrix at new pivot: "<<endl;
289 // aHelix.Ea();
290 // cout<<"haha"<<endl;
291 HepSymMatrix aErrorMatrix = aHelix.Ea().similarity( Helix2XpJcb );
292 if ( myMsgFlag ) cout << "PhiTerm Error matrix:" << aErrorMatrix << endl;
293
294 // Uints Conversion.
295 for ( int i = 1; i <= 6; i++ )
296 {
297 for ( int j = 1; j <= i; j++ )
298 {
299 if ( i <= 3 && j <= 3 ) aErrorMatrix.fast( i, j ) *= 100.0;
300 if ( i >= 4 && j >= 4 ) aErrorMatrix.fast( i, j ) *= 1.0e+6;
301 if ( i >= 4 && j <= 3 ) aErrorMatrix.fast( i, j ) *= 10000.0;
302 }
303 }
304
305 return aErrorMatrix;
306}

Referenced by TrkExtAlg::execute().

◆ GetMdcRecTrkPtr()

RecMdcTrack * ExtMdcTrack::GetMdcRecTrkPtr ( ) const

Definition at line 227 of file ExtMdcTrack.cxx.

227{ return ( *myMdcRecTrkIter ); }

◆ GetMomentum()

const Hep3Vector ExtMdcTrack::GetMomentum ( ) const

Definition at line 243 of file ExtMdcTrack.cxx.

243 {
244 Ext_Helix aHelix( myPivot, myHelixPar, myMdcErr );
245 Hep3Vector aMomentum = aHelix.momentum( myPhiTerm ); // In GeV/c units.
246 if ( myMsgFlag ) cout << "PhiTerm Momentum: " << aMomentum << endl;
247 aMomentum *= 1000.0; // In MeV/c uints.
248 return ( aMomentum );
249}

Referenced by TrkExtAlg::execute(), and ReadTrk().

◆ GetOneGoodTrk()

bool ExtMdcTrack::GetOneGoodTrk ( )

Definition at line 55 of file ExtMdcTrack.cxx.

55 {
56 if ( myMsgFlag ) cout << "ExtMdcTrack::GetOneGoodTrk() begin" << endl;
57 if ( myInputTrk == "Mdc" )
58 {
59 myMdcRecTrkIter++;
60 if ( myMdcRecTrkIter != myMdcTrackCol->end() ) return true;
61 else
62 {
63 if ( myMsgFlag ) cout << "No more track!" << endl;
64 return false;
65 }
66 }
67 else if ( myInputTrk == "Kal" ) // use KalTrack as input
68 {
69 myMdcKalTrkIter++;
70 if ( myMdcKalTrkIter != myMdcKalTrackCol->end() ) return true;
71 else
72 {
73 if ( myMsgFlag ) cout << "No more track!" << endl;
74 return false;
75 }
76 }
77
78 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
79 exit( 1 );
80}

Referenced by TrkExtAlg::execute().

◆ GetParticleCharge()

double ExtMdcTrack::GetParticleCharge ( ) const

Definition at line 353 of file ExtMdcTrack.cxx.

353 {
354 return ( ( myHelixPar[2] > 0. ) ? 1.0 : -1.0 );
355}

Referenced by TrkExtAlg::execute().

◆ GetPosition()

const Hep3Vector ExtMdcTrack::GetPosition ( ) const

Definition at line 229 of file ExtMdcTrack.cxx.

229 {
230 // if(myInputTrk=="Mdc") {
231 Ext_Helix aHelix( myPivot, myHelixPar, myMdcErr );
232 Hep3Vector aPoint = aHelix.x( myPhiTerm );
233 if ( myMsgFlag ) cout << "PhiTerm Position: " << aPoint << endl;
234 aPoint *= 10.0;
235 return ( aPoint );
236 /* }
237 else if(myInputTrk=="Kal") {
238 return (myLPosition);
239 }
240 */
241}

Referenced by TrkExtAlg::execute().

◆ GetPt()

double ExtMdcTrack::GetPt ( ) const

Definition at line 351 of file ExtMdcTrack.cxx.

351{ return ( 1.0 / fabs( myHelixPar[2] ) ); }

Referenced by ReadTrk().

◆ GetTrackID()

int ExtMdcTrack::GetTrackID ( )
inline

Definition at line 50 of file ExtMdcTrack.h.

50{ return myTrackID; } // Get RecMdcTrackl ID.

Referenced by TrkExtAlg::execute().

◆ GetTrackLength()

double ExtMdcTrack::GetTrackLength ( ) const

Definition at line 308 of file ExtMdcTrack.cxx.

308 {
309 if ( myInputTrk == "Mdc" )
310 {
311
312 /* //old version
313 Helix aHelix(myPivot,myHelixPar,myMdcErr);
314
315 double phi0 = aHelix.phi0();
316 HepPoint3D w = -(*this).GetParticleCharge() * aHelix.center();
317 Hep3Vector center( w.x(),w.y(),w.z() );
318 double centerX = center.x();
319 double centerY = center.y();
320 double phiCenter;
321 if(fabs(centerX) > 1.0e-10)
322 {
323 phiCenter = atan2(centerY,centerX);
324 if(phiCenter < 0.) phiCenter += 2.0*M_PI;
325 }
326 else
327 {
328 phiCenter = (centerY>0)? M_PI_2:3.0*M_PI_2;
329 }
330 double dPhi = fabs(phi0 + myPhiTerm - phiCenter);
331 if(dPhi >= 2.0*M_PI) dPhi -= 2.0*M_PI;
332 double tanLambda = aHelix.tanl();
333 double cosLambdaInv = sqrt(tanLambda*tanLambda + 1.0);
334 return (10*fabs(aHelix.radius() * dPhi * cosLambdaInv));//10* for cm -> mm
335 */
336
337 Ext_Helix aHelix( myPivot, myHelixPar, myMdcErr );
338 double dPhi = fabs( myPhiTerm );
339 double tanLambda = aHelix.tanl();
340 double cosLambdaInv = sqrt( tanLambda * tanLambda + 1.0 );
341 return ( 10 * fabs( aHelix.radius() * dPhi * cosLambdaInv ) ); // 10* for cm -> mm
342 }
343 else if ( myInputTrk == "Kal" )
344 {
345 return 10 * myTrkLength; // 10* for cm -> mm
346 }
347 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
348 exit( 1 );
349}

Referenced by TrkExtAlg::execute(), and ReadTrk().

◆ GetTrkTof()

double ExtMdcTrack::GetTrkTof ( ) const
inline

Definition at line 56 of file ExtMdcTrack.h.

56{ return myTrkTof; };

Referenced by TrkExtAlg::execute().

◆ ReadTrk()

bool ExtMdcTrack::ReadTrk ( int pid = 2)

Definition at line 82 of file ExtMdcTrack.cxx.

82 {
83 if ( myMsgFlag ) cout << "ExtMdcTrack::ReadTrk() begin" << endl;
84 myParID = pid;
85 if ( myInputTrk == "Mdc" )
86 {
87 if ( myMdcRecTrkIter != myMdcTrackCol->end() )
88 {
89 RecMdcTrack* aMdcTrack = *myMdcRecTrkIter;
90 // if(!aMdcTrack->getStat())//If good track.Now status default 0
91 {
92 if ( myMsgFlag ) cout << "Read a good track!" << endl;
93
94 // get MdcTrk data
95 myTrackID = aMdcTrack->trackId();
96 myHelixPar = aMdcTrack->helix();
97 myPivot = aMdcTrack->getPivot();
98 myMdcErr = aMdcTrack->err();
99 // double aPhiTerm = aMdcTrack->getFiTerm();
100 myPhiTerm = aMdcTrack->getFiTerm();
101 myTrkLength = GetTrackLength();
102 double p = ( GetMomentum() ).mag();
103 double beta = p / sqrt( mass[myParID] * mass[myParID] + p * p );
104 myTrkTof = myTrkLength / ( beta * 299.792458 );
105
106 /* //Start caculation of myPhiTerm.(when pivot is
107 (0,0,0).) double r = DBL_MAX; double rMdc = 81.0; double dro = myHelixPar(1);
108 if(myHelixPar(3)!=0.0)
109 r = 333.564095/myHelixPar(3);
110 if( fabs(2.0*r+dro)>rMdc && fabs(dro)<rMdc )
111 {
112 double aValue =
113 ((dro+r)*(dro+r)+r*r-rMdc*rMdc)/2.0/fabs(r)/fabs(dro+r); if(r<0.0) myPhiTerm =
114 acos(aValue); else myPhiTerm = -1.0*acos(aValue);
115 }
116 else
117 {
118 if(myMsgFlag) cout<<"Get a track which can't go out of
119 MDC!"<<endl; myMdcRecTrkIter++; continue;
120 }
121 */
122 // double
123 // aTrackLength=fabs(r*myPhiTerm)*sqrt(myHelixPar(5)*myHelixPar(5)+1);
124 if ( myMsgFlag )
125 {
126 cout << "MDC track:" << myTrackID << endl;
127 cout << "Helix: " << myHelixPar;
128 cout << "pivot: " << myPivot << "cm" << endl;
129 cout << "Error: " << myMdcErr << endl;
130
131 /* Convert();
132 cout<<"********after convert:"<<endl;
133 cout<<"Helix: "<<myHelixPar;
134 cout<<"pivot: "<<myPivot;
135 cout<<"Error: "<<myMdcErr<<endl;
136 */
137 cout << "Pt: " << GetPt() << "GeV/c" << endl;
138 cout << "PhiTerm: " << myPhiTerm << endl;
139 // cout<<"recPhiTerm: "<<aPhiTerm<<endl;
140 cout << "trackLength(mm): " << GetTrackLength() << endl;
141 // cout<<"trackLengthTest(cm):
142 //"<<aTrackLength<<endl;
143 }
144
145 return true;
146 }
147 // else
148 // {
149 // myMdcRecTrkIter++;
150 // cout<<"Get a bad track!"<<endl;
151 // }
152 }
153 else
154 {
155 if ( myMsgFlag ) cout << "No more track!" << endl;
156 return false;
157 }
158 }
159 else if ( myInputTrk == "Kal" ) // use KalTrack as input
160 {
161 if ( myMdcKalTrkIter != myMdcKalTrackCol->end() )
162 {
163 RecMdcKalTrack* aMdcKalTrack = *myMdcKalTrkIter;
164 {
165 if ( myMsgFlag ) cout << "Get a good track!" << endl;
166
167 // get MdcTrk data
168 myTrackID = aMdcKalTrack->getTrackId();
169 myHelixPar = aMdcKalTrack->getLHelix( myParID );
170 // myPivot = HepPoint3D(0,0,0);
171 myPivot = aMdcKalTrack->getLPivot( myParID );
172 myMdcErr = aMdcKalTrack->getLError( myParID );
173 myPhiTerm = aMdcKalTrack->getFiTerm( myParID );
174 myPhiTerm = 0.0;
175 myTrkLength = aMdcKalTrack->getPathSM( myParID );
176 myLPosition = aMdcKalTrack->getLPoint( myParID );
177 myTrkTof = aMdcKalTrack->getTof( myParID );
178 // cout<<"myInitialTof = "<<myTrkTof<<endl;
179
180 if ( myMsgFlag )
181 {
182 cout << "Kal track:" << myTrackID << endl;
183 cout << "myParID:" << myParID << endl;
184 cout << "Helix: " << myHelixPar;
185 cout << "pivot: " << myPivot << "cm" << endl;
186 cout << "Error: " << myMdcErr << endl;
187 cout << "Pt: " << GetPt() << "GeV/c" << endl;
188 cout << "PhiTerm: " << myPhiTerm << endl;
189 // cout<<"trackLength(mm):
190 //"<<GetTrackLength()<<endl;
191 cout << "trackLength(cm): " << myTrkLength << endl;
192 cout << "myTrkTof: " << myTrkTof << endl;
193 cout << "Last point position: " << myLPosition << endl;
194 }
195 return true;
196 }
197 }
198 else
199 {
200 if ( myMsgFlag ) cout << "No more track!" << endl;
201 return false;
202 }
203 }
204 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
205 exit( 1 );
206}
double mass
const HepSymMatrix err() const
const HepVector helix() const
......
double GetTrackLength() const
double GetPt() const
const Hep3Vector GetMomentum() const

Referenced by TrkExtAlg::execute().

◆ SetMdcKalTrkCol()

bool ExtMdcTrack::SetMdcKalTrkCol ( RecMdcKalTrackCol * aPointer)

Definition at line 47 of file ExtMdcTrack.cxx.

47 {
48 myMdcKalTrackCol = aPointer;
49 myMdcKalTrkIter = myMdcKalTrackCol->begin();
50 myMdcKalTrkIter--;
51 myInputTrk = "Kal";
52 return true;
53}

Referenced by TrkExtAlg::execute().

◆ SetMdcRecTrkCol()

bool ExtMdcTrack::SetMdcRecTrkCol ( RecMdcTrackCol * aPointer)

Definition at line 39 of file ExtMdcTrack.cxx.

39 {
40 myMdcTrackCol = aPointer;
41 myMdcRecTrkIter = myMdcTrackCol->begin();
42 myMdcRecTrkIter--;
43 myInputTrk = "Mdc";
44 return true;
45}

Referenced by TrkExtAlg::execute().

◆ SetMsgFlag()

void ExtMdcTrack::SetMsgFlag ( bool aFlag)
inline

Definition at line 41 of file ExtMdcTrack.h.

41{ myMsgFlag = aFlag; };

Referenced by TrkExtAlg::execute().

◆ SetParId()

bool ExtMdcTrack::SetParId ( int pid)
inline

Definition at line 44 of file ExtMdcTrack.h.

44 {
45 myParID = pid;
46 return true;
47 };

The documentation for this class was generated from the following files: