lcsim/src/org/lcsim/contrib/JanStrube/standalone/at/hephy/Converter
diff -N LcioToRaveObjects.java
--- LcioToRaveObjects.java 29 Nov 2006 02:32:15 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,208 +0,0 @@
-package at.hephy.Converter;
-import at.hephy.Rave.RaveTrack;
-import at.hephy.Rave.RaveVector6D;
-import at.hephy.Rave.RaveCovariance6D;
-// import hep.lcio.event.Track;
-import org.lcsim.event.Track;
-import hep.physics.matrix.SymmetricMatrix;
-import org.lcsim.spacegeom.SpacePoint;
-import org.lcsim.spacegeom.SpaceVector;
-import Jama.Matrix;
-
-import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.d0;
-import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.phi0;
-import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.omega;
-import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.tanLambda;
-import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.z0;
-
-import static org.lcsim.contrib.JanStrube.vtxFitter.Fitter.getSpatialDerivativeMatrix;
-import static org.lcsim.contrib.JanStrube.vtxFitter.Fitter.getMomentumDerivativeMatrix;
-import static org.lcsim.constants.Constants.fieldConversion;
-
-import static java.lang.Math.sin;
-import static java.lang.Math.cos;
-import static java.lang.Math.abs;
-
-public class LcioToRaveObjects
-{
- public RaveTrack convert( org.lcsim.contrib.JanStrube.tracking.Track lct )
- {
- SpacePoint refPoint = lct.getReferencePoint();
- SpacePoint r = lct.getPosition();
- SpaceVector p = lct.getMomentum();
- double _d0 = lct.getParameter(d0);
- double _omega = lct.getParameter(omega);
- double _phi0 = lct.getParameter(phi0);
- double _tanLambda = lct.getParameter(tanLambda);
- double _z0 = lct.getParameter(z0);
- RaveVector6D s = new RaveVector6D (r.x(), r.y(), r.z(), p.x(), p.y(), p.z());
- double signOmega = _omega / abs(_omega) ;
- int charge = lct.getCharge();
- double Bz = p.rxy() * _omega / charge / fieldConversion;
- // assume that the Track doesn't have to be swum for now
- double l = 0;
- double _phi = _phi0 - _omega*l;
- double pt = lct.getPt();
-
- double [][] brJacob = {
- { Math.sin(_phi0),
- -Math.cos(_phi0), 0.0, 0.0, 0.0, 0.0 },
- {(1/_omega-_d0)*cos(_phi0) - cos(_phi)/_omega, (1/_omega-_d0)*sin(_phi0) - sin(_phi)/_omega, 0
- , -pt*sin(_phi), pt*cos(_phi), 0},
- {1/_omega/_omega*(sin(_phi0)-sin(_phi)), 1/_omega/_omega*(cos(_phi0)-cos(_phi)), 0
- , -pt/_omega*cos(_phi)+pt*l*sin(_phi), -pt/_omega*sin(_phi)-pt*l*cos(_phi), -pt/_omega*_tanLambda},
- {0, 0, 1, 0, 0, 0},
- {-cos(_phi)*l*_tanLambda/(1+_tanLambda*_tanLambda), -sin(_phi)*l*_tanLambda/(1+_tanLambda*_tanLambda), l
- , -pt*sin(_phi)*_omega*l*_tanLambda/(1+_tanLambda*_tanLambda), pt*cos(_phi)*_omega*l*_tanLambda/(1+_tanLambda*_tanLambda), pt}
- };
-
- SymmetricMatrix bCov = lct.getErrorMatrix();
- double[][] rCov= { {0.,0.,0.,0.,0.,0.}, {0.,0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.,0.} };
- for ( int x=0; x< 6; x++ )
- {
- for ( int y=0; y<6; y++ )
- {
- for ( int z=0; z<5; z++ )
- {
- for ( int z2=0; z2<5; z2++ )
- {
- rCov[x][y]+=brJacob[z][x]*bCov.e(z, z2)*brJacob[z2][y];
- };
- };
- };
- };
-
- RaveCovariance6D err = new RaveCovariance6D ( rCov[0][0], rCov[0][1], rCov[0][2],
- rCov[1][1], rCov[1][2], rCov[2][2],
- rCov[0][3], rCov[0][4], rCov[0][5],
- rCov[1][3], rCov[1][4], rCov[1][5],
- rCov[2][3], rCov[2][4], rCov[2][5],
- rCov[3][3], rCov[3][4], rCov[3][5],
- rCov[4][4], rCov[4][5], rCov[5][5] ) ;
-
- RaveTrack trk = new RaveTrack ( s, err, charge, 0, "id" );
- return trk;
- }
-
-
-
- public RaveTrack convert( Track lct )
- {
- /*
- float bInvP = lct.getOmega() ;
- float bTheta = lct.getTanLambda() ;
- float bPhi = lct.getPhi() ; */
- double bInvP = lct.getTrackParameter ( 0 );
- double bTheta = lct.getTrackParameter ( 1 );
- double bPhi = lct.getTrackParameter ( 2 );
- double bRRef = lct.getReferencePoint()[0] ;
- double bRPhiRef = lct.getReferencePoint()[1] ;
- double bZRef = lct.getReferencePoint()[2] ;
-
- RaveVector6D s = new RaveVector6D ( bRRef * Math.cos( bRPhiRef / bRRef ) ,
- bRRef * Math.sin( bRPhiRef / bRRef ) ,
- bZRef ,
- Math.sin( bTheta ) * Math.cos( bPhi ) / Math.abs( bInvP ) ,
- Math.sin( bTheta ) * Math.sin( bPhi ) / Math.abs( bInvP ) ,
- Math.cos( bTheta ) / Math.abs( bInvP ) ) ;
- double signInvP = bInvP / Math.abs( bInvP ) ;
-
- double [][] brJacob = {
- { (-1) * Math.sin( bRPhiRef / bRRef ),
- Math.cos( bRPhiRef / bRRef ), 0.0, 0.0, 0.0, 0.0 },
- { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 },
- { 0., 0., 0., Math.cos( bTheta ) * Math.cos( bPhi ) / Math.abs( bInvP ) ,
- Math.cos( bTheta ) * Math.cos( bPhi ) / Math.abs( bInvP ) ,
- (-1.0) * Math.sin( bTheta ) / Math.abs( bInvP ) },
- { 0.0, 0.0, 0.0,
- (-1.0) * Math.sin( bTheta ) * Math.sin( bPhi ) / Math.abs( bInvP ),
- Math.sin( bTheta ) * Math.cos( bPhi ) / Math.abs( bInvP ), 0. },
- { 0., 0., 0.,
- (-1.0) * signInvP * Math.sin( bTheta ) * Math.cos( bPhi ) / Math.pow( bInvP, 2 ),
- (-1.0) * signInvP * Math.sin( bTheta ) * Math.sin( bPhi ) / Math.pow( bInvP, 2 ),
- (-1.0) * signInvP * Math.cos( bTheta ) / Math.pow( bInvP, 2 ) }
- };
- /*
- HepMatrix brJacob = new HepMatrix ( 6, 5 ) ;
- brJacob[0][1] = 0.0 ;
- brJacob[1][1] = 0.0 ;
- brJacob[2][1] = 1.0 ;
- brJacob[3][1] = 0.0 ;
- brJacob[4][1] = 0.0 ;
- brJacob[5][1] = 0.0 ;
- brJacob[0][2] = 0.0 ;
- brJacob[1][2] = 0.0 ;
- brJacob[2][2] = 0.0 ;
- brJacob[3][2] = Math.cos( bTheta ) * Math.cos( bPhi ) / Math.abs( bInvP ) ;
- brJacob[4][2] = Math.cos( bTheta ) * Math.sin( bPhi ) / Math.abs( bInvP ) ;
- brJacob[5][2] = (-1.0) * Math.sin( bTheta ) / Math.abs( bInvP ) ;
- brJacob[0][3] = 0.0 ;
- brJacob[1][3] = 0.0 ;
- brJacob[2][3] = 0.0 ;
- brJacob[3][3] = (-1.0) * Math.sin( bTheta ) * Math.sin( bPhi ) / Math.abs( bInvP ) ;
- brJacob[4][3] = Math.sin( bTheta ) * Math.cos( bPhi ) / Math.abs( bInvP ) ;
- brJacob[5][3] = 0.0 ;
- brJacob[0][4] = 0.0 ;
- brJacob[1][4] = 0.0 ;
- brJacob[2][4] = 0.0 ;
- brJacob[3][4] = (-1.0) * signInvP * Math.sin( bTheta ) * Math.cos( bPhi ) / Math.pow( bInvP, 2 ) ;
- brJacob[4][4] = (-1.0) * signInvP * Math.sin( bTheta ) * Math.sin( bPhi ) / Math.pow( bInvP, 2 ) ;
- brJacob[5][4] = (-1.0) * signInvP * Math.cos( bTheta ) / Math.pow( bInvP, 2 ) ;
- */
-
- SymmetricMatrix bCov = lct.getErrorMatrix();
- /*
- double[][] bCov={{ m[0], m[1], m[3], m[6], m[10]}, { m[1], m[2], m[4], m[7], m[11] },
- { m[3], m[4], m[5], m[8], m[12] }, { m[6], m[7], m[8], m[9], m[13] },
- { m[10], m[11], m[12], m[13], m[14] } };
- HepSymMatrix bCov = new HepSymMatrix ( 5 ) ;
- bCov[0][0] = lct.getCovMatrix()[ 0] ;
- bCov[0][1] = lct.getCovMatrix()[ 1] ;
- bCov[1][1] = lct.getCovMatrix()[ 2] ;
- bCov[0][2] = lct.getCovMatrix()[ 3] ;
- bCov[1][2] = lct.getCovMatrix()[ 4] ;
- bCov[2][2] = lct.getCovMatrix()[ 5] ;
- bCov[0][3] = lct.getCovMatrix()[ 6] ;
- bCov[1][3] = lct.getCovMatrix()[ 7] ;
- bCov[2][3] = lct.getCovMatrix()[ 8] ;
- bCov[3][3] = lct.getCovMatrix()[ 9] ;
- bCov[0][4] = lct.getCovMatrix()[10] ;
- bCov[1][4] = lct.getCovMatrix()[11] ;
- bCov[2][4] = lct.getCovMatrix()[12] ;
- bCov[3][4] = lct.getCovMatrix()[13] ;
- bCov[4][4] = lct.getCovMatrix()[14] ;
- */
-
- /*
- HepMatrix rCov = new HepMatrix ( 6, 6 ) ;
- rCov = brJacob * bCov * brJacob.T() ;
- */
- double[][] rCov= { {0.,0.,0.,0.,0.,0.}, {0.,0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.,0.} };
- for ( int x=0; x< 6; x++ )
- {
- for ( int y=0; y<6; y++ )
- {
- for ( int z=0; z<5; z++ )
- {
- for ( int z2=0; z2<5; z2++ )
- {
- rCov[x][y]+=brJacob[z][x]*bCov.e(z, z2)*brJacob[z2][y];
- };
- };
- };
- };
-
- RaveCovariance6D err = new RaveCovariance6D ( rCov[0][0], rCov[0][1], rCov[0][2],
- rCov[1][1], rCov[1][2], rCov[2][2],
- rCov[0][3], rCov[0][4], rCov[0][5],
- rCov[1][3], rCov[1][4], rCov[1][5],
- rCov[2][3], rCov[2][4], rCov[2][5],
- rCov[3][3], rCov[3][4], rCov[3][5],
- rCov[4][4], rCov[4][5], rCov[5][5] ) ;
-
- // int charge = signed ( copysign ( 1.0, (-1.0)*signInvP ) );
- int charge = (int) ( -1.0 * signInvP / Math.abs ( signInvP ) );
- RaveTrack trk = new RaveTrack ( s, err, charge, 0, "id" );
- return trk;
- }
-}