BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkMomCalculator Class Reference

#include <TrkMomCalculator.h>

Public Member Functions

 TrkMomCalculator ()
 
virtual ~TrkMomCalculator ()
 

Static Public Member Functions

static double ptMom (const TrkSimpTraj &, const BField &, double fltlen)
 
static Hep3Vector vecMom (const TrkSimpTraj &, const BField &, double fltlen)
 
static BesVectorErr errMom (const TrkSimpTraj &, const BField &, double fltlen)
 
static int charge (const TrkSimpTraj &, const BField &, double fltlen)
 
static HepMatrix posmomCov (const TrkSimpTraj &, const BField &, double fltlen)
 
static void getAllCovs (const TrkSimpTraj &, const BField &, double fltlen, HepSymMatrix &xxCov, HepSymMatrix &ppCov, HepMatrix &xpCov)
 
static bool weightToCov (const HepSymMatrix &inXX, const HepSymMatrix &inPP, const HepMatrix &inXP, HepSymMatrix &outXX, HepSymMatrix &outPP, HepMatrix &outXP)
 
static void getAllWeights (const TrkSimpTraj &, const BField &, double fltlen, HepVector &pos, HepVector &mom, HepSymMatrix &xxWeight, HepSymMatrix &ppWeight, HepMatrix &xpWeight)
 

Detailed Description

Definition at line 36 of file TrkMomCalculator.h.

Constructor & Destructor Documentation

◆ TrkMomCalculator()

TrkMomCalculator::TrkMomCalculator ( )

Definition at line 41 of file TrkMomCalculator.cxx.

41 {
42//------------------------------------------------------------------------
43}

◆ ~TrkMomCalculator()

TrkMomCalculator::~TrkMomCalculator ( )
virtual

Definition at line 36 of file TrkMomCalculator.cxx.

36 {
37//------------------------------------------------------------------------
38}

Member Function Documentation

◆ charge()

int TrkMomCalculator::charge ( const TrkSimpTraj & theTraj,
const BField & theField,
double fltlen )
static

Definition at line 140 of file TrkMomCalculator.cxx.

141 {
142//------------------------------------------------------------------------
143
144 TrkMomVisitor theVisitor(theTraj);
145
146 if (theVisitor.helix() != 0 || theVisitor.circle() != 0) {
147
148// treat as curve, calculate Pt accordingly (see calcCurvMom function
149// below)
150
151 bool plus = false;
153 int index = parInd;
154 plus = (theField.bFieldNominal() < 0.0 &&
155 theTraj.parameters()->parameter()[index] > 0.0)
156 ||
157 (theField.bFieldNominal() > 0.0 &&
158 theTraj.parameters()->parameter()[index] <
159 0.0);
160 return ( plus ? 1 : -1 );
161
162// return calcCurvCharge(
163// theTraj.direction(fltlen),
164// theTraj.curvature(fltlen), theField);
165
166 } else if (theVisitor.neut() != 0) {
167
168// treat as neutral particle, so charge is zero
169 return 0;
170
171 } else {
172
173// particle must be a plain line--take charge as zero
174 return 0;
175 }
176}
HepVector & parameter()
Definition DifIndepPar.h:51
TrkParams * parameters()
Definition TrkSimpTraj.h:80

Referenced by TrkSimpleRep::charge().

◆ errMom()

BesVectorErr TrkMomCalculator::errMom ( const TrkSimpTraj & theTraj,
const BField & theField,
double fltlen )
static

Definition at line 112 of file TrkMomCalculator.cxx.

113 {
114//------------------------------------------------------------------------
115
116 TrkMomVisitor theVisitor(theTraj);
117
118 if (theVisitor.helix() != 0 || theVisitor.circle() != 0) {
119
120// treat as curve, calculate ErrMom accordingly (see calcCurvMom function
121// below)
122 return calcCurvErrMom(theTraj, theField, fltlen);
123
124 } else if (theVisitor.neut() != 0) {
125
126// treat as neutral particle, same as curve in this case
127 return calcNeutErrMom(theTraj, theField, fltlen);
128
129 } else {
130
131// particle must be a plain line--no way to calculate momentum or err
132// The matrix is initialized to zero (see BesError constructor)
133 BesError theErr(3);
134 return BesVectorErr(Hep3Vector(999, 999, 999), theErr);
135 }
136}

Referenced by TrkCompTrk::momentumErr(), and TrkSimpleRep::momentumErr().

◆ getAllCovs()

void TrkMomCalculator::getAllCovs ( const TrkSimpTraj & theTraj,
const BField & theField,
double fltlen,
HepSymMatrix & xxCov,
HepSymMatrix & ppCov,
HepMatrix & xpCov )
static

Definition at line 207 of file TrkMomCalculator.cxx.

212 {
213//------------------------------------------------------------------------
214
215 TrkMomVisitor theVisitor(theTraj);
216
217 if (theVisitor.helix() != 0) {
218
219 // fast inline calculation...
220 calcCurvAllCovs(theTraj,theField,fltlen,xxCov,ppCov,xpCov);
221
222 } else if (theVisitor.circle() != 0){
223
224 // treat as curve, calculate ErrMom accordingly (see calcCurvMom function
225 // below)
226 calcCurvAllCovsOLD(theTraj,theField,fltlen,xxCov,ppCov,xpCov);
227
228 } else if (theVisitor.neut() != 0) {
229
230 // treat as neutral particle, same as curve in this case
231 calcNeutAllCovs(theTraj,theField,fltlen,xxCov,ppCov,xpCov);
232
233 } else {
234
235 // particle must be a plain line--no way to calculate momentum or err
236 // The matrix is initialized to zero (see BesError constructor)
237 int i,j;
238 for(i=0;i<3;i++)
239 for(j=i;j<3;j++)
240 {
241 xxCov[i][j]=0;
242 ppCov[i][j]=0;
243 xpCov[i][j]=0;
244 xpCov[j][i]=0;
245 }
246 }
247
248}

Referenced by TrkCompTrk::getAllCovs(), and TrkSimpleRep::getAllCovs().

◆ getAllWeights()

void TrkMomCalculator::getAllWeights ( const TrkSimpTraj & theTraj,
const BField & theField,
double fltlen,
HepVector & pos,
HepVector & mom,
HepSymMatrix & xxWeight,
HepSymMatrix & ppWeight,
HepMatrix & xpWeight )
static

Definition at line 252 of file TrkMomCalculator.cxx.

259 {
260//------------------------------------------------------------------------
261
262 TrkMomVisitor theVisitor(theTraj);
263
264 if (theVisitor.helix() != 0){
265
266 // treat as curve, calculate ErrMom accordingly (see calcCurvMom function
267 // below)
268 calcCurvAllWeights(theTraj,theField,fltlen,
269 pos,mom,xxWeight,ppWeight,xpWeight);
270
271 } else if (theVisitor.circle() != 0) {
272
273 calcCurvAllWeightsOLD(theTraj,theField,fltlen,
274 pos,mom,xxWeight,ppWeight,xpWeight);
275
276 } else if (theVisitor.neut() != 0) {
277
278 // treat as neutral particle, same as curve in this case
279 calcNeutAllWeights(theTraj,theField,fltlen,
280 pos,mom,xxWeight,ppWeight,xpWeight);
281
282 } else {
283
284 // particle must be a plain line--no way to calculate momentum or err
285 // temporary: initialize everything to 0
286 int i,j;
287 for(i=0;i<3;i++)
288 for(j=i;j<3;j++) {
289 xxWeight[i][j]=0;
290 ppWeight[i][j]=0;
291 xpWeight[i][j]=0;
292 xpWeight[j][i]=0;
293 }
294
295 for(i=0;i<3;i++) {
296 pos[i]=0;
297 mom[i]=0;
298 }
299 }
300}

Referenced by TrkCompTrk::getAllWeights(), and TrkSimpleRep::getAllWeights().

◆ posmomCov()

HepMatrix TrkMomCalculator::posmomCov ( const TrkSimpTraj & theTraj,
const BField & theField,
double fltlen )
static

Definition at line 180 of file TrkMomCalculator.cxx.

181 {
182//------------------------------------------------------------------------
183
184 TrkMomVisitor theVisitor(theTraj);
185
186 if (theVisitor.helix() != 0 || theVisitor.circle() != 0) {
187
188// treat as curve, calculate ErrMom accordingly (see calcCurvMom function
189// below)
190 return calcCurvPosmomCov(theTraj, theField, fltlen);
191
192 } else if (theVisitor.neut() != 0) {
193
194// treat as neutral particle, same as curve in this case
195 return calcNeutPosmomCov(theTraj, theField, fltlen);
196
197 } else {
198
199// particle must be a plain line--no way to calculate momentum or err
200// The matrix is initialized to zero (see BesError constructor)
201 return HepMatrix(3,3,0);
202 }
203}

Referenced by TrkCompTrk::posmomCov(), and TrkSimpleRep::posmomCov().

◆ ptMom()

double TrkMomCalculator::ptMom ( const TrkSimpTraj & theTraj,
const BField & theField,
double fltlen )
static

Definition at line 47 of file TrkMomCalculator.cxx.

48 {
49//------------------------------------------------------------------------
50
51 TrkMomVisitor theVisitor(theTraj);
52
53 if (theVisitor.helix() != 0 || theVisitor.circle() != 0) {
54
55// treat as curve, calculate Pt accordingly (see calcCurvMom function
56// below)
57 return calcCurvPtMom(theTraj.direction(fltlen),
58 theTraj.curvature(fltlen), theField);
59
60 } else if (theVisitor.neut() != 0) {
61
62// treat as neutral particle (with the ptot as a parameter)
63 double sindip = theTraj.direction(fltlen).z();
64 double arg = 1.0-sindip*sindip;
65 if (arg < 0.0) arg = 0.0;
66 double cosdip = sqrt(arg);
67 double ptot = theTraj.parameters()->parameter()[NeutParams::_p];
68
69 return cosdip * ptot;
70
71 } else {
72
73// particle must be a plain line--no way to calculate momentum
74 return 999999.99;
75
76 }
77
78}
double arg(const EvtComplex &c)
virtual Hep3Vector direction(double) const =0
virtual double curvature(double) const =0

Referenced by TrkCompTrk::pt(), and TrkSimpleRep::pt().

◆ vecMom()

Hep3Vector TrkMomCalculator::vecMom ( const TrkSimpTraj & theTraj,
const BField & theField,
double fltlen )
static

Definition at line 82 of file TrkMomCalculator.cxx.

83 {
84//------------------------------------------------------------------------
85 TrkMomVisitor theVisitor(theTraj);
86
87 if (theVisitor.helix() != 0 || theVisitor.circle() != 0) {
88
89// treat as curve, calculate VecMom accordingly (see calcCurvMom function
90// below)
91
92 return calcCurvVecMom(theTraj.direction(fltlen),
93 theTraj.curvature(fltlen), theField);
94
95 } else if (theVisitor.neut() != 0) {
96
97// treat as neutral particle (with the pt as a parameter)
98 Hep3Vector theMom = theTraj.direction(fltlen);
99 theMom.setMag(theTraj.parameters()->parameter()[NeutParams::_p]);
100 return theMom;
101
102 } else {
103
104// particle must be a plain line--no way to calculate momentum
105 return Hep3Vector(999, 999, 999);
106
107 }
108}

Referenced by TrkCompTrk::momentum(), and TrkSimpleRep::momentum().

◆ weightToCov()

bool TrkMomCalculator::weightToCov ( const HepSymMatrix & inXX,
const HepSymMatrix & inPP,
const HepMatrix & inXP,
HepSymMatrix & outXX,
HepSymMatrix & outPP,
HepMatrix & outXP )
static

Definition at line 562 of file TrkMomCalculator.cxx.

563 {
564 assert(inXX.num_row()==outXX.num_row());
565 assert(inPP.num_row()==outPP.num_row());
566 assert(inXP.num_row()==outXP.num_row());
567 assert(inXP.num_col()==outXP.num_col());
568 assert(inXX.num_row()==inXP.num_row());
569 assert(inPP.num_row()==inXP.num_col());
570 int status;
571 HepSymMatrix aInv = inXX.inverse(status);
572 if(status)return false;
573 HepSymMatrix beta = inPP-aInv.similarityT(inXP);
574 outPP = beta.inverse(status);
575 if(status)return false;
576 outXP = -aInv*inXP*outPP;
577 HepMatrix alpha(aInv-aInv*inXP*outXP.T());
578 outXX.assign(alpha);
579 return true;
580}
const double alpha

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