lcsim/src/org/lcsim/fit/helicaltrack
diff -N HelixParamCalculator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HelixParamCalculator.java 7 Jul 2008 18:44:21 -0000 1.1
@@ -0,0 +1,164 @@
+/*
+ * HelixParameterCalculator.java
+ *
+ * Created on July 7th, 2008, 11:09 AM
+ *
+ *
+ */
+package org.lcsim.fit.helicaltrack;
+
+import hep.physics.vec.BasicHep3Vector;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.EventHeader;
+
+/**
+ * Class used for calculating MC particle track paramters
+ * @author Pelham Keahey
+ *
+ */
+public class HelixParamCalculator {
+
+ MCParticle mcp;
+ EventHeader event;
+ private double R,BField,theta;
+ //Some varibles are usesd in other calculations, thus they are global
+ /*
+ xc, yc --coordinates
+ mcdca -- MC distance of closest approach
+ mcphi0 --azimuthal angle
+ tanL -- Slope SZ plane ds/dz
+ */
+ private double xc,yc,mcdca,mcphi0,tanL;
+
+ public HelixParamCalculator(MCParticle mcpc,EventHeader eventc)
+ {
+ //mc and event global varibles used for calculation
+ mcp=mcpc;
+ event = eventc;
+
+ //Returns the MagneticField at point (0,0,0), assumes constant magfield
+ BField = event.getDetector().getFieldMap().getField(new BasicHep3Vector(0.,0.,0.)).z();
+
+ //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);
+ double cth = pz / p;
+ theta = Math.acos(cth);
+
+ //Calculate Radius of the Helix
+ R = ((mcp.getCharge())*(mcp.getMomentum().magnitude()*Math.sin(theta))/(.0003*BField));
+
+ //Slope in the Dz/Ds sense, tanL Calculation
+ tanL = mcp.getPZ()/(Math.sqrt(mcp.getPX()*mcp.getPX()+mcp.getPY()*mcp.getPY()));
+
+ //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);
+ if(mcp.getCharge()>0)
+ {
+ mcdca = R - xcyc;
+ }
+ else
+ {
+ mcdca = R + xcyc;
+ }
+
+
+ //azimuthal calculation of the momentum at the DCA, phi0, Calculation
+ mcphi0 = Math.atan2(xc/(R-mcdca), -yc/(R-mcdca));
+ if(mcphi0<0)
+ {
+ mcphi0 += 2*Math.PI;
+ }
+ }
+ /**
+ * Return the magneticfield at point 0,0,0
+ * @return double BField
+ */
+ public double getMagField()
+ {
+ return BField;
+ }
+ /**
+ * Return the radius of the track
+ * @return double R
+ */
+ public double getRadius()
+ {
+ return R;
+ }
+ /**
+ * Return the theta angle for the projection of the helix in the SZ plane
+ * from the z axis
+ * @return double theta
+ */
+ public double getTheta()
+ {
+ return theta;
+ }
+ /**
+ * Return the particle's momentum
+ * @return double mcp momentum
+ */
+ public double getMCMomentum()
+ {
+ return mcp.getMomentum().magnitude();
+ }
+ /**
+ * Return the curvature (omega)
+ * @return double omega
+ */
+ public double getMCOmega()
+ {
+ return mcp.getCharge()/((mcp.getMomentum().magnitude()*Math.sin(theta))/(.0003*BField));
+ }
+ /**
+ * Return the transvers momentum of the MC particle, Pt
+ * @return double Pt
+ */
+ public double getMCTransverseMomentum()
+ {
+ return (mcp.getMomentum().magnitude())*Math.sin(theta);
+ }
+ /**
+ * Return the slope of the helix in the SZ plane, tan(lambda)
+ * @return double tanL
+ */
+ public double getSlopeSZPlane()
+ {
+ return tanL;
+ }
+ /**
+ * Return the distance of closest approach
+ * @return double mcdca
+ */
+ public double getDCA()
+ {
+ return mcdca;
+ }
+ /**
+ * Return the azimuthal angle of the momentum when at the position of closest approach
+ * @return double mcphi0
+ */
+ public double getPhi0()
+ {
+ return mcphi0;
+ }
+ /**
+ * Return the z position at the distance of closest approach
+ * @return double z0 position
+ */
+ 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);
+ }
+
+
+}