2#include "VertexFit/KalmanKinematicFit.h"
3#include "VertexFit/KinematicConstraints.h"
4#include "VertexFit/HTrackParameter.h"
8const int KalmanKinematicFit::NTRKPAR = 4;
9const int KalmanKinematicFit::Resonance = 1;
10const int KalmanKinematicFit::TotalEnergy = 2;
11const int KalmanKinematicFit::TotalMomentum = 4;
12const int KalmanKinematicFit::Position = 8;
13const int KalmanKinematicFit::ThreeMomentum = 16;
14const int KalmanKinematicFit::FourMomentum = 32;
15const int KalmanKinematicFit::EqualMass = 64;
21 if(m_pointer)
return m_pointer;
26KalmanKinematicFit::KalmanKinematicFit(){;}
56 m_collideangle = 11e-3;
60 m_cpu = HepVector(10, 0);
61 m_virtual_wtrk.clear();
93 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5);
99 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6);
104 int n5,
int n6,
int n7) {
105 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7);
110 int n5,
int n6,
int n7,
int n8) {
111 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8);
116 int n5,
int n6,
int n7,
int n8,
int n9) {
117 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9);
122 int n5,
int n6,
int n7,
int n8,
int n9,
int n10) {
123 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10);
129 int n5,
int n6,
int n7,
int n8,
int n9,
131 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10, n11);
136 int n5,
int n6,
int n7,
int n8,
int n9,
137 int n10,
int n11,
int n12) {
138 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
144 HepSymMatrix Vre = HepSymMatrix(1,0);
147 if((
unsigned int) number != m_kc.size()-1)
148 std::cout <<
"wrong kinematic constraints index" << std::endl;
177 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5);
183 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6);
188 int n5,
int n6,
int n7) {
189 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7);
194 int n5,
int n6,
int n7,
int n8) {
195 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8);
200 int n5,
int n6,
int n7,
int n8,
int n9) {
201 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9);
206 int n5,
int n6,
int n7,
int n8,
int n9,
208 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10);
214 int n5,
int n6,
int n7,
int n8,
int n9,
216 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10, n11);
221 int n5,
int n6,
int n7,
int n8,
int n9,
222 int n10,
int n11,
int n12) {
223 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
231 if((
unsigned int) number != m_kc.size()-1)
232 std::cout <<
"wrong kinematic constraints index" << std::endl;
260 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5);
266 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6);
271 int n5,
int n6,
int n7) {
272 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7);
277 int n5,
int n6,
int n7,
int n8) {
278 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8);
283 int n5,
int n6,
int n7,
int n8,
int n9) {
284 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9);
289 int n5,
int n6,
int n7,
int n8,
int n9,
291 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10);
297 int n5,
int n6,
int n7,
int n8,
int n9,
299 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10, n11);
304 int n5,
int n6,
int n7,
int n8,
int n9,
305 int n10,
int n11,
int n12) {
306 std::vector<int> tlis =
AddList(
n1,
n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
314 if((
unsigned int) number != m_kc.size()-1)
315 std::cout <<
"wrong kinematic constraints index" << std::endl;
323 HepSymMatrix Vne = HepSymMatrix(1,0);
326 if((
unsigned int) number != m_kc.size()-1)
327 std::cout <<
"wrong kinematic constraints index" << std::endl;
335 std::vector<int> tlis;
345 if((
unsigned int) number != m_kc.size()-1)
346 std::cout <<
"wrong kinematic constraints index" << std::endl;
355 std::vector<int> tlis;
363 HepSymMatrix Vme = HepSymMatrix(4,0);
364 Vme[0][0] = 2*m_espread*m_espread*
sin(m_collideangle)*
sin(m_collideangle);
365 Vme[0][3] = 2*m_espread*m_espread*
sin(m_collideangle);
366 Vme[3][3] = 2*m_espread*m_espread;
370 if((
unsigned int) number != m_kc.size()-1)
371 std::cout <<
"wrong kinematic constraints index" << std::endl;
376 HepLorentzVector p4(0.0, 0.0, 0.0,
etot);
377 std::vector<int> tlis;
384 HepSymMatrix Vme = HepSymMatrix (4,0);
385 Vme[3][3] = 2*m_espread*m_espread;
388 if((
unsigned int) number != m_kc.size()-1)
389 std::cout <<
"wrong kinematic constraints index" << std::endl;
393void KalmanKinematicFit::fit() {
406 HepSymMatrix AC(m_nc, 0);
407 AC = m_C0.similarity(m_A);
409 m_cpu[1] += timer.CpuTime();
414 m_W = HepSymMatrix(m_nc, 0);
415 m_W = (m_Vm + m_C0.similarity(m_A)).inverse(ifail);
418 m_Dinv = m_D0inv + m_W.similarity(m_B.T());
419 m_D = m_Dinv.inverse(ifailD);
421 m_cpu[2] += timer.CpuTime();
425 HepVector G(m_nc, 0);
426 G = m_A * (m_p0 - m_p) + m_B * (m_q0 - m_q)+ m_G;
429 m_KQ = m_D * m_BT * m_W;
432 m_KP = m_C0 * m_AT * m_W - m_C0 * m_AT * m_W * m_B * m_KQ;
434 m_p = m_p0 - m_KP * G;
435 m_q = m_q0 - m_KQ * G;
437 m_cpu[4] += timer.CpuTime();
441 m_chi = (m_W.similarity(G.T()) - m_Dinv.similarity((m_q - m_q0).T()))[0][0];
443 m_cpu[3] += timer.CpuTime();
445 if(m_dynamicerror ==1)
449 m_cpu[6] += timer.CpuTime();
456void KalmanKinematicFit::upCovmtx() {
458 E = -m_C0 * m_A.T() * m_KQ.T();
459 m_C = m_C0 - m_W.similarity((m_A*m_C0).T()) + m_Dinv.similarity(E);
466void KalmanKinematicFit::fit(
int n) {
467 if(m_chisq.size() == 0) {
468 for(
unsigned int i = 0; i < m_kc.size(); i++)
469 m_chisq.push_back(9999.0);
477 HepSymMatrix
AC(m_nc, 0);
478 AC = m_C0.similarity(m_A);
482 m_W = HepSymMatrix(m_nc, 0);
483 m_W = (m_Vm + m_C0.similarity(m_A)).inverse(ifail);
486 m_Dinv = m_D0inv + m_W.similarity(m_B.T());
487 m_D = m_Dinv.inverse(ifailD);
490 HepVector G(m_nc, 0);
491 G = m_A * (m_p0 - m_p) + m_B * (m_q0 - m_q)+ m_G;
494 m_KQ = m_D * m_BT * m_W;
497 m_KP = m_C0 * m_AT * m_W - m_C0 * m_AT * m_W * m_B * m_KQ;
499 m_p = m_p0 - m_KP * G;
500 m_q = m_q0 - m_KQ * G;
503 m_chisq[
n] = (m_W.similarity(G.T()) - m_Dinv.similarity((m_q - m_q0).T()))[0][0];
504 if(m_dynamicerror ==1)
528 HepVector m_p_tmp = HepVector(
numberone(), 0);
529 HepVector m_q_tmp = HepVector(
numbertwo(), 0);
531 HepSymMatrix m_W_tmp;
533 HepSymMatrix m_Dinv_tmp;
542 HepSymMatrix Ew1(4, 0);
543 for(
int j = 0; j < 3; j++) {
548 for(
int m = 0; m < 3; m++) {
549 for(
int n = 0;
n < 3;
n++) {
567 HepSymMatrix Dinv(4,0);
568 setDOriginInv(pb, Dinv);
579 HepSymMatrix Dinv(3,0);
580 setDOriginInv(pb, Dinv);
589 HepSymMatrix Dinv(2,0);
590 setDOriginInv(pb, Dinv);
599 HepSymMatrix Dinv(1,0);
600 setDOriginInv(pb, Dinv);
614 setQOrigin(pb, beam);
616 HepSymMatrix Dinv(3, 0);
619 setDOriginInv(pb, Dinv);
624 HepSymMatrix Ew1(4, 0);
625 for(
int j = 0; j < 3; j++) {
630 for(
int m = 0; m < 3; m++) {
631 for(
int n = 0;
n < 3;
n++) {
649 std::vector<double>
chisq;
652 for(
int i = 0; i < m_kc.size(); i++)
659 m_G = HepVector(
nc, 0);
660 m_Vm = HepSymMatrix(
nc, 0);
662 for(
unsigned int i = 0; i < m_kc.size(); i++) {
668 double tmp_chisq = 999;
670 for(
int it = 0; it < m_niter; it++) {
673 for(
unsigned int i = 0; i < m_kc.size(); i++) {
675 updateConstraints(kc);
678 m_cpu[0] += timer.CpuTime();
745 chisq.push_back(m_chi);
748 if(fabs(delchi) < m_chiter){
757 if(m_chi > m_chicut)
return okfit;
760 m_cpu[5] += timer.CpuTime();
769 if(
n < 0 || (
unsigned int)
n >= m_kc.size())
return okfit;
788 HepSymMatrix Ew1(4, 0);
789 for(
int j = 0; j < 3; j++) {
794 for(
int m = 0; m < 3; m++) {
795 for(
int n = 0;
n < 3;
n++) {
813 HepSymMatrix Dinv(4,0);
814 setDOriginInv(pb, Dinv);
823 HepSymMatrix Dinv(3,0);
824 setDOriginInv(pb, Dinv);
833 HepSymMatrix Dinv(2,0);
834 setDOriginInv(pb, Dinv);
843 HepSymMatrix Dinv(1,0);
844 setDOriginInv(pb, Dinv);
858 setQOrigin(pb, beam);
860 HepSymMatrix Dinv(3, 0);
864 setDOriginInv(pb, Dinv);
870 HepSymMatrix Ew1(4, 0);
871 for(
int j = 0; j < 3; j++) {
876 for(
int m = 0; m < 3; m++) {
877 for(
int n = 0;
n < 3;
n++) {
895 std::vector<double>
chisq;
905 m_G = HepVector(
nc, 0);
906 m_Vm = HepSymMatrix(
nc, 0);
911 for(
int it = 0; it < m_niter; it++) {
914 updateConstraints(kc);
917 chisq.push_back(m_chisq[
n]);
922 if(fabs(delchi) < m_chiter)
926 if(m_chisq[
n] >= m_chicut) {
946 int ntrk = (kc.
Ltrk()).size();
949 HepSymMatrix ew1(7, 0);
950 HepSymMatrix ew2(7, 0);
952 HepSymMatrix ew4(4, 0);
953 HepMatrix dwdp(4, 4, 0);
958 for (
int i = 0; i < ntrk; i++) {
959 int itk = (kc.
Ltrk())[i];
961 w4 = w4 + dwdp * pInfit(itk);
965 for(
int j2=0; j2<ntrk; j2++){
971 ew4 = m_C.similarity(
I);
977 double pt = sqrt(px*px + py*py);
978 double p0 = sqrt(px*px + py*py + pz*pz);
979 double m = sqrt(e*e - p0*p0);
981 J[0][1] = -(pz*px*pt)/(p0*p0);
982 J[0][2] = -m*px/(p0*p0);
983 J[0][3] = e*px/(p0*p0);
985 J[1][1] = -(pz*py*pt)/(p0*p0);
986 J[1][2] = -m*py/(p0*p0);
987 J[1][3] = e*py/(p0*p0);
989 J[2][1] = pt*pt*pt/(p0*p0);
990 J[2][2] = -m*pz/(p0*p0);
991 J[2][3] = e*pz/(p0*p0);
996 ew1 = ew4.similarity(J);
997 ew2[0][0] = ew1[0][0];
998 ew2[1][1] = ew1[1][1];
999 ew2[2][2] = ew1[2][2];
1000 ew2[3][3] = ew1[3][3];
1010 m_virtual_wtrk.push_back(vwtrk);
1015void KalmanKinematicFit::gda(){
1026 HepSymMatrix Ew(NTRKPAR, 0);
1027 HepLorentzVector p1 = p4Infit(i);
1028 HepLorentzVector p2 = p4Origin(i);
1029 double eorigin = pOrigin(i)[3];
1030 HepMatrix dwda1(NTRKPAR, 3, 0);
1032 dwda1[1][1] = - (p2.e()*p2.e())/(p2.px()*p2.px() + p2.py()*p2.py());
1035 HepSymMatrix emcmea1(3, 0);
1049 Ew[0][0] = emcmea1[0][0];
1050 Ew[1][1] = emcmea1[1][1];
1051 Ew[3][3] = emcmea1[2][2];
1054 setCOrigin(pa+3, Ew.sub(4,4));
1055 else setCOrigin(pa,Ew);
1069 HepSymMatrix Ew(7,0);
1071 HepSymMatrix Ew1(7,0);
1075 for(
int i=0; i<4; i++) {
1076 W[i] = pInfit(
n)[i];
1078 for(
int j=0; j<4; j++) {
1079 for(
int k=0; k<4; k++) {
1084 double px = p4Infit(
n).px();
1085 double py = p4Infit(
n).py();
1086 double pz = p4Infit(
n).pz();
1087 double m = p4Infit(
n).m();
1088 double e = p4Infit(
n).e();
1089 HepMatrix J(7, 7, 0);
1100 Ew1 = Ew.similarity(J);
1108 HepVector a0 = horigin.
hel();
1109 HepVector a1 = hinfit.
hel();
1110 HepSymMatrix v0 = horigin.
eHel();
1111 HepSymMatrix v1 = hinfit.
eHel();
1112 HepVector
pull(9,0);
1113 for (
int k=0; k<5; k++) {
1114 pull[k] = (a0[k]-a1[k])/sqrt(
abs(v0[k][k]-v1[k][k]));
1116 for (
int l=5; l<9; l++) {
1125 a0 = m_p0.sub(pa, pa+3);
1126 a1 = m_p.sub(pa, pa+3);
1129 HepVector
pull(3,0);
1130 for (
int k=0; k<2; k++) {
1131 pull[k] = (a0[k]-a1[k])/sqrt(v0[k][k]-v1[k][k]);
1133 pull[2] = (a0[3]-a1[3])/sqrt(v0[3][3]-v1[3][3]);
1150 HepLorentzVector p0 = p4Origin(
n);
1151 HepLorentzVector p1 = p4Infit(
n);
1154 a0[0] = p4Origin(
n).phi();
1155 a1[0] = p4Infit(
n).phi();
1156 a0[1] = p4Origin(
n).pz()/p4Origin(
n).perp();
1157 a1[1] = p4Infit(
n).pz()/p4Infit(
n).perp();
1158 HepMatrix Jacobi(2, 4, 0);
1159 Jacobi[0][0] = - p4Infit(
n).py()/p4Infit(
n).perp2();
1160 Jacobi[0][1] = p4Infit(
n).px()/p4Infit(
n).perp2();
1161 Jacobi[1][0] = - (p4Infit(
n).px()/p4Infit(
n).perp()) * (p4Infit(
n).pz()/p4Infit(
n).perp2());
1162 Jacobi[1][1] = - (p4Infit(
n).py()/p4Infit(
n).perp()) * (p4Infit(
n).pz()/p4Infit(
n).perp2());
1163 Jacobi[1][2] = 1/p4Infit(
n).perp();
1164 HepSymMatrix v1 =
getCInfit(
n).similarity(Jacobi);
1166 HepVector
pull(2,0);
1167 for (
int k=0; k<2; k++) {
1168 pull[k] = (a0[k]-a1[k])/sqrt(v0[k][k]-v1[k][k]);
1178HepVector KalmanKinematicFit::pInfit(
int n)
const {
1184 double mass = m_p.sub(pa+3, pa+3)[0];
1186 p4[0] = m_p.sub(pa,pa)[0];
1187 p4[1] = m_p.sub(pa+1, pa+1)[0];
1188 p4[2] = m_p.sub(pa+2, pa+2)[0];
1189 p4[3] = sqrt(p4[0]*p4[0] + p4[1]*p4[1] + p4[2]*p4[2] +
mass *
mass);
1194 double phi = m_p.sub(pa, pa)[0];
1195 double lambda = m_p.sub(pa+1, pa+1)[0];
1196 double mass = m_p.sub(pa+2, pa+2)[0];
1197 double E = m_p.sub(pa+3, pa+3)[0];
1200 p4[0] = p0*
cos(phi)/sqrt(1 + lambda*lambda);
1201 p4[1] = p0*
sin(phi)/sqrt(1 + lambda*lambda);
1202 p4[2] = p0*lambda/sqrt(1 + lambda*lambda);
1208 return m_q.sub(pb, pb+3);
1212 double mass = (m_p.sub(pa, pa))[0];
1213 double phi = m_q.sub(pb, pb)[0];
1214 double lambda = m_q.sub(pb+1, pb+1)[0];
1215 double E = m_q.sub(pb+2, pb+2)[0];
1218 p4[0] = p0*
cos(phi)/sqrt(1 + lambda*lambda);
1219 p4[1] = p0*
sin(phi)/sqrt(1 + lambda*lambda);
1220 p4[2] = p0*lambda/sqrt(1 + lambda*lambda);
1226 double phi = m_p.sub(pa, pa)[0];
1227 double lambda = m_p.sub(pa+1, pa+1)[0];
1228 double mass = m_q.sub(pb, pb)[0];
1229 double E = m_q.sub(pb+1, pb+1)[0];
1232 p4[0] = p0*
cos(phi)/sqrt(1 + lambda*lambda);
1233 p4[1] = p0*
sin(phi)/sqrt(1 + lambda*lambda);
1234 p4[2] = p0*lambda/sqrt(1 + lambda*lambda);
1240 double phi = m_p.sub(pa, pa)[0];
1241 double lambda = m_p.sub(pa+1, pa+1)[0];
1242 double mass = m_p.sub(pa+2, pa+2)[0];
1243 double p0 = m_q.sub(pb, pb)[0];
1245 p4[0] = p0*
cos(phi)/sqrt(1 + lambda*lambda);
1246 p4[1] = p0*
sin(phi)/sqrt(1 + lambda*lambda);
1247 p4[2] = p0*lambda/sqrt(1 + lambda*lambda);
1253 double x = m_p.sub(pa, pa)[0] - m_q.sub(pb, pb)[0];
1254 double y = m_p.sub(pa+1, pa+1)[0] - m_q.sub(pb+1, pb+1)[0];
1255 double z = m_p.sub(pa+2, pa+2)[0] - m_q.sub(pb+2, pb+2)[0];
1256 double p0 = m_p.sub(pa+3, pa+3)[0];
1257 double R = sqrt(x*x +
y*
y + z*z);
1267 double mass = m_p.sub(pa+3, pa+3)[0];
1269 p4[0] = m_p.sub(pa,pa)[0];
1270 p4[1] = m_p.sub(pa+1, pa+1)[0];
1271 p4[2] = m_p.sub(pa+2, pa+2)[0];
1272 p4[3] = sqrt(p4[0]*p4[0] + p4[1]*p4[1] + p4[2]*p4[2] +
mass *
mass);
1280HepVector KalmanKinematicFit::pOrigin(
int n)
const {
1286 double mass = m_p0.sub(pa+3, pa+3)[0];
1288 p4[0] = m_p0.sub(pa,pa)[0];
1289 p4[1] = m_p0.sub(pa+1, pa+1)[0];
1290 p4[2] = m_p0.sub(pa+2, pa+2)[0];
1291 p4[3] = sqrt(p4[0]*p4[0] + p4[1]*p4[1] + p4[2]*p4[2] +
mass *
mass);
1296 double phi = m_p0.sub(pa, pa)[0];
1297 double lambda = m_p0.sub(pa+1, pa+1)[0];
1298 double mass = m_p0.sub(pa+2, pa+2)[0];
1299 double E = m_p0.sub(pa+3, pa+3)[0];
1302 p4[0] = p0*
cos(phi)/sqrt(1 + lambda*lambda);
1303 p4[1] = p0*
sin(phi)/sqrt(1 + lambda*lambda);
1304 p4[2] = p0*lambda/sqrt(1 + lambda*lambda);
1310 return m_q0.sub(pb, pb+3);
1314 double mass = (m_p0.sub(pa, pa))[0];
1315 double phi = m_q0.sub(pb, pb)[0];
1316 double lambda = m_q0.sub(pb+1, pb+1)[0];
1317 double E = m_q0.sub(pb+2, pb+2)[0];
1320 p4[0] = p0*
cos(phi)/sqrt(1 + lambda*lambda);
1321 p4[1] = p0*
sin(phi)/sqrt(1 + lambda*lambda);
1322 p4[2] = p0*lambda/sqrt(1 + lambda*lambda);
1328 double phi = m_p0.sub(pa, pa)[0];
1329 double lambda = m_p0.sub(pa+1, pa+1)[0];
1330 double mass = m_q0.sub(pb, pb)[0];
1331 double E = m_q0.sub(pb+1, pb+1)[0];
1334 p4[0] = p0*
cos(phi)/sqrt(1 + lambda*lambda);
1335 p4[1] = p0*
sin(phi)/sqrt(1 + lambda*lambda);
1336 p4[2] = p0*lambda/sqrt(1 + lambda*lambda);
1342 double phi = m_p0.sub(pa, pa)[0];
1343 double lambda = m_p0.sub(pa+1, pa+1)[0];
1344 double mass = m_p0.sub(pa+2, pa+2)[0];
1345 double p0 = m_q0.sub(pb, pb)[0];
1347 p4[0] = p0*
cos(phi)/sqrt(1 + lambda*lambda);
1348 p4[1] = p0*
sin(phi)/sqrt(1 + lambda*lambda);
1349 p4[2] = p0*lambda/sqrt(1 + lambda*lambda);
1355 double x = m_p0.sub(pa, pa)[0] - m_q0.sub(pb, pb)[0];
1356 double y = m_p0.sub(pa+1, pa+1)[0] - m_q0.sub(pb+1, pb+1)[0];
1357 double z = m_p0.sub(pa+2, pa+2)[0] - m_q0.sub(pb+2, pb+2)[0];
1358 double p0 = m_p0.sub(pa+3, pa+3)[0];
1359 double R = sqrt(x*x +
y*
y + z*z);
1369 double mass = m_p0.sub(pa+3, pa+3)[0];
1371 p4[0] = m_p0.sub(pa,pa)[0];
1372 p4[1] = m_p0.sub(pa+1, pa+1)[0];
1373 p4[2] = m_p0.sub(pa+2, pa+2)[0];
1374 p4[3] = sqrt(p4[0]*p4[0] + p4[1]*p4[1] + p4[2]*p4[2] +
mass *
mass);
1387 return m_C0.sub(pa, pa+NTRKPAR-1);
1391 return m_C0.sub(pa, pa+NTRKPAR-1);
1395 return m_C0.sub(pa, pa);
1399 return m_C0.sub(pa, pa+1);
1403 return m_C0.sub(pa, pa+2);
1407 return m_C0.sub(pa, pa+NTRKPAR-1);
1421 return m_C.sub(pa, pa+NTRKPAR-1);
1425 return m_C.sub(pa, pa+NTRKPAR-1);
1429 return m_C.sub(pa, pa);
1433 return m_C.sub(pa, pa+1);
1437 return m_C.sub(pa, pa+2);
1441 return m_C.sub(pa, pa+NTRKPAR-1);
1454 int type = kc.
Type();
1460 double mres = kc.
mres();
1461 HepLorentzVector pmis;
1462 for(
unsigned int j = 0; j< (kc.
Ltrk()).size(); j++){
1463 int n = (kc.
Ltrk())[j];
1464 pmis = pmis + p4Infit(
n);
1466 for(
unsigned int j = 0; j< (kc.
Ltrk()).size(); j++){
1467 int n = (kc.
Ltrk())[j];
1468 double lambda = p4Infit(
n).pz()/p4Infit(
n).perp();
1469 double a1 = 1 + lambda*lambda;
1475 HepMatrix ta(1, NTRKPAR, 0);
1476 ta[0][0] = -2 * pmis.px() + 2 * pmis.e() * p4Infit(
n).px() / p4Infit(
n).e();
1477 ta[0][1] = -2 * pmis.py() + 2 * pmis.e() * p4Infit(
n).py() / p4Infit(
n).e();
1478 ta[0][2] = -2 * pmis.pz() + 2 * pmis.e() * p4Infit(
n).pz() / p4Infit(
n).e();
1479 ta[0][3] = 2 * pmis.e() * p4Infit(
n).m() / p4Infit(
n).e();
1481 setAT(pa, m_nc, ta.T());
1485 HepMatrix ta(1, NTRKPAR, 0);
1486 double a1 = lambda * lambda + 1;
1487 ta[0][0] = 2 * pmis.px() * p4Infit(
n).py() - 2 * pmis.py() * p4Infit(
n).px();
1488 ta[0][1] = 2 * pmis.px() * p4Infit(
n).px() * lambda/sqrt(a1) + 2 * pmis.py() * (p4Infit(
n)).py() * lambda/sqrt(a1) - 2 * pmis.pz() * (p4Infit(
n)).pz() /(sqrt(a1) * lambda);
1489 ta[0][2] = 2 * pmis.px() * (p4Infit(
n)).px() * p4Infit(
n).m() /((p4Infit(
n)).rho() * p4Infit(
n).rho()) + 2 * pmis.py() * (p4Infit(
n)).py() * p4Infit(
n).m()/((p4Infit(
n)).rho() * p4Infit(
n).rho())+ 2 * pmis.pz() * (p4Infit(
n)).pz() * p4Infit(
n).m()/((p4Infit(
n)).rho() * p4Infit(
n).rho());
1490 ta[0][3] = 2 * pmis.e() - 2 * pmis.px() * (p4Infit(
n)).px() * p4Infit(
n).e() /((p4Infit(
n)).rho() * p4Infit(
n).rho())- 2 * pmis.py() * (p4Infit(
n)).py() * p4Infit(
n).e()/((p4Infit(
n)).rho() * p4Infit(
n).rho())- 2 * pmis.pz() * (p4Infit(
n)).pz() * p4Infit(
n).e()/((p4Infit(
n)).rho() * p4Infit(
n).rho());
1492 setAT(pa, m_nc, ta.T());
1496 HepMatrix tb(1, 4, 0);
1497 tb[0][0] = -2 * pmis.px();
1498 tb[0][1] = -2 * pmis.py();
1499 tb[0][2] = -2 * pmis.pz();
1500 tb[0][3] = 2 * pmis.e();
1502 setBT(pb,m_nc,tb.T());
1506 HepMatrix ta(1, 1, 0);
1507 double a1 = lambda * lambda + 1;
1508 ta[0][0] = 2 * pmis.px() * (p4Infit(
n)).px() * p4Infit(
n).m() /((p4Infit(
n)).rho() * p4Infit(
n).rho()) + 2 * pmis.py() * (p4Infit(
n)).py() * p4Infit(
n).m()/((p4Infit(
n)).rho() * p4Infit(
n).rho())+ 2 * pmis.pz() * (p4Infit(
n)).pz() * p4Infit(
n).m()/((p4Infit(
n)).rho() * p4Infit(
n).rho());
1510 setAT(pa, m_nc, ta.T());
1511 HepMatrix tb(1, 3, 0);
1512 tb[0][0] = 2 * pmis.px() * p4Infit(
n).py() - 2 * pmis.py() * p4Infit(
n).px();
1513 tb[0][1] = 2 * pmis.px() * p4Infit(
n).px() * lambda/sqrt(a1) + 2 * pmis.py() * (p4Infit(
n)).py() * lambda/sqrt(a1) - 2 * pmis.pz() * (p4Infit(
n)).pz() /(sqrt(a1) * lambda);
1514 tb[0][2] = 2 * pmis.e() - 2 * pmis.px() * (p4Infit(
n)).px() * p4Infit(
n).e() /((p4Infit(
n)).rho() * p4Infit(
n).rho())- 2 * pmis.py() * (p4Infit(
n)).py() * p4Infit(
n).e()/((p4Infit(
n)).rho() * p4Infit(
n).rho())- 2 * pmis.pz() * (p4Infit(
n)).pz() * p4Infit(
n).e()/((p4Infit(
n)).rho() * p4Infit(
n).rho());
1516 setBT(pb,m_nc,tb.T());
1520 HepMatrix ta(1, 2, 0);
1521 double a1 = lambda * lambda + 1;
1522 ta[0][0] = 2 * pmis.px() * p4Infit(
n).py() - 2 * pmis.py() * p4Infit(
n).px();
1523 ta[0][1] = 2 * pmis.px() * p4Infit(
n).px() * lambda/sqrt(a1) + 2 * pmis.py() * (p4Infit(
n)).py() * lambda/sqrt(a1) - 2 * pmis.pz() * (p4Infit(
n)).pz() /(sqrt(a1) * lambda);
1525 setAT(pa, m_nc, ta.T());
1527 HepMatrix tb(1, 2, 0);
1528 tb[0][0] = 2 * pmis.px() * (p4Infit(
n)).px() * p4Infit(
n).m() /((p4Infit(
n)).rho() * p4Infit(
n).rho()) + 2 * pmis.py() * (p4Infit(
n)).py() * p4Infit(
n).m()/((p4Infit(
n)).rho() * p4Infit(
n).rho())+ 2 * pmis.pz() * (p4Infit(
n)).pz() * p4Infit(
n).m()/((p4Infit(
n)).rho() * p4Infit(
n).rho());
1529 tb[0][1] = 2 * pmis.e() - 2 * pmis.px() * (p4Infit(
n)).px() * p4Infit(
n).e() /((p4Infit(
n)).rho() * p4Infit(
n).rho())- 2 * pmis.py() * (p4Infit(
n)).py() * p4Infit(
n).e()/((p4Infit(
n)).rho() * p4Infit(
n).rho())- 2 * pmis.pz() * (p4Infit(
n)).pz() * p4Infit(
n).e()/((p4Infit(
n)).rho() * p4Infit(
n).rho());
1531 setBT(pb, m_nc, tb.T());
1535 HepMatrix ta(1, 3, 0);
1536 ta[0][0] = 2 * pmis.px() * p4Infit(
n).py() - 2 * pmis.py() * p4Infit(
n).px();
1537 ta[0][1] = 2 * pmis.px() * p4Infit(
n).px() * lambda/sqrt(a1)+ 2 * pmis.py() * (p4Infit(
n)).py() * lambda/sqrt(a1) - 2 * pmis.pz() * (p4Infit(
n)).pz() /(sqrt(a1) * lambda);
1538 ta[0][2] = 2 * pmis.e() * (p4Infit(
n)).m()/(p4Infit(
n)).e();
1540 setAT(pa, m_nc, ta.T());
1541 HepMatrix tb(1, 1, 0);
1542 tb[0][0] = 2 * pmis.e() * (p4Infit(
n)).rho()/(p4Infit(
n)).e() - 2 * pmis.px() * (p4Infit(
n)).px()/(p4Infit(
n)).rho() - 2 * pmis.py() * (p4Infit(
n)).py()/(p4Infit(
n)).rho() - 2 * pmis.pz() * (p4Infit(
n)).pz()/(p4Infit(
n)).rho();
1544 setBT(pb, m_nc, tb.T());
1548 HepMatrix ta(1, NTRKPAR, 0);
1549 ta[0][0] = -2 * pmis.px() + 2 * pmis.e() * p4Infit(
n).px() / p4Infit(
n).e();
1550 ta[0][1] = -2 * pmis.py() + 2 * pmis.e() * p4Infit(
n).py() / p4Infit(
n).e();
1551 ta[0][2] = -2 * pmis.pz() + 2 * pmis.e() * p4Infit(
n).pz() / p4Infit(
n).e();
1552 ta[0][3] = 2 * pmis.e() * p4Infit(
n).m() / p4Infit(
n).e();
1554 setAT(pa, m_nc, ta.T());
1561 dc[0] = pmis.m2() - mres * mres;
1572 HepLorentzVector pmis;
1573 for(
unsigned int j = 0; j < (kc.
Ltrk()).size(); j++){
1574 int n = (kc.
Ltrk())[j];
1575 pmis = pmis + p4Infit(
n);
1578 for(
unsigned int j = 0; j < (kc.
Ltrk()).size(); j++) {
1579 int n = (kc.
Ltrk())[j];
1585 HepMatrix ta(1, NTRKPAR, 0);
1586 ta[0][0] = p4Infit(
n).px()/p4Infit(
n).e();
1587 ta[0][1] = p4Infit(
n).py()/p4Infit(
n).e();
1588 ta[0][2] = p4Infit(
n).pz()/p4Infit(
n).e();
1589 ta[0][3] = p4Infit(
n).m()/p4Infit(
n).e();
1591 setAT(pa, m_nc, ta.T());
1595 HepMatrix ta(1, NTRKPAR, 0);
1598 setAT(pa, m_nc, ta.T());
1602 HepMatrix tb(1, 4, 0);
1605 setAT(pb, m_nc, tb.T());
1609 HepMatrix ta(1, 1, 0);
1610 ta[0][0] = p4Infit(
n).m()/p4Infit(
n).e();
1612 setAT(pa, m_nc, ta.T());
1614 HepMatrix tb(1, 3, 0);
1616 setBT(pb, m_nc, tb.T());
1620 HepMatrix ta(1, 2, 0);
1622 setAT(pa, m_nc, ta.T());
1624 HepMatrix tb(1, 2, 0);
1630 setBT(pb, m_nc, tb.T());
1634 HepMatrix ta(1, 3, 0);
1635 ta[0][2] = p4Infit(
n).m()/p4Infit(
n).e();
1637 setAT(pa, m_nc, ta.T());
1639 HepMatrix tb(1, 1, 0);
1640 tb[0][0] = p4Infit(
n).rho()/p4Infit(
n).e();
1642 setBT(pb, m_nc, tb.T());
1646 HepMatrix ta(1, NTRKPAR, 0);
1647 ta[0][0] = p4Infit(
n).px()/p4Infit(
n).e();
1648 ta[0][1] = p4Infit(
n).py()/p4Infit(
n).e();
1649 ta[0][2] = p4Infit(
n).pz()/p4Infit(
n).e();
1650 ta[0][3] = p4Infit(
n).m()/p4Infit(
n).e();
1652 setAT(pa, m_nc, ta.T());
1665 case TotalMomentum: {
1669 double ptot = kc.
ptot();
1670 HepLorentzVector pmis;
1671 for(
unsigned int j = 0; j< (kc.
Ltrk()).size(); j++){
1672 int n = (kc.
Ltrk())[j];
1673 pmis = pmis + p4Infit(
n);
1676 for(
unsigned int j = 0; j < (kc.
Ltrk()).size(); j++) {
1677 int n = (kc.
Ltrk())[j];
1681 double lambda = p4Infit(
n).pz()/p4Infit(
n).perp();
1684 HepMatrix ta(1, NTRKPAR, 0);
1685 ta[0][0] = pmis.px()/pmis.rho();
1686 ta[0][1] = pmis.py()/pmis.rho();
1687 ta[0][2] = pmis.pz()/pmis.rho();
1689 setAT(pa, m_nc, ta.T());
1693 HepMatrix ta(1, NTRKPAR, 0);
1694 ta[0][0] = - (pmis.px()/pmis.rho()) * p4Infit(
n).py() + (pmis.px()/pmis.rho())*p4Infit(
n).px();
1695 ta[0][1] = - (pmis.px()/pmis.rho()) * p4Infit(
n).px() * (lambda/(1 + lambda*lambda)) - (pmis.py()/pmis.rho()) * p4Infit(
n).py() * (lambda/(1 + lambda*lambda)) + (pmis.pz()/pmis.rho()) * p4Infit(
n).pz() * (1/(lambda * (1 + lambda*lambda)));
1696 ta[0][2] = -((pmis.px()/pmis.rho()) * p4Infit(
n).m()/(p4Infit(
n).rho()*p4Infit(
n).rho())) * (p4Infit(
n).px() + p4Infit(
n).py() +p4Infit(
n).pz());
1697 ta[0][3] = ((pmis.px()/pmis.rho()) * p4Infit(
n).e()/(p4Infit(
n).rho()*p4Infit(
n).rho())) * (p4Infit(
n).px() + p4Infit(
n).py() +
1701 setAT(pa, m_nc, ta.T());
1705 HepMatrix tb(1, 4, 0);
1706 tb[0][0] = pmis.px()/pmis.rho();
1707 tb[0][1] = pmis.py()/pmis.rho();
1708 tb[0][2] = pmis.pz()/pmis.rho();
1710 setBT(pb, m_nc, tb.T());
1714 HepMatrix ta(1, 1, 0);
1716 setAT(pa, m_nc, ta.T());
1717 HepMatrix tb(1, 3, 0);
1718 tb[0][0] = pmis.px()/pmis.rho();
1719 tb[0][1] = pmis.py()/pmis.rho();
1720 tb[0][2] = pmis.pz()/pmis.rho();
1722 setBT(pb, m_nc, tb.T());
1726 HepMatrix ta(1, 2, 0);
1727 ta[0][0] = - (pmis.px()/pmis.rho()) * p4Infit(
n).py() + (pmis.px()/pmis.rho())*p4Infit(
n).px();
1728 ta[0][1] = - (pmis.px()/pmis.rho()) * p4Infit(
n).px() * (lambda/(1 + lambda*lambda)) - (pmis.py()/pmis.rho()) * p4Infit(
n).py() * (lambda/(1 + lambda*lambda)) + (pmis.pz()/pmis.rho()) * p4Infit(
n).pz() * (1/(lambda * (1 + lambda*lambda)));
1730 setAT(pa, m_nc, ta.T());
1732 HepMatrix tb(1, 2, 0);
1733 tb[0][0] = -((pmis.px()/pmis.rho()) * p4Infit(
n).m()/(p4Infit(
n).rho()*p4Infit(
n).rho())) * (p4Infit(
n).px() + p4Infit(
n).py() +p4Infit(
n).pz());
1734 tb[0][1] = ((pmis.px()/pmis.rho()) * p4Infit(
n).e()/(p4Infit(
n).rho()*p4Infit(
n).rho())) * (p4Infit(
n).px() + p4Infit(
n).py() +
1738 setBT(pb, m_nc, tb.T());
1742 HepMatrix ta(1, 3, 0);
1743 ta[0][0] = - (pmis.px()/pmis.rho()) * p4Infit(
n).py() + (pmis.px()/pmis.rho())*p4Infit(
n).px();
1744 ta[0][1] = - (pmis.px()/pmis.rho()) * p4Infit(
n).px() * (lambda/(1 + lambda*lambda)) - (pmis.py()/pmis.rho()) * p4Infit(
n).py() * (lambda/(1 + lambda*lambda)) + (pmis.pz()/pmis.rho()) * p4Infit(
n).pz() * (1/(lambda * (1 + lambda*lambda)));
1746 setAT(pa, m_nc, ta.T());
1748 HepMatrix tb(1, 1, 0);
1749 tb[0][0] = (pmis.px()/pmis.rho()) * (p4Infit(
n).px()/p4Infit(
n).rho()) + (pmis.py()/pmis.rho()) * (p4Infit(
n).py()/p4Infit(
n).rho()) + (pmis.pz()/pmis.rho()) * (p4Infit(
n).pz()/p4Infit(
n).rho());
1751 setBT(pb, m_nc, tb.T());
1755 HepMatrix ta(1, NTRKPAR, 0);
1756 ta[0][0] = pmis.px()/pmis.rho();
1757 ta[0][1] = pmis.py()/pmis.rho();
1758 ta[0][2] = pmis.pz()/pmis.rho();
1760 setAT(pa, m_nc, ta.T());
1768 dc[0] = pmis.rho() - ptot;
1775 case ThreeMomentum: {
1781 Hep3Vector p3 = kc.
p3();
1782 HepLorentzVector pmis;
1783 for(
unsigned int j = 0; j< (kc.
Ltrk()).size(); j++){
1784 int n = (kc.
Ltrk())[j];
1785 pmis = pmis + p4Infit(
n);
1787 for(
unsigned int j = 0; j < (kc.
Ltrk()).size(); j++) {
1788 int n = (kc.
Ltrk())[j];
1792 double lambda = p4Infit(
n).pz()/p4Infit(
n).perp();
1795 HepMatrix ta(kc.
nc(), NTRKPAR, 0);
1800 setAT(pa, m_nc, ta.T());
1804 HepMatrix ta(kc.
nc(), NTRKPAR, 0);
1805 ta[0][0] = -p4Infit(
n).py();
1806 ta[0][1] = -p4Infit(
n).px()*(lambda/sqrt(1 + lambda*lambda));
1807 ta[0][2] = -p4Infit(
n).m()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1808 ta[0][3] = p4Infit(
n).e()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1809 ta[1][0] = p4Infit(
n).px();
1810 ta[1][1] = -p4Infit(
n).py()*(lambda/sqrt(1 + lambda*lambda));
1811 ta[1][2] = -p4Infit(
n).m()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1812 ta[1][3] = p4Infit(
n).e()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1814 ta[2][1] = p4Infit(
n).pz()*(1/(lambda * (1 + lambda*lambda)));
1815 ta[2][2] = -p4Infit(
n).m()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1816 ta[2][3] = p4Infit(
n).e()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1821 setAT(pa, m_nc, ta.T());
1825 HepMatrix tb(kc.
nc(), 4, 0);
1830 setBT(pb, m_nc, tb.T());
1834 HepMatrix ta(kc.
nc(), 1, 0);
1836 setAT(pa, m_nc, ta.T());
1838 HepMatrix tb(kc.
nc(), 3, 0);
1843 setBT(pb, m_nc, tb.T());
1848 HepMatrix ta(kc.
nc(), 2, 0);
1849 ta[0][0] = -p4Infit(
n).py();
1850 ta[0][1] = -p4Infit(
n).px()*(lambda/sqrt(1 + lambda*lambda));
1851 ta[1][0] = p4Infit(
n).px();
1852 ta[1][1] = -p4Infit(
n).py()*(lambda/sqrt(1 + lambda*lambda));
1854 ta[2][1] = p4Infit(
n).pz()*(1/(lambda * (1 + lambda*lambda)));
1856 setAT(pa, m_nc, ta.T());
1858 HepMatrix tb(kc.
nc(), 2, 0);
1859 tb[0][1] = -p4Infit(
n).m()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1860 tb[1][1] = -p4Infit(
n).m()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1861 tb[2][1] = -p4Infit(
n).m()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
1863 setBT(pb, m_nc, tb.T());
1867 HepMatrix ta(kc.
nc(), 3, 0);
1868 ta[0][0] = -p4Infit(
n).py();
1869 ta[0][1] = -p4Infit(
n).px()*(lambda/sqrt(1 + lambda*lambda));
1870 ta[1][0] = p4Infit(
n).px();
1871 ta[1][1] = -p4Infit(
n).py()*(lambda/sqrt(1 + lambda*lambda));
1873 ta[2][1] = p4Infit(
n).pz()*(1/(lambda * (1 + lambda*lambda)));
1875 setAT(pa, m_nc, ta.T());
1877 HepMatrix tb(kc.
nc(), 1, 0);
1878 tb[0][0] = p4Infit(
n).px()/p4Infit(
n).rho();
1879 tb[1][0] = p4Infit(
n).py()/p4Infit(
n).rho();
1880 tb[2][0] = p4Infit(
n).pz()/p4Infit(
n).rho();
1882 setBT(pb, m_nc, tb.T());
1886 HepMatrix ta(kc.
nc(), NTRKPAR, 0);
1891 setAT(pa, m_nc, ta.T());
1896 HepVector
dc(kc.
nc(), 0);
1897 dc[0] = pmis.px() - p3.x();
1898 dc[1] = pmis.py() - p3.y();
1899 dc[2] = pmis.pz() - p3.z();
1900 for(
int i = 0; i < kc.
nc(); i++) {
1901 m_G[m_nc+i] =
dc[i];
1914 HepLorentzVector pmis1, pmis2;
1915 for(
int n = 0;
n < isiz;
n++) {
1917 pmis1 = pmis1 + p4Infit(
n1);
1921 for(
int n = 0;
n < jsiz;
n++){
1923 pmis2 = pmis2 + p4Infit(
n2);
1926 for(
int i = 0; i < isiz; i++) {
1928 double lambda = p4Infit(
n1).pz()/p4Infit(
n1).perp();
1934 HepMatrix ta(1, NTRKPAR, 0);
1935 ta[0][0] = -2 * pmis1.px() + 2 * pmis1.e() * p4Infit(
n1).px() / p4Infit(
n1).e();
1936 ta[0][1] = -2 * pmis1.py() + 2 * pmis1.e() * p4Infit(
n1).py() / p4Infit(
n1).e();
1937 ta[0][2] = -2 * pmis1.pz() + 2 * pmis1.e() * p4Infit(
n1).pz() / p4Infit(
n1).e();
1938 ta[0][3] = 2 * pmis1.e() * p4Infit(
n1).m() / p4Infit(
n1).e();
1940 setAT(pa, m_nc, ta.T());
1944 HepMatrix ta(1, NTRKPAR, 0);
1945 double a1 = lambda * lambda + 1;
1946 ta[0][0] = 2 * pmis1.px() * p4Infit(
n1).py() - 2 * pmis1.py() * p4Infit(
n1).px();
1947 ta[0][1] = 2 * pmis1.px() * p4Infit(
n1).px() * lambda/sqrt(a1) + 2 * pmis1.py() * (p4Infit(
n1)).py() * lambda/sqrt(a1) - 2 * pmis1.pz() * (p4Infit(
n1)).pz() /(sqrt(a1) * lambda);
1948 ta[0][2] = 2 * pmis1.px() * (p4Infit(
n1)).px() * p4Infit(
n1).m() /((p4Infit(
n1)).rho() * p4Infit(
n1).rho()) + 2 * pmis1.py() * (p4Infit(
n1)).py() * p4Infit(
n1).m()/((p4Infit(
n1)).rho() * p4Infit(
n1).rho())+ 2 * pmis1.pz() * (p4Infit(
n1)).pz() * p4Infit(
n1).m()/((p4Infit(
n1)).rho() * p4Infit(
n1).rho());
1949 ta[0][3] = 2 * pmis1.e() - 2 * pmis1.px() * (p4Infit(
n1)).px() * p4Infit(
n1).e() /((p4Infit(
n1)).rho() * p4Infit(
n1).rho())- 2 * pmis1.py() * (p4Infit(
n1)).py() * p4Infit(
n1).e()/((p4Infit(
n1)).rho() * p4Infit(
n1).rho())- 2 * pmis1.pz() * (p4Infit(
n1)).pz() * p4Infit(
n1).e()/((p4Infit(
n1)).rho() * p4Infit(
n1).rho());
1951 setAT(pa, m_nc, ta.T());
1955 HepMatrix tb(1, 4, 0);
1956 tb[0][0] = -2 * pmis1.px();
1957 tb[0][1] = -2 * pmis1.py();
1958 tb[0][2] = -2 * pmis1.pz();
1959 tb[0][3] = 2 * pmis1.e();
1961 setBT(pb,m_nc,tb.T());
1965 HepMatrix ta(1, 1, 0);
1966 ta[0][0] = 2 * pmis1.e() * (p4Infit(
n1).m()/p4Infit(
n1).e());
1968 setAT(pa, m_nc, ta.T());
1969 HepMatrix tb(1, 3, 0);
1970 tb[0][0] = -2 * pmis1.px();
1971 tb[0][1] = -2 * pmis1.py();
1972 tb[0][2] = -2 * pmis1.pz();
1974 setBT(pb,m_nc,tb.T());
1978 HepMatrix ta(1, 2, 0);
1979 double a1 = lambda * lambda + 1;
1980 ta[0][0] = 2 * pmis1.px() * p4Infit(
n1).py() - 2 * pmis1.py() * p4Infit(
n1).px();
1981 ta[0][1] = 2 * pmis1.px() * p4Infit(
n1).px() * lambda/sqrt(a1) + 2 * pmis1.py() * (p4Infit(
n1)).py() * lambda/sqrt(a1) - 2 * pmis1.pz() * (p4Infit(
n1)).pz() /(sqrt(a1) * lambda);
1983 setAT(pa, m_nc, ta.T());
1985 HepMatrix tb(1, 2, 0);
1986 tb[0][0] = 2 * pmis1.px() * (p4Infit(
n1)).px() * p4Infit(
n1).m() /((p4Infit(
n1)).rho() * p4Infit(
n1).rho()) + 2 * pmis1.py() * (p4Infit(
n1)).py() * p4Infit(
n1).m()/((p4Infit(
n1)).rho() * p4Infit(
n1).rho())+ 2 * pmis1.pz() * (p4Infit(
n1)).pz() * p4Infit(
n1).m()/((p4Infit(
n1)).rho() * p4Infit(
n1).rho());
1987 tb[0][1] = 2 * pmis1.e() - 2 * pmis1.px() * (p4Infit(
n1)).px() * p4Infit(
n1).e() /((p4Infit(
n1)).rho() * p4Infit(
n1).rho())- 2 * pmis1.py() * (p4Infit(
n1)).py() * p4Infit(
n1).e()/((p4Infit(
n1)).rho() * p4Infit(
n1).rho())- 2 * pmis1.pz() * (p4Infit(
n1)).pz() * p4Infit(
n1).e()/((p4Infit(
n1)).rho() * p4Infit(
n1).rho());
1989 setBT(pb, m_nc, tb.T());
1993 HepMatrix ta(1, 3, 0);
1994 double a1 = lambda * lambda + 1;
1995 ta[0][0] = 2 * pmis1.px() * p4Infit(
n1).py() - 2 * pmis1.py() * p4Infit(
n1).px();
1996 ta[0][1] = 2 * pmis1.px() * p4Infit(
n1).px() * lambda/sqrt(a1)+ 2 * pmis1.py() * (p4Infit(
n1)).py() * lambda/sqrt(a1) - 2 * pmis1.pz() * (p4Infit(
n1)).pz() /(sqrt(a1) * lambda);
1997 ta[0][2] = 2 * pmis1.e() * (p4Infit(
n1)).m()/(p4Infit(
n1)).e();
1999 setAT(pa, m_nc, ta.T());
2000 HepMatrix tb(1, 1, 0);
2001 tb[0][0] = 2 * pmis1.e() * (p4Infit(
n1)).rho()/(p4Infit(
n1)).e() - 2 * pmis1.px() * (p4Infit(
n1)).px()/(p4Infit(
n1)).rho() - 2 * pmis1.py() * (p4Infit(
n1)).py()/(p4Infit(
n1)).rho() - 2 * pmis1.pz() * (p4Infit(
n1)).pz()/(p4Infit(
n1)).rho();
2003 setBT(pb, m_nc, tb.T());
2007 HepMatrix ta(1, NTRKPAR, 0);
2008 ta[0][0] = -2 * pmis1.px() + 2 * pmis1.e() * p4Infit(
n1).px() / p4Infit(
n1).e();
2009 ta[0][1] = -2 * pmis1.py() + 2 * pmis1.e() * p4Infit(
n1).py() / p4Infit(
n1).e();
2010 ta[0][2] = -2 * pmis1.pz() + 2 * pmis1.e() * p4Infit(
n1).pz() / p4Infit(
n1).e();
2011 ta[0][3] = 2 * pmis1.e() * p4Infit(
n1).m() / p4Infit(
n1).e();
2013 setAT(pa, m_nc, ta.T());
2019 for(
int i = isiz; i < isiz+jsiz; i++) {
2021 double lambda = p4Infit(
n2).pz()/p4Infit(
n2).perp();
2027 HepMatrix ta(1, NTRKPAR, 0);
2028 ta[0][0] = -2 * pmis2.px() + 2 * pmis2.e() * p4Infit(
n2).px() / p4Infit(
n2).e();
2029 ta[0][1] = -2 * pmis2.py() + 2 * pmis2.e() * p4Infit(
n2).py() / p4Infit(
n2).e();
2030 ta[0][2] = -2 * pmis2.pz() + 2 * pmis2.e() * p4Infit(
n2).pz() / p4Infit(
n2).e();
2031 ta[0][3] = 2 * pmis2.e() * p4Infit(
n2).m() / p4Infit(
n2).e();
2033 setAT(pa, m_nc, -ta.T());
2037 HepMatrix ta(1, NTRKPAR, 0);
2038 double a1 = lambda * lambda + 1;
2039 ta[0][0] = 2 * pmis2.px() * p4Infit(
n2).py() - 2 * pmis2.py() * p4Infit(
n2).px();
2040 ta[0][1] = 2 * pmis2.px() * p4Infit(
n2).px() * lambda/sqrt(a1) + 2 * pmis2.py() * (p4Infit(
n2)).py() * lambda/sqrt(a1) - 2 * pmis2.pz() * (p4Infit(
n2)).pz() /(sqrt(a1) * lambda);
2041 ta[0][2] = 2 * pmis2.px() * (p4Infit(
n2)).px() * p4Infit(
n2).m() /((p4Infit(
n2)).rho() * p4Infit(
n2).rho()) + 2 * pmis2.py() * (p4Infit(
n2)).py() * p4Infit(
n2).m()/((p4Infit(
n2)).rho() * p4Infit(
n2).rho())+ 2 * pmis2.pz() * (p4Infit(
n2)).pz() * p4Infit(
n2).m()/((p4Infit(
n2)).rho() * p4Infit(
n2).rho());
2042 ta[0][3] = 2 * pmis2.e() - 2 * pmis2.px() * (p4Infit(
n2)).px() * p4Infit(
n2).e() /((p4Infit(
n2)).rho() * p4Infit(
n2).rho())- 2 * pmis2.py() * (p4Infit(
n2)).py() * p4Infit(
n2).e()/((p4Infit(
n2)).rho() * p4Infit(
n2).rho())- 2 * pmis2.pz() * (p4Infit(
n2)).pz() * p4Infit(
n2).e()/((p4Infit(
n2)).rho() * p4Infit(
n2).rho());
2044 setAT(pa, m_nc, -ta.T());
2048 HepMatrix tb(1, 4, 0);
2049 tb[0][0] = -2 * pmis2.px();
2050 tb[0][1] = -2 * pmis2.py();
2051 tb[0][2] = -2 * pmis2.pz();
2052 tb[0][3] = 2 * pmis2.e();
2054 setBT(pb,m_nc,-tb.T());
2058 HepMatrix ta(1, 1, 0);
2059 ta[0][0] = 2 * pmis2.e() * (p4Infit(
n2).m()/p4Infit(
n2).e());
2061 setAT(pa, m_nc, -ta.T());
2062 HepMatrix tb(1, 3, 0);
2063 tb[0][0] = -2 * pmis2.px();
2064 tb[0][1] = -2 * pmis2.py();
2065 tb[0][2] = -2 * pmis2.pz();
2067 setBT(pb,m_nc,-tb.T());
2071 HepMatrix ta(1, 2, 0);
2072 double a1 = lambda * lambda + 1;
2073 ta[0][0] = 2 * pmis2.px() * p4Infit(
n2).py() - 2 * pmis2.py() * p4Infit(
n2).px();
2074 ta[0][1] = 2 * pmis2.px() * p4Infit(
n2).px() * lambda/sqrt(a1) + 2 * pmis2.py() * (p4Infit(
n2)).py() * lambda/sqrt(a1) - 2 * pmis2.pz() * (p4Infit(
n2)).pz() /(sqrt(a1) * lambda);
2076 setAT(pa, m_nc, -ta.T());
2078 HepMatrix tb(1, 2, 0);
2079 tb[0][0] = 2 * pmis2.px() * (p4Infit(
n2)).px() * p4Infit(
n2).m() /((p4Infit(
n2)).rho() * p4Infit(
n2).rho()) + 2 * pmis2.py() * (p4Infit(
n2)).py() * p4Infit(
n2).m()/((p4Infit(
n2)).rho() * p4Infit(
n2).rho())+ 2 * pmis2.pz() * (p4Infit(
n2)).pz() * p4Infit(
n2).m()/((p4Infit(
n2)).rho() * p4Infit(
n2).rho());
2080 tb[0][1] = 2 * pmis2.e() - 2 * pmis2.px() * (p4Infit(
n2)).px() * p4Infit(
n2).e() /((p4Infit(
n2)).rho() * p4Infit(
n2).rho())- 2 * pmis2.py() * (p4Infit(
n2)).py() * p4Infit(
n2).e()/((p4Infit(
n2)).rho() * p4Infit(
n2).rho())- 2 * pmis2.pz() * (p4Infit(
n2)).pz() * p4Infit(
n2).e()/((p4Infit(
n2)).rho() * p4Infit(
n2).rho());
2082 setBT(pb, m_nc, -tb.T());
2086 HepMatrix ta(1, 3, 0);
2087 double a1 = lambda * lambda + 1;
2088 ta[0][0] = 2 * pmis2.px() * p4Infit(
n2).py() - 2 * pmis2.py() * p4Infit(
n2).px();
2089 ta[0][1] = 2 * pmis2.px() * p4Infit(
n2).px() * lambda/sqrt(a1) + 2 * pmis2.py() * (p4Infit(
n2)).py() * lambda/sqrt(a1) - 2 * pmis2.pz() * (p4Infit(
n2)).pz() /(sqrt(a1) * lambda);
2090 ta[0][2] = 2 * pmis2.e() * (p4Infit(
n2)).m()/(p4Infit(
n2)).e();
2092 setAT(pa, m_nc, -ta.T());
2093 HepMatrix tb(1, 1, 0);
2094 tb[0][0] = 2 * pmis2.e() * (p4Infit(
n2)).rho()/(p4Infit(
n2)).e() - 2 * pmis2.px() * (p4Infit(
n2)).px()/(p4Infit(
n2)).rho() - 2 * pmis2.py() * (p4Infit(
n2)).py()/(p4Infit(
n2)).rho() - 2 * pmis2.pz() * (p4Infit(
n2)).pz()/(p4Infit(
n2)).rho();
2096 setBT(pb, m_nc, -tb.T());
2100 HepMatrix ta(1, NTRKPAR, 0);
2101 ta[0][0] = -2 * pmis2.px() + 2 * pmis2.e() * p4Infit(
n2).px() / p4Infit(
n2).e();
2102 ta[0][1] = -2 * pmis2.py() + 2 * pmis2.e() * p4Infit(
n2).py() / p4Infit(
n2).e();
2103 ta[0][2] = -2 * pmis2.pz() + 2 * pmis2.e() * p4Infit(
n2).pz() / p4Infit(
n2).e();
2104 ta[0][3] = 2 * pmis2.e() * p4Infit(
n2).m() / p4Infit(
n2).e();
2106 setAT(pa, m_nc, -ta.T());
2116 dc[0] = pmis1.m2() - pmis2.m2();
2133 HepLorentzVector p4 = kc.
p4();
2134 HepLorentzVector pmis;
2135 for(
unsigned int j = 0; j< (kc.
Ltrk()).size(); j++){
2136 int n = (kc.
Ltrk())[j];
2137 pmis = pmis + p4Infit(
n);
2139 for(
unsigned int j = 0; j < (kc.
Ltrk()).size(); j++) {
2140 int n = (kc.
Ltrk())[j];
2141 double lambda = p4Infit(
n).pz()/p4Infit(
n).perp();
2147 HepMatrix ta(kc.
nc(), NTRKPAR, 0);
2151 ta[3][0] = p4Infit(
n).px() / p4Infit(
n).e();
2152 ta[3][1] = p4Infit(
n).py() / p4Infit(
n).e();
2153 ta[3][2] = p4Infit(
n).pz() / p4Infit(
n).e();
2154 ta[3][3] = p4Infit(
n).m() / p4Infit(
n).e();
2156 setAT(pa, m_nc, ta.T());
2160 HepMatrix ta(kc.
nc(), NTRKPAR, 0);
2161 ta[0][0] = -p4Infit(
n).py();
2162 ta[0][1] = -p4Infit(
n).px()*(lambda/(1 + lambda*lambda));
2163 ta[0][2] = -p4Infit(
n).m()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2164 ta[0][3] = p4Infit(
n).e()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2165 ta[1][0] = p4Infit(
n).px();
2166 ta[1][1] = -p4Infit(
n).py()*(lambda/(1 + lambda*lambda));
2167 ta[1][2] = -p4Infit(
n).m()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2168 ta[1][3] = p4Infit(
n).e()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2170 ta[2][1] = p4Infit(
n).pz()*(1/(lambda * (1 + lambda*lambda)));
2171 ta[2][2] = -p4Infit(
n).m()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2172 ta[2][3] = p4Infit(
n).e()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2178 setAT(pa, m_nc, ta.T());
2182 HepMatrix tb(kc.
nc(), 4, 0);
2188 setBT(pb, m_nc, tb.T());
2192 HepMatrix ta(kc.
nc(), 1, 0);
2193 ta[0][0] = -p4Infit(
n).m()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2194 ta[1][0] = -p4Infit(
n).m()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2195 ta[2][0] = -p4Infit(
n).m()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2198 setAT(pa, m_nc, ta.T());
2200 HepMatrix tb(kc.
nc(), 3, 0);
2201 tb[0][0] = -p4Infit(
n).py();
2202 tb[0][1] = -p4Infit(
n).px()*(lambda/(1 + lambda*lambda));
2203 tb[0][2] = p4Infit(
n).e()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2204 tb[1][0] = p4Infit(
n).px();
2205 tb[1][1] = -p4Infit(
n).py()*(lambda/(1 + lambda*lambda));
2206 tb[1][2] = p4Infit(
n).e()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2208 tb[2][1] = p4Infit(
n).pz()*(1/(lambda * (1 + lambda*lambda)));
2209 tb[2][2] = p4Infit(
n).e()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2215 setBT(pb, m_nc, tb.T());
2220 HepMatrix ta(kc.
nc(), 2, 0);
2221 ta[0][0] = -p4Infit(
n).py();
2222 ta[0][1] = -p4Infit(
n).px()*(lambda/sqrt(1 + lambda*lambda));
2223 ta[1][0] = p4Infit(
n).px();
2224 ta[1][1] = -p4Infit(
n).py()*(lambda/sqrt(1 + lambda*lambda));
2226 ta[2][1] = p4Infit(
n).pz()*(1/(lambda * (1 + lambda*lambda)));
2229 setAT(pa, m_nc, ta.T());
2231 HepMatrix tb(kc.
nc(), 2, 0);
2237 tb[0][0] = -p4Infit(
n).m()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2238 tb[1][0] = -p4Infit(
n).m()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2239 tb[2][0] = -p4Infit(
n).m()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2240 tb[0][1] = p4Infit(
n).e()*p4Infit(
n).px()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2241 tb[1][1] = p4Infit(
n).e()*p4Infit(
n).py()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2242 tb[2][1] = p4Infit(
n).e()*p4Infit(
n).pz()/(p4Infit(
n).rho()*p4Infit(
n).rho());
2245 setBT(pb, m_nc, tb.T());
2249 HepMatrix ta(kc.
nc(), 3, 0);
2250 ta[0][0] = -p4Infit(
n).py();
2251 ta[0][1] = -p4Infit(
n).px()*(lambda/sqrt(1 + lambda*lambda));
2252 ta[1][0] = p4Infit(
n).px();
2253 ta[1][1] = -p4Infit(
n).py()*(lambda/sqrt(1 + lambda*lambda));
2255 ta[2][1] = p4Infit(
n).pz()*(1/(lambda * (1 + lambda*lambda)));
2256 ta[3][2] = p4Infit(
n).m()/p4Infit(
n).e();
2258 setAT(pa, m_nc, ta.T());
2260 HepMatrix tb(kc.
nc(), 1, 0);
2261 tb[0][0] = p4Infit(
n).px()/p4Infit(
n).rho();
2262 tb[1][0] = p4Infit(
n).py()/p4Infit(
n).rho();
2263 tb[2][0] = p4Infit(
n).pz()/p4Infit(
n).rho();
2264 tb[3][0] = p4Infit(
n).rho()/p4Infit(
n).e();
2266 setBT(pb, m_nc, tb.T());
2270 double ptrk = m_p.sub(pa+3, pa+3)[0];
2271 double x = m_p.sub(pa, pa)[0] - m_q.sub(pb, pb)[0];
2272 double y = m_p.sub(pa+1, pa+1)[0] - m_q.sub(pb+1, pb+1)[0];
2273 double z = m_p.sub(pa+2, pa+2)[0] - m_q.sub(pb+2, pb+2)[0];
2274 double R = sqrt(x*x +
y*
y + z*z);
2275 HepMatrix ta(kc.
nc(), 4, 0);
2276 ta[0][0] =
ptrk*(
y*
y + z*z)/(R*R*R);
2281 ta[1][1] =
ptrk*(
x*
x + z*z)/(R*R*R);
2286 ta[2][2] =
ptrk*(
x*
x +
y*
y)/(R*R*R);
2290 setAT(pa, m_nc, ta.T());
2292 HepMatrix tb(kc.
nc(), 3, 0);
2293 tb[0][0] = -
ptrk*(
y*
y + z*z)/(R*R*R);
2297 tb[1][1] = -
ptrk*(
x*
x + z*z)/(R*R*R);
2301 tb[2][2] = -
ptrk*(
x*
x +
y*
y)/(R*R*R);
2302 HepMatrix tbp = m_B.sub(1, 4, 1, 3);
2305 setBT(pb, m_nc, tb.T());
2309 HepMatrix ta(kc.
nc(), NTRKPAR, 0);
2313 ta[3][0] = p4Infit(
n).px() / p4Infit(
n).e();
2314 ta[3][1] = p4Infit(
n).py() / p4Infit(
n).e();
2315 ta[3][2] = p4Infit(
n).pz() / p4Infit(
n).e();
2316 ta[3][3] = p4Infit(
n).m() / p4Infit(
n).e();
2318 setAT(pa, m_nc, ta.T());
2324 HepVector
dc(kc.
nc(), 0);
2325 dc[0] = pmis.px() - p4.px();
2326 dc[1] = pmis.py() - p4.py();
2327 dc[2] = pmis.pz() - p4.pz();
2328 dc[3] = pmis.e() - p4.e();
2329 for(
int i = 0; i < kc.
nc(); i++) {
2330 m_G[m_nc+i] =
dc[i];
string::const_iterator ptype
HepGeom::Point3D< double > HepPoint3D
double sin(const BesAngle a)
double cos(const BesAngle a)
HepSymMatrix eHel() const
void AddTotalEnergy(int number, double etot, std::vector< int > lis)
void AddFourMomentum(int number, HepLorentzVector p4)
void AddThreeMomentum(int number, Hep3Vector p3)
void BuildVirtualParticle(int number)
HepSymMatrix getCInfit(int i) const
void AddResonance(int number, double mres, std::vector< int > tlis)
void AddTotalMomentum(int number, double ptot, std::vector< int > lis)
HepSymMatrix getCOrigin(int i) const
static KalmanKinematicFit * instance()
void AddEqualMass(int number, std::vector< int > tlis1, std::vector< int > tlis2)
void FourMomentumConstraints(const HepLorentzVector p4, std::vector< int > tlis, HepSymMatrix Vme)
std::vector< int > Ltrk()
void ResonanceConstraints(const double mres, std::vector< int > tlis, HepSymMatrix Vre)
HepSymMatrix Vmeasure() const
void ThreeMomentumConstraints(const Hep3Vector p3, std::vector< int > tlis)
void TotalEnergyConstraints(const double etot, std::vector< int > tlis)
std::vector< int > numEqual()
HepLorentzVector p4() const
void TotalMomentumConstraints(const double ptot, std::vector< int > tlis)
void EqualMassConstraints(std::vector< int > tlis1, std::vector< int > tlis2, HepSymMatrix Vne)
std::vector< int > AddList(int n1)
std::vector< WTrackParameter > wTrackInfit() const
void setVBeamPosition(const HepSymMatrix VBeamPosition)
void clearGammaShapeList()
int numberGammaShape() const
vector< int > mappositionA() const
HepSymMatrix getVBeamPosition() const
HepPoint3D getBeamPosition() const
std::vector< GammaShape > GammaShapeValue() const
std::vector< WTrackParameter > wTrackOrigin() const
std::vector< int > GammaShapeList() const
vector< int > mappositionB() const
vector< int > mapkinematic() const
void setBeamPosition(const HepPoint3D BeamPosition)
void setWTrackInfit(const int n, const WTrackParameter wtrk)
void setEw(const HepSymMatrix &Ew)
void setMass(const double mass)
void setCharge(const int charge)
void setW(const HepVector &w)
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)