Commit in lcsim/src/org/lcsim/contrib/JanStrube/standalone on MAIN
FitterTestDriver.java+63added 1.1
MainLoop.java+5-41.1 -> 1.2
MainLoop.py+8-61.1 -> 1.2
FitterTestDriver.py-1291.1 removed
+76-139
1 added + 1 removed + 2 modified, total 4 files
Driver to test the fitter on real events

lcsim/src/org/lcsim/contrib/JanStrube/standalone
FitterTestDriver.java added at 1.1
diff -N FitterTestDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ FitterTestDriver.java	19 Aug 2006 20:03:16 -0000	1.1
@@ -0,0 +1,63 @@
+import java.util.Random;
+
+import org.lcsim.contrib.JanStrube.tracking.NewFastMCTrackFactory;
+import org.lcsim.contrib.JanStrube.vtxFitter.Fitter;
+import org.lcsim.contrib.JanStrube.vtxFitter.Vertex;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.spacegeom.CartesianPoint;
+import org.lcsim.spacegeom.SpacePoint;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+import static java.lang.Math.abs;
+
+class FitterTestDriver extends Driver {
+    private AIDA aida = AIDA.defaultInstance();
+    private SpacePoint referencePoint;
+    private SpacePoint origin;
+    private Random rand;
+    
+    public FitterTestDriver() {
+        referencePoint = new CartesianPoint(0, 0, 0);
+        origin = new CartesianPoint(0, 0, 0);
+        rand = new Random(74234);
+    }
+
+    public void process(EventHeader event) {
+        // beamconstraint when smearing the tracks ?
+        NewFastMCTrackFactory tf = new NewFastMCTrackFactory(event, false);
+        for (MCParticle part : event.getMCParticles()) {
+            if (abs(part.getPDGID()) != 310)
+                continue;
+          Vertex unsmearedVertex = new Vertex();
+          unsmearedVertex.setOrigin(origin);
+          Vertex smearedVertex = new Vertex();
+          smearedVertex.setOrigin(origin);
+          
+          for (MCParticle daughter : part.getDaughters()) {
+              unsmearedVertex.addTrack(tf.getTrack(
+                      new SpacePoint(daughter.getMomentum()),
+                      new SpacePoint(daughter.getOrigin()),
+                      referencePoint,
+                      (int)daughter.getCharge(),
+                      rand,
+                      false), 0);
+                   smearedVertex.addTrack(tf.getTrack(
+                      new SpacePoint(daughter.getMomentum()),
+                      new SpacePoint(daughter.getOrigin()),
+                      referencePoint,
+                      (int)daughter.getCharge(),
+                      rand,
+                      true), 0);
+               }
+          Fitter fitter = new Fitter(unsmearedVertex, 5.0);
+          Vertex newVtx1 = fitter.fit();
+          aida.cloud1D("deltaX").fill(newVtx1.origin().x() - part.getOrigin().x());
+          aida.cloud1D("deltaY").fill(newVtx1.origin().y() - part.getOrigin().y());
+          aida.cloud1D("deltaZ").fill(newVtx1.origin().z() - part.getOrigin().z());
+
+        }
+    }
+          
+}
\ No newline at end of file

lcsim/src/org/lcsim/contrib/JanStrube/standalone
MainLoop.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MainLoop.java	28 Jun 2006 01:54:46 -0000	1.1
+++ MainLoop.java	19 Aug 2006 20:03:16 -0000	1.2
@@ -1,4 +1,3 @@
-package org.lcsim.contrib.JanStrube.standalone;
 // MainLoop.java
 // Java wrapper to enable running outside of JAS3
 // 16-JUL-2005 Jan Strube
@@ -22,13 +21,15 @@
    public static void main(String[] args) throws Exception
    {
       LCSimLoop loop = new LCSimLoop();
-      URL location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/ILC500/Zgamma/stdhep/pythia/pythiaZgamma.stdhep");
+//      URL location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/ILC500/Zgamma/stdhep/pythia/pythiaZgamma.stdhep");
+      URL location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/singleParticle/stdhep/K0S_pipi_Theta45-135_5-25Gev.stdhep");
+
       FileCache cache = new FileCache();
       File trackFile = cache.getCachedFile(location);
       loop.setStdhepRecordSource(trackFile, "sidaug05");
 //      loop.setLCIORecordSource(input);
-      loop.add(new MCFast(false, false));
-      loop.add(new VertexFitterDriver());
+//      loop.add(new MCFast(false, false));
+      loop.add(new FitterTestDriver());
 //      File output = new File("exampleAnalysisJava.slcio");
 //      loop.add(new LCIODriver(output));
       loop.loop(-1);

lcsim/src/org/lcsim/contrib/JanStrube/standalone
MainLoop.py 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MainLoop.py	28 Jun 2006 01:54:46 -0000	1.1
+++ MainLoop.py	19 Aug 2006 20:03:16 -0000	1.2
@@ -9,26 +9,28 @@
 from java.io import File
 #from ZvTubePlotter import ZvTubePlotter
 from java.lang import System
-#import VertexFitterDriver
+from FitterTestDriver import FitterTestDriver
 from java.lang import Boolean
 from ReconParticleTestDriver import ReconParticleTestDriver
 
-true = Boolean("true")
-false = Boolean("false")
+True = Boolean("true")
+False = Boolean("false")
 
 def main():
     loop = LCSimLoop()
 #    location = URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/ILC500/Zgamma/stdhep/pythia/pythiaZgamma.stdhep")
-    location = URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/singleParticle/stdhep/psi_mumu_Theta4-176_5-100GeV.stdhep")
+#    location = URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/singleParticle/stdhep/psi_mumu_Theta4-176_5-100GeV.stdhep")
+    location = URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/singleParticle/stdhep/K0S_pipi_Theta45-135_5-25Gev.stdhep")
     cache = FileCache()
     trackFile = cache.getCachedFile(location)
     loop.setStdhepRecordSource(trackFile, "sidaug05")
 #    loop.setLCIORecordSource(input)
     # no beamspotConstraint, no simple smearing
-    loop.add(MCFast(false, false))
+    loop.add(FitterTestDriver())
+#    loop.add(MCFast(false, false))
 #    loop.add(ZvTubePlotter())
 #    loop.add(VertexFitterDriver())
-    loop.add(ReconParticleTestDriver())
+#    loop.add(ReconParticleTestDriver())
 #    output = File(System.getProperty("user.home"),"fastmc.slcio")
 #    loop.add(LCIODriver(output))
     loop.loop(-1)

lcsim/src/org/lcsim/contrib/JanStrube/standalone
FitterTestDriver.py removed after 1.1
diff -N FitterTestDriver.py
--- FitterTestDriver.py	28 Jun 2006 01:54:46 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,129 +0,0 @@
-from org.lcsim.util import Driver
-from org.lcsim.recon.vertexing.fitter import VertexFitter
-
-class FitterTestDriver(Driver):
-    def __init__(self):
-        #super.__init__(self):
-        aida = AIDA.defaultInstance()
-        fitter = VertexFitter(5)
-
-    def process(self, event):
-        tracks = event.getTracks()
-        if not len(tracks) == 2:
-            return
-
-def getJacobi(old):
-    new = []
-    new.append([old[0], 0, 0, 0, 0])
-    new.append([0, 0, 0, old[1], 0])
-    new.append([0, 0, 0, 0, old[2]])
-    new.append([0, old[3], 0, 0, 0])
-    new.append([0, 0, 1+Math.tan(old[4])*Math.tan(old[4]), 0, 0])
-    return new
-
-
-def jacobian():
-    return
-
-def flattenMatrix(matrix):
-    result = []
-    length = len(matrix)
-    for i in range(length):
-        for j in range(i, length):
-            result.append(matrix[i][j]);
-    return result;
-
-#public class VertexFitterTest extends TestCase {
-    #private Track track1;
-    #private Track track2;
-    #private LCSimLoop loop;
-    #private URL location;
-    #private FileCache cache;
-    #private File trackFile;
-    #private VertexFitter fitter;
-    #private AIDA aida = AIDA.defaultInstance();
-    #protected void setUp() throws Exception {
-        #super.setUp();
-        #loop = new LCSimLoop();
-        #// contains psi- mu mu events
-        #location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/ILC500/Zgamma/stdhep/pythia/pythiaZgamma.stdhep");
-#//         location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/singleParticle/stdhep/psi_mumu_Theta4-176_5-100GeV.stdhep");
-        #cache = new FileCache();
-        #trackFile = cache.getCachedFile(location);
-        #loop.setStdhepRecordSource(trackFile, "sidaug05");
-        #fitter = new VertexFitter(5);
-    #}
-    
-    #private class TrackFitDriver extends Driver {
-        #private List<double[]> weights = new ArrayList<double[]>();
-        #private List<double[]> trackParams = new ArrayList<double[]>();
-        #public void process(EventHeader event) {
-            #trackParams.clear();
-            #weights.clear();
-            #List<Track> tracks = event.getTracks();
-            #if (tracks.size() != 2)
-                #return;
-            #for (Track iTrack : tracks) {
-                #Matrix olderrors = new Matrix(iTrack.getErrorMatrix());
-                #olderrors.print(21, 20);
-                #double[] params = iTrack.getTrackParameters();
-                #System.err.println();
-                #Matrix jacobi = new Matrix(getJacobi(params));
-                #jacobi.print(21, 20);
-                #double theta = PI/2 - atan(params[4]);
-                #double[] newparams = new double[]{params[0], params[3], theta, params[1], params[2]};
-                #trackParams.add(newparams);
-                #double[][] weightArray = jacobi.times(olderrors).times(jacobi.transpose()).getArray();
-                #Matrix nw = new Matrix(weightArray);
-                #nw.print(31, 30);
-                #System.err.printf("Old Det: %g\nNew Det: %g\nJacobi Det: %g\n", olderrors.det(), nw.det(), jacobi.det());
-                #weights.add(flattenWeights(weightArray));
-            #}
-            
-            #System.err.printf("%d tracks\n", trackParams.size());
-            #System.err.println("fitting");
-            #boolean[] inVtx = new boolean[] {true, true};
-            #double[] initialPosition = new double[] {0, 0, 0};
-            
-            #for (double[] x : trackParams) {
-                #System.err.print("Track Parameters: ");
-                #for (double y : x) {
-                    #System.err.printf("%f\t", y);
-                #}
-                #System.err.println();
-            #}
-            #//System.err.printf("Check: Parameter 4 of track 2: %.3f\n", trackParams.toArray(new double[][]{})[1][3]);
-#//            for (double[] x : trackParams.toArray(new double[][]{})) {
-#//                System.err.print("Track Parameters: ");
-#//                for (double y : x) {
-#//                    System.err.printf("%f\t", y);
-#//                }
-#//                System.err.println();
-#//            }
-
-            #for (double[] x : weights) {
-                #System.err.print("Track weights: ");
-                #for (double y : x) {
-                    #System.err.printf("%f\t", y);
-                #}
-                #System.err.println();
-            #}
-            #Matrix newTrackParams = new Matrix(trackParams.toArray(new double[][]{}));
-            #newTrackParams.print(20, 21);
-            #Matrix newWeights = new Matrix(weights.toArray(new double[][]{}));
-            #newWeights.print(21, 20);
-            #Vertex v = fitter.fit(tracks.size(), false, inVtx, newTrackParams.transpose().getArray(), newWeights.transpose().getArray(), initialPosition);
-            #aida.cloud1D("vtx_chi2").fill(v._chi2);
-        #}
-        
-        
-        #}
-    #}
-
-    
-    #protected void tearDown() throws Exception {
-        #super.tearDown();
-        #aida.saveAs("x.aida");
-        #loop.dispose();
-    #}
-#}
CVSspam 0.2.8