Print

Print


Commit in lcsim/src/org/lcsim/contrib/RobKutschke/TRFSelfTest/generator on MAIN
RKTrack.java+150added 1.1
RKTrackGen.java+95added 1.1
RKTrackGenParams.java+205added 1.1
toTRF.java+108added 1.1
+558
4 added files
First Release

lcsim/src/org/lcsim/contrib/RobKutschke/TRFSelfTest/generator
RKTrack.java added at 1.1
diff -N RKTrack.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ RKTrack.java	8 Jun 2009 06:03:49 -0000	1.1
@@ -0,0 +1,150 @@
+package org.lcsim.contrib.RobKutschke.TRFSelfTest.generator;
+
+import org.lcsim.recon.tracking.trfutil.TRFMath;
+import org.lcsim.constants.Constants;
+
+/**
+ * 
+ * One generated track.  The constructor uses a parameterization that
+ * is useful for thinking about the range of generated parameters.
+ * Other information is available.  Distances are in mm and momentum in GeV/c.
+ * 
+ *  pt  = transverse momentum (GeV)
+ *  cz  = cos(theta)
+ *  phi = azimuth of momentum (radians)
+ *  d0  = signed DCA wrt z axis (mm)
+ *  z0  = z at PCA to z axis (mm)
+ * 
+ * Parameters are defined in the CLEO convention.
+ * 
+ *@author $Author: kutschke $
+ *@version $Id: RKTrack.java,v 1.1 2009/06/08 06:03:49 kutschke Exp $
+ *
+ * Date $Date: 2009/06/08 06:03:49 $
+ *
+ */
+
+
+public class RKTrack {
+
+
+    public RKTrack( double q, 
+		    double pt, 
+		    double cz, 
+		    double phi0, 
+		    double d0,
+		    double z0,
+		    double bz){
+	
+	this.q    = q;
+	this.pt   = pt;
+	this.cz   = cz;
+	this.phi0 = phi0;
+	this.d0   = d0;
+	this.z0   = z0;
+	this.bz   = bz;
+	
+	update();
+    }
+
+    public RKTrack ( RKTrack t ){
+	q    = t.q;
+	pt   = t.pt;
+	cz   = t.cz;
+	phi0 = t.phi0;
+	d0   = t.d0;
+	z0   = t.z0;
+	bz   = t.bz;
+	
+	update();
+    }
+
+    
+    public double q()     { return     q;}
+    public double pt()    { return    pt;}
+    public double cz()    { return    cz;}
+    public double phi0()  { return  phi0;}
+    public double d0()    { return    d0;}
+    public double z0()    { return    z0;}
+    public double cu()    { return    cu;}
+    public double p()     { return     p;}
+    public double cotth() { return cz/sz;}
+    public double x0()    { return    x0;}
+    public double y0()    { return    y0;}
+    public double sz()    { return    sz;}
+    public double rho()   { return   rho;}
+
+    public double e() {
+	return e(m_pi);
+    }
+
+    public double e( double m ){
+	return Math.sqrt( p*p + m*m);
+    }
+    
+    // Synonym for cottan(theta);
+    public double tanlam()  { return cz/sz;}
+
+    public double momentum(){ return     p;}
+    public double charge()  { return     q;}
+
+    public String toString(){
+	return String.format("CLEO Style track: q=%4.1f pt=%10.4f cz=%10.4f phi0=%10.4f d0=%10.4f z0=%10.4f\n",
+			   q, pt, cz, phi0, d0, z0  );
+    }
+
+    public double phi_pos(){
+	return TRFMath.fmod2(Math.atan2(y0,x0),TRFMath.TWOPI);
+    }
+
+    private double bz=5.0;
+
+    private double  q;       // Charge
+    private double pt;       // Transverse momentum wrt z axis
+    private double cz;       // Cos(theta) of momentum
+    private double phi0;     // Azimuth of momentum
+    private double d0;       // Signed DCA to z axis
+    private double z0;       // z0 at PCA to z axis
+
+
+    // Derived quantities:
+    private double p;        // momentum
+    private double rho;      // Radius of curvature
+    private double cu;       // Curvature in cleo convention ( = q/2/rho).
+
+    private double sz;       // sin(theta)
+    private double cotth;    // cot(theta)
+
+    private double sphi0;    // sin(phi0)
+    private double cphi0;    // cos(phi0)
+
+    private double x0;       // x at PCA to z axis.
+    private double y0;       // y at PCA to z axis.
+
+    // Matches precicision in TRF.
+    private double m_pi = 0.13957;
+
+    private void update(){
+	rho   = pt/Constants.fieldConversion/bz;
+	cu    = 0.5*q/rho;
+	sphi0 = Math.sin(phi0);
+	cphi0 = Math.cos(phi0);
+	sz    = Math.sqrt( 1. - cz*cz);
+	cotth = cz/sz;
+	p     = pt/sz;
+	x0    = -d0*sphi0;
+	y0    =  d0*cphi0;
+
+    }
+
+    // Some other possibly useful things.
+    //double rc = d0 + 0.5/kappa;
+    //double xc = -rc*sphi0;
+    //double yc =  rc*cphi0;
+
+
+    //double cx = cphi0*sinth;
+    //double cy = sphi0*sinth;
+    //double cz = costh;
+
+}

lcsim/src/org/lcsim/contrib/RobKutschke/TRFSelfTest/generator
RKTrackGen.java added at 1.1
diff -N RKTrackGen.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ RKTrackGen.java	8 Jun 2009 06:03:49 -0000	1.1
@@ -0,0 +1,95 @@
+package org.lcsim.contrib.RobKutschke.TRFSelfTest.generator;
+
+import java.util.Random;
+
+import org.lcsim.util.aida.AIDA;
+
+import org.lcsim.recon.tracking.trfbase.TrackVector;
+import org.lcsim.recon.tracking.trfbase.VTrack;
+
+/**
+ * 
+ * A crude track generator.  It emits tracks in the CLEO parameterization.
+ *
+ *@author $Author: kutschke $
+ *@version $Id: RKTrackGen.java,v 1.1 2009/06/08 06:03:49 kutschke Exp $
+ *
+ * Date $Date: 2009/06/08 06:03:49 $
+ *
+ */
+
+public class RKTrackGen {
+
+    private AIDA aida = AIDA.defaultInstance();
+
+    public RKTrackGen( long seed){
+	par= new RKTrackGenParams();
+	ran = new Random(seed);
+    }
+
+    public RKTrackGen( RKTrackGenParams par, long seed){
+	this.par=par;
+	ran = new Random(seed);
+    }
+
+    public RKTrack newRKTrack (){
+
+	// Generate track parameters in cleo convention.
+	double pt    = par.ptmin()  + (par.ptmax()-par.ptmin())*ran.nextDouble();
+	double q = 1.;
+	if ( par.chargeControl() == -1 ){
+	    q = -1;
+	}else if ( par.chargeControl() != 1 ){
+	    q = ( ran.nextDouble() > 0.5 ) ? 1. : -1.;
+	}
+	double cz    = par.czmin()  + (par.czmax()-par.czmin())*ran.nextDouble();
+	double phi0  = par.phimin() + (par.phimax()-par.phimin())*ran.nextDouble();
+	double d0    = par.d0min()  + (par.d0max()-par.d0min())*ran.nextDouble();
+	double z0    = par.z0min()  + (par.z0max()-par.z0min())*ran.nextDouble();
+
+	// Use endcap mode for cz.
+	if ( par.czEndcapMode ){
+	    if ( ran.nextDouble() > 0.5 ) cz = -cz;
+	}
+
+	RKTrack t = new RKTrack( q, pt, cz, phi0, d0, z0, par.bz());
+
+	plotGenTrack(t);
+
+	return t;
+    }
+
+    // Monitoring histograms for the generated track.
+    public void plotGenTrack( RKTrack t ){
+
+	int nbins = 50;
+
+	double d0min = -5.;
+	double d0max =  5.;
+	double z0min = -15.;
+	double z0max =  15.;
+
+	aida.histogram1D("GeneratedParams/charge",5,-2.,2.).fill(t.q());
+	aida.histogram1D("GeneratedParams/pt", nbins,0.,25.).fill(t.pt());
+	aida.histogram1D("GeneratedParams/cos(theta)", nbins, -1., 1.).fill(t.cz());
+	aida.histogram1D("GeneratedParams/phi0",nbins, -Math.PI, Math.PI).fill(t.phi0());
+	aida.histogram1D("GeneratedParams/d0", nbins, d0min, d0max).fill(t.d0());
+	aida.histogram1D("GeneratedParams/z0", nbins, z0min, z0max).fill(t.z0());
+	aida.histogram1D("GeneratedParams/p", nbins, 0., 50.).fill(t.p());
+	aida.cloud2D("GeneratedParams/PCA0",-1).fill(t.x0(),t.y0());
+	aida.cloud2D("GeneratedParams/D0 vs Z0",-1).fill(t.z0(),t.d0());
+
+    }
+
+
+    public RKTrackGenParams getParams(){
+	return new RKTrackGenParams(par);
+    }
+
+    private Random ran = null;
+    private RKTrackGenParams par = null;
+
+
+
+
+}

lcsim/src/org/lcsim/contrib/RobKutschke/TRFSelfTest/generator
RKTrackGenParams.java added at 1.1
diff -N RKTrackGenParams.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ RKTrackGenParams.java	8 Jun 2009 06:03:49 -0000	1.1
@@ -0,0 +1,205 @@
+package org.lcsim.contrib.RobKutschke.TRFSelfTest.generator;
+
+import org.lcsim.recon.tracking.trfutil.TRFMath;
+import org.lcsim.contrib.RobKutschke.ToyConfig.ToyConfig;
+
+/**
+ * 
+ * Parameters to control RKTrackGen.
+ *
+ *@author $Author: kutschke $
+ *@version $Id: RKTrackGenParams.java,v 1.1 2009/06/08 06:03:49 kutschke Exp $
+ *
+ * Date $Date: 2009/06/08 06:03:49 $
+ *
+ */
+
+public class RKTrackGenParams {
+
+    // Limits for track parameter generation.
+    private double ptmin =      1.00;
+    private double ptmax =     10.00;
+    private double czmin =     -0.95;
+    private double czmax =      0.95;
+    private double phimin = -Math.PI;
+    private double phimax =  Math.PI;
+    private double d0min =     -4.00;
+    private double d0max =      4.00; 
+    private double z0min =    -10.00;
+    private double z0max =     10.00;
+
+    // Control of charge generation:
+    //  +1  = generate only charge +1
+    //  -1  = generate only charge -1
+    // else = generate both charges +1 and -1 in equal amounts.
+    int chargeControl = 0;
+
+    // Enable end cap mode for cz generation.
+    // That is, generate cz uniformly over:
+    //         czmin< cz <=  czmax
+    //   and  -czmax< cz <= -czmin
+    // The default mode is to generate uniformly over:
+    //    czmin< cz <=  czmax
+    boolean czEndcapMode = false;
+
+    // Strength of solenoidal magnetic field on z axis.
+    private double bz = 5.00;
+
+    public RKTrackGenParams(){
+    }
+
+    public RKTrackGenParams( ToyConfig config ){
+
+	// Override default values using values specified in the
+	// runtime configuration file, if present.
+	ptmin   = config.getDouble( "ptmin",  ptmin);
+	ptmax   = config.getDouble( "ptmax",  ptmax);
+	czmin   = config.getDouble( "czmin",  czmin);
+	czmax   = config.getDouble( "czmax",  czmax);
+	phimin  = config.getDouble( "phimin", phimin);
+	phimax  = config.getDouble( "phimax", phimax);
+	d0min   = config.getDouble( "d0min",  d0min);
+	d0max   = config.getDouble( "d0max",  d0max);
+	z0min   = config.getDouble( "z0min",  z0min);
+	z0max   = config.getDouble( "z0max",  z0max);
+
+	bz            = config.getDouble ( "bz",            bz);
+	chargeControl = config.getInt    ( "chargeControl", chargeControl);
+	czEndcapMode  = config.getBoolean( "czEndcapMode",  czEndcapMode);
+
+    }
+
+    public RKTrackGenParams(
+			    double ptmin,
+			    double ptmax,
+			    double czmin,
+			    double czmax,
+			    double phimax,
+			    double phimin,
+			    double d0min,
+			    double d0max,
+			    double z0min,
+			    double z0max,
+			    double bz,
+			    int chargeControl
+			    ){
+	this.ptmin  = ptmin;
+	this.ptmax  = ptmax;
+	this.czmin  = czmin;
+	this.czmax  = czmax;
+	this.phimax = phimax;
+	this.phimin = phimin;
+	this.d0min  = d0min;
+	this.d0max  = d0max;
+	this.z0min  = z0min;
+	this.z0max  = z0max;
+	this.bz     = bz;
+	this.chargeControl = chargeControl;
+    }
+
+    public RKTrackGenParams( RKTrackGenParams par ){
+	ptmin  = par.ptmin;
+	ptmax  = par.ptmax;
+	czmin  = par.czmin;
+	czmax  = par.czmax;
+	phimax = par.phimax;
+	phimin = par.phimin;
+	d0min  = par.d0min;
+	d0max  = par.d0max;
+	z0min  = par.z0min;
+	z0max  = par.z0max;
+	bz     = par.bz;
+	chargeControl = par.chargeControl;
+    }
+
+
+    public void setptmin(double ptmin){
+	this.ptmin=ptmin;
+    }
+
+    public void setptmax(double ptmax){
+	this.ptmax=ptmax;
+    }
+
+    public void setczmin(double czmin){
+	this.czmin=czmin;
+    }
+
+    public void setczmax(double czmax){
+	this.czmax=czmax;
+    }
+
+    public void setphimin(double phimin){
+	this.phimin=phimin;
+    }
+
+    public void setphimax(double phimax){
+	this.phimax=phimax;
+    }
+
+    public void setd0min(double d0min){
+	this.d0min=d0min;
+    }
+
+    public void setd0max(double d0max){
+	this.d0max=d0max;
+    }
+
+    public void setz0min(double z0min){
+	this.z0min=z0min;
+    }
+
+    public void setz0max(double z0max){
+	this.z0max=z0max;
+    }
+
+    public void setbz(double bz){
+	this.bz=bz;
+    }
+
+    public void setchargeControl(int c){
+	chargeControl=c;
+    }
+
+    public double ptmin(){ return ptmin;}
+    public double ptmax(){ return ptmax;}
+
+    public double czmin(){ return czmin;}
+    public double czmax(){ return czmax;}
+
+    public double phimin(){ return phimin;}
+    public double phimax(){ return phimax;}
+
+    public double d0min(){ return d0min;}
+    public double d0max(){ return d0max;}
+
+    public double z0min(){ return z0min;}
+    public double z0max(){ return z0max;}
+
+    public double bz(){ return bz;}
+
+    public double chargeControl(){ return chargeControl;}
+
+    public String toString(){
+	StringBuffer s = new StringBuffer();
+	s.append("Parameters for track generation: \n");
+	s.append(String.format( "Pt:   (%10.4f, %10.4f) (GeV)\n", ptmin,  ptmax ));
+	s.append(String.format( "cz:   (%10.4f, %10.4f)\n", czmin,  czmax ));
+	s.append(String.format( "Phi0: (%10.4f, %10.4f)\n", phimin, phimax ));
+	s.append(String.format( "d0:   (%10.4f, %10.4f) (mm)\n", d0min,  d0max ));
+	s.append(String.format( "z0:   (%10.4f, %10.4f) (mm)\n", z0min,  z0max ));
+	if ( chargeControl == 1 || chargeControl == -1 ){
+	    s.append(String.format( "Charge %3d only.  ", chargeControl ));
+	} else{
+	    s.append("Charge +1 and -1 equally.  ");
+	}
+	if ( czEndcapMode ){
+	    s.append("Endcap mode for cos(theta).\n");
+	} else{
+	    s.append("Normal mode for cos(theta).\n");
+	}
+
+	s.append(String.format("BField strength %10.2f (T)\n", bz));
+	return s.toString();
+    }
+}

lcsim/src/org/lcsim/contrib/RobKutschke/TRFSelfTest/generator
toTRF.java added at 1.1
diff -N toTRF.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ toTRF.java	8 Jun 2009 06:03:49 -0000	1.1
@@ -0,0 +1,108 @@
+package org.lcsim.contrib.RobKutschke.TRFSelfTest.generator;
+
+import org.lcsim.recon.tracking.trfutil.TRFMath;
+
+import org.lcsim.recon.tracking.trfbase.TrackVector;
+import org.lcsim.recon.tracking.trfbase.VTrack;
+import org.lcsim.recon.tracking.trfdca.SurfDCA;
+import org.lcsim.recon.tracking.trfcyl.SurfCylinder;
+import org.lcsim.recon.tracking.trfzp.SurfZPlane;
+
+import org.lcsim.contrib.RobKutschke.TRFSelfTest.util.cyl_int;
+import org.lcsim.contrib.RobKutschke.TRFSelfTest.util.zplane_int;
+
+/**
+ * 
+ * Utility routine to convert RKTracks into TRF VTracks.
+ *
+ *@author $Author: kutschke $
+ *@version $Id: toTRF.java,v 1.1 2009/06/08 06:03:49 kutschke Exp $
+ *
+ * Date $Date: 2009/06/08 06:03:49 $
+ *
+ */
+
+
+public class toTRF {
+
+    // TRF wants distances in cm, not mm.
+    private double mmTocm = 0.1;
+
+    private RKTrack t;
+
+    public toTRF( RKTrack t ){
+	this.t = t;
+    }
+
+    public VTrack atDcaZaxis(){
+
+	// Opposite sign convention.
+	double r_signed = -t.d0();
+
+	TrackVector tv  = new TrackVector();
+	tv.set(0, r_signed * mmTocm );
+	tv.set(1, t.z0()   * mmTocm );
+	tv.set(2, t.phi0()          );
+	tv.set(3, t.cotth()         );
+	tv.set(4, t.q()/t.pt()      );
+	SurfDCA s = new SurfDCA( 0., 0. );
+	VTrack vt = new VTrack(s, tv);
+	return vt;
+	
+    }
+
+    public VTrack atCyl( double r){
+
+	cyl_int c = new cyl_int( t.cu(), t.d0(), t.phi0(), t.z0(), t.cotth(), r );
+
+	double phi_pos = Math.atan2(c.getY(),c.getX());
+	double phi_dir = TRFMath.fmod2(t.phi0() + t.charge()*c.getPsi(),TRFMath.TWOPI);
+	double alpha   = TRFMath.fmod2(phi_dir-phi_pos,TRFMath.TWOPI);
+
+	TrackVector tv  = new TrackVector();
+	tv.set(0, phi_pos           );
+	tv.set(1, c.getZ() * mmTocm );
+	tv.set(2, alpha             );
+	tv.set(3, t.cotth()         );
+	tv.set(4, t.q()/t.pt()      );
+
+	SurfCylinder s = new SurfCylinder( r*mmTocm );
+	VTrack vt = new VTrack(s, tv);
+	return vt;
+    }
+
+    public VTrack atZPlane( double z){
+
+	zplane_int zpi = new zplane_int ( t.cu(), t.d0(), t.phi0(), t.z0(), t.cotth(), z );
+	
+	double phi = t.phi0() + t.q()*zpi.getPsi();
+	double dxdz = Math.cos(phi)/t.cotth();
+	double dydz = Math.sin(phi)/t.cotth();
+
+	TrackVector tv  = new TrackVector();
+	tv.set(0, zpi.getX()*mmTocm );
+	tv.set(1, zpi.getY()*mmTocm );
+	tv.set(2, dxdz              );
+	tv.set(3, dydz              );
+	tv.set(4, t.q()/t.p()       );
+
+	SurfZPlane s = new SurfZPlane( z*mmTocm );
+	VTrack vt = new VTrack(s, tv);
+	if ( t.cz() >= 0. ){
+	    vt.setForward();
+	}else{
+	    vt.setBackward();
+	}
+
+	return vt;
+
+    }
+
+    // Path length corresponding to one half of an arc.
+    public double halfarc(){
+	return Math.PI*t.rho()/t.sz()*mmTocm;
+    }
+
+
+    
+}
CVSspam 0.2.8