Commit in hps-java/src/test/java/org/lcsim on MAIN | |||
DoEvioTest.java | +35 | -17 | 1.1 -> 1.2 |
HPSTrackerEvent.java | +6 | -5 | 1.1 -> 1.2 |
+41 | -22 |
bug fix for HPSTrackerEvent and Tracker test data reading for DoEvioTest
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++) {
diff -u -r1.1 -r1.2 --- HPSTrackerEvent.java 14 Feb 2012 03:19:57 -0000 1.1 +++ HPSTrackerEvent.java 15 Feb 2012 01:11:39 -0000 1.2 @@ -16,12 +16,9 @@
* Header[5] = TempD[15:0], TempC[15:0] * Header[6] = Z[31:0] * Header[7] = Z[31:0]
- *
* Samples... (See TrackerSample.h)
- *
* Tail = 1 x 32-bits * Should be zero
-
*/ package org.lcsim;
@@ -117,7 +114,7 @@
} // Get sample count
-// int count() {
+// public int count() {
// return ((size_ - (headSize_ + tailSize_)) / sampleSize_); // } // Get sample at index
@@ -126,7 +123,11 @@
return (null); } else { HPSTrackerSample sample_ = new HPSTrackerSample();
-// sample_.setData( (data_[headSize_ + (index * sampleSize_)])[];
+ for (int ii=0;ii<sampleSize_;ii++) { + ldata_[ii] = data_[headSize_ + (index * sampleSize_) + ii]; + } +// sample_.setData(data_[headSize_ + (index * sampleSize_)]); + sample_.setData(ldata_);
return (sample_); } }
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