hps-java/src/test/java/org/lcsim
diff -u -r1.1 -r1.2
--- DoEvioTest.java 14 Feb 2012 03:19:57 -0000 1.1
+++ DoEvioTest.java 15 Feb 2012 01:11:39 -0000 1.2
@@ -1,6 +1,7 @@
package org.lcsim;
import junit.framework.TestCase;
+import java.nio.channels.FileChannel;
import org.jlab.coda.jevio.EvioFile;
import org.jlab.coda.jevio.IEvioListener;
@@ -48,7 +49,7 @@
* This is a test of using jevio routines to read EVIO files.
*
* @author homer
- * @version $Id: DoEvioTest.java,v 1.1 2012/02/14 03:19:57 homer Exp $
+ * @version $Id: DoEvioTest.java,v 1.2 2012/02/15 01:11:39 homer Exp $
*/
public class DoEvioTest extends TestCase {
@@ -58,6 +59,9 @@
* The buffer representing a map of the input file.
*/
private MappedByteBuffer mappedByteBuffer;
+ int eventDataSizeBytes = 8000000;
+// byte trkbytes[] = new byte[eventDataSizeBytes];
+ int trkbytes[] = new int[eventDataSizeBytes];
public void testDoTestEvio() throws IOException {
System.out.println("Test for EVIO.");
@@ -87,6 +91,7 @@
// Tracker data file name for testing
String TrkFileName = "/mydat/myhpstest/00_baseline.bin";
+
ByteBuffer buf = ByteBuffer.allocate(1000 * 8192);
System.out.println("step1" + TRACKERTAG);
@@ -107,22 +112,37 @@
System.out.println("------------------");
System.out.println("" + structure);
-
+ System.out.println("Tag type = " + header.getTag());
switch (header.getTag()) {
- case 0: //Tracker (will be TRACKERTAG)
+ case 600: //Tracker (will be TRACKERTAG)
// IReadout ro;
+ 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();
- trkev.setData(trkdata);
+// for (int ii=0; ii<10; ii++) System.out.println("trkdata["+ii+"] = "+trkdata[ii]+"\t"+Integer.toString(trkdata[ii] & 0xffff, 16).toUpperCase());
+// trkev.setData(trkdata);
+ for (int ii = 0; ii < 10; ii++) {
+ System.out.println("trkbytes[" + ii + "] = " + trkbytes[ii] + "\t" + Integer.toString(trkbytes[ii] & 0xffff, 16).toUpperCase());
+ }
+ trkev.setData(trkbytes);
+ System.out.println("starting loop over samples");
for (int i = 0; i < header.getNumber(); i++) {
+ System.out.println("sample# = " + i);
HPSTrackerSample trksamp = trkev.sample(i);
+ System.out.println("got trksamp, trksamp = " + trksamp);
long chanaddr = trksamp.channel();
+ System.out.println("got chanaddr");
short chanadc[] = new short[6];
+ System.out.println("getting channel data");
+
for (int ichan = 0; ichan < 6; ichan++) {
+ System.out.println("channel = " + ichan);
+
chanadc[0] = (short) trksamp.value(ichan);
int time = 0; // need to find source of this
IDetectorElement detector_element = null;
@@ -199,19 +219,16 @@
System.out.println("step7");
// jump past the block header
- buf.position(
- 4 * 8);
+ buf.position(4 * 8);
// ByteBuffer buf2 = buf.slice();
- System.out.println(
- "step8");
+ System.out.println("step8");
// ByteParser parser = new ByteParser();
// buf2.rewind();
EvioEvent event = null;
- System.out.println(
- "step8.1");
+ System.out.println("step8.1");
/*
* try {
System.out.println("step8.2");
@@ -223,8 +240,7 @@
}
*/
- System.out.println(
- "step9");
+ System.out.println("step9");
File fileIn = new File(fileName);
File trkIn = new File(TrkFileName);
@@ -235,17 +251,19 @@
FileInputStream fileInputStream = new FileInputStream(trkIn);
FileChannel inputChannel = fileInputStream.getChannel();
+ long sz = inputChannel.size();
mappedByteBuffer = inputChannel.map(FileChannel.MapMode.READ_ONLY, 0L, sz);
inputChannel.close(); // this object is no longer needed
// set buffer to beginning
mappedByteBuffer.position(0);
- int eventDataSizeBytes = 8000000;
- byte trkbytes[] = new byte[eventDataSizeBytes];
-int offset=0;
-int bytesRemaining=0;
- mappedByteBuffer.get(trkbytes, offset, bytesRemaining);
+ int offset = 0;
+ int IntsRemaining = mappedByteBuffer.remaining() / 4;
+ for (int ii = 0; ii < IntsRemaining; ii++) {
+// System.out.println("trkbytes["+ii+"]");
+ trkbytes[ii] = mappedByteBuffer.getInt();
+ }
// int[] header = new int[8000000];
// for (int i = 0; i < 8000000; i++) {