Commit in hps-java/src/test/java/org/lcsim on MAIN
DoEvioTest.java-4031.10 removed
DummyEvioTest.java-221.1 removed
hps/evio/DoEvioTest.java+406added 1.1
        /DummyEvioTest.java+22added 1.1
        /DumpRyanEvioFile.java+62added 1.1
hps/recon/tracking/WriteEvio4TestFileForRyan.java+64added 1.1
+554-425
4 added + 2 removed, total 6 files
add some new tests; move some existing tests to proper package

hps-java/src/test/java/org/lcsim
DoEvioTest.java removed after 1.10
diff -N DoEvioTest.java
--- DoEvioTest.java	1 Mar 2012 22:31:27 -0000	1.10
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,403 +0,0 @@
-package org.lcsim;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.IntBuffer;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jlab.coda.jevio.BaseStructureHeader;
-import org.jlab.coda.jevio.EventParser;
-import org.jlab.coda.jevio.EvioEvent;
-import org.jlab.coda.jevio.EvioException;
-import org.jlab.coda.jevio.EvioFile;
-import org.jlab.coda.jevio.IBlockHeader;
-import org.jlab.coda.jevio.IEvioListener;
-import org.jlab.coda.jevio.IEvioStructure;
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.event.RawTrackerHit;
-import org.lcsim.event.SimTrackerHit;
-import org.lcsim.event.base.BaseLCSimEvent;
-import org.lcsim.event.base.BaseRawTrackerHit;
-import org.lcsim.util.lcio.LCIOWriter;
-
-/**
- * This is a test of using jevio routines to read EVIO files.  
- * 
- * @author homer
- * @version $Id: DoEvioTest.java,v 1.10 2012/03/01 22:31:27 jeremy Exp $
- */
-public class DoEvioTest extends TestCase {
-
-    private LCIOWriter writer;
-    BaseLCSimEvent newEvent;
-    int VERBOSE = 2;
-    
-    /**
-     * The buffer representing a map of the input file.
-     */
-    private MappedByteBuffer trkByteBuffer;
-    int eventDataSizeBytes = 8000000;
-//        byte rawdataInts[] = new byte[eventDataSizeBytes];
-    int rawdataInts[] = new int[eventDataSizeBytes];
-    int rawdataLength = 0;
-
-    public void testDoTestEvio() throws IOException {
-        System.out.println("Test for EVIO.");
-
-        final int UNKNOWN32 = (0x0);
-        final int UINT32 = (0x1);
-        final int FLOAT32 = (0x2);
-        final int CHARSTAR8 = (0x3);
-        final int SHORT16 = (0x4);
-        final int USHORT16 = (0x5);
-        final int CHAR8 = (0x6);
-        final int UCHAR8 = (0x7);
-        final int DOUBLE64 = (0x8);
-        final int LONG64 = (0x9);
-        final int ULONG64 = (0xa);
-        final int INT32 = (0xb);
-        final int TAGSEGMENT = (0xc);
-        final int SEGMENT = (0xd);
-        final int BANK = (0xe);
-        final int ALSOBANK = (0x10);
-        final int ALSOSEGMENT = (0x20);
-        final int ALSOTAGSEGMENT = (0x40);
-        final int TRACKERTAG = (600);
-
-    // load the DAQ to LCSim cell maps
-final MapDAQCellID mapcell = new MapDAQCellID();
-    mapcell.fillSVTCellMap();
-    
-        //        String fileName = "/mydat/neal/hps/cedExport/data/dvcs_5_500.ev";
-        String fileName = "/mydat/myhpstest/hps_test_data_2011_nov_18_1.evio";
-//        String fileName = "/mydat/myhpstest/sample.dat";
-// Tracker data file name for testing
-        String TrkFileName = "/mydat/myhpstest/00_baseline.bin";
-
-
-        ByteBuffer buf = ByteBuffer.allocate(1000 * 8192);
-
-        if (VERBOSE > 4) {
-            System.out.println("step1" + TRACKERTAG);
-        }
-        // parse bytes
-        class myListener implements IEvioListener {
-
-            public void startEventParse(EvioEvent evioEvent) {
-                if (VERBOSE > 4) {
-                    System.out.println("step2");
-                }
-            }
-
-            public void endEventParse(EvioEvent evioEvent) {
-                if (VERBOSE > 4) {
-                    System.out.println("step3 - endEventParse");
-                }
-            }
-
-            public void gotStructure(EvioEvent evioEvent, IEvioStructure structure) {
-
-                BaseStructureHeader header = structure.getHeader();
-
-//                System.out.println("------------------");
-                if (VERBOSE > 0) {
-                    System.out.println("" + structure);
-                }
-//                System.out.println("Tag type = " + header.getTag());
-
-                switch (header.getTag()) {
-                    case TRACKERTAG: //Tracker (will be TRACKERTAG)
-//                        IReadout ro;
-                        if (header.getDataType().getValue() != INT32) { // Is this right???
-                            System.out.println("Non INT32 Tracker Data!!!");
-                            break;
-                        }
-                        System.out.println("about to simulate having received tracker EVIO data");
-
-                        List<RawTrackerHit> raw_hits = new ArrayList<RawTrackerHit>();
-                        List<SimTrackerHit> sim_hits = new ArrayList<SimTrackerHit>();
-
-                        HPSTrackerEvent trkev = new HPSTrackerEvent();
-                        int trkdata[] = structure.getIntData();
-
-                        int trklength = header.getLength();
-                        IntBuffer trkIntBuffer = IntBuffer.wrap(trkdata);
-//                        for (int ii=0; ii<10; ii++) System.out.println("trkdata["+ii+"] = "+trkdata[ii]+"\t"+Integer.toString(trkdata[ii] & 0xffff, 16).toUpperCase());
-
-// ---- this is the code needed for real EVIO data (IF! IntBuffer is too slow.)
-//                        int dataStartMarker = 0;
-//                        while (dataStartMarker<trklength) {
-//                        int frameSize = trkdata[dataStartMarker];
-//                        for (int ii = 1; ii <= frameSize; ii++) {
-//                                rawdataInts[ii] = trkdata[dataStartMarker+ii];
-//                        }
-//                        dataStartMarker+=frameSize;
-// ----------------------------------------------------                        
-
-//R                        int frameSize = trkIntBuffer.get();
-//R                        while (trkIntBuffer.hasRemaining() && frameSize!=0) {
-                        int frameSize = trkByteBuffer.getInt();
-                        while (trkByteBuffer.hasRemaining() && frameSize != 0) {
-                            for (int ii = 0; ii < frameSize; ii++) {
-                                rawdataInts[ii] = trkByteBuffer.getInt();
-//R                                rawdataInts[ii] = trkIntBuffer.get();
-                            }
-                            if (VERBOSE > 4) {
-                                for (int ii = 0; ii < 10; ii++) {
-                                    System.out.println("rawdataInts[" + ii + "] = " + rawdataInts[ii] + "\t"
-                                            + Integer.toString((rawdataInts[ii] >> 16) & 0xffff, 16).toUpperCase() + ":"
-                                            + Integer.toString(rawdataInts[ii] & 0xffff, 16).toUpperCase());
-                                }
-                            }
-                            trkev.setSize(frameSize);
-                            trkev.setData(rawdataInts);
-                            if (VERBOSE > 1) {
-                                System.out.println("starting loop over samples");
-                            }
-//                        for (int i = 0; i < header.getNumber(); i++) {
-                            for (int i = 0; i < trkev.count(); i++) {
-                                if (VERBOSE > 4) {
-                                    System.out.println("sample# = " + i);
-                                }
-                                HPSTrackerSample trksamp = trkev.sample(i);
-//                            System.out.println("got trksamp, trksamp = " + trksamp);
-                                long chanaddr = trksamp.channel();
-                                if (VERBOSE > 3) {
-                                    System.out.println("got CellID");
-                                }
-                                int LCSimCellID_ = mapcell.SVTCellIDlookup(chanaddr);
-                                if (VERBOSE > 3) {
-                                    System.out.println("got corresponding LCSim CellID = "+LCSimCellID_);
-                                }
-                                
-                                long chanapv = trksamp.apv();
-                                if (VERBOSE > 3) {
-                                    System.out.println("got apv");
-                                }
-                                short chanadc[] = new short[6];
-                                if (VERBOSE > 3) {
-                                    System.out.println("getting sample data");
-                                }
-
-                                for (int isamp = 0; isamp < 6; isamp++) {
-//                                System.out.println("sample = " + isamp);
-
-                                    chanadc[isamp] = (short) trksamp.value(isamp);
-                                }
-                                IDetectorElement detector_element = null;
-
-                                if (VERBOSE > 2) {
-                                    System.out.println("Creating raw_hit with channel,apv = " + LCSimCellID_ + " , " + chanapv + " and adc = " + chanadc[0]);
-                                }
-
-                                int time = 0; // need to find source of this
-                                RawTrackerHit raw_hit = new BaseRawTrackerHit(time, LCSimCellID_, chanadc, sim_hits, detector_element);
-                                // Put hits onto readout and hit list
-//                    ro.addHit(raw_hit);
-                                raw_hits.add(raw_hit);
-                            }
-                        }
-                        if (VERBOSE > 1) {
-                            System.out.println("Show the hits we created ...");
-                            Iterator<RawTrackerHit> rhiter = raw_hits.iterator();
-
-                            while (rhiter.hasNext()) {
-                                RawTrackerHit rh = rhiter.next();
-                                System.out.println("this hit was created: cellID=" + rh.getCellID() + " adc[0]=" + (rh.getADCValues())[0]);
-                            }
-                        }
-                        switch (header.getDataType()) {
-                            case FLOAT32:
-                                if (VERBOSE > 4) {
-                                    System.out.println("        FLOAT VALS");
-                                }
-                                float floatdata[] = structure.getFloatData();
-                                for (float f : floatdata) {
-                                    if (VERBOSE > 4) {
-                                        System.out.println("         " + f);
-                                    }
-                                }
-                                break;
-
-                            case DOUBLE64:
-                                if (VERBOSE > 4) {
-                                    System.out.println("        DOUBLE VALS");
-                                }
-                                double doubledata[] = structure.getDoubleData();
-                                for (double d : doubledata) {
-                                    if (VERBOSE > 4) {
-                                        System.out.println("         " + d);
-                                    }
-                                }
-                                break;
-
-                            case SHORT16:
-                                if (VERBOSE > 4) {
-                                    System.out.println("        SHORT VALS");
-                                }
-                                short shortdata[] = structure.getShortData();
-                                for (short i : shortdata) {
-                                    if (VERBOSE > 4) {
-                                        System.out.println("        0x" + Integer.toHexString(i));
-                                    }
-                                }
-                                break;
-
-                            case INT32:
-                            case UINT32:
-                                if (VERBOSE > 4) {
-                                    System.out.println("        INT VALS");
-                                }
-                                int intdata[] = structure.getIntData();
-                                for (int i : intdata) {
-                                    if (VERBOSE > 4) {
-                                        System.out.println("        0x" + Integer.toHexString(i));
-                                    }
-                                }
-                                break;
-
-                            case LONG64:
-                                if (VERBOSE > 4) {
-                                    System.out.println("        LONG VALS");
-                                }
-                                long longdata[] = structure.getLongData();
-                                for (long i : longdata) {
-                                    if (VERBOSE > 4) {
-                                        System.out.println("        0x" + Long.toHexString(i));
-                                    }
-                                }
-                                break;
-
-                            case CHAR8:
-                            case UCHAR8:
-                                if (VERBOSE > 4) {
-                                    System.out.println("        BYTE VALS");
-                                }
-                                byte bytedata[] = structure.getByteData();
-                                for (byte i : bytedata) {
-                                    if (VERBOSE > 4) {
-                                        System.out.println("         " + i);
-                                    }
-                                }
-                                break;
-
-                            case CHARSTAR8:
-                                System.out.println("        STRING VALS");
-                                String stringdata[] = structure.getStringData();
-                                for (String str : stringdata) {
-                                    System.out.println("         " + str);
-                                }
-                                break;
-                        }
-                }
-            }
-        }
-
-        if (VERBOSE > 4) {
-            System.out.println("step7");
-        }
-
-        // jump past the block header
-        buf.position(4 * 8);
-//        ByteBuffer buf2 = buf.slice();
-
-
-        if (VERBOSE > 4) {
-            System.out.println("step8");
-        }
-//        ByteParser parser = new ByteParser();
-//        buf2.rewind();
-        EvioEvent event = null;
-
-        if (VERBOSE > 4) {
-            System.out.println("step8.1");
-        }
-        /*
-         * try {
-        System.out.println("step8.2");
-        event = parser.parseEvent(buf2);
-        System.out.println("step8.3");
-        System.out.println("Event = " + event.toString());
-        } catch (EvioException e) {
-        e.printStackTrace();
-        }
-         */
-
-//        System.out.println("step9");
-        File fileIn = new File(fileName);
-        File trkIn = new File(TrkFileName);
-
-        System.out.println(
-                "read ev file: " + fileName + " size: " + fileIn.length());
-        System.out.println(
-                "read trk file: " + TrkFileName + " size: " + trkIn.length());
-        FileInputStream fileInputStream = new FileInputStream(trkIn);
-        FileChannel inputChannel = fileInputStream.getChannel();
-
-        long sz = inputChannel.size();
-        trkByteBuffer = inputChannel.map(FileChannel.MapMode.READ_ONLY, 0L, sz);
-
-        inputChannel.close(); // this object is no longer needed
-        // set buffer to beginning
-        trkByteBuffer.position(0);
-
-        int offset = 0;
-        rawdataLength = trkByteBuffer.remaining() / 4;
-        if (VERBOSE > 4) {
-            System.out.println("Number of Ints to read is " + rawdataLength);
-        }
-        ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
-        trkByteBuffer.order(byteOrder);
-
-//        int[] header = new int[8000000];
-//        for (int i = 0; i < 8000000; i++) {
-//            header[i] = trkByteBuffer.getInt();
-//        }
-
-
-
-        try {
-            EvioFile evioFile = new EvioFile(fileName);
-
-            EventParser parser = new EventParser();
-            parser.addEvioListener(new myListener());
-            //EventParser.getInstance().addEvioListener(new myListener());
-            int stat = 1;
-            while (stat != 0) {
-                try {
-                    EvioEvent ev = evioFile.nextEvent();
-                    if (ev == null) {
-                        stat = 0;
-                    }
-                    evioFile.parseEvent(ev);
-                    System.out.println("reading event");
-//                    int[] buftt = ev.getEvtArray();
-                    System.out.println("events remaining =" + evioFile.getNumEventsRemaining());
-                    IBlockHeader bh = evioFile.getCurrentBlockHeader();
-                    System.out.println("nextEvent: BLOCK HEADER :\n" + bh.toString());
-                } catch (EvioException e) {
-                    System.out.println(e);
-                }
-
-                //                MappedByteBuffer buffer = evioFile.getMappedByteBuffer();
-                if (VERBOSE > 4) {
-                    System.out.println("step10");
-                }
-            }
-        } catch (IOException e) {
-            System.out.println(e);
-        }
-        // read events until eof reached
-        inputChannel.close();
-        
-    }
-}

hps-java/src/test/java/org/lcsim
DummyEvioTest.java removed after 1.1
diff -N DummyEvioTest.java
--- DummyEvioTest.java	27 Jul 2011 23:25:16 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,22 +0,0 @@
-package org.lcsim;
-
-import junit.framework.TestCase;
-
-import org.jlab.coda.jevio.EvioEvent;
-
-/**
- * This just makes sure that the jevio-base library is accessible from hps-java.
- * It doesn't actually test anything.  
- * 
- * @author jeremym
- * @version $Id: DummyEvioTest.java,v 1.1 2011/07/27 23:25:16 jeremy Exp $
- */
-public class DummyEvioTest extends TestCase
-{
-    public void testEvioDoesNothing()
-    {
-        System.out.println("Dummy test for EVIO.  It does nothing!");
-        EvioEvent ev = new EvioEvent(); 
-    }
-
-}

hps-java/src/test/java/org/lcsim/hps/evio
DoEvioTest.java added at 1.1
diff -N DoEvioTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DoEvioTest.java	28 Mar 2012 18:43:37 -0000	1.1
@@ -0,0 +1,406 @@
+package org.lcsim.hps.evio;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.IntBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jlab.coda.jevio.BaseStructureHeader;
+import org.jlab.coda.jevio.EventParser;
+import org.jlab.coda.jevio.EvioEvent;
+import org.jlab.coda.jevio.EvioException;
+import org.jlab.coda.jevio.EvioFile;
+import org.jlab.coda.jevio.IBlockHeader;
+import org.jlab.coda.jevio.IEvioListener;
+import org.jlab.coda.jevio.IEvioStructure;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.base.BaseLCSimEvent;
+import org.lcsim.event.base.BaseRawTrackerHit;
+import org.lcsim.hps.recon.tracking.HPSTrackerEvent;
+import org.lcsim.hps.recon.tracking.HPSTrackerSample;
+import org.lcsim.hps.recon.tracking.MapDAQCellID;
+import org.lcsim.util.lcio.LCIOWriter;
+
+/**
+ * This is a test of using jevio routines to read EVIO files.  
+ * 
+ * @author homer
+ * @version $Id: DoEvioTest.java,v 1.1 2012/03/28 18:43:37 jeremy Exp $
+ */
+public class DoEvioTest extends TestCase {
+
+    private LCIOWriter writer;
+    BaseLCSimEvent newEvent;
+    int VERBOSE = 2;
+    
+    /**
+     * The buffer representing a map of the input file.
+     */
+    private MappedByteBuffer trkByteBuffer;
+    int eventDataSizeBytes = 8000000;
+//        byte rawdataInts[] = new byte[eventDataSizeBytes];
+    int rawdataInts[] = new int[eventDataSizeBytes];
+    int rawdataLength = 0;
+
+    public void testDoTestEvio() throws IOException {
+        System.out.println("Test for EVIO.");
+
+        final int UNKNOWN32 = (0x0);
+        final int UINT32 = (0x1);
+        final int FLOAT32 = (0x2);
+        final int CHARSTAR8 = (0x3);
+        final int SHORT16 = (0x4);
+        final int USHORT16 = (0x5);
+        final int CHAR8 = (0x6);
+        final int UCHAR8 = (0x7);
+        final int DOUBLE64 = (0x8);
+        final int LONG64 = (0x9);
+        final int ULONG64 = (0xa);
+        final int INT32 = (0xb);
+        final int TAGSEGMENT = (0xc);
+        final int SEGMENT = (0xd);
+        final int BANK = (0xe);
+        final int ALSOBANK = (0x10);
+        final int ALSOSEGMENT = (0x20);
+        final int ALSOTAGSEGMENT = (0x40);
+        final int TRACKERTAG = (600);
+
+    // load the DAQ to LCSim cell maps
+final MapDAQCellID mapcell = new MapDAQCellID();
+    mapcell.fillSVTCellMap();
+    
+        //        String fileName = "/mydat/neal/hps/cedExport/data/dvcs_5_500.ev";
+        String fileName = "/mydat/myhpstest/hps_test_data_2011_nov_18_1.evio";
+//        String fileName = "/mydat/myhpstest/sample.dat";
+// Tracker data file name for testing
+        String TrkFileName = "/mydat/myhpstest/00_baseline.bin";
+
+
+        ByteBuffer buf = ByteBuffer.allocate(1000 * 8192);
+
+        if (VERBOSE > 4) {
+            System.out.println("step1" + TRACKERTAG);
+        }
+        // parse bytes
+        class myListener implements IEvioListener {
+
+            public void startEventParse(EvioEvent evioEvent) {
+                if (VERBOSE > 4) {
+                    System.out.println("step2");
+                }
+            }
+
+            public void endEventParse(EvioEvent evioEvent) {
+                if (VERBOSE > 4) {
+                    System.out.println("step3 - endEventParse");
+                }
+            }
+
+            public void gotStructure(EvioEvent evioEvent, IEvioStructure structure) {
+
+                BaseStructureHeader header = structure.getHeader();
+
+//                System.out.println("------------------");
+                if (VERBOSE > 0) {
+                    System.out.println("" + structure);
+                }
+//                System.out.println("Tag type = " + header.getTag());
+
+                switch (header.getTag()) {
+                    case TRACKERTAG: //Tracker (will be TRACKERTAG)
+//                        IReadout ro;
+                        if (header.getDataType().getValue() != INT32) { // Is this right???
+                            System.out.println("Non INT32 Tracker Data!!!");
+                            break;
+                        }
+                        System.out.println("about to simulate having received tracker EVIO data");
+
+                        List<RawTrackerHit> raw_hits = new ArrayList<RawTrackerHit>();
+                        List<SimTrackerHit> sim_hits = new ArrayList<SimTrackerHit>();
+
+                        HPSTrackerEvent trkev = new HPSTrackerEvent();
+                        int trkdata[] = structure.getIntData();
+
+                        int trklength = header.getLength();
+                        IntBuffer trkIntBuffer = IntBuffer.wrap(trkdata);
+//                        for (int ii=0; ii<10; ii++) System.out.println("trkdata["+ii+"] = "+trkdata[ii]+"\t"+Integer.toString(trkdata[ii] & 0xffff, 16).toUpperCase());
+
+// ---- this is the code needed for real EVIO data (IF! IntBuffer is too slow.)
+//                        int dataStartMarker = 0;
+//                        while (dataStartMarker<trklength) {
+//                        int frameSize = trkdata[dataStartMarker];
+//                        for (int ii = 1; ii <= frameSize; ii++) {
+//                                rawdataInts[ii] = trkdata[dataStartMarker+ii];
+//                        }
+//                        dataStartMarker+=frameSize;
+// ----------------------------------------------------                        
+
+//R                        int frameSize = trkIntBuffer.get();
+//R                        while (trkIntBuffer.hasRemaining() && frameSize!=0) {
+                        int frameSize = trkByteBuffer.getInt();
+                        while (trkByteBuffer.hasRemaining() && frameSize != 0) {
+                            for (int ii = 0; ii < frameSize; ii++) {
+                                rawdataInts[ii] = trkByteBuffer.getInt();
+//R                                rawdataInts[ii] = trkIntBuffer.get();
+                            }
+                            if (VERBOSE > 4) {
+                                for (int ii = 0; ii < 10; ii++) {
+                                    System.out.println("rawdataInts[" + ii + "] = " + rawdataInts[ii] + "\t"
+                                            + Integer.toString((rawdataInts[ii] >> 16) & 0xffff, 16).toUpperCase() + ":"
+                                            + Integer.toString(rawdataInts[ii] & 0xffff, 16).toUpperCase());
+                                }
+                            }
+                            trkev.setSize(frameSize);
+                            trkev.setData(rawdataInts);
+                            if (VERBOSE > 1) {
+                                System.out.println("starting loop over samples");
+                            }
+//                        for (int i = 0; i < header.getNumber(); i++) {
+                            for (int i = 0; i < trkev.count(); i++) {
+                                if (VERBOSE > 4) {
+                                    System.out.println("sample# = " + i);
+                                }
+                                HPSTrackerSample trksamp = trkev.sample(i);
+//                            System.out.println("got trksamp, trksamp = " + trksamp);
+                                long chanaddr = trksamp.channel();
+                                if (VERBOSE > 3) {
+                                    System.out.println("got CellID");
+                                }
+                                int LCSimCellID_ = mapcell.SVTCellIDlookup(chanaddr);
+                                if (VERBOSE > 3) {
+                                    System.out.println("got corresponding LCSim CellID = "+LCSimCellID_);
+                                }
+                                
+                                long chanapv = trksamp.apv();
+                                if (VERBOSE > 3) {
+                                    System.out.println("got apv");
+                                }
+                                short chanadc[] = new short[6];
+                                if (VERBOSE > 3) {
+                                    System.out.println("getting sample data");
+                                }
+
+                                for (int isamp = 0; isamp < 6; isamp++) {
+//                                System.out.println("sample = " + isamp);
+
+                                    chanadc[isamp] = (short) trksamp.value(isamp);
+                                }
+                                IDetectorElement detector_element = null;
+
+                                if (VERBOSE > 2) {
+                                    System.out.println("Creating raw_hit with channel,apv = " + LCSimCellID_ + " , " + chanapv + " and adc = " + chanadc[0]);
+                                }
+
+                                int time = 0; // need to find source of this
+                                RawTrackerHit raw_hit = new BaseRawTrackerHit(time, LCSimCellID_, chanadc, sim_hits, detector_element);
+                                // Put hits onto readout and hit list
+//                    ro.addHit(raw_hit);
+                                raw_hits.add(raw_hit);
+                            }
+                        }
+                        if (VERBOSE > 1) {
+                            System.out.println("Show the hits we created ...");
+                            Iterator<RawTrackerHit> rhiter = raw_hits.iterator();
+
+                            while (rhiter.hasNext()) {
+                                RawTrackerHit rh = rhiter.next();
+                                System.out.println("this hit was created: cellID=" + rh.getCellID() + " adc[0]=" + (rh.getADCValues())[0]);
+                            }
+                        }
+                        switch (header.getDataType()) {
+                            case FLOAT32:
+                                if (VERBOSE > 4) {
+                                    System.out.println("        FLOAT VALS");
+                                }
+                                float floatdata[] = structure.getFloatData();
+                                for (float f : floatdata) {
+                                    if (VERBOSE > 4) {
+                                        System.out.println("         " + f);
+                                    }
+                                }
+                                break;
+
+                            case DOUBLE64:
+                                if (VERBOSE > 4) {
+                                    System.out.println("        DOUBLE VALS");
+                                }
+                                double doubledata[] = structure.getDoubleData();
+                                for (double d : doubledata) {
+                                    if (VERBOSE > 4) {
+                                        System.out.println("         " + d);
+                                    }
+                                }
+                                break;
+
+                            case SHORT16:
+                                if (VERBOSE > 4) {
+                                    System.out.println("        SHORT VALS");
+                                }
+                                short shortdata[] = structure.getShortData();
+                                for (short i : shortdata) {
+                                    if (VERBOSE > 4) {
+                                        System.out.println("        0x" + Integer.toHexString(i));
+                                    }
+                                }
+                                break;
+
+                            case INT32:
+                            case UINT32:
+                                if (VERBOSE > 4) {
+                                    System.out.println("        INT VALS");
+                                }
+                                int intdata[] = structure.getIntData();
+                                for (int i : intdata) {
+                                    if (VERBOSE > 4) {
+                                        System.out.println("        0x" + Integer.toHexString(i));
+                                    }
+                                }
+                                break;
+
+                            case LONG64:
+                                if (VERBOSE > 4) {
+                                    System.out.println("        LONG VALS");
+                                }
+                                long longdata[] = structure.getLongData();
+                                for (long i : longdata) {
+                                    if (VERBOSE > 4) {
+                                        System.out.println("        0x" + Long.toHexString(i));
+                                    }
+                                }
+                                break;
+
+                            case CHAR8:
+                            case UCHAR8:
+                                if (VERBOSE > 4) {
+                                    System.out.println("        BYTE VALS");
+                                }
+                                byte bytedata[] = structure.getByteData();
+                                for (byte i : bytedata) {
+                                    if (VERBOSE > 4) {
+                                        System.out.println("         " + i);
+                                    }
+                                }
+                                break;
+
+                            case CHARSTAR8:
+                                System.out.println("        STRING VALS");
+                                String stringdata[] = structure.getStringData();
+                                for (String str : stringdata) {
+                                    System.out.println("         " + str);
+                                }
+                                break;
+                        }
+                }
+            }
+        }
+
+        if (VERBOSE > 4) {
+            System.out.println("step7");
+        }
+
+        // jump past the block header
+        buf.position(4 * 8);
+//        ByteBuffer buf2 = buf.slice();
+
+
+        if (VERBOSE > 4) {
+            System.out.println("step8");
+        }
+//        ByteParser parser = new ByteParser();
+//        buf2.rewind();
+        EvioEvent event = null;
+
+        if (VERBOSE > 4) {
+            System.out.println("step8.1");
+        }
+        /*
+         * try {
+        System.out.println("step8.2");
+        event = parser.parseEvent(buf2);
+        System.out.println("step8.3");
+        System.out.println("Event = " + event.toString());
+        } catch (EvioException e) {
+        e.printStackTrace();
+        }
+         */
+
+//        System.out.println("step9");
+        File fileIn = new File(fileName);
+        File trkIn = new File(TrkFileName);
+
+        System.out.println(
+                "read ev file: " + fileName + " size: " + fileIn.length());
+        System.out.println(
+                "read trk file: " + TrkFileName + " size: " + trkIn.length());
+        FileInputStream fileInputStream = new FileInputStream(trkIn);
+        FileChannel inputChannel = fileInputStream.getChannel();
+
+        long sz = inputChannel.size();
+        trkByteBuffer = inputChannel.map(FileChannel.MapMode.READ_ONLY, 0L, sz);
+
+        inputChannel.close(); // this object is no longer needed
+        // set buffer to beginning
+        trkByteBuffer.position(0);
+
+        int offset = 0;
+        rawdataLength = trkByteBuffer.remaining() / 4;
+        if (VERBOSE > 4) {
+            System.out.println("Number of Ints to read is " + rawdataLength);
+        }
+        ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
+        trkByteBuffer.order(byteOrder);
+
+//        int[] header = new int[8000000];
+//        for (int i = 0; i < 8000000; i++) {
+//            header[i] = trkByteBuffer.getInt();
+//        }
+
+
+
+        try {
+            EvioFile evioFile = new EvioFile(fileName);
+
+            EventParser parser = new EventParser();
+            parser.addEvioListener(new myListener());
+            //EventParser.getInstance().addEvioListener(new myListener());
+            int stat = 1;
+            while (stat != 0) {
+                try {
+                    EvioEvent ev = evioFile.nextEvent();
+                    if (ev == null) {
+                        stat = 0;
+                    }
+                    evioFile.parseEvent(ev);
+                    System.out.println("reading event");
+//                    int[] buftt = ev.getEvtArray();
+                    System.out.println("events remaining =" + evioFile.getNumEventsRemaining());
+                    IBlockHeader bh = evioFile.getCurrentBlockHeader();
+                    System.out.println("nextEvent: BLOCK HEADER :\n" + bh.toString());
+                } catch (EvioException e) {
+                    System.out.println(e);
+                }
+
+                //                MappedByteBuffer buffer = evioFile.getMappedByteBuffer();
+                if (VERBOSE > 4) {
+                    System.out.println("step10");
+                }
+            }
+        } catch (IOException e) {
+            System.out.println(e);
+        }
+        // read events until eof reached
+        inputChannel.close();
+        
+    }
+}

hps-java/src/test/java/org/lcsim/hps/evio
DummyEvioTest.java added at 1.1
diff -N DummyEvioTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DummyEvioTest.java	28 Mar 2012 18:43:37 -0000	1.1
@@ -0,0 +1,22 @@
+package org.lcsim.hps.evio;
+
+import junit.framework.TestCase;
+
+import org.jlab.coda.jevio.EvioEvent;
+
+/**
+ * This just makes sure that the jevio-base library is accessible from hps-java.
+ * It doesn't actually test anything.  
+ * 
+ * @author jeremym
+ * @version $Id: DummyEvioTest.java,v 1.1 2012/03/28 18:43:37 jeremy Exp $
+ */
+public class DummyEvioTest extends TestCase
+{
+    public void testEvioDoesNothing()
+    {
+        System.out.println("Dummy test for EVIO.  It does nothing!");
+        EvioEvent ev = new EvioEvent(); 
+    }
+
+}

hps-java/src/test/java/org/lcsim/hps/evio
DumpRyanEvioFile.java added at 1.1
diff -N DumpRyanEvioFile.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DumpRyanEvioFile.java	28 Mar 2012 18:43:37 -0000	1.1
@@ -0,0 +1,62 @@
+package org.lcsim.hps.evio;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jlab.coda.jevio.BaseStructure;
+import org.jlab.coda.jevio.CompositeData;
+import org.jlab.coda.jevio.EvioEvent;
+import org.jlab.coda.jevio.EvioReader;
+import org.jlab.coda.jevio.test.CompositeTester;
+import org.lcsim.util.cache.FileCache;
+
+public class DumpRyanEvioFile extends TestCase {
+    
+    public void testMe() throws Exception {
+        
+        //FileCache cache = new FileCache();
+        //cache.setCacheDirectory(new File(".testdata"));
+        //File evioTestData = cache.getCachedFile(new URL("http://www.lcsim.org/test/hps/hps_000246.dat")); // ECal data in pulse integral mode
+        
+        File evioTestData = new File("/u/ey/rherbst/projects/heavyp/devel/software/data/coda_test_strip.dat");
+        
+        EvioReader reader = new EvioReader(evioTestData);
+        EvioEvent event = reader.parseNextEvent();
+        
+        int eventCount = 1;
+        
+        while (true) {
+         
+            System.out.println("event #" + eventCount);
+            System.out.println("event has " + event.getChildCount() + " children");
+            /*
+            if (event.getChildCount() > 0) {
+                for (BaseStructure topBank : event.getChildren()) {
+                    System.out.println("top bank has " + topBank.getChildCount() + " children");
+                    if (topBank.getChildCount() > 0) {
+                        for (BaseStructure subBank : topBank.getChildren()) {
+                            System.out.println("subBank has " + subBank.getChildCount() + " children");
+                            CompositeData cdata = subBank.getCompositeData();
+                            System.out.println("Printing subBank CompositeData...");
+                            if (cdata != null)
+                                CompositeTester.printCompositeDataObject(cdata);
+                        }
+                    }
+                }               
+            }
+            */
+            
+            if (reader.getNumEventsRemaining() == 0) {
+                break;
+            } 
+            else {
+                event = reader.parseNextEvent();
+            }
+            ++eventCount;
+            System.out.println("--------------------");
+        }
+        
+    }       
+}

hps-java/src/test/java/org/lcsim/hps/recon/tracking
WriteEvio4TestFileForRyan.java added at 1.1
diff -N WriteEvio4TestFileForRyan.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ WriteEvio4TestFileForRyan.java	28 Mar 2012 18:43:37 -0000	1.1
@@ -0,0 +1,64 @@
+package org.lcsim.hps.recon.tracking;
+
+import junit.framework.TestCase;
+
+import org.jlab.coda.jevio.BaseStructure;
+import org.jlab.coda.jevio.BaseStructureHeader;
+import org.jlab.coda.jevio.DataType;
+import org.jlab.coda.jevio.EventBuilder;
+import org.jlab.coda.jevio.EventWriter;
+import org.jlab.coda.jevio.EvioBank;
+import org.jlab.coda.jevio.EvioEvent;
+import org.jlab.coda.jevio.EvioReader;
+
+public class WriteEvio4TestFileForRyan extends TestCase {
+	
+	static final String fname = "Evio4TestFileRyan.evio";
+	
+	public void testIt() throws Exception {
+		
+		// Make an example event with dummy data.
+		EventBuilder builder = new EventBuilder(123, DataType.BANK, 1); // tag=123, dataType=bank, number=1
+		int tag = 100;
+		int number = 1;
+		for (int i=0; i<8; i++) {
+			EvioBank bank = new EvioBank(tag, DataType.INT32, number);
+			bank.appendIntData(new int[] {1,2,3,4});
+			bank.setAllHeaderLengths();
+			builder.addChild(builder.getEvent(), bank);
+			tag -= 1;
+			number += 1;
+		}
+		
+		// Write this EVIO event.
+        builder.setAllHeaderLengths();
+        EventWriter writer = new EventWriter(fname);
+        writer.writeEvent(builder.getEvent());
+        writer.close();
+        
+        // Read back the file and make test assertions.
+        EvioReader reader = new EvioReader(fname);
+        EvioEvent event = reader.parseNextEvent();
+        BaseStructureHeader eventHeader = event.getHeader();        
+        assertEquals(eventHeader.getTag(), 123);
+        assertEquals(eventHeader.getDataType(), DataType.BANK);
+        assertEquals(eventHeader.getNumber(), 1);
+        tag = 100;
+        number = 1;
+        for (int i=0; i<8; i++) {
+        	BaseStructure bank = event.getChildren().get(i);
+        	BaseStructureHeader bankHeader = bank.getHeader();
+        	assertEquals(bankHeader.getTag(), tag);
+        	assertEquals(bankHeader.getNumber(), number);
+        	assertEquals(bankHeader.getDataType(), DataType.INT32);
+        	int[] intData = bank.getIntData();
+        	assertEquals(intData.length, 4);
+        	assertEquals(intData[0], 1);
+        	assertEquals(intData[1], 2);
+        	assertEquals(intData[2], 3);
+        	assertEquals(intData[3], 4);
+        	tag -= 1;
+        	number +=1;
+        }
+	}
+}
\ No newline at end of file
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1