View Javadoc

1   package org.lcsim.recon.tracking.vsegment.hit.base;
2   
3   import java.util.List;
4   import java.util.ArrayList;
5   
6   import org.lcsim.event.MCParticle;
7   
8   import org.lcsim.recon.tracking.vsegment.geom.Sensor;
9   import org.lcsim.recon.tracking.vsegment.hit.DigiTrackerHit;
10  
11  /**
12   * Adapter class that provides partial implementation of {@link DigiTrackerHit} interface. 
13   *
14   * @author D.Onoprienko
15   * @version $Id: DigiTrackerHitAdapter.java,v 1.1 2008/12/06 21:53:44 onoprien Exp $
16   */
17  abstract public class DigiTrackerHitAdapter implements DigiTrackerHit {
18    
19  // -- Getters :  ---------------------------------------------------------------
20  
21    /** 
22     * Returns signal in the channel.
23     * The signal value is the digitization algorithm output if running on Monte Carlo,
24     * calibrated and corrected signal if runnung on data.
25     */
26    public double getSignal() {return _signal;}
27  
28    /** Returns time associated with the hit. */
29    public double getTime() {return _time;}
30  
31    /** Returns {@link Sensor} object this hit belongs to. */
32    public Sensor getSensor() {return _sensor;}
33    
34    /** Returns channel ID on the sensor. */
35    public int getChannel() {return _channel;}
36    
37    /**
38     * Defines natural ordering of hits based on their sensor and channel ID.
39     * If sensor IDs are equal, the ordering is based on channel ID. If channel IDs
40     * are equal, too, then the ordering is based on hash codes to make it stable 
41     * and consistent with equals.
42     */
43    public int compareTo(DigiTrackerHit hit) {
44      if (getSensor() == hit.getSensor()) {
45        if (getChannel() == hit.getChannel()) {
46          return hashCode() - hit.hashCode();
47        } else {
48          return getChannel() - hit.getChannel();
49        }
50      } else {
51        return getSensor().getID() - hit.getSensor().getID();
52      }
53    }
54    
55  // -- Private parts :  ---------------------------------------------------------
56    
57    protected double _signal;
58    protected double _time;
59    protected Sensor _sensor;
60    protected int _channel;
61  
62  }