hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.6 -r1.7
--- HPSNearestNeighborRMS.java 17 May 2012 18:24:10 -0000 1.6
+++ HPSNearestNeighborRMS.java 30 Jul 2012 22:27:09 -0000 1.7
@@ -6,18 +6,17 @@
import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper;
import org.lcsim.event.RawTrackerHit;
-
/**
*
* @author mgraham
*/
public class HPSNearestNeighborRMS implements HPSClusteringAlgorithm {
-
+
private static String _NAME = "NearestNeighborRMS";
private double _seed_threshold;
private double _neighbor_threshold;
- private double _cluster_threshold;
- private double _meanTime=24;
+ private double _cluster_threshold;
+ private double _meanTime = 24;
private double _timeWindow = 48;
private double _maxChisq = 10.0;
@@ -28,14 +27,14 @@
* Cluster threshold is minimum charge of the entire cluster.
* All thresholds are in units of RMS noise of the channel(s).
*
- * @param seed_threshold seed threshhold
+ * @param seed_threshold seed threshold
* @param neighbor_threshold neighbor threshold
* @param cluster_threshold cluster threshold
*/
public HPSNearestNeighborRMS(double seed_threshold, double neighbor_threshold, double cluster_threshold) {
_seed_threshold = seed_threshold;
_neighbor_threshold = neighbor_threshold;
- _cluster_threshold = cluster_threshold;
+ _cluster_threshold = cluster_threshold;
}
/**
@@ -77,42 +76,6 @@
}
/**
- * Return the seed threshold. Units are RMS noise.
- *
- * @return seed threshold
- */
- public double getSeedThreshold() {
- return _seed_threshold;
- }
-
- /**
- * Return the neighbor threshold. Units are RMS noise.
- *
- * @return neighbor threshold
- */
- public double getNeighborThreshold() {
- return _neighbor_threshold;
- }
-
- /**
- * Return the cluster threshold. Units are RMS noise.
- *
- * @return cluster threshold
- */
- public double getClusterThreshold() {
- return _cluster_threshold;
- }
-
- /**
- * Return the name of the clustering algorithm.
- *
- * @return _name clusting algorithm name
- */
- public String getName() {
- return _NAME;
- }
-
- /**
* Find clusters using the nearest neighbor algorithm.
*
* @param base_hits List of RawTrackerHits to be clustered
@@ -138,8 +101,8 @@
// Loop over the raw hits and construct the maps used to relate cells and hits, initialize the
// clustering status map, and create a list of possible cluster seeds
for (HPSFittedRawTrackerHit base_hit : base_hits) {
-
- RawTrackerHit rth=base_hit.getRawTrackerHit();
+
+ RawTrackerHit rth = base_hit.getRawTrackerHit();
// get the channel number for this hit
SiTrackerIdentifierHelper sid_helper = (SiTrackerIdentifierHelper) rth.getIdentifierHelper();
IIdentifier id = rth.getIdentifier();
@@ -147,13 +110,13 @@
// Check for duplicate RawTrackerHit
if (hit_to_channel.containsKey(base_hit)) {
- throw new RuntimeException("Duplicate hit: "+id.toString());
+ throw new RuntimeException("Duplicate hit: " + id.toString());
}
// Check for duplicate RawTrackerHits or channel numbers
if (channel_to_hit.containsKey(channel_number)) {
// throw new RuntimeException("Duplicate channel number: "+channel_number);
- System.out.println("Duplicate channel number: "+channel_number);
+ System.out.println("Duplicate channel number: " + channel_number);
}
// Add this hit to the maps that relate channels and hits
@@ -162,13 +125,13 @@
// Get the signal from the readout chip
double signal = base_hit.getAmp();
- double noiseRMS = HPSSVTCalibrationConstants.getNoise((SiSensor)rth.getDetectorElement(),channel_number);
- double time=base_hit.getT0();
+ double noiseRMS = HPSSVTCalibrationConstants.getNoise((SiSensor) rth.getDetectorElement(), channel_number);
+ double time = base_hit.getT0();
// Mark this hit as available for clustering if it is above the neighbor threshold
- clusterable.put(channel_number, signal/noiseRMS >= _neighbor_threshold);
+ clusterable.put(channel_number, signal / noiseRMS >= _neighbor_threshold);
// Add this hit to the list of seeds if it is above the seed threshold
- if (signal/noiseRMS >= _seed_threshold&&passTimingCut(base_hit) && passChisqCut(base_hit)) {
+ if (signal / noiseRMS >= _seed_threshold && passTimingCut(base_hit) && passChisqCut(base_hit)) {
cluster_seeds.add(channel_number);
}
}
@@ -180,7 +143,9 @@
for (int seed_channel : cluster_seeds) {
// First check if this hit is still available for clustering
- if (!clusterable.get(seed_channel)) continue;
+ if (!clusterable.get(seed_channel)) {
+ continue;
+ }
// Create a new cluster
List<HPSFittedRawTrackerHit> cluster = new ArrayList<HPSFittedRawTrackerHit>();
@@ -201,7 +166,7 @@
int clustered_cell = unchecked.removeFirst();
cluster.add(channel_to_hit.get(clustered_cell));
cluster_signal += channel_to_hit.get(clustered_cell).getAmp();
- cluster_noise_squared += Math.pow(HPSSVTCalibrationConstants.getNoise((SiSensor)(channel_to_hit.get(clustered_cell)).getRawTrackerHit().getDetectorElement(),clustered_cell),2);
+ cluster_noise_squared += Math.pow(HPSSVTCalibrationConstants.getNoise((SiSensor) (channel_to_hit.get(clustered_cell)).getRawTrackerHit().getDetectorElement(), clustered_cell), 2);
// cluster_noise_squared +=0; //need to get the noise from the calib. const. class
// Get the neigbor channels
// Set<Integer> neighbor_channels = electrodes.getNearestNeighborCells(clustered_cell);
@@ -214,10 +179,14 @@
Boolean addhit = clusterable.get(channel);
// If the map entry is null, there is no raw hit for this channel
- if (addhit == null) continue;
+ if (addhit == null) {
+ continue;
+ }
// Check if this neighbor channel is still available for clustering
- if (!addhit) continue;
+ if (!addhit) {
+ continue;
+ }
// Add channel to the list of unchecked clustered channels
// and mark it unavailable for clustering
@@ -228,9 +197,8 @@
} // end of loop over unchecked cells
// Finished with this cluster, check cluster threshold and add it to the list of clusters
- if (cluster.size() > 0 &&
- cluster_signal/Math.sqrt(cluster_noise_squared) > _cluster_threshold)
- {
+ if (cluster.size() > 0
+ && cluster_signal / Math.sqrt(cluster_noise_squared) > _cluster_threshold) {
cluster_list.add(cluster);
}
@@ -238,43 +206,44 @@
// Finished finding clusters
return cluster_list;
- }
-
- private boolean passTimingCut(HPSFittedRawTrackerHit hit){
-
- boolean pass=false;
- double time=hit.getT0();
- if(Math.abs(time-_meanTime)<_timeWindow)
+ }
+
+ private boolean passTimingCut(HPSFittedRawTrackerHit hit) {
+
+ boolean pass = false;
+ double time = hit.getT0();
+ if (Math.abs(time - _meanTime) < _timeWindow) {
pass = true;
-
+ }
+
return pass;
}
-
- private boolean passChisqCut(HPSFittedRawTrackerHit hit){
+
+ private boolean passChisqCut(HPSFittedRawTrackerHit hit) {
return hit.getShapeFitParameters().getChiSq() < _maxChisq;
}
-
- public int getNeighborCell(int cell, int ncells_0, int ncells_1)
- {
+
+ public int getNeighborCell(int cell, int ncells_0, int ncells_1) {
int neighbor_cell = cell + ncells_0;
- if (isValidCell(neighbor_cell)) return neighbor_cell;
- else return -1;
+ if (isValidCell(neighbor_cell)) {
+ return neighbor_cell;
+ } else {
+ return -1;
+ }
}
-
- public Set<Integer> getNearestNeighborCells(int cell)
- {
+
+ public Set<Integer> getNearestNeighborCells(int cell) {
Set<Integer> neighbors = new HashSet<Integer>();
- for (int ineigh = -1 ; ineigh <= 1; ineigh=ineigh+2)
- {
- int neighbor_cell = getNeighborCell(cell,ineigh,0);
- if (isValidCell(neighbor_cell)) neighbors.add(neighbor_cell);
+ for (int ineigh = -1; ineigh <= 1; ineigh = ineigh + 2) {
+ int neighbor_cell = getNeighborCell(cell, ineigh, 0);
+ if (isValidCell(neighbor_cell)) {
+ neighbors.add(neighbor_cell);
+ }
}
return neighbors;
}
-
-
- public boolean isValidCell(int cell)
- {
+
+ public boolean isValidCell(int cell) {
return (cell >= 0 && cell < HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR);
}
}
hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.8 -r1.9
--- HPSHelicalTrackHitDriver.java 24 May 2012 17:29:38 -0000 1.8
+++ HPSHelicalTrackHitDriver.java 30 Jul 2012 22:27:09 -0000 1.9
@@ -62,7 +62,7 @@
// private StereoHitMaker _crosser = new StereoHitMaker(2., 10.);
private boolean _debug = false;
- private StereoHitMaker _crosser = new StereoHitMaker(0.0, 10.);
+ private StereoHitMaker _crosser = new StereoHitMaker(0.01, 10.01);
private HitIdentifier _ID = new HitIdentifier();
private String _outname = "HelicalTrackHits";
private String _hitrelname = "HelicalTrackHitRelations";
@@ -70,8 +70,6 @@
private List<String> _colnames = new ArrayList<String>();
private Map<String, String> _stereomap = new HashMap<String, String>();
private Hep3Vector _orgloc = new BasicHep3Vector(0., 0., 0.);
- private double _eps = 1.0e-6;
- private SymmetricMatrix _covTrkSystem;
private boolean _doTranformToTracking = true;
private HPSTransformations _detToTrk;
String subdetectorName = "Tracker";
@@ -83,8 +81,6 @@
// setDetToTrkMatrix();
_detToTrk = new HPSTransformations();
_colnames.add("StripClusterer_SiTrackerHitStrip1D");
- _crosser.setMaxSeparation(10.01);
- _crosser.setTolerance(0.01); // user parameter?
}
public void setSubdetectorName(String subdetectorName) {
@@ -217,15 +213,6 @@
System.out.println("Number of stereo hits = " + stereohits.size());
}
- for (HelicalTrackCross htc : stereohits) {
- double ypos = htc.x();
- double zpos = htc.z();
- List<HelicalTrackStrip> htstrips = htc.getStrips();
- for (HelicalTrackStrip hts : htstrips) {
- }
- }
-
-
// Add the stereo hits to our list of HelicalTrackHits
helhits.addAll(stereohits);
//mg...6/24/11 add new set of helical track hits that are rotated to from jlab to tracking frame