View Javadoc

1   package org.lcsim.recon.tracking.seedtracker;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.lcsim.fit.helicaltrack.HelicalTrack2DHit;
7   import org.lcsim.fit.helicaltrack.HelicalTrackHit;
8   import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
9   
10  /**
11   *
12   * @author Richard Partridge
13   */
14  public class Sector {
15      private String _identifier;
16      private String _layerID;
17      private List<HelicalTrackHit> _hitlist;
18      private int _phisector;
19      private int _zsector;
20      private double _rmin;
21      private double _rmax;
22      private double _phimin;
23      private double _phimax;
24      private double _zmin;
25      private double _zmax;
26      private double _philo;
27      private double _phihi;
28      private double _zlo;
29      private double _zhi;
30  
31      public Sector(String identifier, String layerID, int phisector, int zsector,
32              double philo, double phihi, double zlo, double zhi) {
33  
34          //  Save the identifier, indices, and limits for this sector
35          _identifier = identifier;
36          _layerID = layerID;
37          _phisector = phisector;
38          _zsector = zsector;
39          _philo = philo;
40          _phihi = phihi;
41          _zlo = zlo;
42          _zhi = zhi;
43  
44          //  Initialize the hit list
45          _hitlist = new ArrayList<HelicalTrackHit>();
46  
47          //  Initialize the geographic region encompassed by hits in this sector
48          _rmin = 99999.;
49          _rmax = 0.;
50          _phimin = 2.0 * Math.PI;
51          _phimax = 0.0;
52          _zmin = 99999.;
53          _zmax = -99999.;
54      }
55  
56      public void addHit(HelicalTrackHit hit) {
57  
58          //  Check the layerID matches
59          if (!hit.getLayerIdentifier().equals(_layerID)) SectorError();
60  
61          //  Check that phi is within limits
62          double phi = hit.phi();
63          if (phi < _philo || phi > _phihi) SectorError();
64  
65          //  Check that z is within limits
66          double z;
67          if (hit.BarrelEndcapFlag() == BarrelEndcapFlag.BARREL) {
68              z = hit.z();
69          } else {
70              z = hit.r();
71          }
72          if (z < _zlo || z > _zhi) SectorError();
73  
74          //  Add the hit to the list for this sector
75          _hitlist.add(hit);
76  
77          //  Get the location of this hit
78          double r = hit.r();
79          double zmin = hit.z();
80          double zmax = zmin;
81          if (hit instanceof HelicalTrack2DHit) {
82              HelicalTrack2DHit hit2d = (HelicalTrack2DHit) hit;
83              zmin = hit2d.zmin();
84              zmax = hit2d.zmax();
85          }
86  
87          //  Update the span in location for hits in this sector
88          _rmin = Math.min(_rmin, r);
89          _rmax = Math.max(_rmax, r);
90          _phimin = Math.min(_phimin, phi);
91          _phimax = Math.max(_phimax, phi);
92          _zmin = Math.min(_zmin, zmin);
93          _zmax = Math.max(_zmax, zmax);
94      }
95  
96      public String Identifier() {
97          return _identifier;
98      }
99  
100     public String LayerID() {
101         return _layerID;
102     }
103 
104     public List<HelicalTrackHit> Hits() {
105         return _hitlist;
106     }
107 
108     public double rmin() {
109         return _rmin;
110     }
111 
112     public double rmax() {
113         return _rmax;
114     }
115 
116     public double phimin() {
117         return _phimin;
118     }
119 
120     public double phimax() {
121         return _phimax;
122     }
123 
124     public double zmin() {
125         return _zmin;
126     }
127 
128     public double zmax() {
129         return _zmax;
130     }
131 
132     public int phiSector() {
133         return _phisector;
134     }
135     
136     public int zSector() {
137         return _zsector;
138     }
139     
140     public double philo() {
141         return _philo;
142     }
143     
144     public double phihi() {
145         return _phihi;
146     }
147     
148     public double zlo() {
149         return _zlo;
150     }
151     
152     public double zhi() {
153         return _zhi;
154     }
155 
156     private void SectorError() {
157         throw new RuntimeException("Hit Sectoring error");
158     }
159 }