hps-java/src/main/java/org/lcsim/hps/users/omoreno
diff -u -r1.5 -r1.6
--- SvtTrackRecoEfficiency.java 2 Oct 2012 06:15:52 -0000 1.5
+++ SvtTrackRecoEfficiency.java 18 Oct 2012 02:43:31 -0000 1.6
@@ -13,22 +13,26 @@
//--- aida ---//
import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
import hep.aida.IPlotter;
+import hep.physics.vec.BasicHep3Vector;
//--- hep ---//
import hep.physics.vec.Hep3Vector;
import hep.physics.vec.VecOp;
+import org.lcsim.recon.tracking.seedtracker.SeedStrategy;
+import org.lcsim.recon.tracking.seedtracker.StrategyXMLUtils;
//--- lcsim ---//
import org.lcsim.util.Driver;
import org.lcsim.util.aida.AIDA;
import org.lcsim.detector.tracker.silicon.SiSensor;
import org.lcsim.event.EventHeader;
import org.lcsim.event.MCParticle;
+import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.RelationalTable;
import org.lcsim.event.SimTrackerHit;
-import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.Track;
import org.lcsim.event.base.BaseRelationalTable;
import org.lcsim.fit.helicaltrack.HelicalTrackCross;
@@ -36,6 +40,7 @@
import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
import org.lcsim.geometry.Detector;
+import org.lcsim.hps.recon.tracking.FindableTrack.Ignore;
import org.lcsim.hps.recon.tracking.HPSFittedRawTrackerHit;
//--- hps-java ---//
import org.lcsim.hps.recon.tracking.SvtUtils;
@@ -46,30 +51,34 @@
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtTrackRecoEfficiency.java,v 1.5 2012/10/02 06:15:52 omoreno Exp $
+ * @version $Id: SvtTrackRecoEfficiency.java,v 1.6 2012/10/18 02:43:31 omoreno Exp $
*/
public class SvtTrackRecoEfficiency extends Driver {
private AIDA aida;
private List<IPlotter> plotters = new ArrayList<IPlotter>();
- private List<IHistogram1D> histo1D = new ArrayList<IHistogram1D>();
- private List<SimTrackerHit> simTrackerHits = new ArrayList<SimTrackerHit>();
+ private List<IHistogram1D> histo1D = new ArrayList<IHistogram1D>();
+ private List<IHistogram2D> histo2D = new ArrayList<IHistogram2D>();
+ private Map<Integer, List<SimTrackerHit>> topSimTrackerHitsList = new HashMap<Integer, List<SimTrackerHit>>();
+ private Map<Integer, List<SimTrackerHit>> bottomSimTrackerHitsList = new HashMap<Integer, List<SimTrackerHit>>();
TrackUtils trkUtils = new TrackUtils();
FindableTrack findable = null;
TrackAnalysis trkAnalysis = null;
RelationalTable<SimTrackerHit, MCParticle> simHitToMcParticle;
+ RelationalTable<SimTrackerHit, RawTrackerHit> simHitToRawHit;
BufferedWriter efficiencyOutput = null;
BufferedWriter momentumOutput = null;
// Collection Names
String simTrackerHitCollectionName = "TrackerHits";
String rawTrackerHitCollectionName = "SVTRawTrackerHits";
+ String fittedRawTrackerHitCollectionName = "SVTFittedRawTrackerHits";
String trackCollectionName = "MatchedTracks";
String stereoHitCollectionName = "RotatedHelicalTrackHits";
int eventNumber = 0;
- int plotterIndex, histo1DIndex;
+ int plotterIndex, histo1DIndex, histo2DIndex;
int[] topSimTrackerHits;
int[] bottomSimTrackerHits;
double findableTracks, foundTracks;
@@ -79,11 +88,13 @@
String efficiencyOutputFile = null;
String momentumOutputFile = null;
-
+ String strategyResourcePath = null;
+
boolean debug = false;
boolean trackingEfficiencyPlots = true;
boolean trackMatch = false;
boolean trackIsFindable = false;
+ boolean isTopTrack = false;
/**
* Enable/Disable debug
@@ -96,27 +107,47 @@
/**
* Set the name of the file to output efficiency data to
*/
- public void setEfficiencyOutputFile(String efficiencyOutputFile){
+ public void setEfficiencyOutputFile(String efficiencyOutputFile)
+ {
this.efficiencyOutputFile = efficiencyOutputFile;
}
/**
* Set the name of the file to output momentum data to
*/
- public void setMomentumOutputFile(String momentumOutputFile){
+ public void setMomentumOutputFile(String momentumOutputFile)
+ {
this.momentumOutputFile = momentumOutputFile;
}
/**
* Set the required number of layers an MC particle must hit
*/
- public void setTotalLayersHit(int totalLayersHit){
+ public void setTotalLayersHit(int totalLayersHit)
+ {
if(totalLayersHit%2 == 1) throw new RuntimeException(this.getClass().getSimpleName() + ": Total number of layers hit must be even");
this.totalLayersHit = totalLayersHit;
}
/**
*
+ * @param strategyResource
+ */
+ public void setStrategyResourcePath(String strategyResourcePath)
+ {
+ this.strategyResourcePath = strategyResourcePath;
+ }
+
+ /**
+ * Print debug
+ */
+ private void printDebug(String message)
+ {
+ System.out.println(this.getClass().getSimpleName() + ": " + message);
+ }
+
+ /**
+ *
*/
protected void detectorChanged(Detector detector)
{
@@ -136,6 +167,12 @@
}
}
+ // Initialize the Layer to RawTrackerHit maps
+ for(int index = 0; index < 10; index++){
+ topSimTrackerHitsList.put(index + 1, new ArrayList<SimTrackerHit>());
+ bottomSimTrackerHitsList.put(index + 1, new ArrayList<SimTrackerHit>());
+ }
+
if(trackingEfficiencyPlots){
plotters.add(PlotUtils.setupPlotter("Tracking Efficiency", 0, 0));
histo1D.add(aida.histogram1D("Tracking Efficiency", 60, 0, 6));
@@ -147,6 +184,55 @@
PlotUtils.setup1DRegion(plotters.get(plotterIndex), "Momentum", 0, "Momentum [GeV]", histo1D.get(histo1DIndex));
plotterIndex++;
histo1DIndex++;
+ plotters.add(PlotUtils.setupPlotter("Stereo Hits", 0, 0));
+ histo1D.add(aida.histogram1D("Stereo Hits", 5, 0, 5));
+ PlotUtils.setup1DRegion(plotters.get(plotterIndex), "Stereo Hits", 0, "Number of Stereo Hits", histo1D.get(histo1DIndex));
+ plotterIndex++;
+ histo1DIndex++;
+
+ plotters.add(PlotUtils.setupPlotter("Hit Positions - Missed SimTrackerHits", 5, 4));
+ for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ String title = SvtUtils.getInstance().getDescription(sensor) + " - Hit Positions - Missed SimTrackerHits";
+ if(SvtUtils.getInstance().isTopLayer(sensor)){
+ histo2D.add(aida.histogram2D(title, 50, -50, 50, 50, 0, 50));
+ } else {
+ histo2D.add(aida.histogram2D(title, 50, -50, 50, 50, -50, 0));
+ }
+ PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "x [mm]", "y [mm]", histo2D.get(histo2DIndex));
+ histo2DIndex++;
+ }
+ plotterIndex++;
+
+ plotters.add(PlotUtils.setupPlotter("t0 - Missed SimTrackerHits", 5, 4));
+ for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ String title = SvtUtils.getInstance().getDescription(sensor) + " - t0 - Missed SimTrackerHits";
+ histo1D.add(aida.histogram1D(title, 50, 0, 100));
+ PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "t0 [ns]", histo1D.get(histo1DIndex));
+ histo1DIndex++;
+ }
+ plotterIndex++;
+
+ plotters.add(PlotUtils.setupPlotter("Hit Positions - Found SimTrackerHits", 5, 4));
+ for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ String title = SvtUtils.getInstance().getDescription(sensor) + " - Hit Positions - Found SimTrackerHits";
+ if(SvtUtils.getInstance().isTopLayer(sensor)){
+ histo2D.add(aida.histogram2D(title, 50, -50, 50, 50, 0, 50));
+ } else {
+ histo2D.add(aida.histogram2D(title, 50, -50, 50, 50, -50, 0));
+ }
+ PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "x [mm]", "y [mm]", histo2D.get(histo2DIndex));
+ histo2DIndex++;
+ }
+ plotterIndex++;
+
+ plotters.add(PlotUtils.setupPlotter("t0 - Found SimTrackerHits", 5, 4));
+ for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ String title = SvtUtils.getInstance().getDescription(sensor) + " - t0 - Found SimTrackerHits";
+ histo1D.add(aida.histogram1D(title, 50, 0, 100));
+ PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "t0 [ns]", histo1D.get(histo1DIndex));
+ histo1DIndex++;
+ }
+ plotterIndex++;
}
for(IPlotter plotter : plotters){
@@ -162,57 +248,53 @@
@Override
protected void process(EventHeader event)
{
+
+ if(event.get(Track.class, trackCollectionName).size() > 1) return;
eventNumber++;
- // If the event contains SimTrackerHits store them for later use
- if(event.hasCollection(SimTrackerHit.class, simTrackerHitCollectionName)){
- simTrackerHits.addAll(event.get(SimTrackerHit.class, simTrackerHitCollectionName));
- if(debug){
- System.out.println(this.getClass().getSimpleName() + ": Event: " + eventNumber + " Number of SimTrackerHits: " + simTrackerHits.size());
- System.out.print(this.getClass().getSimpleName() + ": MC Particles: ");
- for(MCParticle mcParticle : event.getMCParticles()){
- System.out.print(mcParticle.getPDGID() + " ");
- }
- System.out.print("\n");
- }
- }
-
- // The SimTrackerHits should not be stored for more than 200 events
- if(eventNumber%200 == 0 && !simTrackerHits.isEmpty()){
- simTrackerHits.clear();
+ // If the event doesn't contain SimTrackerHits, skip the event
+ if(!event.hasCollection(SimTrackerHit.class, simTrackerHitCollectionName)) return;
+ List<SimTrackerHit> simTrackerHits = event.get(SimTrackerHit.class, simTrackerHitCollectionName);
+ if(debug)
+ this.printDebug("Event " + eventNumber + " contains " + simTrackerHits.size() + " SimTrackerHits");
+
+ // Add the SimTrackerHits to its respective sensor readout
+ for(SimTrackerHit simHitTrackerHit : simTrackerHits){
+ ((SiSensor) simHitTrackerHit.getDetectorElement()).getReadout().addHit(simHitTrackerHit);
}
- // Skip the event if it doesn't contain RawTrackerHits; Only interested in triggered events
- if(!event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) return;
-
+ // Get the list of RawTrackerHits and add them to the sensor readout
List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName);
for(RawTrackerHit rawHit : rawHits){
- System.out.println(this.getClass().getSimpleName() + ": Sensor: " + SvtUtils.getInstance().getDescription((SiSensor) rawHit.getDetectorElement())
- + ": Raw hit channel: " + rawHit.getIdentifierFieldValue("strip"));
+ ((SiSensor) rawHit.getDetectorElement()).getReadout().addHit(rawHit);
}
- List<HPSFittedRawTrackerHit> fittedRawHits = event.get(HPSFittedRawTrackerHit.class, "SVTFittedRawTrackerHits");
- for(HPSFittedRawTrackerHit fittedRawHit : fittedRawHits){
- System.out.println(this.getClass().getSimpleName() + ": Sensor: " + SvtUtils.getInstance().getDescription((SiSensor) fittedRawHit.getRawTrackerHit().getDetectorElement())
- + ": Raw hit channel: " + fittedRawHit.getRawTrackerHit().getIdentifierFieldValue("strip") + ": Fit" + fittedRawHit.getShapeFitParameters());
+ // Get the list of HPSFittedRawTrackerHits and add them to the sensor readout
+ List<HPSFittedRawTrackerHit> fittedHits = event.get(HPSFittedRawTrackerHit.class, fittedRawTrackerHitCollectionName);
+ for(HPSFittedRawTrackerHit fittedHit : fittedHits){
+ ((SiSensor) fittedHit.getRawTrackerHit().getDetectorElement()).getReadout().addHit(fittedHit);
}
- System.out.println(this.getClass().getSimpleName() + ": Number of SimTrackerHits: " + simTrackerHits.size());
-
// Get the MC Particles associated with the SimTrackerHits
- List<MCParticle> mcParticles = new ArrayList<MCParticle>();
- System.out.print(this.getClass().getSimpleName() + ": MC Particles: ");
- for(SimTrackerHit simTrackerHit : simTrackerHits){
- if(mcParticles.contains(simTrackerHit.getMCParticle())) continue;
- System.out.print(simTrackerHit.getMCParticle().getPDGID() + " ");
- mcParticles.add(simTrackerHit.getMCParticle());
+ List<MCParticle> mcParticles = event.getMCParticles();
+ if(debug){
+ String particleList = "[ ";
+ for(MCParticle mcParticle : mcParticles){
+ particleList += mcParticle.getPDGID() + ", ";
+ }
+ particleList += "]";
+ this.printDebug("MC Particles: " + particleList);
}
- System.out.print("\n");
-
+
+ // Get the magnetic field
+ Hep3Vector IP = new BasicHep3Vector(0., 0., 1.);
+ this.printDebug("BField: " + event.getDetector().getFieldMap().getField(IP).y());
+
// Check if the MC particle track should be found by the tracking algorithm
- // Note: Only require 4 of the 5 SVT layers to be hit
+ // Note: Only require 4 of the 5 SVT layers to be hit; Layers must be in the same SVT volume
findable = new FindableTrack(event, simTrackerHits);
+ // Use an iterator to avoid ConcurrentModificationException
Iterator<MCParticle> mcParticleIterator = mcParticles.iterator();
trackIsFindable = false;
while(mcParticleIterator.hasNext()){
@@ -221,13 +303,14 @@
// Check that all SimTrackerHits are within the same detector volume
Set<SimTrackerHit> trackerHits = findable.getSimTrackerHits(mcParticle);
- for(SimTrackerHit trackerHit : trackerHits){
- System.out.println(this.getClass().getSimpleName() + ": SimTrackerHit position: " + trackerHit.getPositionVec().toString());
- }
if(this.isSameSvtVolume(trackerHits)){
- if(debug) System.out.println(this.getClass().getSimpleName() + ": Track is findable ...");
+ if(debug){
+ this.printDebug("Track is findable");
+ this.printDebug("MC particle momentum: " + mcParticle.getMomentum().toString());
+ }
+
findableTracks++;
- trackIsFindable = true;
+ trackIsFindable = true;
}
} else {
mcParticleIterator.remove();
@@ -235,26 +318,27 @@
}
// If a track is findable, check if a track was actually found otherwise return
- if(!event.hasCollection(Track.class, trackCollectionName) || !trackIsFindable) return;
- List<Track> tracks = event.get(Track.class, trackCollectionName);
-
- System.out.println(this.getClass().getSimpleName() + ": Number of tracks: " + tracks.size());
-
- if(mcParticles.isEmpty() && !tracks.isEmpty()){
- throw new RuntimeException(this.getClass().getSimpleName() + ": Tracks have no associated MC particle");
+ if(!event.hasCollection(Track.class, trackCollectionName) || !trackIsFindable){
+ if(trackIsFindable)
+ throw new RuntimeException("Track is not suppose to be 'findable");
+ return;
}
-
- List<HelicalTrackHit> stereoHits = event.get(HelicalTrackHit.class, stereoHitCollectionName);
- System.out.println(this.getClass().getSimpleName() + ": Number of stereo hits: " + stereoHits.size());
+ List<Track> tracks = event.get(Track.class, trackCollectionName);
+ if(debug)
+ this.printDebug("Event " + eventNumber + " contains " + tracks.size() + " Tracks");
// Relate a stereo hits to a SimTrackerHit; This is a required argument by TrackAnalysis
+ List<HelicalTrackHit> stereoHits = event.get(HelicalTrackHit.class, stereoHitCollectionName);
+ if(debug)
+ this.printDebug("Event " + eventNumber + " contains " + stereoHits.size() + " HelicalTrackHits");
RelationalTable<HelicalTrackHit, MCParticle> hitToMC = stereoHitToMC(stereoHits, simTrackerHits);
// Check if an MC particle is related to a found track
for(Track track : tracks){
trkAnalysis = new TrackAnalysis(track, hitToMC);
if(mcParticles.contains(trkAnalysis.getMCParticle())){
- System.out.println(this.getClass().getSimpleName() + ": Track match found");
+ if(debug)
+ this.printDebug("Track match found");
foundTracks++;
if(trackingEfficiencyPlots){
aida.histogram1D("Tracking Efficiency").fill(trkAnalysis.getMCParticle().getMomentum().magnitude(), 1);
@@ -264,14 +348,183 @@
}
}
-
- if(trackingEfficiencyPlots){
+ if(!mcParticles.isEmpty() && trackingEfficiencyPlots){
// If the list still contains MC Particles, a matching track wasn't found
- System.out.println(this.getClass().getSimpleName() + ": No matching track found");
+ if(debug)
+ this.printDebug("No matching track found");
+
+ // Check that all stereoHits were correctly assigned to an MCParticle
for(MCParticle mcParticle : mcParticles){
+
+ // Check if there is a stereo hit associated with every pair of layers hit by the MC particle
+ Set<SimTrackerHit> simHits = findable.getSimTrackerHits(mcParticle);
+ boolean[] planesHit = new boolean[10];
+
+ // Clear all previously stored simTrackerHits
+ for(int index = 0; index < 10; index++){
+ topSimTrackerHitsList.get(index+1).clear();
+ bottomSimTrackerHitsList.get(index+1).clear();
+ }
+
+ // Determine if the MC particle passed through the top or bottom SVT volume
+ for(SimTrackerHit simHit : simHits){
+ if(SvtUtils.getInstance().isTopLayer((SiSensor) simHit.getDetectorElement())){
+ this.printDebug("MC Particle passed through the top layer");
+ isTopTrack = true;
+ break;
+ } else {
+ this.printDebug("MC Particle passed through the bottom layer");
+ isTopTrack = false;
+ break;
+ }
+ }
+
+ // Check which layers have SimTrackerHits
+ // Arrange them by layers
+ for(SimTrackerHit simHit : simHits){
+ planesHit[simHit.getLayer()-1] = true;
+ }
+ boolean[] layerHit = new boolean[5];
+ int layerN = 0;
+ for(int index = 0; index < planesHit.length; index+=2){
+ if(planesHit[index] && planesHit[index+1]){
+ layerHit[layerN] = true;
+ this.printDebug("Layer " + (layerN+1) + " was hit");
+ }
+ layerN++;
+ }
+
+ // Check which layers have a stereo hit associated with them
+ boolean[] topStereoLayerHit = new boolean[5];
+ boolean[] bottomStereoLayerHit = new boolean[5];
+ for(HelicalTrackHit stereoHit : stereoHits){
+ if(stereoHit.getCorrectedPosition().z() > 0){
+ topStereoLayerHit[(stereoHit.Layer() - 1)/2] = true;
+ } else {
+ bottomStereoLayerHit[(stereoHit.Layer() - 1)/2] = true;
+ }
+ }
+
+ // Loop through all of the layers and check if it contains both a SimTrackerHit pair
+ // and a stereo hit
+ SiSensor axialSensor = null;
+ SiSensor stereoSensor = null;
+ String title = null;
+ for(int index = 0; index < layerHit.length; index++){
+ if(isTopTrack){
+ axialSensor = SvtUtils.getInstance().getTopSensor(2*index + 1);
+ stereoSensor = SvtUtils.getInstance().getTopSensor(2*index + 2);
+
+ for(SimTrackerHit simHit : axialSensor.getReadout().getHits(SimTrackerHit.class)){
+ if(layerHit[index] && !topStereoLayerHit[index]){
+ this.printDebug("Top Layer " + (index+1) + " is missing a stereo hit");
+ title = SvtUtils.getInstance().getDescription(axialSensor) + " - Hit Positions - Missed SimTrackerHits";
+ } else if(layerHit[index] && topStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(axialSensor) + " - Hit Positions - Found SimTrackerHits";
+ } else throw new RuntimeException("Histogram title was not found");
+ aida.histogram2D(title).fill(simHit.getPositionVec().x(), simHit.getPositionVec().y());
+ }
+
+ for(HPSFittedRawTrackerHit fittedRawHit : axialSensor.getReadout().getHits(HPSFittedRawTrackerHit.class)){
+ if(layerHit[index] && !topStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(axialSensor) + " - t0 - Missed SimTrackerHits";
+ } else if(layerHit[index] && topStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(axialSensor) + " - t0 - Found SimTrackerHits";
+ } else throw new RuntimeException("Histogram title was not found");
+
+ aida.histogram1D(title).fill(fittedRawHit.getT0());
+ }
+
+ for(SimTrackerHit simHit : stereoSensor.getReadout().getHits(SimTrackerHit.class)){
+ if(layerHit[index] && !topStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - Hit Positions - Missed SimTrackerHits";
+ } else if(layerHit[index] && topStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - Hit Positions - Found SimTrackerHits";
+ } else throw new RuntimeException("Histogram title was not found");
+ aida.histogram2D(title).fill(simHit.getPositionVec().x(), simHit.getPositionVec().y());
+ }
+
+ for(HPSFittedRawTrackerHit fittedRawHit : stereoSensor.getReadout().getHits(HPSFittedRawTrackerHit.class)){
+ if(layerHit[index] && !topStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - t0 - Missed SimTrackerHits";
+ } else if(layerHit[index] && topStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - t0 - Found SimTrackerHits";
+ } else throw new RuntimeException("Histogram title was not found");
+
+ aida.histogram1D(title).fill(fittedRawHit.getT0());
+ }
+
+ } else {
+ axialSensor = SvtUtils.getInstance().getBottomSensor(2*index + 2);
+ stereoSensor = SvtUtils.getInstance().getBottomSensor(2*index + 1);
+
+ for(SimTrackerHit simHit : axialSensor.getReadout().getHits(SimTrackerHit.class)){
+ if(debug)
+ this.printDebug(SvtUtils.getInstance().getDescription(axialSensor) + ": Position: " + simHit.getPositionVec().toString());
+
+ if(layerHit[index] && !bottomStereoLayerHit[index]){
+ this.printDebug("Bottom Layer " + (index+1) + " is missing a stereo hit");
+ title = SvtUtils.getInstance().getDescription(axialSensor) + " - Hit Positions - Missed SimTrackerHits";
+ } else if(layerHit[index] && bottomStereoLayerHit[index]) {
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - Hit Positions - Found SimTrackerHits";
+ } else throw new RuntimeException("Histogram title was not found");
+ aida.histogram2D(title).fill(simHit.getPositionVec().x(), simHit.getPositionVec().y());
+ }
+
+ for(HPSFittedRawTrackerHit fittedRawHit : axialSensor.getReadout().getHits(HPSFittedRawTrackerHit.class)){
+ if(layerHit[index] && !bottomStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(axialSensor) + " - t0 - Missed SimTrackerHits";
+ } else if(layerHit[index] && bottomStereoLayerHit[index]) {
+ title = SvtUtils.getInstance().getDescription(axialSensor) + " - t0 - Found SimTrackerHits";
+ } else throw new RuntimeException("Histogram title was not found");
+ aida.histogram1D(title).fill(fittedRawHit.getT0());
+ }
+
+ for(SimTrackerHit simHit : stereoSensor.getReadout().getHits(SimTrackerHit.class)){
+ if(layerHit[index] && !bottomStereoLayerHit[index]){
+ this.printDebug("Bottom Layer " + (index+1) + " is missing a stereo hit");
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - Hit Positions - Missed SimTrackerHits";
+ } else if(layerHit[index] && bottomStereoLayerHit[index]) {
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - Hit Positions - Found SimTrackerHits";
+ } else throw new RuntimeException("Histogram title was not found");
+ aida.histogram2D(title).fill(simHit.getPositionVec().x(), simHit.getPositionVec().y());
+ }
+
+ for(HPSFittedRawTrackerHit fittedRawHit : stereoSensor.getReadout().getHits(HPSFittedRawTrackerHit.class)){
+ if(layerHit[index] && !bottomStereoLayerHit[index]){
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - t0 - Missed SimTrackerHits";
+ } else if(layerHit[index] && bottomStereoLayerHit[index]) {
+ title = SvtUtils.getInstance().getDescription(stereoSensor) + " - t0 - Found SimTrackerHits";
+ } else throw new RuntimeException("Histogram title was not found");
+ aida.histogram1D(title).fill(fittedRawHit.getT0());
+ }
+ }
+ }
+
aida.histogram1D("Tracking Efficiency").fill(mcParticle.getMomentum().magnitude(), 0);
aida.histogram1D("Momentum").fill(mcParticle.getMomentum().magnitude());
+ aida.histogram1D("Stereo Hits").fill(hitToMC.allTo(mcParticle).size());
+
+ // Check if all HelicalTrackHits were properly assigned to an MC particle
+ Set<HelicalTrackHit> mcpStereoHits = hitToMC.allTo(mcParticle);
+ Iterator<HelicalTrackHit> stereoHitIterator = stereoHits.iterator();
+ while(stereoHitIterator.hasNext()){
+ HelicalTrackHit stereoHit = stereoHitIterator.next();
+ if(mcpStereoHits.contains(stereoHit)){
+ this.printDebug("MC particle: " + mcParticle.getPDGID() + ": Matched stereo hit position: " + stereoHit.getCorrectedPosition().toString());
+ stereoHitIterator.remove();
+ }
+ }
+
+
}
+
+ // If the list of HelicalTrackHits is not empty, there exist unmatched hits
+ /*if(!stereoHits.isEmpty()){
+ for(HelicalTrackHit stereoHit : stereoHits){
+ this.printDebug("Unmatched stereo hit position: " + stereoHit.getCorrectedPosition().toString());
+ }
+ }*/
}
}
@@ -309,10 +562,10 @@
if(Math.signum(simTrackerHitPosition.y()) == Math.signum(this.getClusterPosition(strip).z())){
hitToMC.add(stereoHit, layerToSimTrackerHit.get(strip.layer()).get(0).getMCParticle());
layerToSimTrackerHit.remove(strip.layer());
- System.out.println(this.getClass().getSimpleName() + ": SimTrackerHit position: " + simTrackerHitPosition.toString());
- System.out.println(this.getClass().getSimpleName() + ": Cluster position: " + this.getClusterPosition(strip));
+ //System.out.println(this.getClass().getSimpleName() + ": SimTrackerHit position: " + simTrackerHitPosition.toString());
+ //System.out.println(this.getClass().getSimpleName() + ": Cluster position: " + this.getClusterPosition(strip));
} else {
- System.out.println(this.getClass().getSimpleName() + ": Cluster and SimTrackerHit are on different volumes");
+ //System.out.println(this.getClass().getSimpleName() + ": Cluster and SimTrackerHit are on different volumes");
}
}
else if(layerToSimTrackerHit.get(strip.layer()) != null && layerToSimTrackerHit.get(strip.layer()).size() > 1){
@@ -327,8 +580,8 @@
}
hitToMC.add(stereoHit, simTrackerHitMatch.getMCParticle());
layerToSimTrackerHit.remove(strip.layer()).remove(simTrackerHitMatch);
- System.out.println(this.getClass().getSimpleName() + ": SimTrackerHit position: " + simTrackerHitMatch.getPositionVec().toString());
- System.out.println(this.getClass().getSimpleName() + ": Cluster position: " + this.getClusterPosition(strip));
+ //System.out.println(this.getClass().getSimpleName() + ": SimTrackerHit position: " + simTrackerHitMatch.getPositionVec().toString());
+ //System.out.println(this.getClass().getSimpleName() + ": Cluster position: " + this.getClusterPosition(strip));
}
}
}
@@ -336,6 +589,13 @@
return hitToMC;
}
+ private List<SeedStrategy> getStrategyList(){
+ if(!strategyResourcePath.startsWith("/"))
+ strategyResourcePath = "/" + strategyResourcePath;
+
+ return StrategyXMLUtils.getStrategyListFromInputStream(this.getClass().getResourceAsStream(strategyResourcePath));
+ }
+
private Hep3Vector getClusterPosition(HelicalTrackStrip strip)
{
Hep3Vector origin = strip.origin();
@@ -345,6 +605,7 @@
return VecOp.add(origin, uvec);
}
+
@Override
public void endOfData()
{