Print

Print


Author: [log in to unmask]
Date: Tue Sep 15 09:22:33 2015
New Revision: 3601

Log:
Updated event display to load hit and cluster time-stamps. Cluster time stamps are displayed in stand-alone mode.

Modified:
    java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/event/Cluster.java
    java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/event/EcalHit.java
    java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/io/TextManager.java
    java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/lcsim/EventDisplayOutputDriver.java
    java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/FileViewer.java
    java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/PEventViewer.java
    java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/Viewer.java

Modified: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/event/Cluster.java
 =============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/event/Cluster.java	(original)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/event/Cluster.java	Tue Sep 15 09:22:33 2015
@@ -13,43 +13,46 @@
 public final class Cluster {
 	private final Point center;
 	private final double energy;
+	private final double time;
 	private ArrayList<Point> hitList = new ArrayList<Point>();
 	private ArrayList<Point> shareList = new ArrayList<Point>();
 	
 	/**
-	 * <b>Cluster</b><br/><br/>
-	 * <code>public <b>Cluster</b>(int ix, int iy)</code><br/><br/>
 	 * Creates a new cluster. All clusters are required to have a
 	 * cluster center.
 	 * @param ix - The cluster center's x-index.
 	 * @param iy - The cluster center's y-index.
 	 */
-	public Cluster(int ix, int iy) { this(new Point(ix, iy), Double.NaN); }
+	public Cluster(int ix, int iy) { this(new Point(ix, iy), Double.NaN, Double.NaN); }
 	
 	/**
-	 * <b>Cluster</b><br/><br/>
-	 * <code>public <b>Cluster</b>(Point clusterCenter)</code><br/><br/>
 	 * Creates a new cluster. All clusters are required to have a seed
 	 * hit.
 	 * @param clusterCenter - The <code>Point</code> object indicating in
 	 * which crystal the seed hit occurred.
 	 */
-	public Cluster(Point clusterCenter) { this(clusterCenter, Double.NaN); }
+	public Cluster(Point clusterCenter) { this(clusterCenter, Double.NaN, Double.NaN); }
 	
 	/**
-	 * <b>Cluster</b><br/><br/>
-	 * <code>public <b>Cluster</b>(int ix, int iy)</code><br/><br/>
 	 * Creates a new cluster. All clusters are required to have a
 	 * cluster center.
 	 * @param ix - The cluster center's x-index.
 	 * @param iy - The cluster center's y-index.
 	 * @param energy - The cluster's energy.
 	 */
-	public Cluster(int ix, int iy, double energy) { this(new Point(ix, iy), energy); }
+	public Cluster(int ix, int iy, double energy) { this(new Point(ix, iy), energy, Double.NaN); }
 	
 	/**
-	 * <b>Cluster</b><br/><br/>
-	 * <code>public <b>Cluster</b>(Point clusterCenter)</code><br/><br/>
+	 * Creates a new cluster. All clusters are required to have a
+	 * cluster center.
+	 * @param ix - The cluster center's x-index.
+	 * @param iy - The cluster center's y-index.
+	 * @param energy - The cluster's energy.
+	 * @param time - The cluster's time-stamp.
+	 */
+	public Cluster(int ix, int iy, double energy, double time) { this(new Point(ix, iy), energy, time); }
+	
+	/**
 	 * Creates a new cluster. All clusters are required to have a seed
 	 * hit.
 	 * @param clusterCenter - The <code>Point</code> object indicating in
@@ -57,13 +60,24 @@
 	 * @param energy - The cluster's energy.
 	 */
 	public Cluster(Point clusterCenter, double energy) {
-		center = clusterCenter;
-		this.energy = energy;
+		this(clusterCenter, energy, Double.NaN);
 	}
 	
 	/**
-	 * <b>addComponentHit</b><br/><br/>
-	 * <code>public void <b>addComponentHit</b>(int ix, int iy)</code><br/><br/>
+	 * Creates a new cluster. All clusters are required to have a seed
+	 * hit.
+	 * @param clusterCenter - The <code>Point</code> object indicating in
+	 * which crystal the seed hit occurred.
+	 * @param energy - The cluster's energy.
+	 * @param time - The cluster's time-stamp.
+	 */
+	public Cluster(Point clusterCenter, double energy, double time) {
+		center = clusterCenter;
+		this.energy = energy;
+		this.time = time;
+	}
+	
+	/**
 	 * Adds an <code>Point</code> to the list of this cluster's
 	 * component hits.
 	 * @param ix - The component hit's x-coordinate.
@@ -72,8 +86,6 @@
 	public void addComponentHit(int ix, int iy) { hitList.add(new Point(ix, iy)); }
 	
 	/**
-	 * <b>addComponentHit</b><br/><br/>
-	 * <code>public void <b>addComponentHit</b>(Point eHit)</code><br/><br/>
 	 * Adds an <code>Point</code> to the list of this cluster's
 	 * component hits.
 	 * @param eHit - The <code>Point</code> object indicating in which
@@ -82,8 +94,6 @@
 	public void addComponentHit(Point eHit) { hitList.add(eHit); }
 	
 	/**
-	 * <b>addSharedHit</b><br/><br/>
-	 * <code>public void <b>addSharedHit</b>(int ix, int iy)</code><br/><br/>
 	 * Adds an <code>Point</code> to the list of this cluster's shared
 	 * hits.
 	 * @param ix - The shared hit's x-coordinate.
@@ -92,8 +102,6 @@
 	public void addSharedHit(int ix, int iy) { shareList.add(new Point(ix, iy)); }
 	
 	/**
-	 * <b>addSharedHit</b><br/><br/>
-	 * <code>public void <b>addSharedHit</b>(Point eHit)</code><br/><br/>
 	 * Adds an <code>Point</code> to the list of this cluster's shared
 	 * hits.
 	 * @param eHit - The <code>Point</code> object indicating in which
@@ -102,16 +110,12 @@
 	public void addSharedHit(Point eHit) { shareList.add(eHit); }
 	
 	/**
-	 * <b>getClusterCenter</b><br/><br/>
-	 * <code>public Point <b>getClusterCenter</b>()</code><br/><br/>
 	 * Gets the hit representing the cluster center.
 	 * @return Returns the cluster center hit as an <code>Point</code>.
 	 */
 	public Point getClusterCenter() { return center; }
 	
 	/**
-	 * <b>getClusterEnergy</b><br/><br/>
-	 * <code>public double <b>getClusterEnergy</b>()</code><br/><br/>
 	 * Gets the cluster's energy, if it was defined when the cluster
 	 * was constructed.
 	 * @return Returns the energy of the cluster if it was defined,
@@ -120,8 +124,12 @@
 	public double getClusterEnergy() { return energy; }
 	
 	/**
-	 * <b>getComponentHitCount</b><br/><br/>
-	 * <code>public int <b>getComponentHitCount</b>()</code><br/><br/>
+	 * Gets the time stamp for the cluster in nanoseconds.
+	 * @return Returns the cluster's time stamp.
+	 */
+	public double getClusterTime() { return time; }
+	
+	/**
 	 * Indicates how many component hits compose this cluster. Note
 	 * that this does not include the seed hit or shared hits.
 	 * @return Returns the number of component hits in the cluster
@@ -130,8 +138,6 @@
 	public int getComponentHitCount() { return hitList.size(); }
 	
 	/**
-	 * <b>getComponentHits</b><br/><br/>
-	 * <code>public List<Point> <b>getComponentHits</b>()</code><br/><br/>
 	 * Gets the list of hits that make up the cluster, exempting the
 	 * seed hit and shared hits.
 	 * @return Returns the cluster hits as a <code>List</code> object
@@ -140,8 +146,6 @@
 	public List<Point> getComponentHits() { return hitList; }
 	
 	/**
-	 * <b>getHitCount</b><br/><br/>
-	 * <code>public int <b>getHitCount</b>()</code><br/><br/>
 	 * Indicates how many total hits compose this cluster. This includes
 	 * component hits, shared hits, and the seed hit.
 	 * @return Returns the number of component hits in the cluster
@@ -150,8 +154,6 @@
 	public int getHitCount() { return hitList.size() + shareList.size() + 1; }
 	
 	/**
-	 * <b>getSharedHitCount</b><br/><br/>
-	 * <code>public int <b>getSharedHitCount</b>()</code><br/><br/>
 	 * Indicates how many shared hits compose this cluster. Note that
 	 * this does not include the seed hit or component hits.
 	 * @return Returns the number of shared hits in the cluster as an
@@ -160,8 +162,6 @@
 	public int getSharedHitCount() { return shareList.size(); }
 	
 	/**
-	 * <b>getSharedHits</b><br/><br/>
-	 * <code>public List<Point> <b>getSharedHits</b>()</code><br/><br/>
 	 * Gets the list of hits that make up the cluster, exempting the
 	 * seed hit and component hits.
 	 * @return Returns the shared hits as a <code>List</code> object

Modified: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/event/EcalHit.java
 =============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/event/EcalHit.java	(original)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/event/EcalHit.java	Tue Sep 15 09:22:33 2015
@@ -11,12 +11,12 @@
 public final class EcalHit {
     // The coordinate on the calorimeter panel.
     protected final Point loc;
-    // The (raw) energy of this hit.
+    // The energy of this hit.
     private double energy = 0.0;
+    // The time of this hit.
+    private double time = 0.0;
     
     /**
-     * <b>EcalHit</b><br/><br/>
-     * <code>public <b>EcalHit</b>(int ix, int iy, double energy)</code><br/><br/>
      * Initializes a calorimeter hit object.
      * @param ix - The x-coordinate of the hit.
      * @param iy - The y-coordinate of the hit.
@@ -27,8 +27,6 @@
     }
     
     /**
-     * <b>EcalHit</b><br/><br/>
-     * <code>public <b>EcalHit</b>(Point ixy, double energy)</code><br/><br/>
      * Initializes a calorimeter hit object.
      * @param ixy - The x/y-coordinates of the hit.
      * @param energy - The raw energy of the hit.
@@ -39,16 +37,35 @@
     }
     
     /**
-     * <b>getEnergy</b><br/><br/>
-     * <code>public double <b>getEnergy</b>()</code><br/><br/>
+     * Initializes a calorimeter hit object.
+     * @param ix - The x-coordinate of the hit.
+     * @param iy - The y-coordinate of the hit.
+     * @param energy - The raw energy of the hit.
+     * @param time - The time-stamp for the hit.
+     **/
+    public EcalHit(int ix, int iy, double energy, double time) {
+    	this(new Point(ix, iy), energy, time);
+    }
+    
+    /**
+     * Initializes a calorimeter hit object.
+     * @param ixy - The x/y-coordinates of the hit.
+     * @param energy - The raw energy of the hit.
+     * @param time - The time-stamp for the hit.
+     **/
+    public EcalHit(Point ixy, double energy, double time) {
+    	loc = ixy;
+        this.energy = energy;
+        this.time = time;
+    }
+    
+    /**
      * Indicates the raw energy of this hit.
      * @return Returns the raw energy as a <code>double</code>.
      **/
     public double getEnergy() { return energy; }
     
     /**
-     * <b>getLocation</b><br/><br/>
-     * <code>public Point <b>getLocation</b>()</code><br/><br/>
      * Indicates the location of the object.
      * @return Returns the object's location as a <code>Point
      * </code> object.
@@ -56,40 +73,36 @@
     public Point getLocation() { return loc; }
     
     /**
-     * <b>getX</b><br/><br/>
-     * <code>public int <b>getX</b>()</code><br/><br/>
+     * Indicates the time at which the hit occurred.
+     * @return Returns the hit time.
+     */
+    public double getTime() { return time; }
+    
+    /**
      * Indicates the x-coordinate of the object.
      * @return Returns the x-coordinate as an <code>int</code>.
      **/
     public int getX() { return loc.x; }
     
     /**
-     * <b>getY</b><br/><br/>
-     * <code>public int <b>getY</b>()</code><br/><br/>
      * Indicates the y-coordinate of the object.
      * @return Returns the y-coordinate as an <code>int</code>.
      **/
     public int getY() { return loc.y; }
     
     /**
-     * <b>setEnergy</b><br/><br/>
-     * <code>public void <b>setEnergy</b>(double energy)</code><br/><br/>
      * Sets the energy of the hit to the indicated value.
      * @param energy - The new energy of the hit.
      **/
     public void setEnergy(double energy) { this.energy = energy; }
     
     /**
-     * <b>setX</b><br/><br/>
-     * <code>public void <b>setX</b>(int x)</code><br/><br/>
      * Sets the object's x-coordinate.
      * @param x - The new x-coordinate.
      **/
     public void setX(int x) { loc.x = x; }
     
     /**
-     * <b>setY</b><br/><br/>
-     * <code>public void <b>setY</b>(int y)</code><br/><br/>
      * Sets the obejct's y-coordinate.
      * @param y - The new y-coordinate.
      **/

Modified: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/io/TextManager.java
 =============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/io/TextManager.java	(original)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/io/TextManager.java	Tue Sep 15 09:22:33 2015
@@ -131,14 +131,19 @@
                 double clusterEnergy = Double.NaN;
                 if(st.hasMoreTokens()) { clusterEnergy = Double.parseDouble(st.nextToken()); }
                 
+                // Get the cluster time, if it is defined.
+                double clusterTime = Double.NaN;
+                if(st.hasMoreTokens()) { clusterTime = Double.parseDouble(st.nextToken()); }
+                
                 // Add a new cluster.
-                clusterList.add(new Cluster(ix, iy, clusterEnergy));
+                clusterList.add(new Cluster(ix, iy, clusterEnergy, clusterTime));
             }
             
             // If this is a calorimeter hit, add a new calorimeter hit object.
             else if (name.compareTo("EcalHit") == 0) {
                 double energy = Double.parseDouble(st.nextToken());
-                hitList.add(new EcalHit(ix, iy, energy));
+                double time = Double.parseDouble(st.nextToken());
+                hitList.add(new EcalHit(ix, iy, energy, time));
             }
             
             // If this is a cluster component hit, add it to the last cluster.

Modified: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/lcsim/EventDisplayOutputDriver.java
 =============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/lcsim/EventDisplayOutputDriver.java	(original)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/lcsim/EventDisplayOutputDriver.java	Tue Sep 15 09:22:33 2015
@@ -7,7 +7,6 @@
 
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.EventHeader;
-//import org.hps.recon.ecal.HPSEcalCluster;
 import org.lcsim.util.Driver;
 
 /**
@@ -28,8 +27,6 @@
     private boolean outputClusters = true;
     
     /**
-     * <b>endOfData</b><br/><br/>
-     * <code>public void <b>endOfData</b>()</code><br/><br/>
      * Closes the output file after all events have been processed.
      */
     public void endOfData() {
@@ -43,8 +40,6 @@
     }
     
     /**
-     * <b>process</b><br/><br/>
-     * <code>public void <b>process</b>(EventHeader event)</code><br/><br/>
      * Writes the event to the output file if it matches the the output
      * conditions selected for the driver.
      */
@@ -137,8 +132,6 @@
     }
     
     /**
-     * <b>startOfData</b><br/><br/>
-     * <code>public void <b>startOfData</b>()</code><br/><br/>
      * Opens the output file and clears it if it already exists.
      */
     public void startOfData() {
@@ -154,8 +147,6 @@
     }
     
     /**
-     * <b>setEcalCollectionName</b><br/><br/>
-     * <code>public void <b>setEcalCollectionName</b>(String ecalCollectionName)</code><br/><br/>
      * Sets the name of the LCIO collection containing hits.
      * @param ecalCollectionName - The LCIO hit collection name.
      */
@@ -164,8 +155,6 @@
     }
     
     /**
-     * <b>setClusterCollectionName</b><br/><br/>
-     * <code>public void <b>setClusterCollectionName</b>(String clusterCollectionName)</code><br/><br/>
      * Sets the name of the LCIO collection containing clusters.
      * @param clusterCollectionName - The LCIO cluster collection name.
      */
@@ -174,8 +163,6 @@
     }
     
     /**
-     * <b>setIgnoreEmptyEvents</b><br/><br/>
-     * <code>public void <b>setIgnoreEmptyEvents</b></code><br/><br/>
      * Sets whether events with no hits should be output.
      * @param ignoreEmptyEvents - <code>true</code> indicates that
      * events without hits will be skipped while <code>false</code>
@@ -186,8 +173,6 @@
     }
     
     /**
-     * <b>setIgnoreNoClusterEvents</b><br/><br/>
-     * <code>public void <b>setIgnoreNoClusterEvents</b></code><br/><br/>
      * Sets whether events with no clusters should be output.
      * @param ignoreNoClusterEvents - <code>true</code> indicates that
      * events without clusters will be skipped while <code>false</code>
@@ -198,8 +183,6 @@
     }
     
     /**
-     * <b>setOutputFileName</b><br/><br/>
-     * <code>public void <b>setOutputFileName</b></code><br/><br/>
      * Sets the name of the output file containing the event data.
      * @param outputFileName - The name of the output file.
      */
@@ -208,8 +191,6 @@
     }
     
     /**
-     * <b>setOutputClusters</b><br/><br/>
-     * <code>public void <b>setOutputClusters</b></code><br/><br/>
      * Sets whether clusters should be output to data file,
      * @param outputClusters - <code>true</code> indicates that clusters
      * will be written and <code>false</code> that they will not.

Modified: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/FileViewer.java
 =============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/FileViewer.java	(original)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/FileViewer.java	Tue Sep 15 09:22:33 2015
@@ -44,13 +44,14 @@
     private HashMap<Point, Cluster> clusterMap = new HashMap<Point, Cluster>();
     
     // Additional status display field names for this data type.
-    private static final String[] fieldNames = { "Event Number", "Shared Hits", "Component Hits", "Cluster Energy" };
+    private static final String[] fieldNames = { "Event Number", "Shared Hits", "Component Hits", "Cluster Energy", "Cluster Time" };
     
     // Indices for the field values.
-    private static final int EVENT_NUMBER = 0;
-    private static final int SHARED_HITS = 1;
+    private static final int EVENT_NUMBER   = 0;
+    private static final int SHARED_HITS    = 1;
     private static final int COMPONENT_HITS = 2;
     private static final int CLUSTER_ENERGY = 3;
+    private static final int CLUSTER_TIME   = 4;
     
     /**
      * Constructs a new <code>Viewer</code> for displaying data read
@@ -77,7 +78,7 @@
         fileChooser = new JFileChooser(new File("D:\\cygwin64\\home\\Kyle\\background\\compiled\\output\\")); 
         fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
         fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("Text Files", "txt"));
-        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("LCIO Files", "lcio", "slcio"));
+        //fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("LCIO Files", "lcio", "slcio"));
         
         // Add an open file option to the file menu.
         JMenuItem menuOpen = new JMenuItem("Open File", KeyEvent.VK_O);
@@ -160,6 +161,16 @@
                 }
                 else { energy = "---"; }
                 setStatusField(fieldNames[CLUSTER_ENERGY], energy);
+                
+                // Format the cluster time, or account for it if it
+                // doesn't exist.
+                String time;
+                if(activeCluster.getClusterTime() != Double.NaN) {
+                    DecimalFormat formatter = new DecimalFormat("0.####E0");
+                    time = formatter.format(activeCluster.getClusterEnergy());
+                }
+                else { time = "---"; }
+                setStatusField(fieldNames[CLUSTER_TIME], time);
             }
         }
         // Otherwise, clear the field values.

Modified: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/PEventViewer.java
 =============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/PEventViewer.java	(original)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/PEventViewer.java	Tue Sep 15 09:22:33 2015
@@ -87,14 +87,12 @@
 
             // Add component hits to the calorimeter panel.
             for (final Point ch : cluster.getComponentHits()) {
-                this.ecalPanel.addAssociation(new Association(clusterCenter, toPanelPoint(ch),
-                        HIGHLIGHT_CLUSTER_COMPONENT));
+                this.ecalPanel.addAssociation(new Association(clusterCenter, toPanelPoint(ch), HIGHLIGHT_CLUSTER_COMPONENT));
             }
 
             // Add shared hits to the calorimeter panel.
             for (final Point sh : cluster.getSharedHits()) {
-                this.ecalPanel
-                        .addAssociation(new Association(clusterCenter, toPanelPoint(sh), HIGHLIGHT_CLUSTER_SHARED));
+                this.ecalPanel.addAssociation(new Association(clusterCenter, toPanelPoint(sh), HIGHLIGHT_CLUSTER_SHARED));
             }
         }
 

Modified: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/Viewer.java
 =============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/Viewer.java	(original)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/Viewer.java	Tue Sep 15 09:22:33 2015
@@ -63,7 +63,7 @@
     private final JRadioButtonMenuItem[] menuScaling;
     
     // The default field names.
-    private static final String[] defaultFields = { "x Index", "y Index", "Cell Value" };
+    private static final String[] defaultFields = { "x Index", "y Index", "Energy" };
     
     // The default crystal color.
     private static final Color DEFAULT_CRYSTAL_COLOR = Color.GRAY;