View Javadoc

1   package org.lcsim.event;
2   
3   import java.util.Comparator;
4   
5   /**
6    * <p>
7    * This class represents a hit in a calorimeter detector which has an energy 
8    * deposition in GeV, a time in nanoseconds, and an ID identifying its cell
9    * or channel in the detector.
10   * <p>
11   * The super-interface gives access to subdetector, identifiers, iddecoder, etc.
12   * @see org.lcsim.event.Hit
13   * 
14   * @author Tony Johnson <tonyj@slac.stanford.edu>
15   * @author Jeremy McCormick <jeremym@slac.stanford.edu>
16   */
17  public interface CalorimeterHit extends Hit {
18      
19     /**
20      * Get the raw energy deposition in GeV.
21      * @return The raw energy deposition.
22      */
23     public double getRawEnergy();
24     
25     /**
26      * Get the corrected energy deposition in GeV.
27      * @return The corrected energy deposition
28      */
29     public double getCorrectedEnergy();
30     
31     /**
32      * Get the energy error.  (Units???)
33      * @return The energy error.
34      */
35     public double getEnergyError();
36     
37     /**
38      * Get the ID of the cell or channel. 
39      * This can be converted to a physical position using a IDDecoder object obtained from the hit
40      * or from the collection's MetaData object.
41      * @return The cell or channel ID of the hit.
42      */
43     public long getCellID();
44     
45     /**
46      * Get the time of the <b>earliest</b> energy contribution to this hit in nanoseconds.
47      * @return The hit time in nanoseconds.
48      */
49     public double getTime();
50  
51     /**
52      * Get the position of the hit in millimeters with the global coordinate system. 
53      * If the hit position is stored in the LCIO data, this will be returned directly. 
54      * Otherwise the IDDecoder is used to get the hit position from the hit ID.
55      * @return The position in millimeters as a double array of length 3.
56      */
57     public double[] getPosition();
58  
59     /**
60      * Get the type of the hit.
61      * Mapping of integer types to type names through collection parameters
62      * "CalorimeterHitTypeNames" and "CalorimeterHitTypeValues".
63      * @return The type of the hit.
64      */
65     public int getType();
66     
67     /**
68      * CalorimeterHit corrected energy comparator.
69      */
70     public static class CorrectedEnergyComparator implements Comparator<CalorimeterHit> {
71         /**
72          * Compare the corrected energy of the hits using the <code>Double.compare</code> method.
73          * @return -1 if o1's energy is less than o2's, 1 if o1's is greater than o2's, and 0 if equal.
74          */
75         @Override
76         public int compare(CalorimeterHit o1, CalorimeterHit o2) {
77             return Double.compare(o1.getCorrectedEnergy(), o2.getCorrectedEnergy());
78         }
79     }   
80     
81     /**
82      * CalorimeterHit raw energy comparator.
83      */
84     public static class RawEnergyComparator implements Comparator<CalorimeterHit> {
85         /**
86          * Compare the raw energy of the hits using the <code>Double.compare</code> method.
87          * @return -1 if o1's energy is less than o2's, 1 if o1's is greater than o2's, and 0 if equal.
88          */
89         @Override
90         public int compare(CalorimeterHit o1, CalorimeterHit o2) {
91             return Double.compare(o1.getRawEnergy(), o2.getRawEnergy());
92         }
93     }   
94     
95     /**
96      * CalorimeterHit time comparator.
97      */
98     static class TimeComparator implements Comparator<CalorimeterHit> {
99         /**
100         * Compare the time of the hits using the <code>Double.compare</code> method.
101         * @return -1 if o1's time is less than o2's, 1 if o1's is greater than o2's, and 0 if equal.
102         */
103        @Override
104        public int compare(CalorimeterHit o1, CalorimeterHit o2) {
105            return Double.compare(o1.getTime(), o2.getTime());
106        }
107    }
108    
109 }