Print

Print


Commit in lcsim/src/org/lcsim on MAIN
conditions/ConditionsManagerImplementation.java+2-21.6 -> 1.7
          /ConditionsManager.java+131.6 -> 1.7
util/Driver.java+32-91.11 -> 1.12
    /DriverAdapter.java+18-21.4 -> 1.5
plugin/web/examples/FastMC.java+2-21.1 -> 1.2
plugin/web/index.html+11.3 -> 1.4
+68-15
6 modified files
Add global listeners to ConditionsManager
Add detectorChanged method to Driver
Add HLEVEL_NORMAL etc constants to Driver to make histogram level clearer
Add link to FAQ from org.lcsim page build into JAS plugin

lcsim/src/org/lcsim/conditions
ConditionsManagerImplementation.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- ConditionsManagerImplementation.java	5 Apr 2006 09:09:10 -0000	1.6
+++ ConditionsManagerImplementation.java	3 Apr 2007 18:02:34 -0000	1.7
@@ -96,11 +96,11 @@
    {
       return detectorName;
    }
-   void addConditionsListener(ConditionsListener l)
+   public void addConditionsListener(ConditionsListener l)
    {
       listenerList.add(l);
    }
-   void removeConditionsListener(ConditionsListener l)
+   public void removeConditionsListener(ConditionsListener l)
    {
       listenerList.remove(l);
    }

lcsim/src/org/lcsim/conditions
ConditionsManager.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- ConditionsManager.java	5 Apr 2006 09:09:10 -0000	1.6
+++ ConditionsManager.java	3 Apr 2007 18:02:34 -0000	1.7
@@ -89,6 +89,18 @@
    public abstract void removeConditionsConverter(ConditionsConverter conv);
    
    /**
+    * Add a listener to be notified about changes to ANY conditions.
+    * @param listener The listener to add.
+    */
+   public abstract void addConditionsListener(ConditionsListener listener);
+   
+   /**
+    * Remove a global change listener.
+    * @param listener The listener to remove.
+    */
+   public abstract void removeConditionsListener(ConditionsListener listener);
+   
+   /**
     * Thrown if conditions associated with a given detector can not be found.
     */
    public static class ConditionsNotFoundException extends Exception
@@ -102,6 +114,7 @@
          super("Conditions not found for detector "+name,t);
       }
    }
+   
    /**
     * Thrown if specific set of conditions can not be found.
     */

lcsim/src/org/lcsim/util
Driver.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- Driver.java	2 Apr 2007 22:55:51 -0000	1.11
+++ Driver.java	3 Apr 2007 18:02:34 -0000	1.12
@@ -12,6 +12,7 @@
 import java.util.logging.StreamHandler;
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
 
 /**
  * A driver is a steering routine which can deal with event processing, and/or
@@ -22,23 +23,32 @@
  * and handles coordination of random numbers between Monte Carlo processors.
  *
  * @author Tony Johnson
- * @version $Id: Driver.java,v 1.11 2007/04/02 22:55:51 tonyj Exp $
+ * @version $Id: Driver.java,v 1.12 2007/04/03 18:02:34 tonyj Exp $
  */
 
 public class Driver
 {
+   // We dont use an enum, because we want to be able to test for level>some value.
+   // and because drivers can use special values for special purposes.
+   public final static int HLEVEL_DEFAULT = -1;
+   public final static int HLEVEL_OFF = 0;
+   public final static int HLEVEL_NORMAL=1;
+   public final static int HLEVEL_HIGH=3;
+   public final static int HLEVEL_FULL=5;
+   
    private static Driver mother = new MotherOfAllDrivers();
    private final List<Driver> subDrivers = new ArrayList<Driver>();
    private Driver parent = mother;
-   private int histogramLevel = -1;
+   private int histogramLevel = HLEVEL_DEFAULT;
    private Random random;
    private final String driverName;
-
+   
+   
    public Driver()
    {
       this(null);
    }
-
+   
    Driver(String name)
    {
       if (name == null || name.length() == 0)
@@ -95,8 +105,8 @@
       return Logger.getLogger(pathToMother());
    }
    
-   /** 
-    * Get the name of this driver. Normally this will be the class name of the 
+   /**
+    * Get the name of this driver. Normally this will be the class name of the
     * driver (without the packaging information).
     */
    public String getName()
@@ -114,9 +124,11 @@
     */
    public int getHistogramLevel()
    {
-      return histogramLevel < 0 ? parent.getHistogramLevel() : histogramLevel;
+      return histogramLevel <= HLEVEL_DEFAULT ? parent.getHistogramLevel() : histogramLevel;
    }
-   
+   /**
+    * Set the histogram level for this driver (and its child drivers)
+    */
    public void setHistogramLevel(int level)
    {
       histogramLevel = level;
@@ -155,6 +167,15 @@
    {
       for (Driver driver : subDrivers) driver.startOfData();
    }
+   
+   /** Called by the framework before process method when the detector geometry changes. 
+    * This method is gauranteed to be called once before the first call to process. 
+    * @param Detector The new detector
+    */
+   protected void detectorChanged(Detector detector)
+   {
+      for (Driver driver : subDrivers) driver.detectorChanged(detector);
+   }
    /**
     * Called by the framework to process an event. Don't forget to call
     * <code>super.process(event)</code> to cause the child processes to
@@ -192,6 +213,8 @@
    {
       this.random = random;
    }
+   
+   
    // The only driver that does not have a parent
    // This is used to set defaults for "inherited" items
    private static class MotherOfAllDrivers extends Driver
@@ -199,7 +222,7 @@
       private Random random = new Random();
       MotherOfAllDrivers()
       {
-         super ("TOP");
+         super("TOP");
          StreamHandler handler = new StreamHandler(System.out,new DriverFormatter());
          handler.setLevel(Level.ALL);
          getLogger().setUseParentHandlers(false);

lcsim/src/org/lcsim/util
DriverAdapter.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- DriverAdapter.java	2 Apr 2007 22:55:51 -0000	1.4
+++ DriverAdapter.java	3 Apr 2007 18:02:34 -0000	1.5
@@ -8,12 +8,13 @@
 import org.freehep.record.loop.event.RecordEvent;
 import org.freehep.record.loop.event.RecordSuppliedEvent;
 import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
 
 
 /**
  * Drive a Driver from a Record loop
  * @author Tony Johnson
- * @version $Id: DriverAdapter.java,v 1.4 2007/04/02 22:55:51 tonyj Exp $
+ * @version $Id: DriverAdapter.java,v 1.5 2007/04/03 18:02:34 tonyj Exp $
  */
 public class DriverAdapter extends RecordAdapter
 {
@@ -23,6 +24,7 @@
    // redirection of the recordSupplied method)
    private ConsoleService cs;
    private ConsoleOutputStream out;
+   private Detector detector;
    
    public DriverAdapter(Driver driver)
    {
@@ -61,13 +63,27 @@
       try
       {
          Object event = rse.getRecord();
-         if (event instanceof EventHeader) driver.process((EventHeader) event);
+         if (event instanceof EventHeader) 
+         {
+            EventHeader evt = (EventHeader) event;
+            if (detector != evt.getDetector()) 
+            {
+               detectorChanged(evt.getDetector());
+             }
+            driver.process(evt);
+         }
       }
       catch (Driver.NextEventException x)
       {
          // OK, just continue with next event.
       }
    }
+  
+   private void detectorChanged(Detector detector)
+   {
+      this.detector = detector;
+      driver.detectorChanged(detector);
+   }
    
    public void configure(ConfigurationEvent event)
    {

lcsim/src/org/lcsim/plugin/web/examples
FastMC.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- FastMC.java	14 Feb 2006 19:45:11 -0000	1.1
+++ FastMC.java	3 Apr 2007 18:02:34 -0000	1.2
@@ -7,7 +7,7 @@
  * @see org.lcsim.mc.fast
  * 
  * @author Norman Graf
- * @version $Id: FastMC.java,v 1.1 2006/02/14 19:45:11 jeremy Exp $
+ * @version $Id: FastMC.java,v 1.2 2007/04/03 18:02:34 tonyj Exp $
  */
 public class FastMC extends Driver
 {
@@ -16,7 +16,7 @@
       // Create MCFast with standard options
       Driver fast = new MCFast();
       // Turn on diagnostic histograms
-      fast.setHistogramLevel(1);
+      fast.setHistogramLevel(HLEVEL_NORMAL);
       // Add as sub-driver
       add(fast);
    }

lcsim/src/org/lcsim/plugin/web
index.html 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- index.html	6 Jan 2006 22:46:26 -0000	1.3
+++ index.html	3 Apr 2007 18:02:34 -0000	1.4
@@ -11,6 +11,7 @@
   <ul>
   <li><a target="_external" href="http://confluence.slac.stanford.edu/display/ilc/lcsim+Getting+Started  ">Getting started tutorial</a> 
   <li><a target="_external" href="http://www.lcsim.org/software/lcsim">org.lcsim home page</a>.
+  <li><a target="_external" href="http://confluence.slac.stanford.edu/x/xHE">org.lcsim frequently asked questions (with answers)</a>.
   </ul>
   </body>
 </html>
CVSspam 0.2.8