hps-java/src/main/java/org/lcsim/hps/util
diff -N ClockSingleton.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ClockSingleton.java 29 Aug 2011 23:03:20 -0000 1.1
@@ -0,0 +1,43 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.util;
+
+/**
+ * singleton clock class - use ClockDriver to control.
+ * A better solution might be to store event number/absolute time in the event.
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: ClockSingleton.java,v 1.1 2011/08/29 23:03:20 meeg Exp $
+ */
+public class ClockSingleton {
+ public static final ClockSingleton _instance = new ClockSingleton();
+
+ private int clock = 0;
+ //time between events (bunch spacing)
+ private double dt = 2.0;
+
+ private ClockSingleton() {
+ }
+
+ public static int getClock() {
+ return _instance.clock;
+ }
+
+ public static double getTime() {
+ return _instance.dt * _instance.clock;
+ }
+
+ public static double getDt() {
+ return _instance.dt;
+ }
+
+ public static void setDt(double dt) {
+ _instance.dt = dt;
+ }
+
+ public static void step() {
+ _instance.clock++;
+ }
+}
hps-java/src/main/java/org/lcsim/hps/util
diff -N ClockDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ClockDriver.java 29 Aug 2011 23:03:20 -0000 1.1
@@ -0,0 +1,24 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.util;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+
+/**
+ * Driver to run the clock in ClockSingleton. Run this driver last.
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: ClockDriver.java,v 1.1 2011/08/29 23:03:20 meeg Exp $
+ */
+public class ClockDriver extends Driver {
+ public void setDt(double dt) {
+ ClockSingleton.setDt(dt);
+ }
+
+ public void process(EventHeader event) {
+ ClockSingleton.step();
+ }
+}