00001 #include "w_YFMVTR.h"
00002 #include <iostream.h>
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 bool w_YFMVTR::getResult(const vector<Helix>& vHelix,
00014 HepLorentzVector& track4V, HepSymMatrix& covTrack,
00015 Hep3Vector& vertex3V, HepSymMatrix& covVertex,
00016 HepMatrix& corrVertexTrack,
00017 float& chi2) const {
00018
00019
00020 Vertex theVertexC;
00021
00022
00023 HepLorentzVector temp4V(0.,0.,0.,0.);
00024 track4V = temp4V;
00025
00026 HepSymMatrix tempCov4V(4,0);
00027 covTrack = tempCov4V;
00028
00029 Hep3Vector temp3V(0.,0.,0.);
00030 vertex3V = temp3V;
00031
00032 HepSymMatrix tempCov3V(3,0);
00033 covVertex = tempCov3V;
00034
00035 HepMatrix tempCorr(3,3,0);
00036 corrVertexTrack = tempCorr;
00037
00038 float _chi2 = -1.;
00039 chi2 = _chi2;
00040
00041
00042 if (vHelix.size() > 10)
00043 cerr << "__w_YFMVTR::getResult: Too many tracks (" << vHelix.size()
00044 << "). Surplus tracks will be ignored in the fit !!" << endl;
00045
00046
00047 int n_charged = 0;
00048 int n_neutral = 0;
00049 vector<const Helix>::iterator itH = vHelix.begin();
00050 for ( ; itH < vHelix.end(); itH++ ) {
00051 if (itH->charge() != 0) {
00052 n_charged++;
00053 } else {
00054 n_neutral++;
00055 }
00056 }
00057
00058
00059 FCB.nvx = 0;
00060 FCB.nhx = 0;
00061 FCB.neu = 0;
00062 FCB.lvapc = 1;
00063 FCB.lpsum = 1;
00064 FCB.lmcalc = 1;
00065 FCB.lvfix = 0;
00066 FCB.vxin[0] = 0.;
00067 FCB.vvxin[0] = 0.;
00068
00069
00070 if ( _pVertexC ) {
00071 FCB.nvx = 1;
00072 FCB.lvapc = 0;
00073
00074 FCB.vxin[0] = _pVertexC->v3V().x();
00075 FCB.vxin[1] = _pVertexC->v3V().y();
00076 FCB.vxin[2] = _pVertexC->v3V().z();
00077
00078 int j = 0;
00079 for (int m = 1; m <= 3; m++) {
00080 for (int n = 1; n <= m; n++) {
00081 FCB.vvxin[j++] = _pVertexC->cov_matrix(m,n) ;
00082 }
00083 }
00084 }
00085
00086 int ntrk = 0;
00087 int nchg = 0;
00088 int nneu = 0;
00089 int indf;
00090 int indv;
00091
00092 float cmass[10];
00093 float nmass[10];
00094
00095
00097 for (itH = vHelix.begin() ; itH < vHelix.end(); itH++ ) {
00098
00099 if ((itH - vHelix.begin()) > 10) break;
00100
00101 ntrk++;
00102 indf = 5*(ntrk -1);
00103 indv = 15*(ntrk -1);
00104
00105
00106
00107
00108 if (itH->charge() != 0) {
00109 nchg++;
00110 FCB.nhx++;
00111 FCB.ixhx[nchg -1] = ntrk;
00112 cmass[nchg -1] = itH->mass();
00113
00114
00115 FCB.hxin[indf ] = itH->IR();
00116 FCB.hxin[indf+ 1] = itH->TL();
00117 FCB.hxin[indf+ 2] = itH->P0();
00118 FCB.hxin[indf+ 3] = itH->D0();
00119 FCB.hxin[indf+ 4] = itH->Z0();
00120
00121
00122 int j = 0;
00123 for (int m = 1; m <= 5; m++) {
00124 for (int n = 1; n <= m; n++) {
00125 j++;
00126 FCB.vhxin[indv +j -1] = itH->cov_matrix(m,n);
00127 }
00128 }
00129
00130
00131
00132 } else {
00133
00134
00135
00136 nneu++;
00137 FCB.neu++;
00138 FCB.ixnu[nneu -1] = ntrk;
00139 nmass[nneu -1] = itH->mass();
00140
00141
00142 FCB.hxin[indf ] = itH->IR();
00143 FCB.hxin[indf+ 1] = itH->TL();
00144 FCB.hxin[indf+ 2] = itH->P0();
00145 FCB.hxin[indf+ 3] = itH->D0();
00146 FCB.hxin[indf+ 4] = itH->Z0();
00147
00148
00149 int j = 0;
00150 for (int m = 1; m <= 5; m++) {
00151 for (int n = 1; n <= m; n++) {
00152 j++;
00153 FCB.vtnui[indv +j -1] = itH->cov_matrix(m,n);
00154 }
00155 }
00156
00157
00158
00159 }
00160
00161 }
00162
00163 int j = 0;
00164 int i;
00165 for (i = 0; i < nchg; i++) {
00166 FCB.ampc[j++] = cmass[i];
00167 }
00168 for (i = 0; i < nneu; i++) {
00169 FCB.ampc[j++] = nmass[i];
00170 }
00171 for (i = 0; i < ntrk*5; i++) {
00172 FCB.tnui[i] = FCB.hxin[i];
00173 }
00174
00175 FCB.npidc = 1;
00176
00177
00186
00187
00188
00189
00190 int ifail = W_YFMVTR();
00191
00192 if (! ifail) {
00193
00194 float ptrk[5];
00195 float vptrk[10];
00196
00197 ptrk[0] = FCB.psum[0];
00198 ptrk[1] = FCB.psum[1];
00199 ptrk[2] = FCB.psum[2];
00200 ptrk[3] = sqrt(FCB.amass*FCB.amass + ptrk[0]*ptrk[0] +
00201 ptrk[1]*ptrk[1] + ptrk[2]*ptrk[2]);
00202 ptrk[4] = FCB.amass;
00203
00204
00205
00206 int ndf = ( _pVertexC ) ? ntrk*2 : ntrk*2 -3;
00207 _chi2 = FCB.chisq/((float) ndf);
00208
00209
00210 if (_chi2 < 500.) {
00211 if (ptrk[4] > 500. || ptrk[0] > 1000. || ptrk[1] > 1000. ||
00212 ptrk[2] > 1000. ) {
00213 _chi2 = -1.;
00214 }
00215 } else {
00216 _chi2 = -1.;
00217 }
00218
00219
00220 if (_chi2 > 0.) {
00221
00222 float r1 = ptrk[0]/ptrk[3];
00223 float r2 = ptrk[1]/ptrk[3];
00224 float r3 = ptrk[2]/ptrk[3];
00225 float r4 = ptrk[4]/ptrk[3];
00226
00227 for (int i = 0; i <= 6; i++) {
00228 vptrk[i] = FCB.vpsum[i];
00229 }
00230
00231 vptrk[9] = r1*r1*vptrk[0] + r2*r2*vptrk[2] +
00232 r3*r3*vptrk[5] + r4*r4*FCB.dmass*FCB.dmass +
00233 2.*r1*(r2*vptrk[1] + r3*vptrk[3]) +
00234 2.*r2*r3*vptrk[4] +
00235 2.*r4*(r1*FCB.vmps[0] + r2*FCB.vmps[1] + r3*FCB.vmps[2]);
00236
00237 vptrk[6] = r1*vptrk[0] + r2*vptrk[1] + r3*vptrk[3]
00238 + r4*FCB.vmps[0];
00239
00240 vptrk[7] = r1*vptrk[1] + r2*vptrk[2] + r3*vptrk[4]
00241 + r4*FCB.vmps[1];
00242
00243 vptrk[8] = r1*vptrk[3] + r2*vptrk[4] + r3*vptrk[5]
00244 + r4*FCB.vmps[2];
00245
00246
00247
00248
00249 track4V.setPx(ptrk[0]);
00250 track4V.setPy(ptrk[1]);
00251 track4V.setPz(ptrk[2]);
00252 track4V.setE(ptrk[3]);
00253
00254
00255 vertex3V.setX(FCB.vxout[0]);
00256 vertex3V.setY(FCB.vxout[1]);
00257 vertex3V.setZ(FCB.vxout[2]);
00258
00259
00260 int j = 0;
00261 int m;
00262 int n;
00263 for (m = 1 ; m <= 4; m++) {
00264 for (n = 1; n <= m; n++) {
00265 covTrack(m,n)= vptrk[j++];
00266 }
00267 }
00268
00269
00270 j = 0;
00271 for (m = 1; m <= 3; m++) {
00272 for (n = 1; n <= m; n++) {
00273 covVertex(m,n)= FCB.vvxou[j++];
00274 }
00275 }
00276
00277
00278 j = 0;
00279 for (m = 1; m <= 3; m++) {
00280 for (n = 1; n <= 3; n++) {
00281
00282 corrVertexTrack(n,m)= FCB.vpsvx[j++];
00283 }
00284 }
00285
00286
00287 chi2 = _chi2;
00288
00289 }
00290 }
00291
00292
00293
00294 return (ifail != 0);
00295 }
00296
00297