View Javadoc

1   package org.lcsim.plugin.browser;
2   
3   
4   
5   import org.lcsim.event.CalorimeterHit;
6   import org.lcsim.event.SimCalorimeterHit;
7   import org.lcsim.geometry.IDDecoder;
8   
9   /**
10   * @author tonyj
11   */
12  class SimCalorimeterHitTableModel extends CellIDTableModel
13  {
14      private static final String[] defaultColumns =
15      { "ID", "raw energy (GeV)", "corrected energy (GeV)", "X (mm)", "Y (mm)", "Z (mm)", "time (ns)" };
16  
17      SimCalorimeterHitTableModel()
18      {
19         super(defaultColumns);
20      }
21      
22      public boolean canDisplay(Class c)
23      {
24          return SimCalorimeterHit.class.isAssignableFrom(c);
25      }
26  
27      public Class getColumnClass(int row)
28      {
29          return row < getFieldCount() ? (getIDDecoder() == null) ? Long.class : Integer.class : Double.class;
30      }
31  
32      public Object getValueAt(int row, int column)
33      {
34          CalorimeterHit hit = (CalorimeterHit) getHit(row);
35          int fieldCount = getFieldCount();
36  
37          if (column < fieldCount)
38          {
39              IDDecoder decoder = getIDDecoder();
40              if (decoder != null) decoder.setID(hit.getCellID());
41              return decoder == null ? hit.getCellID() : decoder.getValue(column);
42          }
43          else
44          {
45              switch (column - fieldCount)
46              {
47                  case 0:
48                      return hit.getRawEnergy();
49                  case 1:
50                      double cE = java.lang.Double.NaN;
51                      try
52                      {
53                          cE = hit.getCorrectedEnergy();
54                      }
55                      catch (Exception e)
56                      {
57                      }
58                      return cE;
59                  case 2:
60                      return hit.getPosition()[0];
61                  case 3:
62                      return hit.getPosition()[1];
63                  case 4:
64                      return hit.getPosition()[2];
65                  case 5:
66                      return hit.getTime();
67                  default:
68                      return " ";
69              }
70          }
71      }
72  }