Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux on MAIN
cheat/CheatRecoParticleDriver.java+104added 1.1
     /RecoDefinition.java+2-31.4 -> 1.5
recon/TrackerHitRemover.java+184added 1.1
+290-3
2 added + 1 modified, total 3 files
Tools for CAT performance analysis

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/cheat
CheatRecoParticleDriver.java added at 1.1
diff -N CheatRecoParticleDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CheatRecoParticleDriver.java	24 Feb 2009 22:59:52 -0000	1.1
@@ -0,0 +1,104 @@
+package org.lcsim.contrib.onoprien.crux.cheat;
+
+import java.util.*;
+import java.util.logging.Level;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+
+import org.lcsim.contrib.onoprien.util.job.Driver;
+import org.lcsim.contrib.onoprien.util.job.JobEvent;
+import org.lcsim.contrib.onoprien.util.job.JobEventListener;
+import org.lcsim.contrib.onoprien.util.job.JobManager;
+
+import org.lcsim.contrib.onoprien.crux.infrastructure.CruxParticle;
+import org.lcsim.contrib.onoprien.crux.infrastructure.CruxParticleID;
+import org.lcsim.contrib.onoprien.crux.infrastructure.RecType;
+
+/**
+ * Driver that uses MC truth info to produce a list of reconstructed particles.
+ * Created {@link CruxParticle}s will have their particle ID, 4-momentum and MCParticle set.
+ * Nothing else is attached.
+ *
+ * @author D. Onoprienko
+ * @version $Id: CheatRecoParticleDriver.java,v 1.1 2009/02/24 22:59:52 onoprien Exp $
+ */
+public class CheatRecoParticleDriver extends Driver implements JobEventListener {
+
+// -- Private parts :  ---------------------------------------------------------
+
+  IRecoDefinition _def;
+
+  String _partColName;
+
+
+// -- Constructors and initialization :  ---------------------------------------
+
+  public CheatRecoParticleDriver(IRecoDefinition definition) {
+    _def = definition;
+    JobManager jobMan = JobManager.defaultInstance();
+    jobMan.addListener(this);
+  }
+
+  /** Called by framework to perform detector-dependent initialization. */
+  public void detectorChanged(JobEvent jobEvent) {
+    if (_partColName == null) throw new IllegalStateException(ERR_NS);
+  }
+
+
+// -- Setters :  ---------------------------------------------------------------
+
+  /**
+   * Set any parameter.
+   * The following parameters can be set with this method:
+   * <p><dl>
+   * <dt>"OUT_PARTICLES"</dt> <dd>Name of output list that contains reconstructed particles.<br>
+   *           Default: <tt>null</tt> (must be specified before this driver can be used).</dd>
+   * </dl>
+   *
+   * @param name   Name of parameter to be set. Case is ignored.
+   * @param values  List of values to be used for setting the parameter.
+   * @throws NoSuchParameterException Thrown if the supplied parameter name is unknown.
+   * @throws IllegalArgumentException Thrown if incorrect number of values, or a value
+   *                                  of incorrect type is supplied.
+   */
+  public void set(String name, Object... values) {
+    Object value = values.length == 0 ? null : values[0];
+    try {
+      if (name.equalsIgnoreCase("OUT_PARTICLES")) {
+        _partColName = (String) value;
+      } else {
+        super.set(name, values);
+      }
+    } catch (ClassCastException x) {
+      throw new IllegalArgumentException(ERR_VIT, x);
+    }
+  }
+
+
+// -- Processing event :  ------------------------------------------------------
+
+  public void process(EventHeader event) {
+
+    _def.startEvent(event);
+
+    List<MCParticle> mcList = event.getMCParticles();
+    ArrayList<CruxParticle> partList = new ArrayList<CruxParticle>(mcList.size());
+
+    for (MCParticle mc : mcList) {
+      if (_def.isFindable(RecType.PARTICLE, mc)) {
+        CruxParticle part = new CruxParticle(new CruxParticleID(mc.getType()), mc.asFourVector());
+        part.setMCParticle(mc);
+        partList.add(part);
+      }
+    }
+
+    partList.trimToSize();
+    event.put(_partColName, partList, CruxParticle.class, 0);
+
+    _def.endEvent();
+
+  }
+
+
+}

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/cheat
RecoDefinition.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- RecoDefinition.java	18 Feb 2009 03:29:06 -0000	1.4
+++ RecoDefinition.java	24 Feb 2009 22:59:52 -0000	1.5
@@ -25,7 +25,7 @@
  * the methods.
  *
  * @author D. Onoprienko
- * @version $Id: RecoDefinition.java,v 1.4 2009/02/18 03:29:06 onoprien Exp $
+ * @version $Id: RecoDefinition.java,v 1.5 2009/02/24 22:59:52 onoprien Exp $
  */
 public class RecoDefinition implements IRecoDefinition {
 
@@ -179,13 +179,12 @@
     if (!_cuts.containsKey(type)) throw new IllegalArgumentException(ERR_CNH + type);
     return true;
   }
-  
+
   public boolean isFake(RecType type, Object recObject) {
     if (!_cuts.containsKey(type)) throw new IllegalArgumentException(ERR_CNH + type);
     return true;
   }
 
-
   /**
    * This implementation of <tt>IRecoDefinition</tt> does not use any event-dependent
    * data, therefore this method is implemented to do nothing.

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/recon
TrackerHitRemover.java added at 1.1
diff -N TrackerHitRemover.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackerHitRemover.java	24 Feb 2009 22:59:53 -0000	1.1
@@ -0,0 +1,184 @@
+package org.lcsim.contrib.onoprien.crux.recon;
+
+import java.util.*;
+import java.util.logging.Level;
+
+import org.lcsim.event.EventHeader;
+
+import org.lcsim.contrib.onoprien.util.ListMap;
+import org.lcsim.contrib.onoprien.util.job.Driver;
+import org.lcsim.contrib.onoprien.util.job.JobEvent;
+import org.lcsim.contrib.onoprien.util.job.JobEventListener;
+import org.lcsim.contrib.onoprien.util.job.JobManager;
+
+import org.lcsim.contrib.onoprien.vsegment.geom.Sensor;
+import org.lcsim.contrib.onoprien.vsegment.hit.ITrackerHit;
+import org.lcsim.contrib.onoprien.vsegment.hit.VSTrackerHit;
+
+import org.lcsim.contrib.onoprien.crux.infrastructure.ITrack;
+
+/**
+ * Driver that creates a collection of tracker hits that are not associated with
+ * any of the specified tracks.
+ *
+ * @author D. Onoprienko
+ * @version $Id: TrackerHitRemover.java,v 1.1 2009/02/24 22:59:53 onoprien Exp $
+ */
+public class TrackerHitRemover extends Driver implements JobEventListener {
+
+// -- Private parts :  ---------------------------------------------------------
+
+  private String[] _inColNames;
+  private String _outColName;
+  private String[] _tracksNames;
+
+  private enum Method {SAME_CLUSTER, ANCHOR};
+  private Method _method = Method.SAME_CLUSTER;
+
+
+// -- Constructors and initialization :  ---------------------------------------
+  
+  public TrackerHitRemover() {
+    JobManager.defaultInstance().addListener(this);
+  }
+
+  /** Called by framework to perform detector-dependent initialization. */
+  public void detectorChanged(JobEvent jobEvent) {
+    if (_inColNames == null || _outColName == null) throw new IllegalStateException(ERR_NS);
+  }
+
+// -- Setters :  ---------------------------------------------------------------
+
+  /**
+   * Set any parameter.
+   * The following parameters can be set with this method:
+   * <p><dl>
+   * <dt>"INPUT_HITS"</dt> <dd>One or more names of input hit collections. Only hits from
+   *           these collections will be added to the output list.<br>
+   *           Default: <tt>null</tt> (must be specified before this driver can be used).</dd>
+   * <dt>"OUTPUT_HITS"</dt> <dd>Name of output list that contains unattached hits.<br>
+   *           Default: <tt>null</tt> (must be specified before this driver can be used).</dd>
+   * <dt>"TRACKS"</dt> <dd>Names of track collections. Hits associated with tracks from these
+   *           collections will not be included in the output list. If no names are listed,
+   *           all collections of type {@link ITrack} will be used.<br>
+   *           Default: <tt>All track collections</tt>.</dd>
+   * <dt>"METHOD"</dt> <dd>String value that tells this driver what hits are considered to be
+   *           associated with a track.Possible values:<ul>
+   *           <li>"SAME_CLUSTER" - hit is associated if at least one of the tracker clusters
+   *               that contributed to it has also contributed to at least one hit on the track.
+   *           <li>"ANCHOR" - hit is associated if it is directly attached to the track as an
+   *               anchor hit.</ul>
+   *           Default: <tt>"SAME_CLUSTER"</tt>.</dd>
+   * </dl>
+   *
+   * @param name   Name of parameter to be set. Case is ignored.
+   * @param values  List of values to be used for setting the parameter.
+   * @throws NoSuchParameterException Thrown if the supplied parameter name is unknown.
+   * @throws IllegalArgumentException Thrown if incorrect number of values, or a value
+   *                                  of incorrect type is supplied.
+   */
+  public void set(String name, Object... values) {
+    try {
+      if (name.equalsIgnoreCase("INPUT_HITS")) {
+        if (values.length == 0) throw new IllegalArgumentException(ERR_INV + name);
+        _inColNames = new String[values.length];
+        for (int i=0; i<values.length; i++) _inColNames[i] = (String) values[i];
+      } else if (name.equalsIgnoreCase("OUTPUT_HITS")) {
+        if (values.length != 1) throw new IllegalArgumentException(ERR_INV + name);
+        _outColName = (String) values[0];
+      } else if (name.equalsIgnoreCase("TRACKS")) {
+        if (values.length == 0) {
+          _tracksNames = null;
+        } else {
+          _tracksNames = new String[values.length];
+          for (int i=0; i<values.length; i++) _tracksNames[i] = (String) values[i];
+        }
+      } else if (name.equalsIgnoreCase("METHOD")) {
+        if (values.length != 1) throw new IllegalArgumentException(ERR_INV + name);
+        _method = Enum.valueOf(Method.class, (String) values[0]);
+      } else {
+        super.set(name, values);
+      }
+    } catch (ClassCastException x) {
+      throw new IllegalArgumentException(ERR_VIT, x);
+    }
+  }
+
+
+// -- Processing event :  ------------------------------------------------------
+
+  public void process(EventHeader event) {
+
+    boolean vsHitsOnly = true;
+
+    LinkedHashSet<ITrackerHit> inHits = new LinkedHashSet<ITrackerHit>();
+    for (String colName : _inColNames) {
+      try {
+        Collection<ITrackerHit> hits = (Collection<ITrackerHit>) event.get(colName);
+        for (ITrackerHit hit : hits) {
+          vsHitsOnly &= hit instanceof VSTrackerHit;
+          inHits.add(hit);
+        }
+      } catch (IllegalArgumentException x) {}
+    }
+
+    LinkedHashSet<ITrack> tracks = new LinkedHashSet<ITrack>();
+    if (_tracksNames == null) {
+      List<List<ITrack>> trackLists = event.get(ITrack.class);
+      for (List<ITrack> list : trackLists) {
+        tracks.addAll(list);
+      }
+    } else {
+      for (String colName : _tracksNames) {
+        try {
+          Collection<ITrack> trs = (Collection<ITrack>) event.get(colName);
+          tracks.addAll(trs);
+        } catch (IllegalArgumentException x) {}
+      }
+    }
+
+    HashSet<ITrackerHit> veto = new HashSet<ITrackerHit>();
+    for (ITrack track : tracks) {
+      switch (_method) {
+        case SAME_CLUSTER :
+          veto.addAll(track.getTrackerClusters()); break;
+        case ANCHOR :
+          veto.addAll(track.getAnchorHits()); break;
+        default : throw new IllegalStateException();
+      }
+    }
+
+    ArrayList<ITrackerHit> outHits = new ArrayList<ITrackerHit>(inHits.size());
+    for (ITrackerHit hit : inHits) {
+      switch (_method) {
+        case SAME_CLUSTER:
+          HashSet<ITrackerHit> clusters =  new HashSet<ITrackerHit>(hit.getClusters());
+          if (! clusters.removeAll(veto)) {
+            outHits.add(hit);
+          }
+          break;
+        case ANCHOR:
+          if (! veto.contains(hit)) {
+            outHits.add(hit);
+          }
+          break;
+        default: throw new IllegalStateException();
+      }
+    }
+
+    if (vsHitsOnly) {
+      ListMap<Sensor,VSTrackerHit> out = new ListMap<Sensor,VSTrackerHit>();
+      for (ITrackerHit hit : outHits) {
+        VSTrackerHit vsHit = (VSTrackerHit) hit;
+        out.add(vsHit.getSensor(), vsHit);
+        event.put(_outColName, out, VSTrackerHit.class, 0);
+      }
+    } else {
+      outHits.trimToSize();
+      event.put(_outColName, outHits, ITrackerHit.class, 0);
+    }
+
+  }
+
+
+}
CVSspam 0.2.8