Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
HelicalTrackHitDriver.java+383added 1.1
MaterialManager.java+37added 1.1
SeedTracker.java+45added 1.1
AxialTrackReconDriver.java+1-11.1 -> 1.2
MultiTrackReco.java+2-21.3 -> 1.4
SvtTrackExtrapolator.java+1-11.5 -> 1.6
TrackUtils.java+2-21.10 -> 1.11
TrackerReconDriver.java+1-21.31 -> 1.32
HPSHelicalTrackHitDriver.java-3841.19 removed
HPSMaterialManager.java-381.1 removed
HPSSeedTracker.java-431.1 removed
kalman/KalmanFilterDriver.java+8-11.1 -> 1.2
      /KalmanGeom.java+276-51.4 -> 1.5
+756-479
3 added + 3 removed + 7 modified, total 13 files
Cleaning up; adhering to package being used for absolute class name

hps-java/src/main/java/org/lcsim/hps/recon/tracking
HelicalTrackHitDriver.java added at 1.1
diff -N HelicalTrackHitDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HelicalTrackHitDriver.java	26 Nov 2012 18:12:01 -0000	1.1
@@ -0,0 +1,383 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.recon.tracking;
+
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.ITransform3D;
+import org.lcsim.detector.tracker.silicon.SiTrackerModule;
+import org.lcsim.digisim.MyLCRelation;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.LCRelation;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.fit.helicaltrack.HelicalTrackCross;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
+import org.lcsim.hps.event.HPSTransformations;
+import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit;
+import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
+import org.lcsim.recon.tracking.digitization.sisim.TrackerHitType;
+
+/**
+ *
+ * @author phansson, mgraham
+ */
+public class HelicalTrackHitDriver extends org.lcsim.fit.helicaltrack.HelicalTrackHitDriver {
+    private boolean _debug = false;
+    private String subdetectorName = "Tracker";
+    private Map<String,String> _stereomap = new HashMap<String,String>();
+    private List<String> _colnames = new ArrayList<String>();
+    private boolean _doTransformToTracking = true;
+    private HPSTransformations _detToTrk = new HPSTransformations();
+    public enum LayerGeometryType { 
+        /*
+         * Each Layer in the geometry is a separate sensor
+         */
+        Split, 
+        /*
+         * Each layer in the geometry comprises top and bottom sensor
+         */
+        Common
+    }
+    private LayerGeometryType _layerGeometryType;
+
+    public HelicalTrackHitDriver() {
+        this.setLayerGeometryType("Common");
+        this.addCollection("StripClusterer_SiTrackerHitStrip1D");
+    }
+    public void setLayerGeometryType(String geomType) {
+        this._layerGeometryType = LayerGeometryType.valueOf(geomType);
+    }
+    
+    public void setSubdetectorName(String subdetectorName) {
+        this.subdetectorName = subdetectorName;
+    }
+    
+    public void setDebug(boolean debug) {
+        this._debug = debug;
+    }
+    
+    public void setTransformToTracking(boolean trans) {
+        this._doTransformToTracking = trans;
+    }
+    
+    public void setStripHitsCollectionName(String stripHitsCollectionName) {
+        HitRelationName(stripHitsCollectionName);
+    }
+
+    public void setHelicalTrackHitRelationsCollectionName(String helicalTrackHitRelationsCollectionName) {
+        HitRelationName(helicalTrackHitRelationsCollectionName);
+    }
+
+    public void setHelicalTrackMCRelationsCollectionName(String helicalTrackMCRelationsCollectionName) {
+        MCRelationName(helicalTrackMCRelationsCollectionName);
+    }
+
+    public void setOutputHitCollectionName(String outputHitCollectionName) {
+        OutputCollection(outputHitCollectionName);
+    }
+   
+    
+    @Override
+    public void process(EventHeader event) {
+        //super.process(event);
+
+        //  Initialize the list of HelicalTrackHits
+        List<HelicalTrackCross> stereoCrosses = new ArrayList<HelicalTrackCross>();
+        List<HelicalTrackHit> helhits = new ArrayList<HelicalTrackHit>();
+        
+        //  Create a List of LCRelations to relate HelicalTrackHits to the original hits
+        List<LCRelation> hitrelations = new ArrayList<LCRelation>();
+        //  Create a List of LCRelations to relate HelicalTrackHits to the MC particle
+        List<LCRelation> mcrelations = new ArrayList<LCRelation>();
+
+        
+        
+        for(String _colname : this._colnames) {
+            
+            if (!event.hasCollection(SiTrackerHit.class, _colname)) {
+                continue;
+            }
+
+            //  Get the list of SiTrackerHits for this collection
+            List<SiTrackerHit> hitlist = (List<SiTrackerHit>) event.get(_colname);
+            if (_debug) System.out.printf("%s: found %d SiTrackerHits = ",this.getClass().getSimpleName(),hitlist.size());
+            
+            //  Create collections for strip hits by layer and hit cross references
+            Map<String, List<HelicalTrackStrip>> striplistmap = new HashMap<String, List<HelicalTrackStrip>>();
+            Map<HelicalTrackStrip, SiTrackerHitStrip1D> stripmap = new HashMap<HelicalTrackStrip, SiTrackerHitStrip1D>();
+            
+            for(SiTrackerHit hit : hitlist) {
+                
+                if( hit instanceof SiTrackerHitStrip1D) {
+                    
+                    //  Cast the hit as a 1D strip hit and find the identifier for the detector/layer combo
+                    SiTrackerHitStrip1D h = (SiTrackerHitStrip1D) hit;
+                    IDetectorElement de = h.getSensor();
+                    String id = this.makeID(_ID.getName(de), _ID.getLayer(de));
+
+                    //  This hit should be a on a stereo pair!
+                    if (!_stereomap.containsKey(id) &&! _stereomap.containsValue(id)) {
+                        throw new RuntimeException(this.getClass().getSimpleName() + ": this " + id + " was not among the stereo modules!");
+                    }
+                    
+                    //  Create a HelicalTrackStrip for this hit
+                    HelicalTrackStrip strip = makeDigiStrip(h);
+
+                    //  Get the list of strips for this layer - create a new list if one doesn't already exist
+                    List<HelicalTrackStrip> lyrhits = striplistmap.get(id);
+                    if (lyrhits == null) {
+                        lyrhits = new ArrayList<HelicalTrackStrip>();
+                        striplistmap.put(id, lyrhits);
+                    }
+
+                    //  Add the strip to the list of strips on this sensor
+                    lyrhits.add(strip);
+
+                    //  Map a reference back to the hit needed to create the stereo hit LC relations
+                    stripmap.put(strip, h);
+
+                    if(_debug) System.out.printf("%s: added strip (org=%s,umeas=%.3f) at layer %d ",this.getClass().getSimpleName(),strip.origin().toString(),strip.umeas(),strip.layer());
+                    
+                } else {
+
+                    //  If not a 1D strip hit, make a pixel hit
+                    HelicalTrackHit hit3d = this.makeDigi3DHit(hit);
+                    helhits.add(hit3d);
+                    hitrelations.add(new MyLCRelation(hit3d, hit));
+                }
+                
+            } // Loop over SiTrackerHits
+            
+            
+            //  Create a list of stereo hits
+            //List<HelicalTrackCross> stereohits = new ArrayList<HelicalTrackCross>();
+            
+            if (_debug) System.out.println(this.getClass().getSimpleName() + ": Create stereo hits from " + striplistmap.size() + " strips (map size)");
+                        
+            //  Loop over the stereo layer pairs
+            for (String id1 : _stereomap.keySet()) {
+
+                //  Get the second layer
+                String id2 = _stereomap.get(id1);
+
+                if (_debug) {
+                    if (striplistmap.get(id1) != null && striplistmap.get(id2) != null) {
+                        System.out.println(this.getClass().getSimpleName() + ": Form stereo hits from " + id1 + " and " + id2);
+                        //for(HelicalTrackStrip strip: striplistmap.get(id1)) System.out.printf("%s: stripid1 at origin %s\n",this.getClass().getSimpleName(),strip.origin().toString());
+                        //for(HelicalTrackStrip strip: striplistmap.get(id2)) System.out.printf("%s: stripid2 at origin %s\n",this.getClass().getSimpleName(),strip.origin().toString());
+                    }
+                }
+                
+                /*
+                 * Form the stereo hits and add them to our hit list
+                 * Add LC relations for stereo hit to SiTrackHitStrip1D object 
+                 * Add LC relation between MC particle and stereo hit
+                 */
+                
+                List<HelicalTrackCross> cross_list =  _crosser.MakeHits(striplistmap.get(id1), striplistmap.get(id2));
+                
+                for(HelicalTrackCross cross : cross_list) {
+                    stereoCrosses.add(cross);
+                    if(cross.getMCParticles()!=null) {
+                        for(MCParticle mcp : cross.getMCParticles()) {
+                            mcrelations.add(new MyLCRelation((HelicalTrackHit)cross,mcp));
+                        }
+                    }
+                    for(HelicalTrackStrip strip : cross.getStrips()) {
+                        hitrelations.add(new MyLCRelation(cross,stripmap.get(strip)));
+                    }
+                    
+                }
+                
+            } // Loop over stereo pairs
+
+            if (_debug) {
+                System.out.printf("%s: added %d stereo hits from %s collection ",this.getClass().getSimpleName(),stereoCrosses.size(),_colname);
+            }
+            
+            
+        } // Loop over collection names
+        
+        
+        
+        // Add things to the event
+        // Cast crosses to HTH
+        helhits.addAll(stereoCrosses);
+        event.put(_outname, helhits, HelicalTrackHit.class, 0);
+        event.put(_hitrelname,hitrelations,LCRelation.class,0);
+        event.put(_mcrelname,mcrelations,LCRelation.class,0);       
+        if(_doTransformToTracking) addRotatedHitsToEvent(event, stereoCrosses);
+        
+        
+        
+    } //Process()
+    
+
+    public void addCollection(String colname) {
+        _colnames.add(colname);
+    }
+    public void setCollection(String colname) {
+        _colnames.clear();
+        this.addCollection(colname);
+    }
+    private String makeID(String detname, int lyr) {
+        return detname + lyr;
+    }
+    
+    public void setStereoPair(String detname, int lyr1, int lyr2) {
+        this._stereomap.put(this.makeID(detname, lyr1), this.makeID(detname, lyr2));
+    }
+    
+    @Override
+    protected void detectorChanged(Detector detector) {
+        /*
+         * Setup default pairing
+         */
+        if (_debug) System.out.printf("%s: Setup stereo hit pair modules ",this.getClass().getSimpleName());
+        
+        List<SiTrackerModule> modules = detector.getSubdetector(this.subdetectorName).getDetectorElement().findDescendants(SiTrackerModule.class);
+        if (modules.isEmpty()) {
+            throw new RuntimeException(this.getClass().getName() + ": No SiTrackerModules found in detector.");
+        }
+        int nLayersTotal = detector.getSubdetector(subdetectorName).getLayering().getLayers().getNumberOfLayers();
+        if (_debug) System.out.printf("%s: %d layers ",this.getClass().getSimpleName(),nLayersTotal);
+        if (nLayersTotal % 2 != 0) {
+            throw new RuntimeException(this.getClass().getName() + ": Don't know how to do stereo pairing for odd number of modules.");
+        }
+        if(this._layerGeometryType==LayerGeometryType.Split) {
+            int nLayers = nLayersTotal/2;
+            for(int i=1;i<=nLayers;++i) {
+                int ly1 = i;
+                int ly2 = i+10;
+                if (_debug) System.out.printf("%s: adding stereo pair from layer %d and %d ",this.getClass().getSimpleName(),ly1,ly2);
+                this.setStereoPair(subdetectorName, ly1, ly2);
+            }            
+        } else if(this._layerGeometryType==LayerGeometryType.Common) {
+            List<int[]> pairs = new ArrayList<int[]>();
+            for (int i = 1; i <= (nLayersTotal) - 1; i += 2) {
+                int[] pair = {i, i + 1};
+                if (_debug)
+                    System.out.println("Adding stereo pair: " + pair[0] + ", " + pair[1]);
+                pairs.add(pair);
+            }
+            for (int[] pair : pairs) {
+                if (_debug) System.out.printf("%s: adding stereo pair from layer %d and %d ",this.getClass().getSimpleName(),pair[0],pair[1]);
+                setStereoPair(subdetectorName, pair[0], pair[1]);
+            }
+        } else {
+            throw new RuntimeException(this.getClass().getSimpleName() + ": this layer geometry is not implemented!");
+        }
+
+        if (_debug) System.out.printf("%s: %d stereo modules added",this.getClass().getSimpleName(),this._stereomap.size());
+        
+    }
+    
+     private HelicalTrackStrip makeDigiStrip(SiTrackerHitStrip1D h) {
+        
+        if(_debug) System.out.println(this.getClass().getSimpleName() + ": makeDigiStrip--");
+        
+        SiTrackerHitStrip1D local = h.getTransformedHit(TrackerHitType.CoordinateSystem.SENSOR);
+        SiTrackerHitStrip1D global = h.getTransformedHit(TrackerHitType.CoordinateSystem.GLOBAL);
+    
+        ITransform3D trans = local.getLocalToGlobal();
+        Hep3Vector org = trans.transformed(_orgloc);
+        Hep3Vector u = global.getMeasuredCoordinate();
+        Hep3Vector v = global.getUnmeasuredCoordinate();
+         
+       
+        
+        double umeas = local.getPosition()[0];
+        double vmin = VecOp.dot(local.getUnmeasuredCoordinate(), local.getHitSegment().getStartPoint());
+        double vmax = VecOp.dot(local.getUnmeasuredCoordinate(), local.getHitSegment().getEndPoint());
+        double du = Math.sqrt(local.getCovarianceAsMatrix().diagonal(0));
+
+       
+        
+        IDetectorElement de = h.getSensor();
+        String det = _ID.getName(de);
+        int lyr = _ID.getLayer(de);
+        BarrelEndcapFlag be = _ID.getBarrelEndcapFlag(de);
+
+        double dEdx = h.getdEdx();
+        double time = h.getTime();
+        List<RawTrackerHit> rawhits = h.getRawHits();
+        HelicalTrackStrip strip = new HelicalTrackStrip(org, u, v, umeas, du,
+                vmin, vmax, dEdx, time, rawhits, det, lyr, be);
+
+        try {
+            if (h.getMCParticles() != null) {
+                for (MCParticle p : h.getMCParticles()) {
+                    strip.addMCParticle(p);
+                }
+            }
+        } catch (RuntimeException e) {
+            // Okay when MC info not present.
+        }
+       
+        if(_debug) {
+            System.out.println(this.getClass().getSimpleName() + ": produced HelicalTrackStrip with origin " + strip.origin().toString());
+        }
+
+        return strip;
+    }
+
+     private void addRotatedHitsToEvent(EventHeader event, List<HelicalTrackCross> stereohits) {
+
+        List<HelicalTrackHit> rotatedhits = new ArrayList<HelicalTrackHit>();
+        List<LCRelation> hthrelations = new ArrayList<LCRelation>();
+        List<LCRelation> mcrelations = new ArrayList<LCRelation>();
+        for (HelicalTrackCross cross : stereohits) {
+            List<HelicalTrackStrip> rotatedstriphits = new ArrayList<HelicalTrackStrip>();
+            for (HelicalTrackStrip strip : cross.getStrips()) {
+
+                Hep3Vector origin = strip.origin();
+                Hep3Vector u = strip.u();
+                Hep3Vector v = strip.v();
+                double umeas = strip.umeas();
+                double du = strip.du();
+                double vmin = strip.vmin();
+                double vmax = strip.vmax();
+                double dedx = strip.dEdx();
+                double time = strip.time();
+                List<RawTrackerHit> rthList = strip.rawhits();
+                String detname = strip.detector();
+                int layer = strip.layer();
+                BarrelEndcapFlag bec = strip.BarrelEndcapFlag();
+                Hep3Vector neworigin = _detToTrk.transformVectorToTracking(origin);
+                Hep3Vector newu = _detToTrk.transformVectorToTracking(u);
+                Hep3Vector newv = _detToTrk.transformVectorToTracking(v);
+                HelicalTrackStrip newstrip = new HelicalTrackStrip(neworigin, newu, newv, umeas, du, vmin, vmax, dedx, time, rthList, detname, layer, bec);
+                for (MCParticle p : strip.MCParticles()) {
+                    newstrip.addMCParticle(p);
+                }
+                rotatedstriphits.add(newstrip);
+            }
+            HelicalTrackCross newhit = new HelicalTrackCross(rotatedstriphits.get(0), rotatedstriphits.get(1));
+            rotatedhits.add(newhit);
+            hthrelations.add(new MyLCRelation(cross, newhit));
+            for (MCParticle mcp : newhit.getMCParticles()) {
+                mcrelations.add(new MyLCRelation(newhit, mcp));
+            }
+        }
+        
+        event.put("Rotated"+_outname, rotatedhits, HelicalTrackHit.class, 0);
+        event.put("Rotated"+_hitrelname, hthrelations, LCRelation.class, 0);
+        event.put("Rotated"+_mcrelname, mcrelations, LCRelation.class, 0);
+        
+        
+        //  Create the LCRelations between HelicalTrackHits and MC particles
+
+    }
+    
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking
MaterialManager.java added at 1.1
diff -N MaterialManager.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MaterialManager.java	26 Nov 2012 18:12:01 -0000	1.1
@@ -0,0 +1,37 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.recon.tracking;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.lcsim.recon.tracking.seedtracker.MaterialXPlane;
+
+
+
+/**
+ *
+ * Simple way to remove multiple scattering in HPS tracker 
+ * by returning empty XPlanes that are used to describe the scatters
+ * 
+ * @author phansson
+ */
+public class MaterialManager extends org.lcsim.recon.tracking.seedtracker.MaterialManager {
+    
+    private boolean _includeMS;
+    private final static List<MaterialXPlane> _emptyMaterialXPlaneList = new ArrayList<MaterialXPlane>();
+    public MaterialManager() {
+        super();
+        this._includeMS = true;
+    }
+    public MaterialManager(boolean includeMS) {
+        super();
+        this._includeMS = includeMS;
+    }
+    @Override
+    public List<MaterialXPlane> getMaterialXPlanes() {
+        return this._includeMS ? super.getMaterialXPlanes() : _emptyMaterialXPlaneList;
+    }
+    
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking
SeedTracker.java added at 1.1
diff -N SeedTracker.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SeedTracker.java	26 Nov 2012 18:12:01 -0000	1.1
@@ -0,0 +1,45 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.recon.tracking;
+
+import java.util.List;
+import org.lcsim.recon.tracking.seedtracker.HelixFitter;
+import org.lcsim.recon.tracking.seedtracker.SeedStrategy;
+import org.lcsim.recon.tracking.seedtracker.SeedTrackFinder;
+
+/**
+ * Class extending lcsim version to allow extra flexibility
+ * 
+ * @author phansson
+ */
+public class SeedTracker extends org.lcsim.recon.tracking.seedtracker.SeedTracker  {
+
+    public SeedTracker(List<SeedStrategy> strategylist) {
+        // use base class only if this constructor is called!
+        super(strategylist);
+    }
+
+    public SeedTracker(List<SeedStrategy> strategylist, boolean includeMS) {
+            
+            // use base class constructor 
+        
+            super(strategylist);
+            
+            // Explicitly only replace the objects that might change
+            
+            //  Instantiate the material manager
+            _materialmanager = new MaterialManager(includeMS);
+
+            //  Instantiate the helix finder since it depends on the material manager
+            _helixfitter = new HelixFitter(_materialmanager);
+
+            //  Instantiate the helix finder since it depends on the material manager
+            _finder = new SeedTrackFinder(_hitmanager, _helixfitter);
+
+        }
+
+
+
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking
AxialTrackReconDriver.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- AxialTrackReconDriver.java	24 May 2012 14:34:00 -0000	1.1
+++ AxialTrackReconDriver.java	26 Nov 2012 18:12:01 -0000	1.2
@@ -170,7 +170,7 @@
 
 
         // Create the Driver.
-        HPSHelicalTrackHitDriver hthdriver = new HPSHelicalTrackHitDriver();
+        HelicalTrackHitDriver hthdriver = new HelicalTrackHitDriver();
         hthdriver.addCollection(stripHitsCollectionName);
         hthdriver.setOutputCollectionName(hthOutputCollectionName);
 //        hthdriver.setHitRelationName(helicalTrackHitRelationsCollectionName);

hps-java/src/main/java/org/lcsim/hps/recon/tracking
MultiTrackReco.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- MultiTrackReco.java	22 Nov 2012 02:48:54 -0000	1.3
+++ MultiTrackReco.java	26 Nov 2012 18:12:01 -0000	1.4
@@ -25,7 +25,7 @@
         HPSTrackerHitDriver thd = new HPSTrackerHitDriver();
         add(thd);
 
-        HPSHelicalTrackHitDriver hitdriver = new HPSHelicalTrackHitDriver();
+        HelicalTrackHitDriver hitdriver = new HelicalTrackHitDriver();
         hitdriver.addCollection(((HPSTrackerHitDriver) thd).getStripHits1DName());
         hitdriver.setOutputCollectionName("AxialTrackHits");
         hitdriver.HitRelationName("AxialTrackHitRelations");
@@ -56,7 +56,7 @@
 
         }
 
-        HPSHelicalTrackHitDriver hthdriver = new HPSHelicalTrackHitDriver();
+        HelicalTrackHitDriver hthdriver = new HelicalTrackHitDriver();
         hthdriver.addCollection(((HPSTrackerHitDriver) thd).getStripHits1DName());
         hthdriver.setOutputCollectionName("HelicalTrackHits");
         hthdriver.HitRelationName("HelicalTrackHitRelations");

hps-java/src/main/java/org/lcsim/hps/recon/tracking
SvtTrackExtrapolator.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- SvtTrackExtrapolator.java	9 Oct 2012 01:16:29 -0000	1.5
+++ SvtTrackExtrapolator.java	26 Nov 2012 18:12:01 -0000	1.6
@@ -27,7 +27,7 @@
 	 */
 	public void setTrack(Track track){
 		trackUtils.setTrack(track);
-                isTrackSet = true;
+            isTrackSet = true;
 	}
         
         /**

hps-java/src/main/java/org/lcsim/hps/recon/tracking
TrackUtils.java 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- TrackUtils.java	14 Nov 2012 22:08:23 -0000	1.10
+++ TrackUtils.java	26 Nov 2012 18:12:01 -0000	1.11
@@ -24,7 +24,7 @@
 /**
  * 
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: TrackUtils.java,v 1.10 2012/11/14 22:08:23 phansson Exp $
+ * @version $Id: TrackUtils.java,v 1.11 2012/11/26 18:12:01 phansson Exp $
  * TODO: Switch to JLab coordinates
  */
 
@@ -238,7 +238,7 @@
                 if(_debug) this.printTrackParameters();
 	
 	}
-	
+      
 	/**
 	 * 
 	 */

hps-java/src/main/java/org/lcsim/hps/recon/tracking
TrackerReconDriver.java 1.31 -> 1.32
diff -u -r1.31 -r1.32
--- TrackerReconDriver.java	26 Nov 2012 03:21:07 -0000	1.31
+++ TrackerReconDriver.java	26 Nov 2012 18:12:01 -0000	1.32
@@ -13,7 +13,6 @@
 import org.lcsim.hps.event.HPSTransformations;
 import org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver;
 import org.lcsim.recon.tracking.seedtracker.SeedStrategy;
-import org.lcsim.recon.tracking.seedtracker.SeedTracker;
 import org.lcsim.recon.tracking.seedtracker.StrategyXMLUtils;
 import org.lcsim.recon.tracking.seedtracker.diagnostic.SeedTrackerDiagnostics;
 import org.lcsim.util.Driver;
@@ -112,7 +111,7 @@
             strategyResource = "/org/lcsim/hps/recon/tracking/strategies/" + strategyResource;
         }
         List<SeedStrategy> sFinallist = StrategyXMLUtils.getStrategyListFromInputStream(this.getClass().getResourceAsStream(strategyResource));
-        SeedTracker stFinal = new HPSSeedTracker(sFinallist,this.includeMS);
+        SeedTracker stFinal = new SeedTracker(sFinallist,this.includeMS);
         HPSTransformations hpstrans = new HPSTransformations();
         stFinal.setMaterialManagerTransform(hpstrans.getTransform());
         stFinal.setInputCollectionName(stInputCollectionName);

hps-java/src/main/java/org/lcsim/hps/recon/tracking
HPSHelicalTrackHitDriver.java removed after 1.19
diff -N HPSHelicalTrackHitDriver.java
--- HPSHelicalTrackHitDriver.java	22 Nov 2012 02:47:28 -0000	1.19
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,384 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.lcsim.hps.recon.tracking;
-
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.ITransform3D;
-import org.lcsim.detector.tracker.silicon.SiTrackerModule;
-import org.lcsim.digisim.MyLCRelation;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.LCRelation;
-import org.lcsim.event.MCParticle;
-import org.lcsim.event.RawTrackerHit;
-import org.lcsim.fit.helicaltrack.HelicalTrackCross;
-import org.lcsim.fit.helicaltrack.HelicalTrackHit;
-import org.lcsim.fit.helicaltrack.HelicalTrackHitDriver;
-import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
-import org.lcsim.geometry.Detector;
-import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
-import org.lcsim.hps.event.HPSTransformations;
-import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit;
-import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
-import org.lcsim.recon.tracking.digitization.sisim.TrackerHitType;
-
-/**
- *
- * @author phansson
- */
-public class HPSHelicalTrackHitDriver extends HelicalTrackHitDriver {
-    private boolean _debug = false;
-    private String subdetectorName = "Tracker";
-    private Map<String,String> _stereomap = new HashMap<String,String>();
-    private List<String> _colnames = new ArrayList<String>();
-    private boolean _doTransformToTracking = true;
-    private HPSTransformations _detToTrk = new HPSTransformations();
-    public enum LayerGeometryType { 
-        /*
-         * Each Layer in the geometry is a separate sensor
-         */
-        Split, 
-        /*
-         * Each layer in the geometry comprises top and bottom sensor
-         */
-        Common
-    }
-    private LayerGeometryType _layerGeometryType;
-
-    public HPSHelicalTrackHitDriver() {
-        this.setLayerGeometryType("Common");
-        this.addCollection("StripClusterer_SiTrackerHitStrip1D");
-    }
-    public void setLayerGeometryType(String geomType) {
-        this._layerGeometryType = LayerGeometryType.valueOf(geomType);
-    }
-    
-    public void setSubdetectorName(String subdetectorName) {
-        this.subdetectorName = subdetectorName;
-    }
-    
-    public void setDebug(boolean debug) {
-        this._debug = debug;
-    }
-    
-    public void setTransformToTracking(boolean trans) {
-        this._doTransformToTracking = trans;
-    }
-    
-    public void setStripHitsCollectionName(String stripHitsCollectionName) {
-        HitRelationName(stripHitsCollectionName);
-    }
-
-    public void setHelicalTrackHitRelationsCollectionName(String helicalTrackHitRelationsCollectionName) {
-        HitRelationName(helicalTrackHitRelationsCollectionName);
-    }
-
-    public void setHelicalTrackMCRelationsCollectionName(String helicalTrackMCRelationsCollectionName) {
-        MCRelationName(helicalTrackMCRelationsCollectionName);
-    }
-
-    public void setOutputHitCollectionName(String outputHitCollectionName) {
-        OutputCollection(outputHitCollectionName);
-    }
-   
-    
-    @Override
-    public void process(EventHeader event) {
-        //super.process(event);
-
-        //  Initialize the list of HelicalTrackHits
-        List<HelicalTrackCross> stereoCrosses = new ArrayList<HelicalTrackCross>();
-        List<HelicalTrackHit> helhits = new ArrayList<HelicalTrackHit>();
-        
-        //  Create a List of LCRelations to relate HelicalTrackHits to the original hits
-        List<LCRelation> hitrelations = new ArrayList<LCRelation>();
-        //  Create a List of LCRelations to relate HelicalTrackHits to the MC particle
-        List<LCRelation> mcrelations = new ArrayList<LCRelation>();
-
-        
-        
-        for(String _colname : this._colnames) {
-            
-            if (!event.hasCollection(SiTrackerHit.class, _colname)) {
-                continue;
-            }
-
-            //  Get the list of SiTrackerHits for this collection
-            List<SiTrackerHit> hitlist = (List<SiTrackerHit>) event.get(_colname);
-            if (_debug) System.out.printf("%s: found %d SiTrackerHits = ",this.getClass().getSimpleName(),hitlist.size());
-            
-            //  Create collections for strip hits by layer and hit cross references
-            Map<String, List<HelicalTrackStrip>> striplistmap = new HashMap<String, List<HelicalTrackStrip>>();
-            Map<HelicalTrackStrip, SiTrackerHitStrip1D> stripmap = new HashMap<HelicalTrackStrip, SiTrackerHitStrip1D>();
-            
-            for(SiTrackerHit hit : hitlist) {
-                
-                if( hit instanceof SiTrackerHitStrip1D) {
-                    
-                    //  Cast the hit as a 1D strip hit and find the identifier for the detector/layer combo
-                    SiTrackerHitStrip1D h = (SiTrackerHitStrip1D) hit;
-                    IDetectorElement de = h.getSensor();
-                    String id = this.makeID(_ID.getName(de), _ID.getLayer(de));
-
-                    //  This hit should be a on a stereo pair!
-                    if (!_stereomap.containsKey(id) &&! _stereomap.containsValue(id)) {
-                        throw new RuntimeException(this.getClass().getSimpleName() + ": this " + id + " was not among the stereo modules!");
-                    }
-                    
-                    //  Create a HelicalTrackStrip for this hit
-                    HelicalTrackStrip strip = makeDigiStrip(h);
-
-                    //  Get the list of strips for this layer - create a new list if one doesn't already exist
-                    List<HelicalTrackStrip> lyrhits = striplistmap.get(id);
-                    if (lyrhits == null) {
-                        lyrhits = new ArrayList<HelicalTrackStrip>();
-                        striplistmap.put(id, lyrhits);
-                    }
-
-                    //  Add the strip to the list of strips on this sensor
-                    lyrhits.add(strip);
-
-                    //  Map a reference back to the hit needed to create the stereo hit LC relations
-                    stripmap.put(strip, h);
-
-                    if(_debug) System.out.printf("%s: added strip (org=%s,umeas=%.3f) at layer %d ",this.getClass().getSimpleName(),strip.origin().toString(),strip.umeas(),strip.layer());
-                    
-                } else {
-
-                    //  If not a 1D strip hit, make a pixel hit
-                    HelicalTrackHit hit3d = this.makeDigi3DHit(hit);
-                    helhits.add(hit3d);
-                    hitrelations.add(new MyLCRelation(hit3d, hit));
-                }
-                
-            } // Loop over SiTrackerHits
-            
-            
-            //  Create a list of stereo hits
-            //List<HelicalTrackCross> stereohits = new ArrayList<HelicalTrackCross>();
-            
-            if (_debug) System.out.println(this.getClass().getSimpleName() + ": Create stereo hits from " + striplistmap.size() + " strips (map size)");
-                        
-            //  Loop over the stereo layer pairs
-            for (String id1 : _stereomap.keySet()) {
-
-                //  Get the second layer
-                String id2 = _stereomap.get(id1);
-
-                if (_debug) {
-                    if (striplistmap.get(id1) != null && striplistmap.get(id2) != null) {
-                        System.out.println(this.getClass().getSimpleName() + ": Form stereo hits from " + id1 + " and " + id2);
-                        //for(HelicalTrackStrip strip: striplistmap.get(id1)) System.out.printf("%s: stripid1 at origin %s\n",this.getClass().getSimpleName(),strip.origin().toString());
-                        //for(HelicalTrackStrip strip: striplistmap.get(id2)) System.out.printf("%s: stripid2 at origin %s\n",this.getClass().getSimpleName(),strip.origin().toString());
-                    }
-                }
-                
-                /*
-                 * Form the stereo hits and add them to our hit list
-                 * Add LC relations for stereo hit to SiTrackHitStrip1D object 
-                 * Add LC relation between MC particle and stereo hit
-                 */
-                
-                List<HelicalTrackCross> cross_list =  _crosser.MakeHits(striplistmap.get(id1), striplistmap.get(id2));
-                
-                for(HelicalTrackCross cross : cross_list) {
-                    stereoCrosses.add(cross);
-                    if(cross.getMCParticles()!=null) {
-                        for(MCParticle mcp : cross.getMCParticles()) {
-                            mcrelations.add(new MyLCRelation((HelicalTrackHit)cross,mcp));
-                        }
-                    }
-                    for(HelicalTrackStrip strip : cross.getStrips()) {
-                        hitrelations.add(new MyLCRelation(cross,stripmap.get(strip)));
-                    }
-                    
-                }
-                
-            } // Loop over stereo pairs
-
-            if (_debug) {
-                System.out.printf("%s: added %d stereo hits from %s collection ",this.getClass().getSimpleName(),stereoCrosses.size(),_colname);
-            }
-            
-            
-        } // Loop over collection names
-        
-        
-        
-        // Add things to the event
-        // Cast crosses to HTH
-        helhits.addAll(stereoCrosses);
-        event.put(_outname, helhits, HelicalTrackHit.class, 0);
-        event.put(_hitrelname,hitrelations,LCRelation.class,0);
-        event.put(_mcrelname,mcrelations,LCRelation.class,0);       
-        if(_doTransformToTracking) addRotatedHitsToEvent(event, stereoCrosses);
-        
-        
-        
-    } //Process()
-    
-
-    public void addCollection(String colname) {
-        _colnames.add(colname);
-    }
-    public void setCollection(String colname) {
-        _colnames.clear();
-        this.addCollection(colname);
-    }
-    private String makeID(String detname, int lyr) {
-        return detname + lyr;
-    }
-    
-    public void setStereoPair(String detname, int lyr1, int lyr2) {
-        this._stereomap.put(this.makeID(detname, lyr1), this.makeID(detname, lyr2));
-    }
-    
-    @Override
-    protected void detectorChanged(Detector detector) {
-        /*
-         * Setup default pairing
-         */
-        if (_debug) System.out.printf("%s: Setup stereo hit pair modules ",this.getClass().getSimpleName());
-        
-        List<SiTrackerModule> modules = detector.getSubdetector(this.subdetectorName).getDetectorElement().findDescendants(SiTrackerModule.class);
-        if (modules.isEmpty()) {
-            throw new RuntimeException(this.getClass().getName() + ": No SiTrackerModules found in detector.");
-        }
-        int nLayersTotal = detector.getSubdetector(subdetectorName).getLayering().getLayers().getNumberOfLayers();
-        if (_debug) System.out.printf("%s: %d layers ",this.getClass().getSimpleName(),nLayersTotal);
-        if (nLayersTotal % 2 != 0) {
-            throw new RuntimeException(this.getClass().getName() + ": Don't know how to do stereo pairing for odd number of modules.");
-        }
-        if(this._layerGeometryType==LayerGeometryType.Split) {
-            int nLayers = nLayersTotal/2;
-            for(int i=1;i<=nLayers;++i) {
-                int ly1 = i;
-                int ly2 = i+10;
-                if (_debug) System.out.printf("%s: adding stereo pair from layer %d and %d ",this.getClass().getSimpleName(),ly1,ly2);
-                this.setStereoPair(subdetectorName, ly1, ly2);
-            }            
-        } else if(this._layerGeometryType==LayerGeometryType.Common) {
-            List<int[]> pairs = new ArrayList<int[]>();
-            for (int i = 1; i <= (nLayersTotal) - 1; i += 2) {
-                int[] pair = {i, i + 1};
-                if (_debug)
-                    System.out.println("Adding stereo pair: " + pair[0] + ", " + pair[1]);
-                pairs.add(pair);
-            }
-            for (int[] pair : pairs) {
-                if (_debug) System.out.printf("%s: adding stereo pair from layer %d and %d ",this.getClass().getSimpleName(),pair[0],pair[1]);
-                setStereoPair(subdetectorName, pair[0], pair[1]);
-            }
-        } else {
-            throw new RuntimeException(this.getClass().getSimpleName() + ": this layer geometry is not implemented!");
-        }
-
-        if (_debug) System.out.printf("%s: %d stereo modules added",this.getClass().getSimpleName(),this._stereomap.size());
-        
-    }
-    
-     private HelicalTrackStrip makeDigiStrip(SiTrackerHitStrip1D h) {
-        
-        if(_debug) System.out.println(this.getClass().getSimpleName() + ": makeDigiStrip--");
-        
-        SiTrackerHitStrip1D local = h.getTransformedHit(TrackerHitType.CoordinateSystem.SENSOR);
-        SiTrackerHitStrip1D global = h.getTransformedHit(TrackerHitType.CoordinateSystem.GLOBAL);
-    
-        ITransform3D trans = local.getLocalToGlobal();
-        Hep3Vector org = trans.transformed(_orgloc);
-        Hep3Vector u = global.getMeasuredCoordinate();
-        Hep3Vector v = global.getUnmeasuredCoordinate();
-         
-       
-        
-        double umeas = local.getPosition()[0];
-        double vmin = VecOp.dot(local.getUnmeasuredCoordinate(), local.getHitSegment().getStartPoint());
-        double vmax = VecOp.dot(local.getUnmeasuredCoordinate(), local.getHitSegment().getEndPoint());
-        double du = Math.sqrt(local.getCovarianceAsMatrix().diagonal(0));
-
-       
-        
-        IDetectorElement de = h.getSensor();
-        String det = _ID.getName(de);
-        int lyr = _ID.getLayer(de);
-        BarrelEndcapFlag be = _ID.getBarrelEndcapFlag(de);
-
-        double dEdx = h.getdEdx();
-        double time = h.getTime();
-        List<RawTrackerHit> rawhits = h.getRawHits();
-        HelicalTrackStrip strip = new HelicalTrackStrip(org, u, v, umeas, du,
-                vmin, vmax, dEdx, time, rawhits, det, lyr, be);
-
-        try {
-            if (h.getMCParticles() != null) {
-                for (MCParticle p : h.getMCParticles()) {
-                    strip.addMCParticle(p);
-                }
-            }
-        } catch (RuntimeException e) {
-            // Okay when MC info not present.
-        }
-       
-        if(_debug) {
-            System.out.println(this.getClass().getSimpleName() + ": produced HelicalTrackStrip with origin " + strip.origin().toString());
-        }
-
-        return strip;
-    }
-
-     private void addRotatedHitsToEvent(EventHeader event, List<HelicalTrackCross> stereohits) {
-
-        List<HelicalTrackHit> rotatedhits = new ArrayList<HelicalTrackHit>();
-        List<LCRelation> hthrelations = new ArrayList<LCRelation>();
-        List<LCRelation> mcrelations = new ArrayList<LCRelation>();
-        for (HelicalTrackCross cross : stereohits) {
-            List<HelicalTrackStrip> rotatedstriphits = new ArrayList<HelicalTrackStrip>();
-            for (HelicalTrackStrip strip : cross.getStrips()) {
-
-                Hep3Vector origin = strip.origin();
-                Hep3Vector u = strip.u();
-                Hep3Vector v = strip.v();
-                double umeas = strip.umeas();
-                double du = strip.du();
-                double vmin = strip.vmin();
-                double vmax = strip.vmax();
-                double dedx = strip.dEdx();
-                double time = strip.time();
-                List<RawTrackerHit> rthList = strip.rawhits();
-                String detname = strip.detector();
-                int layer = strip.layer();
-                BarrelEndcapFlag bec = strip.BarrelEndcapFlag();
-                Hep3Vector neworigin = _detToTrk.transformVectorToTracking(origin);
-                Hep3Vector newu = _detToTrk.transformVectorToTracking(u);
-                Hep3Vector newv = _detToTrk.transformVectorToTracking(v);
-                HelicalTrackStrip newstrip = new HelicalTrackStrip(neworigin, newu, newv, umeas, du, vmin, vmax, dedx, time, rthList, detname, layer, bec);
-                for (MCParticle p : strip.MCParticles()) {
-                    newstrip.addMCParticle(p);
-                }
-                rotatedstriphits.add(newstrip);
-            }
-            HelicalTrackCross newhit = new HelicalTrackCross(rotatedstriphits.get(0), rotatedstriphits.get(1));
-            rotatedhits.add(newhit);
-            hthrelations.add(new MyLCRelation(cross, newhit));
-            for (MCParticle mcp : newhit.getMCParticles()) {
-                mcrelations.add(new MyLCRelation(newhit, mcp));
-            }
-        }
-        
-        event.put("Rotated"+_outname, rotatedhits, HelicalTrackHit.class, 0);
-        event.put("Rotated"+_hitrelname, hthrelations, LCRelation.class, 0);
-        event.put("Rotated"+_mcrelname, mcrelations, LCRelation.class, 0);
-        
-        
-        //  Create the LCRelations between HelicalTrackHits and MC particles
-
-    }
-    
-}

hps-java/src/main/java/org/lcsim/hps/recon/tracking
HPSMaterialManager.java removed after 1.1
diff -N HPSMaterialManager.java
--- HPSMaterialManager.java	26 Nov 2012 03:16:24 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.lcsim.hps.recon.tracking;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.lcsim.recon.tracking.seedtracker.MaterialManager;
-import org.lcsim.recon.tracking.seedtracker.MaterialXPlane;
-
-
-
-/**
- *
- * Simple way to remove multiple scattering in HPS tracker 
- * by returning empty XPlanes that are used to describe the scatters
- * 
- * @author phansson
- */
-public class HPSMaterialManager extends MaterialManager {
-    
-    private boolean _includeMS;
-    private final static List<MaterialXPlane> _emptyMaterialXPlaneList = new ArrayList<MaterialXPlane>();
-    public HPSMaterialManager() {
-        super();
-        this._includeMS = true;
-    }
-    public HPSMaterialManager(boolean includeMS) {
-        super();
-        this._includeMS = includeMS;
-    }
-    @Override
-    public List<MaterialXPlane> getMaterialXPlanes() {
-        return this._includeMS ? super.getMaterialXPlanes() : _emptyMaterialXPlaneList;
-    }
-    
-}

hps-java/src/main/java/org/lcsim/hps/recon/tracking
HPSSeedTracker.java removed after 1.1
diff -N HPSSeedTracker.java
--- HPSSeedTracker.java	26 Nov 2012 03:18:06 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,43 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.lcsim.hps.recon.tracking;
-
-import java.util.List;
-import org.lcsim.recon.tracking.seedtracker.*;
-
-/**
- * Class extending lcsim version to allow extra flexibility
- * 
- * @author phansson
- */
-public class HPSSeedTracker extends SeedTracker  {
-
-    public HPSSeedTracker(List<SeedStrategy> strategylist) {
-        // use base class only if this constructor is called!
-        super(strategylist);
-    }
-
-    public HPSSeedTracker(List<SeedStrategy> strategylist, boolean includeMS) {
-            
-            // use base class constructor 
-        
-            super(strategylist);
-            
-            // Explicitly only replace the objects that might change
-            
-            //  Instantiate the material manager
-            _materialmanager = new HPSMaterialManager(includeMS);
-
-            //  Instantiate the helix finder since it depends on the material manager
-            _helixfitter = new HelixFitter(_materialmanager);
-
-            //  Instantiate the helix finder since it depends on the material manager
-            _finder = new SeedTrackFinder(_hitmanager, _helixfitter);
-
-        }
-
-
-
-}

hps-java/src/main/java/org/lcsim/hps/recon/tracking/kalman
KalmanFilterDriver.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- KalmanFilterDriver.java	1 Jun 2011 17:08:04 -0000	1.1
+++ KalmanFilterDriver.java	26 Nov 2012 18:12:01 -0000	1.2
@@ -76,6 +76,10 @@
                 /* Start with a HelicalTrackFit, turn it into a VTrack,
                  * turn that into an ETrack, and turn that into an HTrack.
                  * Then add detector hits from the original track. */
+                if(trklist.get(i).getTrackerHits().size()<4) {
+                    System.out.println("Continue, this track has only " + trklist.get(i).getTrackerHits().size());
+                    continue;
+                }
                 System.out.println("Making tracks...");
                 Track track = trklist.get(i);
                 HelicalTrackFit helicalTrack = shapeDis.trackToHelix(track);
@@ -88,7 +92,10 @@
                 for (int k = 0; k < track.getTrackerHits().size(); k++) {
                     TrackerHit thit = track.getTrackerHits().get(k);
                     System.out.println("Adding hit...");
-                    ht = geom.addTrackerHit(thit, ht, helicalTrack, vt);
+                    //ht = geom.addTrackerHit(thit, ht, helicalTrack, vt);
+                    // phansson
+                    // removing unused arguments to avoid confusion (see function for details)
+                    ht = geom.addTrackerHit(thit, ht); 
                 }
 
 

hps-java/src/main/java/org/lcsim/hps/recon/tracking/kalman
KalmanGeom.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- KalmanGeom.java	28 Jul 2011 18:29:10 -0000	1.4
+++ KalmanGeom.java	26 Nov 2012 18:12:01 -0000	1.5
@@ -1,19 +1,27 @@
 package org.lcsim.hps.recon.tracking.kalman;
 
-import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.*;
 
 import java.util.ArrayList;
 import java.util.List;
+import org.lcsim.detector.IDetectorElement;
 
 import org.lcsim.detector.ILogicalVolume;
 import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.ITransform3D;
 import org.lcsim.detector.solids.ISolid;
 import org.lcsim.detector.solids.Point3D;
+import org.lcsim.detector.tracker.silicon.ChargeCarrier;
+import org.lcsim.detector.tracker.silicon.SiSensor;
+import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
+import org.lcsim.event.RawTrackerHit;
 import org.lcsim.event.TrackerHit;
 import org.lcsim.fit.helicaltrack.HelicalTrackCross;
 import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
 import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
 import org.lcsim.geometry.Detector;
+import org.lcsim.hps.event.HPSTransformations;
 import org.lcsim.hps.recon.tracking.kalman.util.PropDCAZ;
 import org.lcsim.recon.tracking.trfbase.ETrack;
 import org.lcsim.recon.tracking.trfbase.Hit;
@@ -40,10 +48,10 @@
  * to the callers in a convenient form.
  *
  *
- *@author $Author: jeremy $
- *@version $Id: KalmanGeom.java,v 1.4 2011/07/28 18:29:10 jeremy Exp $
+ *@author $Author: phansson $
+ *@version $Id: KalmanGeom.java,v 1.5 2012/11/26 18:12:01 phansson Exp $
  *
- * Date $Date: 2011/07/28 18:29:10 $
+ * Date $Date: 2012/11/26 18:12:01 $
  *
  */
 /* To make the Kalman filter work for any detector, the type of hit that is
@@ -107,12 +115,15 @@
     ILogicalVolume logical;
     ShapeDispatcher shapeDispatcher = new ShapeDispatcher();
     Detector detector = null;
+    private HPSTransformations _detToTrk;
 
     public KalmanGeom(Detector det) {
         detector = det;
         System.out.println("New detector: " + detector.getName());
         logical = detector.getTrackingVolume().getLogicalVolume();
 
+        _detToTrk = new HPSTransformations();
+        
         // Extract information from the run time configuration system.
         //	try{
         //	    ToyConfig config = ToyConfig.getInstance();
@@ -365,6 +376,12 @@
 //        Point3D hitPoint = new Point3D(position[0], position[1], position[2]);
 //        ISolid hitSolid = findSolidFromPoint(hitPoint);
 
+        
+        //PELLE:
+        // The HelicalTrackFit track and VTrack vtrack are not used
+        
+        
+        
         // Need an ETrack to add hits from clusters.
         ETrack tre = htrack.newTrack();
 
@@ -398,10 +415,11 @@
         }
 
         System.out.println("Origin of strip1: " + strip1.origin());
+        System.out.println("u,v,w of strip1 : " + strip1.u().toString() + "," + strip1.v().toString() + "," + strip1.w().toString());
         System.out.println("Origin of strip2: " + strip2.origin());
+        System.out.println("u,v,w of strip2 : " + strip2.u().toString() + "," + strip2.v().toString() + "," + strip2.w().toString());
         System.out.println("dist1: " + dist1 + ", phi1: " + phi1);
         System.out.println("dist2: " + dist2 + ", phi2: " + phi2);
-
         // ClusXYPlane needs wz, wv, avz, phi and dist to create a cluster.
         double wz1 = strip1.u().z();
         double wz2 = strip2.u().z();
@@ -420,6 +438,13 @@
         double davz1 = strip1.du();
         double davz2 = strip2.du();
 
+        System.out.println("avz1 = " + avz1 + " = " + strip1.umeas() + " - " + (dist1 * (Math.cos(phi1) * strip1.u().x() + Math.sin(phi1) * strip1.u().y())
+                - (strip1.origin().x() * strip1.u().x() + strip1.origin().y() * strip1.u().y()
+                + strip1.origin().z() * strip1.u().z())));
+        System.out.println("avz2 = " + avz2 + " = " + strip2.umeas() + " - " + (dist2 * (Math.cos(phi2) * strip2.u().x() + Math.sin(phi2) * strip2.u().y())
+                - (strip2.origin().x() * strip2.u().x() + strip2.origin().y() * strip2.u().y()
+                + strip2.origin().z() * strip2.u().z())));
+        
 
 
 //        // Just to check and make sure Vtrf makes sense:
@@ -460,6 +485,183 @@
         return htrack;
 
     }
+    
+    
+     // Add a hit from an lcsim Track to a trf HTrack.
+    public HTrack addTrackerHit(TrackerHit thit, HTrack htrack) {
+        /* This should check the kind of solid that got hit and model it as the
+         * correct surface based on the solid dimensions. For now it just
+         * assumes XY planes. */
+        
+        System.out.println("\nAdd Tracker Hit at position " + thit.getPosition()[0]  + "," + thit.getPosition()[1] + "," + thit.getPosition()[2]);
+         
+        //PELLE:
+        // The HelicalTrackFit track and VTrack vtrack are not used so was removed 
+        // to avoid confusion.
+        // They might be needed to be able to figure out what solid to 
+        // to extrapolate between if this gets implemented.
+        
+        
+
+        double[] position = thit.getPosition();
+        if (position.length != 3) {
+            System.out.println("Position has more than 3 coordinates?!");
+        }
+
+
+//        // For checking surfaces
+//        KalmanSurface surface= findTrackerHitSurface(thit);
+//        PropStat prop = new PropStat();
+//        prop.setForward();
+//        double path = (position[2] - track.z0())/track.slope();
+//        KalmanHit khit = new KalmanHit(track, surface, vtrack, prop, path);
+//        Hit hit = khit.MakeHit();
+//        Point3D hitPoint = new Point3D(position[0], position[1], position[2]);
+//        ISolid hitSolid = findSolidFromPoint(hitPoint);
+
+       
+        
+        
+        // Need an ETrack to add hits from clusters.
+        ETrack tre = htrack.newTrack();
+
+        // This also assumes the hit in question is a Helical Track Cross.
+        HelicalTrackCross htrackcross = (HelicalTrackCross) thit;
+        HelicalTrackStrip strip1 = (HelicalTrackStrip) htrackcross.getStrips().get(0);
+        HelicalTrackStrip strip2 = (HelicalTrackStrip) htrackcross.getStrips().get(1);
+
+        Hep3Vector u1 = strip1.u();
+        Hep3Vector u2 = strip2.u();
+        Hep3Vector v1 = strip1.v();
+        Hep3Vector v2 = strip2.v();
+        Hep3Vector w1 = strip1.w();
+        Hep3Vector w2 = strip2.w();
+        
+        Hep3Vector origin1 = strip1.origin();
+        Hep3Vector origin2 = strip2.origin();
+        
+        double u1meas = strip1.umeas();
+        double u2meas = strip2.umeas();
+        
+        
+        System.out.println("strip1 origin: " + origin1);
+        System.out.println("strip2 origin: " + origin2);
+        System.out.printf("strip1 u=%s\tv=%s\tw=%s\n",u1.toString(),v1.toString(),w1.toString());
+        System.out.printf("strip2 u=%s\tv=%s\tw=%s\n",u2.toString(),v2.toString(),w2.toString());
+        System.out.println("strip1 umeas: " + u1meas);
+        System.out.println("strip2 umeas: " + u2meas);
+
+        System.out.println("Rotate strip2 u,v,w into strip1 frame");
+        
+        Hep3Matrix strip2ToTrk = getStripToTrackRotation(strip2);
+        System.out.println("Strip2ToTrk matrix " + strip2ToTrk.toString());
+        System.out.println("Get the rotation matrix for going from track frame to strip1 frame");
+        Hep3Matrix trackToStrip1 = getTrackToStripRotation(strip1);        
+        Hep3Matrix strip2ToStrip1 = VecOp.mult(trackToStrip1,strip2ToTrk);
+
+        
+        u2 = VecOp.mult(strip2ToStrip1, u2);
+        v2 = VecOp.mult(strip2ToStrip1, v2);
+        w2 = VecOp.mult(strip2ToStrip1, w2);
+        
+        System.out.printf("strip2 u=%s\tv=%s\tw=%s\n",u2.toString(),v2.toString(),w2.toString());
+        
+        
+        
+        double dist1 = dotProduct(origin1, w1);
+        double dist2 = dotProduct(origin2, w2);
+
+
+        double phi1 = Math.atan2(w1.y() * dist1 * origin1.y(), w1.x() * dist1 * origin1.x());
+        double phi2 = Math.atan2(w2.y() * dist2 * origin2.y(), w2.x() * dist2 * origin2.x());
+        // phi needs to be between 0 and 2PI. Additionally, it seemed like
+        // rounding errors caused problems for very small negative values of phi,
+        // so these are approximated as 0.
+        if (phi1 < 0) {
+            if (phi1 > -0.00000001) {
+                phi1 = 0;
+            } else {
+                phi1 = phi1 + 2 * Math.PI;
+            }
+        }
+        if (phi2 < 0) {
+            if (phi2 > -0.00000001) {
+                phi2 = 0;
+            } else {
+                phi2 = phi2 + 2 * Math.PI;
+            }
+        }
+        System.out.println("dist1: " + dist1 + ", phi1: " + phi1);
+        System.out.println("dist2: " + dist2 + ", phi2: " + phi2);
+        // ClusXYPlane needs wz, wv, avz, phi and dist to create a cluster.
+        double wz1 = u1.z();
+        double wz2 = u2.z();
+        double wv1 = u1.x() * (-Math.sin(phi1)) + u1.y() * Math.cos(phi1);
+        double wv2 = u2.x() * (-Math.sin(phi2)) + u2.y() * Math.cos(phi2);
+
+
+        double avz1 = u1meas
+                - (dist1 * (Math.cos(phi1) * u1.x() + Math.sin(phi1) * u1.y())
+                - (origin1.x() * u1.x() + origin1.y() * u1.y()
+                + origin1.z() * u1.z()));
+        double avz2 = u2meas
+                - (dist2 * (Math.cos(phi2) * u2.x() + Math.sin(phi2) * u2.y())
+                - (origin2.x() * u2.x() + origin2.y() * u2.y()
+                + origin2.z() * u2.z()));
+        double davz1 = strip1.du();
+        double davz2 = strip2.du();
+
+        System.out.println("avz1 = " + avz1 + " = " + u1meas + " - " + (dist1 * (Math.cos(phi1) * u1.x() + Math.sin(phi1) * u1.y())
+                - (origin1.x() * u1.x() + origin1.y() * u1.y()
+                + origin1.z() * u1.z())));
+        System.out.println("avz2 = " + avz2 + " = " + u2meas + " - " + (dist2 * (Math.cos(phi2) * u2.x() + Math.sin(phi2) * u2.y())
+                - (origin2.x() * u2.x() + origin2.y() * u2.y()
+                + origin2.z() * u2.z())));
+        
+
+
+//        // Just to check and make sure Vtrf makes sense:
+//        if((dist1*Math.cos(phi1) - origin1.x())*Math.cos(phi1) ==
+//                (dist1*Math.sin(phi1) - origin1.y())*Math.sin(phi1)){
+//            System.out.println("Vtrf1 coherent!");
+//        } else{
+//            System.out.println("Vtrf1 doesn't make sense :(");
+//        }
+//        if((dist2*Math.cos(phi2) - origin2.x())*Math.cos(phi2) ==
+//                (dist2*Math.sin(phi2) - origin2.y())*Math.sin(phi2)){
+//            System.out.println("Vtrf2 coherent!");
+//        } else{
+//            System.out.println("Vtrf2 doesn't make sense :(");
+//        }
+
+        System.out.println("wz1 = " + wz1 + ", wv1 = " + wv1 + ", avz1 = " + avz1 + ", davz1 =" + davz1);
+        System.out.println("wz2 = " + wz2 + ", wv2 = " + wv2 + ", avz2 = " + avz2 + ", davz2 =" + davz2);
+
+        // Create new clusters and get hit predictions.
+        ClusXYPlane1 cluster1 = new ClusXYPlane1(dist1, phi1, wv1, wz1, avz1, davz1);
+        ClusXYPlane1 cluster2 = new ClusXYPlane1(dist2, phi2, wv2, wz2, avz2, davz2);
+        List hits1 = cluster1.predict(tre);
+        List hits2 = cluster2.predict(tre);
+        Hit hit1 = (Hit) hits1.get(0);
+        Hit hit2 = (Hit) hits2.get(0);
+
+        System.out.println("hit1 predicted vector: " + hit1.predictedVector());
+        System.out.println("hit2 predicted vector: " + hit2.predictedVector());
+        System.out.println("hit position from trackerhit: [" + thit.getPosition()[0] + ", "
+                + thit.getPosition()[1] + ", " + thit.getPosition()[2] + "]");
+
+        hit1.setParentPointer(cluster1);
+        hit2.setParentPointer(cluster2);
+        htrack.addHit(hit1);
+        htrack.addHit(hit2);
+
+        return htrack;
+
+    }
+    
+    
+    
+    
 
     private boolean pointIsOnSolid(ISolid solid, Point3D hitPoint) {
         return shapeDispatcher.pointIsOnSolid(solid, hitPoint);
@@ -469,4 +671,73 @@
         double dotProduct = v1.x() * v2.x() + v1.y() * v2.y() + v1.z() * v2.z();
         return dotProduct;
     }
+
+
+    private Hep3Matrix getStripToTrackRotation(HelicalTrackStrip strip) {
+        //This function transforms the vec to the track coordinates that the supplied strip has
+        
+        //Transform from strip frame (u,v,w) to JLab frame (done through the RawTrackerHit)
+        ITransform3D stripToDet = GetLocalToGlobal(strip);
+        //Get rotation matrix
+        Hep3Matrix stripToDetMatrix = (BasicHep3Matrix) stripToDet.getRotation().getRotationMatrix();
+        //Transformation between JLab and tracking coordinates
+        Hep3Matrix detToTrackMatrix = (BasicHep3Matrix) _detToTrk.getMatrix();
+        
+        if (true) {
+            System.out.println("Getting the rotation to go from strip (u,v,w) to track coordinates");
+            System.out.println("stripToDet (JLab) translation:");
+            System.out.println(stripToDet.getTranslation().toString());
+            System.out.println("stripToDet Rotation:");
+            System.out.println(stripToDet.getRotation().toString());
+            System.out.println("detToTrack Rotation:");
+            System.out.println(detToTrackMatrix.toString());
+            
+            
+        }
+
+        return (Hep3Matrix) VecOp.mult(detToTrackMatrix,stripToDetMatrix);
+    }
+
+    private ITransform3D GetLocalToGlobal(HelicalTrackStrip strip) {
+        //Transform from sensor frame (u,v,w) to tracking frame
+        RawTrackerHit rth = (RawTrackerHit) strip.rawhits().get(0);
+        IDetectorElement ide = rth.getDetectorElement();
+        SiSensor sensor = ide.findDescendants(SiSensor.class).get(0);
+        SiSensorElectrodes electrodes = sensor.getReadoutElectrodes(ChargeCarrier.HOLE);
+        return electrodes.getLocalToGlobal();
+    }
+    
+    private Hep3Matrix getTrackToStripRotation(HelicalTrackStrip strip) {
+        //This function transforms the hit to the sensor coordinates
+        
+        //Transform from JLab frame to sensor frame (done through the RawTrackerHit)
+        ITransform3D detToStrip = GetGlobalToLocal(strip);
+        //Get rotation matrix
+        Hep3Matrix detToStripMatrix = (BasicHep3Matrix) detToStrip.getRotation().getRotationMatrix();
+        //Transformation between the JLAB and tracking coordinate systems
+        Hep3Matrix detToTrackMatrix = (BasicHep3Matrix) _detToTrk.getMatrix();
+
+        if (true) {
+            System.out.println("Getting the rotation to go from track to strip (u,v,w)");
+            System.out.println("gblToLoc translation:");
+            System.out.println(detToStrip.getTranslation().toString());
+            System.out.println("gblToLoc Rotation:");
+            System.out.println(detToStrip.getRotation().toString());
+            System.out.println("detToTrack Rotation:");
+            System.out.println(detToTrackMatrix.toString());
+        }
+
+        return (Hep3Matrix) VecOp.mult(detToStripMatrix, VecOp.inverse(detToTrackMatrix));
+    }
+
+    private ITransform3D GetGlobalToLocal(HelicalTrackStrip strip) {
+        //Transform from JLab frame (RawTrackerHit) to sensor frame (i.e. u,v,w)
+        RawTrackerHit rth = (RawTrackerHit) strip.rawhits().get(0);
+        IDetectorElement ide = rth.getDetectorElement();
+        SiSensor sensor = ide.findDescendants(SiSensor.class).get(0);
+        SiSensorElectrodes electrodes = sensor.getReadoutElectrodes(ChargeCarrier.HOLE);
+        return electrodes.getGlobalToLocal();
+    }
+
+
 }
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1