Print

Print


Commit in lcsim/src/org/lcsim/fit/helicaltrack on MAIN
HelixParamCalculator.java+25-351.4 -> 1.5
Fix bug in x0 calculation, re-write parts of the code that were a bit obscure.

lcsim/src/org/lcsim/fit/helicaltrack
HelixParamCalculator.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- HelixParamCalculator.java	17 Jul 2008 17:26:51 -0000	1.4
+++ HelixParamCalculator.java	14 Aug 2009 23:28:22 -0000	1.5
@@ -8,6 +8,7 @@
 package org.lcsim.fit.helicaltrack;
 
 import hep.physics.vec.BasicHep3Vector;
+import org.lcsim.constants.Constants;
 import org.lcsim.event.MCParticle;
 import org.lcsim.event.EventHeader;
 
@@ -18,8 +19,7 @@
  */
 public class HelixParamCalculator  {
 
-    MCParticle mcp;
-    private double R,BField,theta,arclength;
+    private double R, p, pt, theta, arclength;
     //Some varibles are usesd in other calculations, thus they are global
     /*
     xc, yc --coordinates
@@ -28,47 +28,47 @@
     tanL -- Slope SZ plane ds/dz
     x0,y0 are the position of the particle at the dca
     */
-    private double xc,yc,mcdca,mcphi0,tanL;
+    private double mcdca,mcphi0,tanL,z0;
     private double x0,y0;
     /**
      * Constructor that is fed a magnetic field and MCPARTICLE
      * @param mcpc
      * @param cBField
      */
-    public HelixParamCalculator(MCParticle mcpc,double cBField)
+    public HelixParamCalculator(MCParticle mcp, double BField)
     {
-        //mc and event global varibles used for calculation
-        mcp=mcpc;
-        
-        //Returns the MagneticField at point (0,0,0), assumes constant magfield
-        BField = cBField;
         
         //Calculate theta, the of the helix projected into an SZ plane, from the z axis
         double px = mcp.getPX();
         double py = mcp.getPY();
         double pz = mcp.getPZ();
-        double pt = Math.sqrt(px*px + py*py);
-        double p = Math.sqrt(pt*pt + pz*pz);
+        pt = Math.sqrt(px*px + py*py);
+        p = Math.sqrt(pt*pt + pz*pz);
         double cth = pz / p;
         theta = Math.acos(cth);
        
         //Calculate Radius of the Helix
-        R = ((mcp.getCharge())*(mcp.getMomentum().magnitude()*Math.sin(theta))/(.0003*BField));
+        R = mcp.getCharge() * pt / (Constants.fieldConversion * BField);
         
         //Slope in the Dz/Ds sense, tanL Calculation
-        tanL = mcp.getPZ()/(Math.sqrt(mcp.getPX()*mcp.getPX()+mcp.getPY()*mcp.getPY()));
-       
+        tanL = pz / pt;
+
+        //  Azimuthal direction at origin
+        double mcphi = Math.atan2(py, px);
+
         //Distance of closest approach Calculation
-        xc   = mcp.getOriginX() + R * Math.sin(Math.atan2(mcp.getPY(),mcp.getPX()));
-        yc   = mcp.getOriginY() - R * Math.cos(Math.atan2(mcp.getPY(),mcp.getPX()));
-        double xcyc = Math.sqrt(xc*xc + yc*yc);
+        double xc   = mcp.getOriginX() + R * Math.sin(mcphi);
+        double yc   = mcp.getOriginY() - R * Math.cos(mcphi);
+
+        double Rc = Math.sqrt(xc*xc + yc*yc);
+
             if(mcp.getCharge()>0)
             {
-            mcdca = R - xcyc;
+            mcdca = R - Rc;
             }
             else
             {
-            mcdca = R + xcyc;      
+            mcdca = R + Rc;
             }
         
         
@@ -80,8 +80,9 @@
             }
         //z0 Calculation, z position of the particle at dca
         x0 = -mcdca*Math.sin(mcphi0);
-        y0 = mcdca*Math.sin(mcphi0);
+        y0 = mcdca*Math.cos(mcphi0);
         arclength  = (((mcp.getOriginX()-x0)*Math.cos(mcphi0))+((mcp.getOriginY()-y0)*Math.sin(mcphi0)));
+        z0 = mcp.getOriginZ() - arclength * tanL;
     
     }
     /**
@@ -94,14 +95,6 @@
         this(mcpc,eventc.getDetector().getFieldMap().getField(new BasicHep3Vector(0.,0.,0.)).z());
     }
     /**
-     * Return the magneticfield at point 0,0,0
-     * @return double BField
-     */
-    public double getMagField()
-    {
-        return BField;
-    }
-    /**
      * Return the radius of the Helix track
      * @return double R
      */
@@ -124,7 +117,7 @@
      */
     public double getMCMomentum()
     {
-        return mcp.getMomentum().magnitude();
+        return p;
     }
     /**
      * Return the curvature (omega)
@@ -132,7 +125,7 @@
      */
     public double getMCOmega()
     {     
-        return mcp.getCharge()/((mcp.getMomentum().magnitude()*Math.sin(theta))/(.0003*BField));
+        return 1. / R;
     }
     /**
      * Return the transvers momentum of the MC particle, Pt
@@ -140,7 +133,7 @@
      */
     public double getMCTransverseMomentum()
     {
-        return (mcp.getMomentum().magnitude())*Math.sin(theta);
+        return pt;
     }
     /**
      * Return the slope of the helix in the SZ plane, tan(lambda)
@@ -172,10 +165,7 @@
      */
     public double getZ0()
     {
-        double x0 = -mcdca*Math.sin(mcphi0);
-        double y0 = mcdca*Math.sin(mcphi0);
-        double s  = (((mcp.getOriginX()-x0)*Math.cos(mcphi0))+((mcp.getOriginY()-y0)*Math.sin(mcphi0)));
-        return mcp.getOriginZ()-(s*tanL);
+        return z0;
     }
     /**
      * Return the arclength of the helix from the ORIGIN TO THE DCA
CVSspam 0.2.8