BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
utility Class Reference

#include <utility.h>

Public Member Functions

HepLorentzVector getp4 (RecMdcKalTrack *mdcKalTrack, int pid)
 
HepLorentzVector vfit (string channel, vector< int > kaonid, vector< int > pionid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
 
HepLorentzVector vfit (string channel, vector< int > kaonid, vector< int > pionid, vector< int > protonid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
 
vector< double > SecondaryVFit (EvtRecVeeVertex *ks, IVertexDbSvc *vtxsvc)
 
vector< double > SecondaryVFit_Lambda (EvtRecVeeVertex *lambda, IVertexDbSvc *vtxsvc)
 
HepLorentzVector getp4 (RecMdcKalTrack *mdcKalTrack, int pid)
 
HepLorentzVector vfit (string channel, vector< int > kaonid, vector< int > pionid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
 
HepLorentzVector vfit (string channel, vector< int > kaonid, vector< int > pionid, vector< int > protonid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
 
vector< double > SecondaryVFit (EvtRecVeeVertex *ks, IVertexDbSvc *vtxsvc)
 
vector< double > SecondaryVFit_Lambda (EvtRecVeeVertex *lambda, IVertexDbSvc *vtxsvc)
 

Detailed Description

Member Function Documentation

◆ getp4() [1/2]

HepLorentzVector utility::getp4 ( RecMdcKalTrack mdcKalTrack,
int  pid 
)

Definition at line 5 of file utility.cxx.

5 {
6
7 HepVector zhelix;
8 double mass=0;
9
10 if(pid==0){
11 zhelix=mdcKalTrack->getZHelixE();
12 mass=0.000511;
13 }
14 else if(pid==1){
15 zhelix=mdcKalTrack->getZHelixMu();
16 mass= 0.105658;
17 }
18 else if(pid==2){
19 zhelix=mdcKalTrack->getZHelix();
20 mass=0.139570;
21 }
22 else if(pid==3){
23 zhelix=mdcKalTrack->getZHelixK();
24 mass= 0.493677;
25 }
26 else{
27 zhelix=mdcKalTrack->getZHelixP();
28 mass= 0.938272;
29 }
30
31 double dr(0),phi0(0),kappa(0),dz(0),tanl(0);
32 dr=zhelix[0];
33 phi0=zhelix[1];
34 kappa=zhelix[2];
35 dz=zhelix[3];
36 tanl=zhelix[4];
37
38 int charge=0;
39 if (kappa > 0.0000000001)
40 charge = 1;
41 else if (kappa < -0.0000000001)
42 charge = -1;
43
44 double pxy=0;
45 if(kappa!=0) pxy = 1.0/fabs(kappa);
46
47 double px = pxy * (-sin(phi0));
48 double py = pxy * cos(phi0);
49 double pz = pxy * tanl;
50
51 double e = sqrt( pxy*pxy + pz*pz + mass*mass );
52
53 return HepLorentzVector(px, py, pz, e);
54
55
56}
double mass
double sin(const BesAngle a)
double cos(const BesAngle a)
float charge

Referenced by vfit().

◆ getp4() [2/2]

HepLorentzVector utility::getp4 ( RecMdcKalTrack mdcKalTrack,
int  pid 
)

◆ SecondaryVFit() [1/2]

vector< double > utility::SecondaryVFit ( EvtRecVeeVertex ks,
IVertexDbSvc vtxsvc 
)

Definition at line 195 of file utility.cxx.

195 {
196
197 // by default: chi2 = -999, length = -999, error = 999
198 double vfitchi2 = -999;
199 double vfitlength = -999;
200 double vfiterror = 999;
201
202 vector<double> results;
203 results.push_back(vfitchi2);
204 results.push_back(vfitlength);
205 results.push_back(vfiterror);
206
207 // --------------------------------------------------
208 // Do a secondary vertex fit and check the flight significance
209 // --------------------------------------------------
210
211 EvtRecTrack* veeTrack1 = ks->pairDaughters().first;
212 RecMdcKalTrack* veeKalTrack1 = veeTrack1->mdcKalTrack();
213 WTrackParameter veeInitialWTrack1 = WTrackParameter(0.13957018, veeKalTrack1->getZHelix(), veeKalTrack1->getZError());
214
215 EvtRecTrack* veeTrack2 = ks->pairDaughters().second;
216 RecMdcKalTrack* veeKalTrack2 = veeTrack2->mdcKalTrack();
217 WTrackParameter veeInitialWTrack2 = WTrackParameter(0.13957018, veeKalTrack2->getZHelix(), veeKalTrack2->getZError());
218
219 VertexParameter wideVertex;
220 HepPoint3D vWideVertex(0., 0., 0.);
221 HepSymMatrix evWideVertex(3, 0);
222
223 evWideVertex[0][0] = 1.0e12;
224 evWideVertex[1][1] = 1.0e12;
225 evWideVertex[2][2] = 1.0e12;
226
227 wideVertex.setVx(vWideVertex);
228 wideVertex.setEvx(evWideVertex);
229
230 // First, perform a vertex fit
231 VertexFit* vtxfit = VertexFit::instance();
232 vtxfit->init();
233
234 // add the daughters
235 vtxfit->AddTrack(0,veeInitialWTrack1);
236 vtxfit->AddTrack(1,veeInitialWTrack2);
237 vtxfit->AddVertex(0,wideVertex,0,1);
238
239 // do the fit
240 vtxfit->Fit(0);
241 vtxfit->Swim(0);
242 vtxfit->BuildVirtualParticle(0);
243
244 // Now perform the secondary vertex fit
246 svtxfit->init();
247
248 // add the primary vertex
249 VertexParameter beamSpot;
250 HepPoint3D vBeamSpot(0., 0., 0.);
251 HepSymMatrix evBeamSpot(3, 0);
252
253 if(vtxsvc->isVertexValid()){
254 double* dbv = vtxsvc->PrimaryVertex();
255 double* vv = vtxsvc->SigmaPrimaryVertex();
256 for (unsigned int ivx = 0; ivx < 3; ivx++){
257 vBeamSpot[ivx] = dbv[ivx];
258 evBeamSpot[ivx][ivx] = vv[ivx] * vv[ivx];
259 }
260 }
261 else{
262 cout << "KSSELECTOR ERROR: Could not find a vertex from VertexDbSvc" << endl;
263 return results;
264 }
265
266 beamSpot.setVx(vBeamSpot);
267 beamSpot.setEvx(evBeamSpot);
268
269 VertexParameter primaryVertex(beamSpot);
270 svtxfit->setPrimaryVertex(primaryVertex);
271
272 // add the secondary vertex
273 svtxfit->setVpar(vtxfit->vpar(0));
274
275 // add the Ks or lambda
276 svtxfit->AddTrack(0,vtxfit->wVirtualTrack(0));
277
278 // do the second vertex fit
279 // if the fit fails, the default values will not be changed
280 if( !svtxfit->Fit() ) return results;
281
282 // save the new ks parameters
283 vfitlength = svtxfit->decayLength();
284 vfiterror = svtxfit->decayLengthError();
285 vfitchi2 = svtxfit->chisq();
286
287 results.clear();
288 results.push_back(vfitchi2);
289 results.push_back(vfitlength);
290 results.push_back(vfiterror);
291
292 return results;
293}
std::pair< SmartRef< EvtRecTrack >, SmartRef< EvtRecTrack > > & pairDaughters()
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
static SecondVertexFit * instance()
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition: TrackPool.cxx:22
void init()
Definition: VertexFit.cxx:29
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
Definition: VertexFit.cxx:89
static VertexFit * instance()
Definition: VertexFit.cxx:15
void BuildVirtualParticle(int number)
Definition: VertexFit.cxx:619
bool Fit()
Definition: VertexFit.cxx:301

Referenced by ChargedDReconstruction::execute(), DsReconstruction::execute(), LambdaCReconstruction::execute(), and NeutralDReconstruction::execute().

◆ SecondaryVFit() [2/2]

vector< double > utility::SecondaryVFit ( EvtRecVeeVertex ks,
IVertexDbSvc vtxsvc 
)

◆ SecondaryVFit_Lambda() [1/2]

vector< double > utility::SecondaryVFit_Lambda ( EvtRecVeeVertex lambda,
IVertexDbSvc vtxsvc 
)

Definition at line 295 of file utility.cxx.

295 {
296
297 // by default: chi2 = -999, length = -999, error = 999
298 double vfitchi2 = -999;
299 double vfitlength = -999;
300 double vfiterror = 999;
301
302 vector<double> results;
303 results.push_back(vfitchi2);
304 results.push_back(vfitlength);
305 results.push_back(vfiterror);
306
307 int index[2] = {0, 1};
308 if (lambda->vertexId() < 0){
309 index[0] = 1;
310 index[1] = 0;
311 }
312
313 EvtRecTrack* recTrk_proton = lambda->daughter(index[0]);
314 EvtRecTrack* recTrk_pion = lambda->daughter(index[1]);
315
316 // --------------------------------------------------
317 // Do a secondary vertex fit and check the flight significance
318 // --------------------------------------------------
319
320 RecMdcKalTrack* mdcKalTrk_proton = recTrk_proton->mdcKalTrack();
321 mdcKalTrk_proton->setPidType(RecMdcKalTrack::proton);
322 WTrackParameter WTrk_proton;
323 if(lambdaSelector.IfProtonPID()) WTrk_proton = WTrackParameter(0.9314940054, mdcKalTrk_proton->getZHelixP(), mdcKalTrk_proton->getZErrorP());
324 else WTrk_proton = WTrackParameter(0.9314940054, mdcKalTrk_proton->getZHelix() , mdcKalTrk_proton->getZError());
325
326 RecMdcKalTrack* mdcKalTrk_pion = recTrk_pion->mdcKalTrack();
327 mdcKalTrk_pion->setPidType(RecMdcKalTrack::pion);
328 WTrackParameter WTrk_pion = WTrackParameter(0.13957018, mdcKalTrk_pion->getZHelix(), mdcKalTrk_pion->getZError());
329
330 VertexParameter wideVertex;
331 HepPoint3D vWideVertex(0., 0., 0.);
332 HepSymMatrix evWideVertex(3, 0);
333
334 evWideVertex[0][0] = 1.0e12;
335 evWideVertex[1][1] = 1.0e12;
336 evWideVertex[2][2] = 1.0e12;
337
338 wideVertex.setVx(vWideVertex);
339 wideVertex.setEvx(evWideVertex);
340
341 // First, perform a vertex fit
342 VertexFit* vtxfit = VertexFit::instance();
343 vtxfit->init();
344
345 // add the daughters
346 vtxfit->AddTrack(0,WTrk_proton);
347 vtxfit->AddTrack(1,WTrk_pion);
348 vtxfit->AddVertex(0,wideVertex,0,1);
349
350 // do the fit
351 vtxfit->Fit(0);
352 vtxfit->Swim(0);
353 vtxfit->BuildVirtualParticle(0);
354
355 // Now perform the secondary vertex fit
357 svtxfit->init();
358
359 // add the primary vertex
360 VertexParameter beamSpot;
361 HepPoint3D vBeamSpot(0., 0., 0.);
362 HepSymMatrix evBeamSpot(3, 0);
363
364 if(vtxsvc->isVertexValid()){
365 double* dbv = vtxsvc->PrimaryVertex();
366 double* vv = vtxsvc->SigmaPrimaryVertex();
367 for (unsigned int ivx = 0; ivx < 3; ivx++){
368 vBeamSpot[ivx] = dbv[ivx];
369 evBeamSpot[ivx][ivx] = vv[ivx] * vv[ivx];
370 }
371 }
372 else{
373 cout << "LambdaSELECTOR ERROR: Could not find a vertex from VertexDbSvc" << endl;
374 return results;
375 }
376
377 beamSpot.setVx(vBeamSpot);
378 beamSpot.setEvx(evBeamSpot);
379
380 VertexParameter primaryVertex(beamSpot);
381 svtxfit->setPrimaryVertex(primaryVertex);
382
383 // add the secondary vertex
384 svtxfit->setVpar(vtxfit->vpar(0));
385
386 // add the Ks or lambda
387 svtxfit->AddTrack(0,vtxfit->wVirtualTrack(0));
388
389 // do the second vertex fit
390 // if the fit fails, the default values will not be changed
391 if( !svtxfit->Fit() ) return results;
392
393 // save the new ks parameters
394 vfitlength = svtxfit->decayLength();
395 vfiterror = svtxfit->decayLengthError();
396 vfitchi2 = svtxfit->chisq();
397
398 results.clear();
399 results.push_back(vfitchi2);
400 results.push_back(vfitlength);
401 results.push_back(vfiterror);
402
403 return results;
404}
LocalLambdaSelector lambdaSelector

Referenced by LambdaCReconstruction::execute().

◆ SecondaryVFit_Lambda() [2/2]

vector< double > utility::SecondaryVFit_Lambda ( EvtRecVeeVertex lambda,
IVertexDbSvc vtxsvc 
)

◆ vfit() [1/4]

HepLorentzVector utility::vfit ( string  channel,
vector< int >  kaonid,
vector< int >  pionid,
HepPoint3D  vx,
EvtRecTrackIterator  charged_begin 
)

Definition at line 59 of file utility.cxx.

59 {
60 //use charged tracks only, except pions from Ks
61
62 HepLorentzVector pchange(0,0,0,0);
63
64 int nvalid= kaonid.size()+pionid.size();
65 if(nvalid<=1)
66 return pchange;
67
68 HepSymMatrix Evx(3, 0);
69 double bx = 1E+6; Evx[0][0] = bx*bx;
70 double by = 1E+6; Evx[1][1] = by*by;
71 double bz = 1E+6; Evx[2][2] = bz*bz;
72 VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
73 double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
74
75
77 vtxfit->init();
78
79
80 HepLorentzVector pold(0,0,0,0);
81
82 for(int i=0; i<kaonid.size();++i){
83 EvtRecTrackIterator itTrk=charged_begin + kaonid[i];
84 RecMdcKalTrack *mdcKalTrk = (*itTrk)->mdcKalTrack();
85 pold+=getp4(mdcKalTrk, 3);
86 WTrackParameter wtrk(xmass[3],mdcKalTrk->getZHelixK(),mdcKalTrk->getZErrorK() );
87 vtxfit->AddTrack(i, wtrk);
88 }
89
90 for(int i=0; i<pionid.size();++i){
91 EvtRecTrackIterator itTrk=charged_begin + pionid[i];
92 RecMdcKalTrack *mdcKalTrk = (*itTrk)->mdcKalTrack();
93 pold+=getp4(mdcKalTrk, 2);
94 WTrackParameter wtrk(xmass[2],mdcKalTrk->getZHelix(),mdcKalTrk->getZError() );
95 vtxfit->AddTrack(kaonid.size()+i, wtrk);
96 }
97
98 vector<int> trkIdxCol;
99 trkIdxCol.clear();
100 for (int i = 0; i < nvalid; i++)
101 trkIdxCol.push_back(i);
102 vtxfit->AddVertex(0, vxpar, trkIdxCol);
103 if(!vtxfit->Fit(0))
104 return pchange;
105
106 vtxfit->Swim(0);
107
108 HepLorentzVector pnew(0,0,0,0);
109
110 for(int i=0; i<nvalid;++i){
111 WTrackParameter wtrk = vtxfit->wtrk(i);
112 HepVector trk_val = HepVector(7,0);
113 trk_val = wtrk.w();
114 HepLorentzVector P_trk(trk_val[0],trk_val[1],trk_val[2],trk_val[3]);
115 pnew+=P_trk;
116 }
117
118 return (pnew-pold);
119
120}
const double xmass[5]
Definition: Gam4pikp.cxx:50
HepLorentzVector getp4(RecMdcKalTrack *mdcKalTrack, int pid)
Definition: utility.cxx:5

Referenced by ChargedDReconstruction::execute(), DsReconstruction::execute(), LambdaCReconstruction::execute(), and NeutralDReconstruction::execute().

◆ vfit() [2/4]

HepLorentzVector utility::vfit ( string  channel,
vector< int >  kaonid,
vector< int >  pionid,
HepPoint3D  vx,
EvtRecTrackIterator  charged_begin 
)

◆ vfit() [3/4]

HepLorentzVector utility::vfit ( string  channel,
vector< int >  kaonid,
vector< int >  pionid,
vector< int >  protonid,
HepPoint3D  vx,
EvtRecTrackIterator  charged_begin 
)

Definition at line 122 of file utility.cxx.

122 {
123 //use charged tracks only, except pions from Ks
124
125 HepLorentzVector pchange(0,0,0,0);
126
127 int nvalid= kaonid.size()+pionid.size()+protonid.size();
128 if(nvalid<=1)
129 return pchange;
130
131 HepSymMatrix Evx(3, 0);
132 double bx = 1E+6; Evx[0][0] = bx*bx;
133 double by = 1E+6; Evx[1][1] = by*by;
134 double bz = 1E+6; Evx[2][2] = bz*bz;
135 VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
136 double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
137
138
139 VertexFit* vtxfit = VertexFit::instance();
140 vtxfit->init();
141
142
143 HepLorentzVector pold(0,0,0,0);
144
145 for(int i=0; i<kaonid.size();++i){
146 EvtRecTrackIterator itTrk=charged_begin + kaonid[i];
147 RecMdcKalTrack *mdcKalTrk = (*itTrk)->mdcKalTrack();
148 pold+=getp4(mdcKalTrk, 3);
149 WTrackParameter wtrk(xmass[3],mdcKalTrk->getZHelixK(),mdcKalTrk->getZErrorK() );
150 vtxfit->AddTrack(i, wtrk);
151 }
152
153 for(int i=0; i<pionid.size();++i){
154 EvtRecTrackIterator itTrk=charged_begin + pionid[i];
155 RecMdcKalTrack *mdcKalTrk = (*itTrk)->mdcKalTrack();
156 pold+=getp4(mdcKalTrk, 2);
157 WTrackParameter wtrk(xmass[2],mdcKalTrk->getZHelix(),mdcKalTrk->getZError() );
158 vtxfit->AddTrack(kaonid.size()+i, wtrk);
159 }
160
161 for(int i=0; i<protonid.size();++i){
162 EvtRecTrackIterator itTrk=charged_begin + protonid[i];
163 RecMdcKalTrack *mdcKalTrk = (*itTrk)->mdcKalTrack();
164 pold+=getp4(mdcKalTrk, 4);
165 WTrackParameter wtrk(xmass[4],mdcKalTrk->getZHelixP(),mdcKalTrk->getZErrorP() );
166 vtxfit->AddTrack(kaonid.size()+pionid.size()+i, wtrk);
167 }
168
169 vector<int> trkIdxCol;
170 trkIdxCol.clear();
171 for (int i = 0; i < nvalid; i++)
172 trkIdxCol.push_back(i);
173 vtxfit->AddVertex(0, vxpar, trkIdxCol);
174 if(!vtxfit->Fit(0))
175 return pchange;
176
177 vtxfit->Swim(0);
178
179 HepLorentzVector pnew(0,0,0,0);
180
181 for(int i=0; i<nvalid;++i){
182 WTrackParameter wtrk = vtxfit->wtrk(i);
183 HepVector trk_val = HepVector(7,0);
184 trk_val = wtrk.w();
185 HepLorentzVector P_trk(trk_val[0],trk_val[1],trk_val[2],trk_val[3]);
186 pnew+=P_trk;
187 }
188
189 return (pnew-pold);
190
191}

◆ vfit() [4/4]

HepLorentzVector utility::vfit ( string  channel,
vector< int >  kaonid,
vector< int >  pionid,
vector< int >  protonid,
HepPoint3D  vx,
EvtRecTrackIterator  charged_begin 
)

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