View Javadoc

1   /*
2    * Cell3D.java
3    *
4    * Created on April 4, 2006, 11:11 AM
5    *
6    * $Id: $
7    */
8   
9   package org.lcsim.recon.cluster.localequivalence;
10  
11  import org.lcsim.event.CalorimeterHit;
12  
13  /**
14   * A Cell based on a CalorimeterHit
15   * 
16   * @author Norman Graf
17   */
18  public class Cell3D extends Cell
19  {
20      private double _value;
21      private Cell _pointsTo;
22      private Cell _pointedTo;
23      private CalorimeterHit _calhit;
24      
25      
26      /** Basic Constructor
27       * @param value The value of this Cell.
28       */
29      public Cell3D(double value)
30      {
31          _value = value;
32          _pointsTo = this;
33          _pointedTo = this;
34          _calhit = null;
35      }
36      
37      /**
38       * @param value The value of this Cell.
39       * @param hit   The CalorimeterHit on which this Cell is based.
40       */
41      public Cell3D(double value, CalorimeterHit hit)
42      {
43          _value = value;
44          _pointsTo = this;
45          _pointedTo = this;
46          _calhit = hit;
47      }
48      
49      /**
50       *
51       * @param hit Assign the CalorimeterHit to this Cell
52       */
53      public Cell3D(CalorimeterHit hit)
54      {
55          _value = hit.getCorrectedEnergy();
56          _pointsTo = this;
57          _pointedTo = this;
58          _calhit = hit;
59      }    
60      
61      public double value()
62      {
63          return _value;
64      }
65      
66      public Cell pointsTo()
67      {
68          return _pointsTo;
69      }
70      
71      public void pointsTo(Cell pointsto)
72      {
73          _pointsTo = pointsto;
74      }
75      
76      public void pointedTo(Cell cell)
77      {
78          _pointedTo = cell;
79      }
80  
81      public long cellID()
82      {
83          return _calhit.getCellID();
84      }
85      
86      public Cell pointedTo()
87      {
88          return _pointedTo;
89      }
90      
91      public String toString()
92      {
93          StringBuffer sb = new StringBuffer(" Cell3D "+cellID()+" with value "+_value+"\n");
94          sb.append("pointed to by: "+_pointedTo.cellID()+"\n");
95          sb.append("points to: "+_pointsTo.cellID()+"\n");
96          return sb.toString();
97     }
98      
99      // Comparable interface
100     public int compareTo(Object o)
101     {
102         double value = ( (Cell3D) o)._value;
103         return (_value < value ? -1 : (_value == value ? 0 : 1));
104     }
105     
106     /**
107      *
108      * @return The CalorimeterHit on which this Cell is based.
109      */
110     public CalorimeterHit getCalorimeterHit()
111     {
112         return _calhit;
113     }
114     
115 }