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  January 2015

HPS-SVN January 2015

Subject:

r1884 - in /java/trunk/ecal-recon/src: main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java main/java/org/hps/recon/ecal/cluster/SimpleReconClusterer.java test/java/org/hps/recon/ecal/cluster/ClustererTest.java

From:

[log in to unmask]

Reply-To:

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

Date:

Tue, 6 Jan 2015 20:01:45 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (142 lines)

Author: [log in to unmask]
Date: Tue Jan  6 12:01:38 2015
New Revision: 1884

Log:
Energy sort cluster hit collections so seed hit always appears as first in list.

Modified:
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/SimpleReconClusterer.java
    java/trunk/ecal-recon/src/test/java/org/hps/recon/ecal/cluster/ClustererTest.java

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java	Tue Jan  6 12:01:38 2015
@@ -198,4 +198,86 @@
         }
         return rejectedHits;
     }   
+     
+    /**
+     * Sort in place the CalorimeterHit list of a set of clusters, 
+     * disambiguating when the energies are exactly the same.
+     * @param clusters The list of clusters with hits to sort.
+     */
+    public static void sortReconClusterHits(List<Cluster> clusters) {
+        Comparator<CalorimeterHit> comparator = Collections.reverseOrder(new UniqueEnergyComparator());
+        for (Cluster cluster : clusters) {
+            Collections.sort(cluster.getCalorimeterHits(), comparator);
+        }
+    }
+    
+    static class UniqueEnergyComparator implements Comparator<CalorimeterHit> {
+        /**
+         * Compares the first hit with respect to the second. This method will compare hits first by
+         * energy, and then spatially. In the case of equal energy hits, the hit closest to the beam
+         * gap and closest to the positron side of the detector will be selected. If all of these
+         * conditions are true, the hit with the positive y-index will be selected. Hits with all
+         * four conditions matching are the same hit.
+         * @param hit1 The hit to compare.
+         * @param hit2 The hit with respect to which the first should be compared.
+         */
+        public int compare(CalorimeterHit hit1, CalorimeterHit hit2) {
+            // Hits are sorted on a hierarchy by three conditions. First,
+            // the hits with the highest energy come first. Next, they
+            // are ranked by vertical proximity to the beam gap, and
+            // lastly, they are sorted by horizontal proximity to the
+            // positron side of the detector.
+
+            // Get the hit energies.
+            double[] e = { hit1.getCorrectedEnergy(), hit2.getCorrectedEnergy() };
+
+            // Perform the energy comparison. The higher energy hit
+            // will be ordered first.
+            if (e[0] < e[1]) {
+                return -1;
+            } else if (e[0] > e[1]) {
+                return 1;
+            }
+
+            // If the hits are the same energy, we must perform the
+            // spatial comparisons.
+            else {
+                // Get the position with respect to the beam gap.
+                int[] iy = { Math.abs(hit1.getIdentifierFieldValue("iy")), Math.abs(hit2.getIdentifierFieldValue("iy")) };
+
+                // The closest hit is first.
+                if (iy[0] > iy[1]) {
+                    return -1;
+                } else if (iy[0] < iy[1]) {
+                    return 1;
+                }
+
+                // Hits that are identical in vertical distance from
+                // beam gap and energy are differentiated with distance
+                // horizontally from the positron side of the detector.
+                else {
+                    // Get the position from the positron side.
+                    int[] ix = { hit1.getIdentifierFieldValue("ix"), hit2.getIdentifierFieldValue("ix") };
+
+                    // The closest hit is first.
+                    if (ix[0] > ix[1]) {
+                        return 1;
+                    } else if (ix[0] < ix[1]) {
+                        return -1;
+                    }
+
+                    // If all of these checks are the same, compare
+                    // the raw value for iy. If these are identical,
+                    // then the two hits are the same. Otherwise, sort
+                    // the numerical value of iy. (This removes the
+                    // issue where hits (x, y) and (x, -y) can have
+                    // the same energy and be otherwise seen as the
+                    // same hit from the above checks.
+                    else {
+                        return Integer.compare(hit1.getIdentifierFieldValue("iy"), hit2.getIdentifierFieldValue("iy"));
+                    }
+                }
+            }
+        }
+    }
 }

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/SimpleReconClusterer.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/SimpleReconClusterer.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/SimpleReconClusterer.java	Tue Jan  6 12:01:38 2015
@@ -123,6 +123,8 @@
             cluster.addHit(hit);
         }
 
+        ClusterUtilities.sortReconClusterHits(clusters);
+        
         return clusters;
     }
 }

Modified: java/trunk/ecal-recon/src/test/java/org/hps/recon/ecal/cluster/ClustererTest.java
 =============================================================================
--- java/trunk/ecal-recon/src/test/java/org/hps/recon/ecal/cluster/ClustererTest.java	(original)
+++ java/trunk/ecal-recon/src/test/java/org/hps/recon/ecal/cluster/ClustererTest.java	Tue Jan  6 12:01:38 2015
@@ -34,7 +34,7 @@
     static final String fileLocation = "http://www.lcsim.org/test/hps-java/MockDataReconTest.slcio";
     File inputFile;
     File testOutputDir;
-    static int nEvents = 500; 
+    static int nEvents = -1; 
     
     public void setUp() {
         // Cache the input file.
@@ -55,7 +55,8 @@
     
     public void testReconClusterer() {
         //runClustererTest("ReconClusterer", new double[] { 0.0075, 0.1, 0.3, 0.0, 20.0, 0. }, true);
-        runClustererTest("ReconClusterer");
+        //runClustererTest("ReconClusterer");
+        runClustererTest("ReconClusterer", null, true, true);
     }
     
     public void testSimpleReconClusterer() {

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