hps-java/src/main/java/org/lcsim/hps/users/omoreno
diff -u -r1.1 -r1.2
--- SvtPerformance.java 24 Jul 2012 06:21:52 -0000 1.1
+++ SvtPerformance.java 25 Jul 2012 02:02:41 -0000 1.2
@@ -14,6 +14,7 @@
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
import org.lcsim.geometry.Detector;
import org.lcsim.hps.monitoring.AIDAFrame;
+import org.lcsim.hps.recon.ecal.HPSEcalCluster;
import org.lcsim.hps.recon.tracking.SvtUtils;
import org.lcsim.hps.recon.tracking.TrackUtils;
import org.lcsim.recon.tracking.seedtracker.SeedTrack;
@@ -24,7 +25,7 @@
* Svt Performance Plots
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtPerformance.java,v 1.1 2012/07/24 06:21:52 omoreno Exp $
+ * @version $Id: SvtPerformance.java,v 1.2 2012/07/25 02:02:41 omoreno Exp $
*/
public class SvtPerformance extends Driver {
@@ -54,9 +55,21 @@
// Collection Names
private String stereoHitCollectionName = "RotatedHelicalTrackHits";
private String trackCollectionName = "MatchedTracks";
+ private String ecalClustersCollectionName = "EcalClusters";
public SvtPerformance(){}
+ //--- Setters ---//
+ //---------------//
+
+ /**
+ * Enable/disble debug mode
+ */
+ public void setEnableDebug(boolean debug){
+ this.debug = debug;
+ }
+
+
protected void detectorChanged(Detector detector){
// setup AIDA
@@ -76,95 +89,97 @@
}
public void process(EventHeader event){
-
-
-
- // Increment the event number
+
+ // Get the list of tracks in the event
+ List<SeedTrack> tracks = event.get(SeedTrack.class, trackCollectionName);
+
+ // For now, only look at event which have less than a single track
+ if(tracks.size() >= 2){
+ if(debug)
+ System.out.println(this.getClass().getSimpleName() + ": Two track event found! Skipping ...!");
+ return;
+ }
+
+ // Increment the event number
totalNumberEvents++;
topLayers = new double[5];
bottomLayers = new double[5];
- // If the event does not contain stereo hits, skip the event
- if(!event.hasCollection(HelicalTrackHit.class, stereoHitCollectionName)) return;
-
- // Get the list of HelicalTrackHits
- List<HelicalTrackHit> stereoHits =event.get(HelicalTrackHit.class, stereoHitCollectionName);
+ if(event.hasCollection(HelicalTrackHit.class, stereoHitCollectionName)){
- for(HelicalTrackHit stereoHit : stereoHits){
-
- if(debug)
- System.out.println(this.getClass().getSimpleName() + " : Stereo Hit position = [" + stereoHit.x()
- + ", " + stereoHit.y() + ", " + stereoHit.z() + "]");
-
- // Get the layer associated with the stereoHit
- int layer = stereoHit.Layer();
- int arrayPosition = (layer - 1)/2;
- if(debug){
- System.out.println(this.getClass().getSimpleName() + " : Layer Number: " + layer);
- System.out.println(this.getClass().getSimpleName() + " : Array Position: " + arrayPosition);
- }
-
- if(layer == 5){
- for(Object hit : stereoHit.getRawHits()){
- RawTrackerHit rawHit = (RawTrackerHit) hit;
- System.out.println("Sensor: " + SvtUtils.getInstance().getDescription((SiSensor) rawHit.getDetectorElement()) + " : Strip " + rawHit.getIdentifierFieldValue("strip"));
- }
- }
-
- // Find the detector volume the hit corresponds to
- if(stereoHit.z() > 0){
- topLayers[arrayPosition]++;
- System.out.println(this.getClass().getSimpleName() + " : Found Top Hit!");
- }
- else if(stereoHit.z() < 0){
- bottomLayers[arrayPosition]++;
- System.out.println(this.getClass().getSimpleName() + " : Found Bottom Hit!");
- }
- else throw new RuntimeException("Invalid hit position - y = " + stereoHit.y());
- }
+ // Get the list of HelicalTrackHits
+ List<HelicalTrackHit> stereoHits =event.get(HelicalTrackHit.class, stereoHitCollectionName);
- /*
- // Check if there are four consencutive hits on either volume
- if(this.hasConsecutiveHits(topLayers)){
- possibleTracks++;
- possibleTopTracks++;
- }
-
- if(this.hasConsecutiveHits(bottomLayers)){
- possibleTracks++;
- possibleBottomTracks++;
- System.out.println(this.getClass().getSimpleName() + " : Found Possible Bottom Track!");
- }
- */
-
- // Check if tracks were actually found
- if(!event.hasCollection(Track.class, trackCollectionName)){
-
- System.out.println("No Tracks Were Found!");
-
- // Check if there are four consencutive hits on either volume
- if(this.hasConsecutiveHits(topLayers)){
- possibleTracks++;
- possibleTopTracks++;
- System.out.println(this.getClass().getSimpleName() + " : Found Possible Top Track!");
- }
+ for(HelicalTrackHit stereoHit : stereoHits){
- if(this.hasConsecutiveHits(bottomLayers)){
- possibleTracks++;
- possibleBottomTracks++;
- System.out.println(this.getClass().getSimpleName() + " : Found Possible Bottom Track!");
- }
- return;
+ if(debug)
+ System.out.println(this.getClass().getSimpleName() + " : Stereo Hit position = [" + stereoHit.x()
+ + ", " + stereoHit.y() + ", " + stereoHit.z() + "]");
+
+ // Get the layer associated with the stereoHit
+ int layer = stereoHit.Layer();
+ int arrayPosition = (layer - 1)/2;
+
+ // Find the detector volume the hit corresponds to - Top or Bottom.
+ // Then "add" the hit to the corresponding layer
+ if(stereoHit.z() > 0){
+ topLayers[arrayPosition]++;
+ if(debug)
+ System.out.println(this.getClass().getSimpleName() + " : Found Top Hit!");
+ }
+ else if(stereoHit.z() < 0){
+ bottomLayers[arrayPosition]++;
+ if(debug)
+ System.out.println(this.getClass().getSimpleName() + " : Found Bottom Hit!");
+ }
+ else throw new RuntimeException("Invalid hit position - y = " + stereoHit.y());
+ }
+ }
+
+ // Get the list of Ecal Clusters
+ List<HPSEcalCluster> ecalClusters = event.get(HPSEcalCluster.class, ecalClustersCollectionName);
+
+ // Check if there are four consencutive hits on either volume and
+ // that there is an Ecal cluster in the same volume
+ if(this.hasConsecutiveHits(topLayers) && !ecalClusters.isEmpty()){
+ for(HPSEcalCluster ecalCluster : ecalClusters){
+ if(ecalCluster.getPosition()[1] > 0){
+ possibleTracks++;
+ possibleTopTracks++;
+ if(debug){
+ System.out.println(this.getClass().getSimpleName() + " : Found Possible Top Track!");
+ if(tracks.isEmpty())
+ System.out.println(this.getClass().getSimpleName() + " : No Track Associated with this Possible Track!");
+ }
+ break;
+ }
+ }
+ }
+
+ if(this.hasConsecutiveHits(bottomLayers) && !ecalClusters.isEmpty()){
+ for(HPSEcalCluster ecalCluster : ecalClusters){
+ if(ecalCluster.getPosition()[1] < 0){
+ possibleTracks++;
+ possibleBottomTracks++;
+ if(debug){
+ System.out.println(this.getClass().getSimpleName() + " : Found Possible Bottom Track!");
+ if(tracks.isEmpty())
+ System.out.println(this.getClass().getSimpleName() + " : No Track Associated with this Possible Track!");
+ }
+ break;
+ }
+ }
+ }
+
+ // Only continue if an event has a track
+ if(tracks.isEmpty()){
+ if(debug)
+ System.out.println(this.getClass().getSimpleName() + ": No Tracks Were Found!");
+ return;
}
- // Get the list of tracks
- List<SeedTrack> tracks = event.get(SeedTrack.class, trackCollectionName);
-
- // Get the total number of tracks found in the event
- double tracksFound = tracks.size();
-
- // Only look at events with a single track
- if(tracksFound >= 2) return;
+ if(debug)
+ System.out.println(this.getClass().getSimpleName() + ": Number of Tracks: " + tracks.size());
totalTracksFound += tracks.size();
@@ -174,33 +189,39 @@
// Check which volume the track corresponds to
if(trkUtil.getZ0() > 0){
totalTopTracksFound++;
- System.out.println(this.getClass().getSimpleName() + " : Found Top Track!");
+ if(debug)
+ System.out.println(this.getClass().getSimpleName() + " : Found Top Track!");
}
else if(trkUtil.getZ0() < 0){
totalBottomTracksFound++;
- System.out.println(this.getClass().getSimpleName() + " : Found Bottom Track!");
+ if(debug)
+ System.out.println(this.getClass().getSimpleName() + " : Found Bottom Track!");
}
}
- // Check if there are four consencutive hits on either volume
- if(this.hasConsecutiveHits(topLayers)){
+ if(debug){
+ System.out.println("Number of tracks per event: " + (totalTracksFound/totalNumberEvents) );
+ System.out.println("Total Track Reconstruction Efficiency: " + (totalTracksFound/possibleTracks));
+ System.out.println("Total Top Track Reconstruction Efficiency " + (totalTopTracksFound/possibleTopTracks));
+ System.out.println("Total Bottom Track Reconstruction Efficiency" + (totalBottomTracksFound/possibleBottomTracks));
+ }
+
+ /*
+ if(this.hasConsecutiveHits(topLayers) && ecalClusters.get(0).getPosition()[1] > 0 ){
possibleTracks++;
possibleTopTracks++;
}
- if(this.hasConsecutiveHits(bottomLayers)){
+ if(this.hasConsecutiveHits(bottomLayers) && ecalClusters.get(0).getPosition()[1] < 0){
possibleTracks++;
possibleBottomTracks++;
System.out.println(this.getClass().getSimpleName() + " : Found Possible Bottom Track!");
- }
+ }*/
}
private boolean hasConsecutiveHits(double[] layers){
for(int index = 0; index < 2; index++){
if(layers[index] > 0 && layers[index + 1] > 0 && layers[index + 2] > 0 && layers[index + 3] > 0){
- for(int layer = 0; layer < layers.length; layer++){
- System.out.println("Layer " + layer+1 + " Hits: " + layers[layer]);
- }
return true;
}
}