hps-java/src/main/java/org/lcsim/hps/util
diff -N HPSLCIOFilterDriver.java
--- HPSLCIOFilterDriver.java 15 Jan 2013 18:55:17 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.lcsim.hps.util;
-import java.io.IOException;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.Track;
-import org.lcsim.util.Driver;
-import org.lcsim.util.lcio.LCIOWriter;
-
-/**
- *
- * @author phansson
- */
-public abstract class HPSLCIOFilterDriver extends Driver {
- protected String outputFile;
- protected LCIOWriter writer;
- protected boolean debug = false;
-
- public HPSLCIOFilterDriver() {
- }
-
- public void setOutputFilePath(String output) {
- this.outputFile = output;
- }
-
- public void setDebug(boolean debug) {
- this.debug = debug;
- }
-
- abstract boolean eventFilter(EventHeader event);
-
- private void setupWriter() {
- // Cleanup existing writer.
- if (writer != null) {
- try {
- writer.flush();
- writer.close();
- writer = null;
- } catch (IOException x) {
- System.err.println(x.getMessage());
- }
- }
-
- // Setup new writer.
- try {
- writer = new LCIOWriter(outputFile);
- } catch (IOException x) {
- throw new RuntimeException("Error creating writer", x);
- }
-
-
- try {
- writer.reOpen();
- } catch (IOException x) {
- throw new RuntimeException("Error rewinding LCIO file", x);
- }
- }
-
- protected void startOfData() {
- setupWriter();
- }
-
- protected void endOfData() {
- try {
- writer.close();
- } catch (IOException x) {
- throw new RuntimeException("Error rewinding LCIO file", x);
- }
- }
-
- protected void process(EventHeader event) {
-
- if(eventFilter(event)) {
- try {
- writer.write(event);
- } catch (IOException x) {
- throw new RuntimeException("Error writing LCIO file", x);
- }
- }
- }
-
- protected void suspend() {
- try {
- writer.flush();
- } catch (IOException x) {
- throw new RuntimeException("Error flushing LCIO file", x);
- }
- }
-
-}
hps-java/src/main/java/org/lcsim/hps/util
diff -N HPSTwoTrackFilterDriver.java
--- HPSTwoTrackFilterDriver.java 15 Jan 2013 18:55:17 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,51 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.lcsim.hps.util;
-
-import org.lcsim.hps.util.HPSLCIOFilterDriver;
-import java.io.IOException;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.Track;
-import org.lcsim.util.Driver;
-
-/**
- *
- * @author phansson
- */
-public class HPSTwoTrackFilterDriver extends HPSLCIOFilterDriver {
- private String trackCollectionName = "MatchedTracks";
-
- public HPSTwoTrackFilterDriver() {
- }
-
- public void setTrackCollectionNamePath(String trackCollection) {
- this.trackCollectionName = trackCollection;
- }
-
- @Override
- boolean eventFilter(EventHeader event) {
- boolean pass = false;
-
- if(!event.hasCollection(Track.class, trackCollectionName)) {
- throw new RuntimeException("Error, event doesn't have the track collection");
- }
-
- if(this.debug) {
- System.out.printf("%s: %d tracks in this event\n",this.getClass().getSimpleName(),event.get(Track.class, trackCollectionName).size());
- }
-
- if (event.get(Track.class, trackCollectionName).size()>1) {
- try {
- writer.write(event);
- } catch (IOException x) {
- throw new RuntimeException("Error writing LCIO file", x);
- }
- }
-
-
- return pass;
- }
-
-}