Print

Print


Author: [log in to unmask]
Date: Fri Nov  7 13:10:05 2014
New Revision: 1450

Log:
Fix up event builder setup so it works with monitoring app.

Modified:
    java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.java
    java/trunk/evio/src/main/java/org/hps/evio/LCSimEventBuilder.java
    java/trunk/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java
    java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java

Modified: java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.java	Fri Nov  7 13:10:05 2014
@@ -41,7 +41,7 @@
     private static final String readoutName = "EcalHits";
     private static final String subdetectorName = "Ecal";
 //    private Detector detector;
-    private final Subdetector subDetector;
+    private Subdetector subDetector;
 
     private static EcalConditions ecalConditions = null;
     private static IIdentifierHelper helper = null;
@@ -53,22 +53,13 @@
         this.botBankTag = botBankTag;
         hitCollectionName = "EcalReadoutHits";
 
-        subDetector = DatabaseConditionsManager.getInstance().getDetectorObject().getSubdetector(subdetectorName);
-
-        // ECAL combined conditions object.
-        ecalConditions = ConditionsManager.defaultInstance()
-                .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
-
-        helper = subDetector.getDetectorElement().getIdentifierHelper();
-
-        System.out.println("You are now using the database conditions for ECalEvioReader.java");
+        //System.out.println("You are now using the database conditions for ECalEvioReader.java");
         // ID helper.
 //        helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
     }
 
     public void setTopBankTag(int topBankTag) {
         this.topBankTag = topBankTag;
-
     }
 
     public void setBotBankTag(int botBankTag) {
@@ -307,4 +298,14 @@
         }
         return hits;
     }
+    
+    void initialize() {
+        subDetector = DatabaseConditionsManager.getInstance().getDetectorObject().getSubdetector(subdetectorName);
+        
+        // ECAL combined conditions object.
+        ecalConditions = ConditionsManager.defaultInstance()
+                .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+        helper = subDetector.getDetectorElement().getIdentifierHelper();
+    }
 }

Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimEventBuilder.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/LCSimEventBuilder.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/LCSimEventBuilder.java	Fri Nov  7 13:10:05 2014
@@ -1,9 +1,10 @@
 package org.hps.evio;
 
 import org.jlab.coda.jevio.EvioEvent;
+import org.lcsim.conditions.ConditionsListener;
 import org.lcsim.event.EventHeader;
 
-public interface LCSimEventBuilder {
+public interface LCSimEventBuilder extends ConditionsListener {
 
     /**
      * Read any run information out of an EVIO event (not necessarily a physics event).
@@ -18,8 +19,10 @@
      */
     EventHeader makeLCSimEvent(EvioEvent evioEvent);
 
+    // FIXME: Why is this needed here when checking the header tag is a static operation on the EvioEvent?  
     boolean isPhysicsEvent(EvioEvent evioEvent);
 
+    // FIXME: This should not be a method on the API.  It should come from the conditions system.
     void setDetectorName(String detectorName);
 
     void setDebug(boolean debug);

Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java	Fri Nov  7 13:10:05 2014
@@ -5,12 +5,15 @@
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import org.hps.readout.ecal.TriggerData;
 import org.jlab.coda.jevio.BaseStructure;
 import org.jlab.coda.jevio.EvioEvent;
+import org.lcsim.conditions.ConditionsEvent;
+import org.lcsim.conditions.ConditionsListener;
+import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.base.BaseLCSimEvent;
-import org.lcsim.geometry.Detector;
 
 /**
  * Build LCSim events from EVIO data.
@@ -20,13 +23,14 @@
  * @version $Id: LCSimTestRunEventBuilder.java,v 1.24 2013/03/01 01:30:25 meeg
  * Exp $
  */
-public class LCSimTestRunEventBuilder implements LCSimEventBuilder {
+public class LCSimTestRunEventBuilder implements LCSimEventBuilder, ConditionsListener {
 
     // Names of subdetectors.
 //    private String trackerName;
     // Detector conditions object.
-    protected Detector detector;
+	//protected Detector detector;
     // Debug flag.
+	String detectorName = null;
     protected boolean debug = false;
     ECalEvioReader ecalReader = null;
     SVTEvioReader svtReader = null;
@@ -42,10 +46,7 @@
 
     @Override
     public void setDetectorName(String detectorName) {
-        // Make a dummy event to setup the conditions system.
-        EventHeader dummyEvent = new BaseLCSimEvent(0, 0, detectorName);
-        detector = dummyEvent.getDetector();
-//        EcalConditions.loadDaqMap(detector, "Ecal");
+    	this.detectorName = detectorName;
     }
 
     @Override
@@ -156,8 +157,9 @@
         }
 
         // Create a new LCSimEvent.
-        EventHeader lcsimEvent = new BaseLCSimEvent(run, eventID[0], detector.getDetectorName(), time);
-
+        //EventHeader lcsimEvent = new BaseLCSimEvent(run, eventID[0], detector.getDetectorName(), time);
+        EventHeader lcsimEvent = new BaseLCSimEvent(run, eventID[0], detectorName, time);
+        
         lcsimEvent.put("TriggerBank", triggerList, TriggerData.class, 0);
         return lcsimEvent;
     }
@@ -187,4 +189,9 @@
         time = ((long) triggerData.getTime()) * 1000000000;
         return triggerData;
     }
+
+	@Override
+	public void conditionsChanged(ConditionsEvent conditionsEvent) {
+		ecalReader.initialize();
+	}
 }

Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java
 =============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java	(original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java	Fri Nov  7 13:10:05 2014
@@ -95,6 +95,7 @@
 import org.hps.record.et.EtConnection;
 import org.jlab.coda.jevio.EvioException;
 import org.jlab.coda.jevio.EvioReader;
+import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.job.JobControlManager;
 import org.lcsim.lcio.LCIOReader;
 import org.lcsim.util.Driver;
@@ -1191,6 +1192,8 @@
 
         // Set the detector name on the event builder so it can find conditions data.
         eventBuilder.setDetectorName(configurationModel.getDetectorName());
+        
+        ConditionsManager.defaultInstance().addConditionsListener(eventBuilder);
 
         log(Level.CONFIG, "Successfully initialized event builder <" + eventBuilderClassName + ">");
     }