Print

Print


Author: [log in to unmask]
Date: Wed Nov  5 07:25:41 2014
New Revision: 1439

Log:
Test case for Engineering Run EVIO to LCIO (currently not working).

Added:
    java/trunk/evio/src/test/
    java/trunk/evio/src/test/java/
    java/trunk/evio/src/test/java/org/
    java/trunk/evio/src/test/java/org/hps/
    java/trunk/evio/src/test/java/org/hps/evio/
    java/trunk/evio/src/test/java/org/hps/evio/LCSimEngRunEventBuilderTest.java
Modified:
    java/trunk/evio/pom.xml

Modified: java/trunk/evio/pom.xml
 =============================================================================
--- java/trunk/evio/pom.xml	(original)
+++ java/trunk/evio/pom.xml	Wed Nov  5 07:25:41 2014
@@ -28,6 +28,16 @@
     </dependencies>
     <build>
         <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>org/hps/evio/LCSimEngRunEventBuilderTest.java</exclude>
+                    </excludes>
+                    <trimStackTrace>true</trimStackTrace>
+                </configuration>
+            </plugin>
             <plugin>
                 <artifactId>maven-resources-plugin</artifactId>
                 <executions>
@@ -106,4 +116,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
+</project>

Added: java/trunk/evio/src/test/java/org/hps/evio/LCSimEngRunEventBuilderTest.java
 =============================================================================
--- java/trunk/evio/src/test/java/org/hps/evio/LCSimEngRunEventBuilderTest.java	(added)
+++ java/trunk/evio/src/test/java/org/hps/evio/LCSimEngRunEventBuilderTest.java	Wed Nov  5 07:25:41 2014
@@ -0,0 +1,75 @@
+package org.hps.evio;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.hps.conditions.DatabaseConditionsManager;
+import org.jlab.coda.jevio.EvioEvent;
+import org.jlab.coda.jevio.EvioReader;
+import org.lcsim.event.EventHeader;
+import org.lcsim.lcio.LCIOWriter;
+import org.lcsim.util.cache.FileCache;
+import org.lcsim.util.test.TestUtil.TestOutputFile;
+
+/**
+ * Test conversion of EVIO to LCIO for Engineering Run EVIO data.
+ * This is ECAL data only for now.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class LCSimEngRunEventBuilderTest extends TestCase {
+		
+	public void testLCSimEngRunEventBuilder() throws Exception {
+	
+		// Setup database conditions.
+		DatabaseConditionsManager conditionsManager = new DatabaseConditionsManager();
+		conditionsManager.setConnectionResource("/org/hps/conditions/config/conditions_dev.properties");
+		conditionsManager.configure("/org/hps/conditions/config/conditions_dev.xml");
+		conditionsManager.register();
+		conditionsManager.setDetector("HPS-Proposal2014-v8-6pt6", 0);
+		
+		// Configure LCIO writer.
+		new TestOutputFile(getClass().getSimpleName()).mkdirs();
+		File lcioFile = new TestOutputFile(getClass().getSimpleName() + File.separator + getClass().getSimpleName() + "_output");
+        LCIOWriter writer;
+		try {
+            writer = new LCIOWriter(lcioFile);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+		
+		// Create event builder.
+		LCSimEventBuilder builder = new LCSimEngRunEventBuilder();
+		
+		// Get remote test file.
+		FileCache cache = new FileCache();
+		File evioFile = cache.getCachedFile(new URL("http://www.lcsim.org/test/hps-java/LCSimEngRunEventBuilderTest/hps_002744.evio.0"));
+
+		// Open the EVIO reader.
+        System.out.println("Opening file " + evioFile);
+        EvioReader reader = null;
+        try {
+            reader = new EvioReader(evioFile);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        
+        // Run the event builder on the EVIO.
+        EvioEvent evioEvent = null;
+        while ((evioEvent = reader.nextEvent()) != null) {
+        	reader.parseEvent(evioEvent);
+    		builder.readEvioEvent(evioEvent);
+        	if (builder.isPhysicsEvent(evioEvent)) {
+        		EventHeader lcsimEvent = builder.makeLCSimEvent(evioEvent);
+        		System.out.println("created LCSim event #" + lcsimEvent.getEventNumber());
+        		writer.write(lcsimEvent);
+        	}
+        }
+        
+        // Close the LCIO writer.
+        writer.flush();
+        writer.close();
+	}
+}