Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

import java.util.List;

import org.lcsim.event.LCRelation;

/**
* An interface for finding clusters of RawTrackerHits on a sensor.
* @author Matt Graham
* An interface for finding clusters of hits on a sensor.
*/
public interface ClusteringAlgorithm {

/**
* Finds the clusters given a list of RawTrackerHits on a particular silicon sensor with
* electrodes given by SiSensorElectrodes. A list of clusters is returned, with each cluster
* being a list of RawTrackerHits the form the cluster.
* Finds clusters given a list of hits on sensor.
*
* @param hits base hits
* @return list of clusters, with each cluster being a list of RawTrackerHits
* @param hits Collection of hits to cluster. Most algorithms will use
* fitted hits which are persited as LCRelations between the
* RawTrackerHit and the resulting fit parameters.
* @return List of clusters, with each cluster being a list of LCRelations
*/
public List<List<FittedRawTrackerHit>> findClusters(List<FittedRawTrackerHit> hits);
public List< List< LCRelation > > findClusters(List< LCRelation > hits);

}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
package org.hps.recon.tracking;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.tracker.silicon.SiSensor;
import org.lcsim.event.EventHeader;
import org.lcsim.event.LCRelation;
import org.lcsim.event.SimTrackerHit;
import org.lcsim.geometry.Detector;
import org.lcsim.lcio.LCIOUtil;
import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit;
import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
import org.lcsim.util.Driver;

/**
*
* @author Matt Graham
*/
// TODO: Add documentation about what this Driver does. --JM
public class DataTrackerHitDriver extends Driver {

// Debug switch for development.
private boolean debug = false;
// Collection name.
private String readoutCollectionName = "TrackerHits";

// Subdetector name.
private String subdetectorName = "Tracker";
// Name of FittedTrackerHit output collection.
private String fittedTrackerHitCollectionName = "SVTFittedRawTrackerHits";

// Name of StripHit1D output collection.
private String stripHitOutputCollectionName = "StripClusterer_SiTrackerHitStrip1D";

// Clustering parameters.
private double clusterSeedThreshold = 4.0;
private double clusterNeighborThreshold = 3.0;
Expand All @@ -44,26 +32,25 @@ public class DataTrackerHitDriver extends Driver {
private double neighborDeltaT = 24.0;
private int clusterMaxSize = 10;
private int clusterCentralStripAveragingThreshold = 4;

// Clustering errors by number of TrackerHits.
private static final double clusterErrorMultiplier = 1.0;
private double oneClusterErr = clusterErrorMultiplier / Math.sqrt(12.);
private double twoClusterErr = clusterErrorMultiplier / 5.0;
private double threeClusterErr = clusterErrorMultiplier / 3.0;
private double fourClusterErr = clusterErrorMultiplier / 2.0;
private double fiveClusterErr = clusterErrorMultiplier / 1.0;
// weight the hits in a cluster by charge? (if not, all hits have equal weight)

// Weight the hits in a cluster by charge? (if not, all hits have equal
// weight)
private boolean useWeights = true;
// Various data lists required by digitization.
private List<String> processPaths = new ArrayList<String>();
private List<IDetectorElement> processDEs = new ArrayList<IDetectorElement>();
private Set<SiSensor> processSensors = new HashSet<SiSensor>();
// Digi class objects.
// private SiDigitizer stripDigitizer;
// private HPSFittedRawTrackerHitMaker hitMaker;
private StripMaker stripClusterer;
// private DumbShaperFit shaperFit;
int[] counts = new int[14];

// Clusterer
private StripMaker stripClusterer;

// List of sensors to process
private List<SiSensor> sensors;

//If flag is false do not save the StripCluster Collection if bigger than threshold (to remove monster events)
private boolean saveMonsterEvents = true;

Expand All @@ -75,9 +62,6 @@ public void setDebug(boolean debug) {
this.debug = debug;
}

// public void setReadoutCollectionName(String readoutCollectionName) {
// this.readoutCollectionName = readoutCollectionName;
// }
public void setSubdetectorName(String subdetectorName) {
this.subdetectorName = subdetectorName;
}
Expand Down Expand Up @@ -162,23 +146,9 @@ public DataTrackerHitDriver() {
@Override
public void detectorChanged(Detector detector) {

// Call sub-Driver's detectorChanged methods.
super.detectorChanged(detector);

// Process detectors specified by path, otherwise process entire
// detector
IDetectorElement deDetector = detector.getDetectorElement();

for (String path : processPaths)
processDEs.add(deDetector.findDetectorElement(path));

if (processDEs.isEmpty())
processDEs.add(deDetector);

for (IDetectorElement detectorElement : processDEs)
processSensors.addAll(detectorElement.findDescendants(SiSensor.class)); // if (debug)
// System.out.println("added " + processSensors.size() + " sensors");

// Get the collection of sensors to process
sensors = detector.getSubdetector("Tracker").getDetectorElement().findDescendants(SiSensor.class);

// Create the sensor simulation.
CDFSiSensorSim stripSim = new CDFSiSensorSim();

Expand All @@ -191,15 +161,12 @@ public void detectorChanged(Detector detector) {
stripClusteringAlgo.setTimeWindow(timeWindow);
stripClusteringAlgo.setNeighborDeltaT(neighborDeltaT);

// hitMaker=new HPSFittedRawTrackerHitMaker(shaperFit);
// Create the clusterers and set hit-making parameters.
stripClusterer = new StripMaker(stripSim, stripClusteringAlgo);

stripClusterer.setMaxClusterSize(clusterMaxSize);
stripClusterer.setCentralStripAveragingThreshold(clusterCentralStripAveragingThreshold);
stripClusterer.setDebug(debug);
// Set the cluster errors.

// Set the cluster errors.
DefaultSiliconResolutionModel model = new DefaultSiliconResolutionModel();

model.setOneClusterErr(oneClusterErr);
Expand All @@ -210,37 +177,20 @@ public void detectorChanged(Detector detector) {
model.setUseWeights(useWeights);

stripClusterer.setResolutionModel(model);

// Set the detector to process.
processPaths.add(subdetectorName);
}

/**
* Perform the digitization.
*/
@Override
public void process(EventHeader event) {
// Call sub-Driver processing.
// super.process(event);

// Make new lists for output.
// Create the collection of 1D strip hits
List<SiTrackerHit> stripHits1D = new ArrayList<SiTrackerHit>();

// Make strip hits.
for (SiSensor sensor : processSensors)
stripHits1D.addAll(stripClusterer.makeHits(sensor));

// Debug prints.
if (debug) {
if (event.hasCollection(SimTrackerHit.class, this.readoutCollectionName))
System.out.println("SimTrackerHit collection " + this.readoutCollectionName
+ " has " + event.get(SimTrackerHit.class, this.readoutCollectionName).size() + " hits.");
if (event.hasCollection(FittedRawTrackerHit.class, fittedTrackerHitCollectionName))
System.out.println("FittedRawTrackerHit collection "
+ this.fittedTrackerHitCollectionName + " has " + event.get(LCRelation.class, fittedTrackerHitCollectionName).size() + " hits.");
System.out.println("TrackerHit collection " + this.stripHitOutputCollectionName + " has " + stripHits1D.size() + " hits.");
}

// Cluster fitted raw hits
for (SiSensor sensor : sensors) stripHits1D.addAll(stripClusterer.makeHits(sensor));

if (debug)
System.out.println("[ DataTrackerHitDriver ] - " + this.stripHitOutputCollectionName + " has " + stripHits1D.size() + " hits.");

Expand All @@ -252,16 +202,6 @@ public void process(EventHeader event) {
int flag = LCIOUtil.bitSet(0, 31, true); // Turn on 64-bit cell ID.
event.put(this.stripHitOutputCollectionName, stripHits1D, SiTrackerHitStrip1D.class, 0, toString());

for (SiTrackerHit stripHit : stripHits1D)
counts[((SiTrackerHitStrip1D) stripHit).getRawHits().get(0).getLayerNumber()-1]++;

}

@Override
public void endOfData() {
if (debug)

for (int layer = 0; layer < 14; layer++)
System.out.format("layer %d, count %d\n",layer, counts[layer]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
import org.lcsim.detector.tracker.silicon.SiStrips;
import org.lcsim.detector.tracker.silicon.SiStriplets;
import org.lcsim.event.LCRelation;

import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
Expand All @@ -15,7 +16,7 @@
public class DefaultSiliconResolutionModel implements SiliconResolutionModel{

@Override
public double getMeasuredResolution(List<FittedRawTrackerHit> cluster, SiSensorElectrodes electrodes)
public double getMeasuredResolution(List< LCRelation > cluster, SiSensorElectrodes electrodes)

{
double measured_resolution;
Expand Down Expand Up @@ -51,13 +52,13 @@ public double getMeasuredResolution(List<FittedRawTrackerHit> cluster, SiSensorE
// be handled differently because it does not inherit from SiStrips.
// To clean this up, the getStripLength method should be added to
// SiSensorElectrodes. This would elimininate the need for casting.
public double getUnmeasuredResolution(List<FittedRawTrackerHit> cluster, SiSensorElectrodes electrodes, Map<FittedRawTrackerHit, Integer> strip_map) {
public double getUnmeasuredResolution(List< LCRelation > cluster, SiSensorElectrodes electrodes, Map<LCRelation, Integer> strip_map) {
// Get length of longest strip in hit

if (electrodes instanceof SiStriplets) return ((SiStriplets) electrodes).getStripLength(strip_map.get(cluster.get(0)));

double hit_length = 0;
for (FittedRawTrackerHit hit : cluster) {
for (LCRelation hit : cluster) {
hit_length = Math.max(hit_length, ((SiStrips) electrodes).getStripLength(strip_map.get(hit)));
}
return hit_length / Math.sqrt(12);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* @version $Id: HPSFittedRawTrackerHit.java,v 1.3 2013/04/16 22:05:43 phansson
* Exp $
*/
// TODO: Add class documentation.
public class FittedRawTrackerHit extends BaseLCRelation {

public FittedRawTrackerHit(RawTrackerHit hit, ShapeFitParameters fit) {
Expand Down Expand Up @@ -50,6 +49,16 @@ public static double getAmp(LCRelation rel) {
return ShapeFitParameters.getAmp(getShapeFitParameters(rel));
}

/**
* Get the fit chi2 probability.
*
* @param relation The relation between a RawTrackerHit and
* ShapeFitParameter.
*/
public static double getChi2Prob(LCRelation relation) {
return ShapeFitParameters.getChiProb(getShapeFitParameters(relation));
}

@Override
public String toString() {
return String.format("HPSFittedRawTrackerHit: hit cell id %d on sensor %s with fit %s\n", this.getRawTrackerHit().getCellID(), getRawTrackerHit().getDetectorElement().getName(), this.getShapeFitParameters().toString());
Expand Down
Loading