LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  July 2015

HPS-SVN July 2015

Subject:

r3320 - in /java/trunk/tracking/src/main/java/org/hps/recon/tracking: TrackData.java TrackDataDriver.java TrackUtils.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Sat, 1 Aug 2015 00:09:27 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (354 lines)

Author: [log in to unmask]
Date: Fri Jul 31 17:09:25 2015
New Revision: 3320

Log:
TrackData now has isolations for all layers

Modified:
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackData.java
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackDataDriver.java
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackData.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackData.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackData.java	Fri Jul 31 17:09:25 2015
@@ -3,70 +3,71 @@
 import org.lcsim.event.GenericObject;
 
 /**
- * Generic object used to persist track data not available through 
- * a Track object.
- * 
+ * Generic object used to persist track data not available through a Track
+ * object.
+ *
  * @author Omar Moreno <[log in to unmask]>
  * @author Sho Uemura <[log in to unmask]>
  *
  */
 public class TrackData implements GenericObject {
-    
+
     public static final int L1_ISOLATION_INDEX = 0;
     public static final int L2_ISOLATION_INDEX = 1;
+    public static final int N_ISOLATIONS = 12;
     public static final int TRACK_TIME_INDEX = 0;
     public static final int TRACK_VOLUME_INDEX = 0;
     public static final String TRACK_DATA_COLLECTION = "TrackData";
     public static final String TRACK_DATA_RELATION_COLLECTION = "TrackDataRelations";
-    
+
     private final double[] doubles;
     private final float[] floats;
     private final int[] ints;
-    
+
     /**
      * Default constructor
      */
     public TrackData() {
-        doubles = new double[2];
+        doubles = new double[N_ISOLATIONS];
         floats = new float[1];
         ints = new int[1];
     }
-        
+
     /**
      * Constructor
-     * 
+     *
      * @param trackVolume : SVT volume associated with the track
-     * @param trackTime : The track time 
-     * @param doubles : an array of doubles containing track data
+     * @param trackTime : The track time
+     * @param isolations : an array of doubles containing isolations for every
+     * sensor layer
      */
-    public TrackData(int trackVolume, float trackTime, double[] doubles) {
-    
-        this.doubles = doubles;
+    public TrackData(int trackVolume, float trackTime, double[] isolations) {
+
+        this.doubles = isolations;
         this.floats = new float[]{trackTime};
         this.ints = new int[]{trackVolume};
     }
 
     /**
-     * @return The layer 1 isolation value
+     * Get isolation value for the hit in the given sensor layer.
+     *
+     * @param layer The sensor layer of interest (0-11)
+     * @return The isolation value: positive if the nearest hit is outwards from
+     * the beam plane, negative if the nearest hit is inwards, offscale low if
+     * the track has no hit in this layer, offscale high if there is no other
+     * hit in this layer
      */
-    public double getL1Isolation() {
-        return doubles[L1_ISOLATION_INDEX];
-    }
-
-    /**
-     * @return The layer 2 isolation value
-     */
-    public double getL2Isolation() {
-        return doubles[L2_ISOLATION_INDEX];
+    public double getIsolation(int layer) {
+        return doubles[layer];
     }
 
     /**
      * @return The track time
      */
-    public float getTrackTime() { 
+    public float getTrackTime() {
         return floats[TRACK_TIME_INDEX];
     }
-    
+
     /**
      * @return The SVT volume associated with the track
      */
@@ -76,33 +77,26 @@
 
     /**
      * @param object : The generic object containing the data.
-     * @return The layer 1 isolation value
+     * @param layer The sensor layer of interest (0-11)
+     * @return The isolation value for the specified layer
      */
-    public static double getL1Isolation(GenericObject object) {
-        return object.getDoubleVal(L1_ISOLATION_INDEX);
+    public static double getIsolation(GenericObject object, int layer) {
+        return object.getDoubleVal(layer);
     }
 
     /**
      * @param object : The generic object containing the data.
-     * @return The layer 2 isolation value
-     */
-    public static double getL2Isolation(GenericObject object) {
-        return object.getDoubleVal(L2_ISOLATION_INDEX);
-    }
-    
-    /**
-     * @param object : The generic object containing the data.
      * @return The track time
      */
-    public static float getTrackTime(GenericObject object) { 
+    public static float getTrackTime(GenericObject object) {
         return object.getFloatVal(TRACK_TIME_INDEX);
     }
-    
+
     /**
      * @param object : The generic object containing the data.
      * @return The SVT volume associated with the track
      */
-    public static int getTrackVolume(GenericObject object) { 
+    public static int getTrackVolume(GenericObject object) {
         return object.getIntVal(TRACK_VOLUME_INDEX);
     }
 

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackDataDriver.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackDataDriver.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackDataDriver.java	Fri Jul 31 17:09:25 2015
@@ -37,15 +37,17 @@
 
     public TrackDataDriver() {
     }
-    
+
     public void setTrackCollectionName(String name) {
-        this.trackCollectionName=name;
+        this.trackCollectionName = name;
     }
 
     protected void process(EventHeader event) {
 
         // If the event doesn't contain a collection of tracks, skip it.
-        if (!event.hasCollection(Track.class, trackCollectionName)) return;
+        if (!event.hasCollection(Track.class, trackCollectionName)) {
+            return;
+        }
 
         // Get the collection of tracks from the event
         List<Track> tracks = event.get(Track.class, trackCollectionName);
@@ -56,15 +58,18 @@
         BaseRelationalTable hthToRotatedHth = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED);
         hthToRotatedHth.addRelations(rotatedHthToHthRelations);
 
+        RelationalTable hitToStrips = TrackUtils.getHitToStripsTable(event);
+        RelationalTable hitToRotated = TrackUtils.getHitToRotatedTable(event);
+
         List<HelicalTrackHit> rotatedHths = event.get(HelicalTrackHit.class, rotatedHthCollectionName);
 
         // Create a container that will be used to store all TrackData objects.
         List<TrackData> trackDataCollection = new ArrayList<TrackData>();
-       
+
         // Create a container that will be used to store all LCRelations between
         // a TrackData object and the corresponding Track
         List<LCRelation> trackDataRelations = new ArrayList<LCRelation>();
-        
+
         // Create a collection to hold the track residuals
         List<TrackResidualsData> trackResidualsCollection = new ArrayList<TrackResidualsData>();
 
@@ -73,11 +78,11 @@
 
         double xResidual = 0;
         double yResidual = 0;
-        
+
         float totalT0 = 0;
         float totalHits = 0;
         float trackTime = 0;
-        
+
         int trackerVolume = -1;
 
         boolean isFirstHit = true;
@@ -154,23 +159,26 @@
 
             // The track time is the mean t0 of hits on a track
             trackTime = totalT0 / totalHits;
-
-            double l1Isolation = 99999999.0;
-            double l2Isolation = 99999999.0;
-            // Loop over all stereo hits comprising a track
-            for (TrackerHit stereoHit : track.getTrackerHits()) {
-                // Loop over the clusters comprising the stereo hit
-                for (HelicalTrackStrip cluster : ((HelicalTrackCross) stereoHit).getStrips()) {
-//                    System.out.println(cluster.layer());
-                    if (cluster.layer() == 1) {
-                        l1Isolation = getNearestDistance(cluster, rotatedHths);
-                    } else if (cluster.layer() == 2) {
-                        l2Isolation = getNearestDistance(cluster, rotatedHths);
-                    }
-                }
+            Double[] isolations = TrackUtils.getIsolations(track, hitToStrips, hitToRotated);
+
+//            double l1Isolation = 99999999.0;
+//            double l2Isolation = 99999999.0;
+//            // Loop over all stereo hits comprising a track
+//            for (TrackerHit stereoHit : track.getTrackerHits()) {
+//                // Loop over the clusters comprising the stereo hit
+//                for (HelicalTrackStrip cluster : ((HelicalTrackCross) stereoHit).getStrips()) {
+////                    System.out.println(cluster.layer());
+//                    if (cluster.layer() == 1) {
+//                        l1Isolation = getNearestDistance(cluster, rotatedHths);
+//                    } else if (cluster.layer() == 2) {
+//                        l2Isolation = getNearestDistance(cluster, rotatedHths);
+//                    }
+//                }
+//            }
+            double qualityArray[] = new double[isolations.length];
+            for (int i = 0; i < isolations.length; i++) {
+                qualityArray[i] = isolations[i] == null ? -99999999.0 : isolations[i];
             }
-
-            double qualityArray[] = {l1Isolation, l2Isolation};
             TrackData trackData = new TrackData(trackerVolume, trackTime, qualityArray);
             trackDataCollection.add(trackData);
             trackDataRelations.add(new BaseLCRelation(trackData, track));
@@ -185,37 +193,37 @@
         event.put(trackResidualsCollectionName, trackResidualsCollection, TrackResidualsData.class, 0);
         event.put(trackResidualsRelationsColName, trackToTrackResidualsRelations, LCRelation.class, 0);
     }
-
-    private static Double getNearestDistance(HelicalTrackStrip cl, List<HelicalTrackHit> toththits) {
-        Hep3Vector corigin = cl.origin();
-        Hep3Vector uvec = VecOp.mult(cl.umeas(), cl.u());
-        Hep3Vector clvec = VecOp.add(corigin, uvec);
-        int layer = cl.layer();
-//        HelicalTrackStrip nearest = null;
-//        Hep3Vector nearestvec = null;
-        Double mindist = 99999999.0;
-        for (HelicalTrackHit hth : toththits) {
-            HelicalTrackCross cross = (HelicalTrackCross) hth;
-            for (HelicalTrackStrip str : cross.getStrips()) {
-                if (layer == str.layer() && str != cl) {
-                    Hep3Vector strorigin = str.origin();
-                    Hep3Vector struvec = VecOp.mult(str.umeas(), str.u());
-                    Hep3Vector strvec = VecOp.add(strorigin, struvec);
-                    double origindist = VecOp.sub(corigin, strorigin).magnitude();
-                    double dist = VecOp.sub(clvec, strvec).magnitude();
-                    if (origindist == 0.0 && dist != 0.0 && dist < Math.abs(mindist)) {
-                        mindist = VecOp.sub(clvec, strvec).magnitude();
-                        if (Math.abs(clvec.z()) > Math.abs(strvec.z())) {
-                            mindist = -mindist;
-                        }
-//                        nearest = str;
-//                        nearestvec = strvec;
-                    }
-                }
-            }
-        }
-//        System.out.println(clvec);
-//        System.out.println(nearestvec);
-        return mindist;
-    }
+//
+//    private static Double getNearestDistance(HelicalTrackStrip cl, List<HelicalTrackHit> toththits) {
+//        Hep3Vector corigin = cl.origin();
+//        Hep3Vector uvec = VecOp.mult(cl.umeas(), cl.u());
+//        Hep3Vector clvec = VecOp.add(corigin, uvec);
+//        int layer = cl.layer();
+////        HelicalTrackStrip nearest = null;
+////        Hep3Vector nearestvec = null;
+//        Double mindist = 99999999.0;
+//        for (HelicalTrackHit hth : toththits) {
+//            HelicalTrackCross cross = (HelicalTrackCross) hth;
+//            for (HelicalTrackStrip str : cross.getStrips()) {
+//                if (layer == str.layer() && str != cl) {
+//                    Hep3Vector strorigin = str.origin();
+//                    Hep3Vector struvec = VecOp.mult(str.umeas(), str.u());
+//                    Hep3Vector strvec = VecOp.add(strorigin, struvec);
+//                    double origindist = VecOp.sub(corigin, strorigin).magnitude();
+//                    double dist = VecOp.sub(clvec, strvec).magnitude();
+//                    if (origindist == 0.0 && dist != 0.0 && dist < Math.abs(mindist)) {
+//                        mindist = VecOp.sub(clvec, strvec).magnitude();
+//                        if (Math.abs(clvec.z()) > Math.abs(strvec.z())) {
+//                            mindist = -mindist;
+//                        }
+////                        nearest = str;
+////                        nearestvec = strvec;
+//                    }
+//                }
+//            }
+//        }
+////        System.out.println(clvec);
+////        System.out.println(nearestvec);
+//        return mindist;
+//    }
 }

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java	Fri Jul 31 17:09:25 2015
@@ -996,7 +996,7 @@
      * @return Double_MAX_VALUE if no other strips found.
      */
     public static double getIsolation(TrackerHit strip, TrackerHit otherStrip, RelationalTable hitToStrips, RelationalTable hitToRotated) {
-        double nearestDistance = Double.MAX_VALUE;
+        double nearestDistance = 99999999.0;
         for (TrackerHit cross : (Set<TrackerHit>) hitToStrips.allTo(otherStrip)) {
             for (TrackerHit crossStrip : (Set<TrackerHit>) hitToStrips.allFrom(cross)) {
                 if (crossStrip != strip && crossStrip != otherStrip) {
@@ -1023,7 +1023,7 @@
                     if (Math.abs(stripPosition.y()) > Math.abs(crossStripPosition.y())) {
                         distance = -distance;
                     }
-                    System.out.format("%s, %s, %s, %f\n", stripPosition, crossStripPosition, VecOp.sub(stripPosition, crossStripPosition), distance);
+//                    System.out.format("%s, %s, %s, %f\n", stripPosition, crossStripPosition, VecOp.sub(stripPosition, crossStripPosition), distance);
 //                    if (distance<=0.0601) continue; //hack to avoid counting adjacent strips that didn't get clustered together
 //                    if (distance<0.1) System.out.format("%d, %d, %f\n",strip.getRawHits().size(),crossStrip.getRawHits().size(), distance);
 //                    if (distance < 0.1) {

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use