7 removed files
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/tester
diff -N ExampleDriverTrackingTest.java
--- ExampleDriverTrackingTest.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,51 +0,0 @@
-package org.lcsim.contrib.onoprien.tester;
-
-import java.util.*;
-import org.lcsim.recon.cat.EmcalMipStubs;
-import org.lcsim.recon.cat.GarfieldHitConverter;
-import org.lcsim.recon.cat.GarfieldTrackFinder;
-import org.lcsim.recon.cat.util.Const;
-import org.lcsim.event.*;
-import org.lcsim.recon.cluster.nn.NearestNeighborClusterDriver;
-import org.lcsim.recon.mcTrackFinder.MCTrackFinder;
-import org.lcsim.util.Driver;
-import org.lcsim.util.aida.AIDA;
-
-/**
- * An example driver that runs calorimeter-assisted track finder, and uses
- * tester package to analyse its performance.
- *
- * @author D. Onoprienko
- * @version $Id: ExampleDriverTrackingTest.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
- */
-public class ExampleDriverTrackingTest extends Driver {
-
- private AIDA aida = AIDA.defaultInstance();
-
- public ExampleDriverTrackingTest() {
-
- GarfieldHitConverter hitDigitizer = new GarfieldHitConverter();
- hitDigitizer.set("OUTPUT_COLLECTION_NAME", "GarfieldHits");
- add(hitDigitizer);
-
- add(new NearestNeighborClusterDriver(2, 2, 1, 2, 0.));
-
- add(new EmcalMipStubs("GarfieldMipStubs",0));
- add(new GarfieldTrackFinder(0));
-
- MCTrackFinder mcFinder = new MCTrackFinder();
- mcFinder.addTrackerHitList("GarfieldHits");
- mcFinder.set("Track_Collection_Name", "CheaterTracks");
- mcFinder.set("Min_Layers", 3);
- add(mcFinder);
-
- TrackingTest test = new TrackingTest("General Track Finding Test");
- test.set("RECONSTRUCTED_TRACK_COLLECTION_NAME", "GarfieldTracks");
- test.set("MC_TRACK_COLLECTION_NAME", "CheaterTracks");
- test.set("MCTrackCut_Pt", 1.0*Const.GeV);
- test.set("MCTrackCut_Theta", 45.*Const.degree);
- test.set("MCTrackCut_nLayers", 3);
- add(test);
- }
-
-}
\ No newline at end of file
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/tester
diff -N PiFinder.java
--- PiFinder.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,27 +0,0 @@
-package org.lcsim.contrib.onoprien.tester;
-
-import org.lcsim.recon.mcTrackFinder.MCTrackFinder;
-import org.lcsim.recon.mcTrackFinder.MCTrack;
-import org.lcsim.event.*;
-import org.lcsim.recon.cat.util.Const;
-
-/**
- * Cheater track finder that finds only tracks left by charged pions from K short decays.
- *
- * @author onoprien
- * @version $Id: PiFinder.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
- */
-public class PiFinder extends MCTrackFinder {
-
- public PiFinder() {}
-
- /**
- * Overrides {@link MCTrackFinder#filter(MCParticle)} to select charged pions from KS0 decays.
- */
- protected boolean filter(MCParticle mcParticle) {
- return super.filter(mcParticle) &&
- (mcParticle.getPDGID() == Const.Particle.PI_MINUS.PDGID || mcParticle.getPDGID() == Const.Particle.PI_PLUS.PDGID ) &&
- (mcParticle.getParents().get(0).getPDGID() == Const.Particle.K_SHORT.PDGID);
- }
-
-}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/tester
diff -N PiTest.java
--- PiTest.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-package org.lcsim.contrib.onoprien.tester;
-
-import hep.aida.*;
-
-import java.util.*;
-import org.lcsim.recon.cat.EmcalMipStubs;
-import org.lcsim.recon.cat.GarfieldHitConverter;
-import org.lcsim.recon.cat.GarfieldTrackFinder;
-import org.lcsim.event.*;
-import org.lcsim.recon.cluster.nn.NearestNeighborClusterDriver;
-import org.lcsim.recon.mcTrackFinder.MCTrack;
-import org.lcsim.recon.mcTrackFinder.MCTrackFinder;
-import org.lcsim.util.Driver;
-import org.lcsim.util.aida.AIDA;
-
-/**
- * Track finding efficiency test for charged pions from K short decays.
- *
- * @author D. Onoprienko
- * @version $Id: PiTest.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
- */
-public class PiTest extends TrackingTest {
-
-// -- Constructor : -----------------------------------------------------------
-
- public PiTest() {
-
- super("KS0 Pions Track Finding Test");
-
- GarfieldHitConverter hitDigitizer = new GarfieldHitConverter();
- hitDigitizer.set("OUTPUT_COLLECTION_NAME", "GarfieldHits");
- add(hitDigitizer);
-
- add(new NearestNeighborClusterDriver(2, 2, 1, 2, 0.));
-
- add(new EmcalMipStubs("GarfieldMipStubs",0));
- add(new GarfieldTrackFinder(0));
-
- MCTrackFinder mcFinder = new PiFinder();
- mcFinder.addTrackerHitList("GarfieldHits");
- mcFinder.set("Track_Collection_Name", "PiTracks");
- mcFinder.set("Min_Layers", 0);
- add(mcFinder);
-
- set("RECONSTRUCTED_TRACK_COLLECTION_NAME", "GarfieldTracks");
- set("MC_TRACK_COLLECTION_NAME", "PiTracks");
- //set("MCTrackCut_Pt", 1.0*Const.GeV);
- //set("MCTrackCut_Theta", 45.*Const.degree);
- set("MCTrackCut_nLayers", 3);
- }
-
-// -- Event analysis : ---------------------------------------------------------
-
- public void analyzeEvent(EventHeader event) {
-
- System.out.println(" ");
- System.out.println("Event "+ event.getEventNumber());
-
- List<MCTrack> trackList = event.get(MCTrack.class, "PiTracks");
-
- int i = 0;
- for (MCTrack track : trackList) {
- double pT = track.getPt();
- all.fill(pT);
- if (track.getStatus(IN_CLASS) == YES) {
- good.fill(pT);
- if (isReconstructed(track)) reco.fill(pT);
- } else {
- if (isReconstructed(track)) System.out.println("Not good...");
- }
- }
-
- }
-
- public void endOfRun() {
-
- IHistogram1D eff = hFac.divide("Efficiency",reco, good);
- IHistogram1D goodFraction = hFac.divide("Reconstructable fraction",good, all);
-
- try {aida.saveAs("run.aida");} catch (Exception e) {}
- }
-
-// -- Private parts : ---------------------------------------------------------
-
- private AIDA aida = AIDA.defaultInstance();
- private IHistogramFactory hFac = aida.histogramFactory();
-
- IHistogram1D all = aida.histogram1D("All", 100, 0.,100.);
- IHistogram1D good = aida.histogram1D("Reconstructable", 100, 0.,100.);
- IHistogram1D reco = aida.histogram1D("Reconstructed", 100, 0.,100.);
-
-}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/tester
diff -N RatedTrack.java
--- RatedTrack.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-package org.lcsim.contrib.onoprien.tester;
-
-import hep.physics.matrix.SymmetricMatrix;
-import java.util.*;
-import org.lcsim.event.*;
-import org.lcsim.recon.mcTrackFinder.MCTrack;
-
-/**
- * The class keeps references to a reconstructed track, associated
- * Monte Carlo tracks, and allows assignment and retrieval of any number
- * of integer status flags.
- *
- * @author D. Onoprienko
- * @version $Id: RatedTrack.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
- */
-public class RatedTrack {
-
-// -- Constructors : ----------------------------------------------------------
-
- /** Create RatedTrack by wrapping a reconstructed track. */
- public RatedTrack(Track track) {
- _track = track;
- _mcTrackList = new ArrayList<MCTrack>(1);
- _status = new HashMap<Integer,Integer>(2);
- }
-
-// -- Getters : ---------------------------------------------------------------
-
- /** Returns underlying reconstructed Track object. */
- public Track getTrack() {return _track;}
-
- /** Returns a list of associated Monte Carlo tracks. */
- public List<MCTrack> getMCTracks() {return _mcTrackList;}
-
- /**
- * Returns a status flag that has been previously assigned to this track through
- * the call to {@link #setStatus(int,int) setStatus(int category, int status)}.
- */
- public int getStatus(int category) {return _status.get(category);}
-
-// -- Setters : ---------------------------------------------------------------
-
- /**
- * Add an <tt>MCTrack</tt> to the list of Monte Carlo
- * tracks associated with this <tt>RatedTrack</tt>.
- */
- public void addMCTrack(MCTrack mcTrack) {_mcTrackList.add(mcTrack);}
-
- /**
- * Set an integer status flag for this track.
- *
- * @param category Identifier of a status category. A track can be assigned
- * statuses in any number of categories.
- * @param status Status flag that can be later retrieved through the call to
- * {@link #getStatus(int) getStatus(int category)}
- */
- public void setStatus(int category, int status) {_status.put(category, status);}
-
-
-// -- Private data : ----------------------------------------------------------
-
- private Track _track;
- private ArrayList<MCTrack> _mcTrackList;
-
- HashMap<Integer,Integer> _status;
-
-}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/tester
diff -N TrackingTest.java
--- TrackingTest.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,121 +0,0 @@
-package org.lcsim.contrib.onoprien.tester;
-
-import java.util.*;
-import java.lang.reflect.*;
-import org.lcsim.event.*;
-import org.lcsim.recon.mcTrackFinder.MCTrack;
-import org.lcsim.util.Driver;
-import hep.physics.particle.Particle;
-import org.lcsim.util.aida.AIDA;
-import hep.aida.ITree;
-
-/**
- * A general track finding performance test.
- * See {@link ExampleDriverTrackingTest} for an example of use.
- *
- * @author D. Onoprienko
- * @version $Id: TrackingTest.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
- */
-public class TrackingTest extends TrackingTestBase {
-
-// -- Indices into the statistics (per event and cumulative) arrays : ---------
-
- protected final int _I_nTotal;
- protected final int _I_eTotal;
- protected final int _I_ptTotal;
- protected final int _I_nGood;
- protected final int _I_eGood;
- protected final int _I_ptGood;
- protected final int _I_nGoodFound;
- protected final int _I_eGoodFound;
- protected final int _I_ptGoodFound;
- protected final int _I_nFound;
- protected final int _I_nFake;
-
-// -- Constructors : ----------------------------------------------------------
-
- /** Default constructor. */
- public TrackingTest() {
- super("TrackingTest");
- _I_nTotal = createIndex("Number of MCTracks tracks");
- _I_eTotal = createIndex("Total energy of MCTracks tracks");
- _I_ptTotal = createIndex("Total Pt of MCTracks tracks");
- _I_nGood = createIndex("Number of reconstructable MCTracks");
- _I_eGood = createIndex("Total energy of reconstructable MCTracks", IndexType.NOPRINT);
- _I_ptGood = createIndex("Total Pt of reconstructable tracks", IndexType.NOPRINT);
- _I_nGoodFound = createIndex("Number of found reconstructable tracks");
- _I_eGoodFound = createIndex("Total energy of found reconstructable tracks", IndexType.NOPRINT);
- _I_ptGoodFound = createIndex("Total Pt of found reconstructable tracks", IndexType.NOPRINT);
- _I_nFound = createIndex("Number of found tracks", IndexType.NOPRINT);
- _I_nFake = createIndex("Number of fake tracks", IndexType.PRINTEVENT);
- }
-
- /** Constructor taking the name of the test. */
- public TrackingTest(String name) {
- this();
- set("TEST_NAME", name);
- }
-
-// -- Processing event : ------------------------------------------------------
-
- protected void analyzeEvent(EventHeader event) {
-
- // Number, energy, and Pt of all tracks, reconstructable tracks, and found reconstructable tracks
-
- for (MCTrack mcTrack : _mcTrackList) {
- _statE[_I_nTotal] += 1.;
- _statE[_I_eTotal] += mcTrack.getMCParticle().getEnergy();
- _statE[_I_ptTotal] += mcTrack.getPt();
- if (mcTrack.getStatus(IN_CLASS) == YES) {
- _statE[_I_nGood] += 1.;
- _statE[_I_eGood] += mcTrack.getMCParticle().getEnergy();
- _statE[_I_ptGood] += mcTrack.getPt();
- if (isReconstructed(mcTrack)) {
- _statE[_I_nGoodFound] += 1.;
- _statE[_I_eGoodFound] += mcTrack.getMCParticle().getEnergy();
- _statE[_I_ptGoodFound] += mcTrack.getPt();
- }
- }
- }
-
- // Number of reconstracted tracks and fakes
-
- _statE[_I_nFound] = _ratedTrackList.size();
- for (RatedTrack rTrack : _ratedTrackList) {
- if (isFake(rTrack)) _statE[_I_nFake] += 1.;
- }
-
- // Fill histograms for reconstructed tracks in class :
-
-// for (RatedTrack rTrack : _ratedTrackList) {
-// MCTrack mcTrack = rTrack.getMCTrack();
-// if (mcTrack != null && mcTrack.getStatus(IN_CLASS) == YES) {
-// double p = mcTrack.getP();
-// double dp = rTrack.getP()-p;
-// _aida.cloud1D(_testName + " deltaP over P").fill(dp/p);
-// }
-// }
-
- }
-
- protected void endOfRun() {
-
- System.out.println("");
- System.out.println(" End-of-run statictics from " + _testName);
- System.out.println("");
-
- System.out.println("Reconstructable to all tracks ratios:");
- System.out.println(" Tracks: " + _statC[_I_nGood]/_statC[_I_nTotal]);
- System.out.println(" Energy: " + _statC[_I_eGood]/_statC[_I_eTotal]);
- System.out.println(" Pt: " + _statC[_I_ptGood]/_statC[_I_ptTotal]);
-
- System.out.println("Track finding efficiency (Found/Reconstructable):");
- System.out.println(" Tracks: " + _statC[_I_nGoodFound]/_statC[_I_nGood]);
- System.out.println(" Energy: " + _statC[_I_eGoodFound]/_statC[_I_eGood]);
- System.out.println(" Pt: " + _statC[_I_ptGoodFound]/_statC[_I_ptGood]);
-
- System.out.println("Purity: " + (1.-_statC[_I_nFake]/_statC[_I_nFound]));
- }
-
-// -- Private fields : --------------------------------------------------------
-}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/tester
diff -N TrackingTestBase.java
--- TrackingTestBase.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,543 +0,0 @@
-package org.lcsim.contrib.onoprien.tester;
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.util.*;
-import javax.swing.*;
-
-import hep.aida.*;
-import hep.aida.ref.histogram.*;
-import hep.physics.particle.Particle;
-import org.lcsim.event.*;
-import org.lcsim.recon.cat.util.NoSuchParameterException;
-import org.lcsim.recon.mcTrackFinder.MCTrack;
-import org.lcsim.util.Driver;
-import org.lcsim.geometry.Detector;
-import org.lcsim.util.aida.AIDA;
-
-/**
- * Abstract driver class that provides infrastructure and utility methods for testing track finders.
- * See {@link TrackingTest} and {@link PiTest} for examples of use.
- * <p>
- * Classes implementing particular tests should extend this class, overriding<br>
- * {@link #analyzeEvent(EventHeader)}<br>
- * and, if necessary,<br>
- * {@link #eventFilter(EventHeader event)},<br>
- * {@link #matchTracks(Track track, MCTrack mcTrack)},<br>
- * {@link #mcTrackFilter(MCTrack mcTrack)},<br>
- * {@link #isReconstructed(MCTrack mcTrack)},<br>
- * {@link #isFake(RatedTrack track)},<br>
- * {@link #startOfRun(Detector)}, and {@link #endOfRun()} methods.<br>
- * Default implementations are provided for these methods.
- * <p>
- * Subclusses extending this driver should be added to the event processing chain
- * after track findind stage. Cheater track finder
- * (see {@link org.lcsim.recon.mcTrackFinder}) should also be run before the test
- * to create a list of MCTracks and put it into the event.
- * <p>
- * When the driver's {@link #process(EventHeader event)}
- * method is called by the framework, it fetches a list of Monte Carlo tracks,
- * marks those for which {@link #mcTrackFilter(MCTrack mcTrack)} returns
- * <tt>true</tt> as being in the requested class (subsequent calls to
- * {@link MCTrack#getStatus(int) mcTrack.getStatus(TrackingTestBase.IN_CLASS)}
- * will return <tt>TrackingTestBase.YES</tt>),
- * associates MCTracks and reconstructed tracks for which
- * {@link #matchTracks(Track track, MCTrack mcTrack)} returns <tt>true</tt> with
- * each other, and then calls
- * {@link #analyzeEvent(EventHeader)} method that should be implemented by subclasses.
- * <p>
- * Only events for which {@link #eventFilter(EventHeader)} returns <tt>true</tt> are processed.
- * <p>
- * There is an optional facility for accumulating and printing statistics.
- * Any number of variables for accumulating statistics can be created with
- * {@link #createIndex(String name, IndexType... args)}. Data put into
- * these variables is automatically accumulated at the end of event processing,
- * and can be printed out with {@link #printStatistics(EventHeader event)} and
- * {@link #printCumulativeStatistics()}.
- *
- * @author D. Onoprienko
- * @version $Id: TrackingTestBase.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
- */
-abstract public class TrackingTestBase extends Driver {
-
-// -- Constants defining status categories and values: ------------------------
-
- public static final int IN_CLASS = -1;
- public static final int FAKE = -2;
-
- public static final int YES = -1;
- public static final int NO = -2;
-
-// -- Constructors : ----------------------------------------------------------
-
- /** Default constructor. */
- public TrackingTestBase() {
- _testName = "";
- _aida = AIDA.defaultInstance();
- _tree = _aida.tree();
- _mcTrackListName = "";
- _recoTrackListName = "";
- _runInProgress = false;
- }
-
- /** Constructor taking the name of the test. */
- public TrackingTestBase(String name) {
- this();
- set("TEST_NAME", name);
- }
-
- // -- Setters : -------------------------------------------------------------
-
- /**
- * Set any <tt>String</tt> parameter.
- * The following parameters can be set with this method:<br>
- * <tt>"TEST_NAME"</tt> - name of the test. The name will printed with the test output statistics.<br>
- * <tt>"RECONSTRUCTED_TRACK_COLLECTION_NAME"</tt> - name of reconstructed track
- * collection produced by the track finder being tested.<br>
- * <tt>"MC_TRACK_COLLECTION_NAME"</tt> - name of MCTrack collection created by previously run MCTrackFinder.
- * @param name Name of parameter to be set. Case ignored.
- * @param value Value to be assigned to the parameter.
- * @throws NoSuchParameterException Thrown if the supplied parameter name is unknown.
- * Subclasses may catch this exception after a call to <tt>super.set()</tt>
- * and set their own parameters.
- */
- public void set(String name, String value) {
- if (name.equalsIgnoreCase("TEST_NAME")) {
- _testName = value;
- } else if (name.equalsIgnoreCase("RECONSTRUCTED_TRACK_COLLECTION_NAME")) {
- _recoTrackListName = value;
- } else if (name.equalsIgnoreCase("MC_TRACK_COLLECTION_NAME")) {
- _mcTrackListName = value;
- } else {
- throw new NoSuchParameterException(name, this.getClass());
- }
- }
-
- /**
- * Set any double parameter.
- * The following parameters can be set with this method:<br>
- * <tt>"MCTrackCut_Pt"</tt> - cut on Pt for MCTrack to be considered reconstructable. Default: 0.<br>
- * <tt>"MCTrackCut_Theta"</tt> - cut on Theta for MCTrack to be considered reconstructable. Default: 0.<br>
- * <tt>"MCTrackCut_Rapidity"</tt> - cut on pseudo-rapidity for MCTrack to be considered reconstructable. Default: infinity.<br>
- * @param name Name of parameter to be set. Case ignored.
- * @param value Value to be assigned to the parameter.
- * @throws NoSuchParameterException Thrown if the supplied parameter name is unknown.
- * Subclasses may catch this exception after a call to <tt>super.set()</tt>
- * and set their own parameters.
- */
- public void set(String name, double value) {
- if (name.equalsIgnoreCase("MCTrackCut_Pt")) {
- _mcTrackCut_Pt = value;
- } else if (name.equalsIgnoreCase("MCTrackCut_Theta")) {
- _mcTrackCut_theta = value;
- } else if (name.equalsIgnoreCase("MCTrackCut_Rapidity")) {
- if (value < 10000.) {
- _mcTrackCut_theta = 2.*Math.atan(Math.exp(-value));
- } else {
- _mcTrackCut_theta = 0.;
- }
- } else {
- throw new NoSuchParameterException(name, this.getClass());
- }
- }
-
- /**
- * Set any integer parameter.
- * The following parameters can be set with this method:<br>
- * <tt>"MCTrackCut_nLayers"</tt> - cut on minimum number of layers with hits
- * for MCTrack to be considered reconstructable. Default: 3.<br>
- * @param name Name of parameter to be set. Case ignored.
- * @param value Value to be assigned to the parameter.
- * @throws NoSuchParameterException Thrown if the supplied parameter name is unknown.
- * Subclasses may catch this exception after a call to <tt>super.set()</tt>
- * and set their own parameters.
- */
- public void set(String name, int value) {
- if (name.equalsIgnoreCase("MCTrackCut_nLayers")) {
- _mcTrackCut_nLayers = value;
- } else {
- throw new NoSuchParameterException(name, this.getClass());
- }
- }
-
-// -- Processing event : ------------------------------------------------------
-
- /** Process event. */
- public final void process(EventHeader event) {
-
- super.process(event);
-
- // Skip undesired events
-
- if (!eventFilter(event)) return;
-
- // Reset "per event" statistics
-
- if (_statE != null) Arrays.fill(_statE, 0.);
-
- // Fetch list of Monte Carlo Tracks, and set IN_CLASS flag for them
-
- _mcTrackList = event.get(MCTrack.class, _mcTrackListName);
- for (MCTrack mcTrack : _mcTrackList) {
- mcTrack.setStatus(IN_CLASS, mcTrackFilter(mcTrack) ? YES : NO);
- }
-
- // Associate reconstructed tracks with Monte Carlo Tracks
-
- _recoTrackList = event.get(Track.class, _recoTrackListName);
- _ratedTrackList = new ArrayList<RatedTrack>(_recoTrackList.size());
-
- for (Track track : _recoTrackList) {
- RatedTrack ratedTrack = new RatedTrack(track);
- for (MCTrack mcTrack : _mcTrackList) {
- if (matchTracks(track, mcTrack)) {
- ratedTrack.addMCTrack(mcTrack);
- mcTrack.addTrack(track);
- }
- }
- _ratedTrackList.add(ratedTrack);
- }
-
- // User's analysis
-
- analyzeEvent(event);
-
- // Update cumulative statistics
-
- if (_statE != null) {
- for (int i=0; i<_statE.length; i++) _statC[i] += _statE[i];
- }
- _nEvents++;
-
- // Clean up
-
- for (MCTrack mcTrack : _mcTrackList) {
- mcTrack.removeTracks();
- }
- _mcTrackList = null;
- _recoTrackList = null;
- _ratedTrackList = null;
-
- }
-
-// -- Selector methods to be overridden by subclasses : -----------------------
-
- /**
- * Returns <code>true</code> for events that should be included in analysis.
- * Default implementation always returns <code>true</code>.
- * Subclasses should overwrite this method if some events need to be excluded.
- */
- protected boolean eventFilter(EventHeader event) {
- return true;
- }
-
- /**
- * Returns <tt>true</tt> if Monte Carlo track belongs to the class that needs to be included in analysis.
- * Cuts on Pt, Theta, and a minimum number of layers with hits.
- * Cut values can be set at run time, leaving them at default values means no cuts.
- * Subclasses can overwrite this method to provide their own definition of "reconstructable" track.
- */
- protected boolean mcTrackFilter(MCTrack mcTrack) {
- if (mcTrack.getPt() < _mcTrackCut_Pt) return false;
- if (mcTrack.getTheta() < _mcTrackCut_theta) return false;
- if (mcTrack.getNLayers() < _mcTrackCut_nLayers) return false;
- return true;
- }
-
- /**
- * Returns <code>true</code> if reconstructed track and Monte Carlo track are deemed to describe the same track.
- * Default implementation: tracks match if they have common hits in at least 3 layers.
- * (Alternative definition to be considered later: Tracks match if MCParticle
- * contributed to hits of reconstructed track in at least 3 layers).
- * <i>Current implementation simply asks for 3 common hits since
- * {@link TrackerHit} is completely "detector blind" at the moment.</i>
- * Subclasses can overwrite this method to provide their own definition of matching tracks.
- */
- protected boolean matchTracks(Track track, MCTrack mcTrack) {
- List<TrackerHit> recoTrackHitList = track.getTrackerHits();
- List<TrackerHit> mcTrackHitList = mcTrack.getTrackerHits();
- int nMatch = 0;
- for (TrackerHit hit : mcTrackHitList) {
- if (recoTrackHitList.contains(hit)) nMatch++;
- }
- return nMatch > 2;
- }
-
- /**
- * Definition of a successfully reconstracted MCTrack.
- * This method is not called internally by any <tt>TrackingTestBase</tt> methods,
- * but can be used (or overridded) by subclasses.
- * What I would like to do here is to require that there is a reconstructed
- * track that picked up hits from this MCTrack in at least 3 layers.
- * Given current limitations of {@link TrackerHit} that has no layer information,
- * the default implementation returns <tt>true</tt> if any reconstructed
- * tracks have been associated with MCTrack supplied as a parameter. If default
- * implementation of {@link #matchTracks(Track, MCTrack)} is used, that means
- * requiring a reconstructed track with 3 hits common with the given MCTrack.
- */
- protected boolean isReconstructed(MCTrack mcTrack) {
- return mcTrack.getTracks().size() > 0;
- }
-
- /**
- * Definition of fake track.
- * This method is not called internally by any <tt>TrackingTestBase</tt> methods,
- * but can be used (or overridded) by subclasses.
- * In the future, I'd like to consider the track fake if there is no MCParticle
- * that contributed to its hits in all but one layer.
- * Given current limitations of {@link TrackerHit}, the actual definition is:
- * the track is fake if there is no MCTrack that contains all but one of its hits.
- */
- protected boolean isFake(RatedTrack track) {
- List<MCTrack> mcTrackList = track.getMCTracks();
- if (mcTrackList.size() == 0) return true;
- List<TrackerHit> recoHitList = track.getTrack().getTrackerHits();
- for (MCTrack mcTrack : mcTrackList) {
- int nSomeoneElsesHits = 0;
- for (TrackerHit hit : recoHitList) {
- if (!mcTrack.getTrackerHits().contains(hit)) nSomeoneElsesHits++;
- }
- if (nSomeoneElsesHits <= 1) return false;
- }
- return true;
- }
-
-// -- User analysis hooks : ---------------------------------------------------
-
- /** User analysis before the run. */
- protected void startOfRun(Detector detector) {}
-
- /** User analysis of the event. */
- abstract protected void analyzeEvent(EventHeader event);
-
- /** User analysis before the run. */
- protected void endOfRun() {}
-
- /**
- * Called when all data processing is finished.
- * Unless overwritten in the subclass, prints out standard cumulative statistics.
- */
- final protected void endOfData() {
- super.endOfData();
- endOfRun();
- _runInProgress = false;
- }
-
- /**
- * Called before the first event is processed, or after a rewind.
- * Unless overwritten in the subclass, resets standard cumulative statistics.
- */
- final public void detectorChanged(Detector detector) {
- super.detectorChanged(detector);
- if (_runInProgress) {
- endOfRun();
- }
- _nEvents = 0;
- if (_statE != null) Arrays.fill(_statC, 0.);
- _runInProgress = true;
- startOfRun(detector);
- }
-
-// -- Protected helper methods: -----------------------------------------------
-
- /**
- * Print to the log.
- * The output destination can be set with <tt>set("LOG_FILE", destination)</tt>.
- * See {@link #set(String, String)} for details.
- */
- protected void printLog(String title, String... messages) {
- if (title != null) {
- System.out.println("");
- System.out.println(title);
- System.out.println("");
- }
- for (String line : messages) {
- System.out.println(line);
- }
- }
-
- protected enum IndexType {NOSUM, SUM, SUM2, NOPRINT, PRINTEVENT, PRINTSUM, PRINTALL}
-
- /**
- * Creates a new statistical variable and returns an index that can be used to access it.
- * "Per event" data can be put into <code>_statE[index]</code>, these variables are reset
- * to zero at the beginning of each event. At the end of the event, statistics is
- * automatically accumulated into <code>_statC[index]</code>. The name of the variable
- * is accessable through <code>_statName[index]</code>.
- *
- * @param name Name to be assigned to the variable.
- * @param args Optional flags defining accumulation type and printing preferences. Possible flags and their meanings:<p>
- * NOSUM - do not accumulate this variable.<br>
- * SUM - <code>_statE[index]</code> added to <code>_statC[index]</code> at the end of event.<br>
- * SUM2 - square of <code>_statE[index]</code> added to <code>_statC[index]</code> at the end of event.<br>
- * If no flag is given, SUM is assumed.<p>
- * NOPRINT - variable is not printed by {@link #printStatistics(EventHeader event)} and {@link #printCumulativeStatistics()}<br>
- * PRINTEVENT - variable is printed by {@link #printStatistics(EventHeader event)} but not by {@link #printCumulativeStatistics()}<br>
- * PRINTSUM - variable is printed by {@link #printCumulativeStatistics()} but not by {@link #printStatistics(EventHeader event)}<br>
- * PRINTALL - variable is printed by both {@link #printCumulativeStatistics()} and {@link #printStatistics(EventHeader event)}<br>
- * If no flag is given, PRINTALL is assumed.<p>
- * @return Index into {@link #_statE}, {@link #_statC}, and {@link #_statName} arrays that can be used to access the variable being created.
- */
- protected int createIndex(String name, IndexType... args) {
-
- int size;
- if (_statE == null) {
- _statE = new double[] {0.};
- _statC = new double[] {0.};
- _statName = new String[] {name};
- _statAccumulateFlag = new IndexType[] {IndexType.SUM};
- _statPrintFlag = new IndexType[] {IndexType.PRINTALL};
- size = 0;
- } else {
-
- size = _statE.length;
-
- double[] tempD = new double[size+1];
- System.arraycopy(_statE, 0, tempD, 0, size);
- _statE = tempD;
- _statE[size] = 0.;
-
- tempD = new double[size+1];
- System.arraycopy(_statC, 0, tempD, 0, size);
- _statC = tempD;
- _statC[size] = 0.;
-
- String[] tempS = new String[size+1];
- System.arraycopy(_statName, 0, tempS, 0, size);
- _statName = tempS;
- _statName[size] = name;
-
- IndexType[] tempI = new IndexType[size+1];
- System.arraycopy(_statAccumulateFlag, 0, tempI, 0, size);
- _statAccumulateFlag = tempI;
- _statAccumulateFlag[size] = IndexType.SUM;
-
- tempI = new IndexType[size+1];
- System.arraycopy(_statPrintFlag, 0, tempI, 0, size);
- _statPrintFlag = tempI;
- _statPrintFlag[size] = IndexType.PRINTSUM;
- }
-
- if (args != null) {
- for (IndexType type : args) {
- switch (type) {
- case NOSUM:
- case SUM:
- case SUM2:
- _statAccumulateFlag[size] = type; break;
- case NOPRINT:
- case PRINTEVENT:
- case PRINTSUM:
- case PRINTALL:
- _statPrintFlag[size] = type; break;
- }
- }
- }
-
- return size;
- }
-
- /** Print standard statistics at the end of an event to standard output. */
- protected void printStatistics(EventHeader event) {
- System.out.println("");
- System.out.println("Tracking test: " + _testName + ", statistics for event " + event.getEventNumber());
- for (int i=0; i<_statE.length; i++) {
- if (_statPrintFlag[i] == IndexType.PRINTEVENT || _statPrintFlag[i] == IndexType.PRINTALL) {
- System.out.println(" " + _statName[i] + " " + _statE[i]);
- }
- }
- System.out.println("");
- }
-
- /**
- * Print cumulative statistics to the log.
- * The output destination can be set with <tt>set("LOG_FILE", destination)</tt>.
- * See {@link #set(String, String)} for details.
- * @param messages Array of strings that should be printed before standard statistics.
- * @param printStandard Flag to indicate whether to print standard statistics.
- */
- protected void printCumulativeStatistics(boolean printStandard, String... messages) {
- ArrayList<String> msgList = new ArrayList<String>(20);
- msgList.add("");
- if (messages != null) for (String msg : messages) msgList.add(" " + msg);
- if (printStandard && _nEvents > 0) {
- for (int i=0; i<_statE.length; i++) {
- if (_statPrintFlag[i] == IndexType.PRINTSUM || _statPrintFlag[i] == IndexType.PRINTALL) {
- msgList.add(" Average " + _statName[i] + " " + _statC[i]/_nEvents);
- }
- }
- }
- msgList.add("");
- String[] msgArray = new String[msgList.size()];
- msgArray = msgList.toArray(msgArray);
- printLog("Tracking test: " + _testName + " cumulative statistics (" + _nEvents + " events)", msgArray);
- }
-
- /**
- * Print standard cumulative statistics.
- * The output destination can be set with <tt>set("LOG_FILE", destination)</tt>.
- * See {@link #set(String, String)} for details.
- */
- protected void printCumulativeStatistics() {printCumulativeStatistics(true);}
-
-// -- Miscellaneous utility methods : -----------------------------------------
-
- public IHistogram1D efficiencyHistogram(String title, IHistogram1D good, IHistogram1D all) {
- IHistogramFactory hFac = _aida.histogramFactory();
- //Histogram1D eff = (Histogram1D) hFac.createHistogram1D(title, all.axis().bins(), all.axis().lowerEdge(), all.axis().upperEdge());
- Histogram1D eff = (Histogram1D) hFac.divide(title, good, all);
- int nBins = eff.axis().bins()+2;
- double error[] = new double[nBins];
- double height[] = new double[nBins];
- for (int i = 0; i<nBins; i++) {
- int bin;
- if ( i == 0 ) {
- bin = IAxis.UNDERFLOW_BIN;
- } else if ( i == nBins+1 ) {
- bin = IAxis.OVERFLOW_BIN;
- } else {
- bin = i - 1;
- }
-
- double g = good.binHeight(bin);
- double a = all.binHeight(bin);
- height[bin] = eff.binHeight(bin);
- if (a < .1) {
- error[bin] = 0.;
- } else {
- double p = g/a;
- error[bin] = Math.min(1.-p, Math.sqrt((p*(1.-p))/a));
- }
- }
- eff.setContents(height, error, null, null, null);
- return eff;
- }
-
-// -- Private fields : --------------------------------------------------------
-
- protected String _testName = "";
-
- protected List<MCTrack> _mcTrackList;
- protected List<Track> _recoTrackList;
- protected ArrayList<RatedTrack> _ratedTrackList;
-
- protected String _mcTrackListName;
- protected String _recoTrackListName;
-
- protected double _mcTrackCut_Pt = 0.;
- protected double _mcTrackCut_theta = 0.;
- protected int _mcTrackCut_nLayers = 0;
-
- protected int _nEvents; // Number of events analyzed
- protected double[] _statE; // Array to hold per event statistics
- protected double[] _statC; // Array to hold cumulative statistics
- protected String[] _statName; // Array to hold names of statical variables
- protected IndexType[] _statAccumulateFlag; // Array to hold flags indicating accumulation methods
- protected IndexType[] _statPrintFlag ; // Array to hold flags indicating accumulation printing options
-
- protected AIDA _aida;
- protected ITree _tree;
-
- private boolean _runInProgress;
-
-}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/tester
diff -N package.html
--- package.html 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,8 +0,0 @@
-<html>
-<body>
-Performance testing package for track finders.
-<p>
-The package contains a base class ({@link TrackingTestBase}) for writing track finder
-performance tests, and a number of concrete tests.
-</body>
-</html>
CVSspam 0.2.8