LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  January 2015

HPS-SVN January 2015

Subject:

r1971 - in /java/trunk: monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java record-util/src/main/java/org/hps/record/composite/CompositeLoop.java record-util/src/main/java/org/hps/record/evio/EvioDetectorConditionsProcessor.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Thu, 22 Jan 2015 23:40:29 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (205 lines)

Author: [log in to unmask]
Date: Thu Jan 22 15:40:20 2015
New Revision: 1971

Log:
Fix conditions setup based on previous changes to event builder.  Also initial support for getting run numbers from events during monitoring session.

Added:
    java/trunk/record-util/src/main/java/org/hps/record/evio/EvioDetectorConditionsProcessor.java
Modified:
    java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java
    java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeLoop.java

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	Thu Jan 22 15:40:20 2015
@@ -60,7 +60,6 @@
 
 import javax.imageio.ImageIO;
 import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
@@ -70,7 +69,6 @@
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
-import javax.swing.JTabbedPane;
 import javax.swing.JTable;
 import javax.swing.SwingUtilities;
 import javax.swing.table.DefaultTableModel;
@@ -97,6 +95,7 @@
 import org.hps.record.composite.EventProcessingThread;
 import org.hps.record.enums.DataSourceType;
 import org.hps.record.et.EtConnection;
+import org.hps.record.evio.EvioDetectorConditionsProcessor;
 import org.jlab.coda.jevio.EvioException;
 import org.jlab.coda.jevio.EvioReader;
 import org.lcsim.conditions.ConditionsManager;
@@ -985,7 +984,7 @@
             // Start thread which will trigger a disconnect if the event processing finishes.
             startSessionWatchdogThread();            
 
-            // Apparently, the visible plots won't draw without this!  (Unless the user clicks directly on the tab.)
+            // FIXME: Apparently, the visible plots won't draw without this!  (Unless the user clicks directly on the tab.)
             plotWindow.getPlotPane().requestFocusInWindow();            
 
             log(Level.INFO, "Successfully started the monitoring session.");
@@ -1036,6 +1035,7 @@
                 throw new IOException(e);
             }
         } else {
+            // This is when a direct file source is used and ET is not needed.
             this.setConnectionStatus(ConnectionStatus.CONNECTED);
         }
     }
@@ -1114,16 +1114,19 @@
         try {
             // Create and the job manager.  The conditions manager is instantiated from this call but not configured.
             jobManager = new JobManager();
+                        
+            // Setup the event builder to translate from EVIO to LCIO.
+            // This must happen before Driver setup so the builder's listeners are activated first!
+            createEventBuilder();
+            
+            // Configure the job manager for the XML steering.
             jobManager.setPerformDryRun(true);
             if (steeringType == SteeringType.RESOURCE) {
                 setupSteeringResource(steering);
             } else if (steeringType.equals(SteeringType.FILE)) {
                 setupSteeringFile(steering);
             }
-
-            // Setup the event builder to translate from EVIO to LCIO.
-            createEventBuilder();
-            
+           
             // Is there a user specified run number from the JobPanel?
             if (configurationModel.hasPropertyValue(ConfigurationModel.USER_RUN_NUMBER_PROPERTY)) {
                 int userRunNumber = configurationModel.getUserRunNumber();
@@ -1181,10 +1184,7 @@
             throw new RuntimeException("Failed to create LCSimEventBuilder.", e);
         }
 
-        // Set the detector name on the event builder so it can find conditions data.
-        // FIXME: This call should be made unnecessary by modifying the EventBuilder API to remove setDetectorName.
-        //eventBuilder.setDetectorName(configurationModel.getDetectorName());
-
+        // Add the builder as a listener so it is notified when conditions change.
         ConditionsManager.defaultInstance().addConditionsListener(eventBuilder);
 
         log(Level.CONFIG, "Successfully initialized event builder <" + eventBuilderClassName + ">");
@@ -1345,10 +1345,13 @@
 
         // RunPanel updater.
         loopConfig.add(runPanel.new RunModelUpdater());
+        
+        // Setup for conditions activation via EVIO events.
+        loopConfig.add(new EvioDetectorConditionsProcessor(configurationModel.getDetectorName()));
 
         // Create the CompositeLoop with the configuration.
         loop = new CompositeLoop(loopConfig);
-
+                
         // Create the processing thread.
         processingThread = new EventProcessingThread(loop);
 

Modified: java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeLoop.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeLoop.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeLoop.java	Thu Jan 22 15:40:20 2015
@@ -293,9 +293,10 @@
             if (config.eventBuilder != null) {
                 if (config.detectorName != null) {
                     // Is LCSim ConditionsManager installed yet?
-                    if (!ConditionsManager.isSetup())
-                        // Setup LCSim conditions system if not already.
+                    if (!ConditionsManager.isSetup()) {
+                        // Setup default LCSim conditions system if not already.
                         LCSimConditionsManagerImplementation.register();
+                    }
                     //config.eventBuilder.setDetectorName(config.detectorName);
                 } else {
                     throw new IllegalArgumentException("Missing detectorName in configuration.");

Added: java/trunk/record-util/src/main/java/org/hps/record/evio/EvioDetectorConditionsProcessor.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/EvioDetectorConditionsProcessor.java	(added)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/EvioDetectorConditionsProcessor.java	Thu Jan 22 15:40:20 2015
@@ -0,0 +1,71 @@
+package org.hps.record.evio;
+
+import org.jlab.coda.jevio.BaseStructure;
+import org.jlab.coda.jevio.EvioEvent;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
+
+/**
+ * <p>
+ * This is an {@link EvioEventProcessor} for initializing the conditions system
+ * from EVIO events.
+ * <p>
+ * The {@link #startRun(EvioEvent)} method will setup conditions from the pre start
+ * events.
+ * <p>
+ * The {@link #process(EvioEvent)} method will setup conditions from a head bank
+ * if it is present in the event.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class EvioDetectorConditionsProcessor extends EvioEventProcessor {
+
+    private String detectorName;
+    
+    public EvioDetectorConditionsProcessor(String detectorName) {
+        if (detectorName == null) {
+            throw new IllegalArgumentException("The detectorName argument is null.");
+        }
+        this.detectorName = detectorName;
+    }
+    
+    @Override
+    public void process(EvioEvent evioEvent) throws Exception {
+        // Get the head head bank from event.
+        BaseStructure headBank = EvioEventUtilities.getHeadBank(evioEvent);
+        
+        // Is the head bank present?
+        if (headBank != null) { 
+                                
+            // Get the run number from the head bank.
+            int runNumber = headBank.getIntData()[1];                    
+
+            // Initialize the conditions system from the detector name and run number.
+            try {
+                ConditionsManager.defaultInstance().setDetector(detectorName, runNumber);
+            } catch (ConditionsNotFoundException e) {
+                throw new RuntimeException("Error setting up conditions from EVIO head bank.", e);
+            }                   
+        } 
+    }
+
+    @Override
+    public void startRun(EvioEvent evioEvent) {
+        System.out.println("EvioDetectorConditionsProcessor.startRun");
+        if (EvioEventUtilities.isPreStartEvent(evioEvent)) {
+            // Get the pre start event's data bank.
+            int[] data = EvioEventUtilities.getControlEventData(evioEvent);
+            
+            // Get the run number from the bank.
+            int runNumber = data[1];            
+            
+            // Initialize the conditions system from the detector name and run number.
+            try {
+                System.out.println("  setting up conditions from pre start: " + detectorName + " #" + runNumber);
+                ConditionsManager.defaultInstance().setDetector(detectorName, runNumber);
+            } catch (ConditionsNotFoundException e) {
+                throw new RuntimeException("Error setting up conditions from EVIO pre start event.", e);
+            }
+        }
+    }
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use