hps-java/src/test/java/org/lcsim
diff -u -r1.5 -r1.6
--- DoEvioTest.java 16 Feb 2012 06:20:42 -0000 1.5
+++ DoEvioTest.java 17 Feb 2012 07:06:44 -0000 1.6
@@ -50,12 +50,13 @@
* This is a test of using jevio routines to read EVIO files.
*
* @author homer
- * @version $Id: DoEvioTest.java,v 1.5 2012/02/16 06:20:42 homer Exp $
+ * @version $Id: DoEvioTest.java,v 1.6 2012/02/17 07:06:44 homer Exp $
*/
public class DoEvioTest extends TestCase {
private LCIOWriter writer;
BaseLCSimEvent newEvent;
+ int VERBOSE = 0;
/**
* The buffer representing a map of the input file.
*/
@@ -89,31 +90,36 @@
// 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);
- System.out.println("step1" + TRACKERTAG);
+ if (VERBOSE > 4) {
+ System.out.println("step1" + TRACKERTAG);
+ }
// parse bytes
class myListener implements IEvioListener {
public void startEventParse(EvioEvent evioEvent) {
- System.out.println("step2");
+ if (VERBOSE > 4) System.out.println("step2");
}
public void endEventParse(EvioEvent evioEvent) {
- System.out.println("step3");
+ if (VERBOSE > 4) System.out.println("step3 - endEventParse");
}
public void gotStructure(EvioEvent evioEvent, IEvioStructure structure) {
BaseStructureHeader header = structure.getHeader();
- System.out.println("------------------");
- System.out.println("" + structure);
- System.out.println("Tag type = " + header.getTag());
+// System.out.println("------------------");
+ if (VERBOSE > 0) {
+ System.out.println("" + structure);
+ }
+// System.out.println("Tag type = " + header.getTag());
switch (header.getTag()) {
case 600: //Tracker (will be TRACKERTAG)
@@ -126,34 +132,46 @@
HPSTrackerEvent trkev = new HPSTrackerEvent();
int trkdata[] = structure.getIntData();
// 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("rawdataInts[" + ii + "] = " + rawdataInts[ii] + "\t"
- + Integer.toString((rawdataInts[ii] >> 16) & 0xffff, 16).toUpperCase() + ":"
- + Integer.toString(rawdataInts[ii] & 0xffff, 16).toUpperCase());
+// trkev.setData(trkdata);
+ 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.setData(rawdataInts);
- System.out.println("starting loop over samples");
+ 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++) {
- System.out.println("sample# = " + i);
+ if (VERBOSE > 4) {
+ System.out.println("sample# = " + i);
+ }
HPSTrackerSample trksamp = trkev.sample(i);
- System.out.println("got trksamp, trksamp = " + trksamp);
+// System.out.println("got trksamp, trksamp = " + trksamp);
long chanaddr = trksamp.channel();
- System.out.println("got chanaddr");
+ if (VERBOSE > 3) {
+ System.out.println("got chanaddr");
+ }
long chanapv = trksamp.apv();
- System.out.println("got apv");
+ if (VERBOSE > 3) {
+ System.out.println("got apv");
+ }
short chanadc[] = new short[6];
- System.out.println("getting sample data");
+ if (VERBOSE > 3) {
+ System.out.println("getting sample data");
+ }
for (int isamp = 0; isamp < 6; isamp++) {
- System.out.println("sample = " + isamp);
+// System.out.println("sample = " + isamp);
chanadc[isamp] = (short) trksamp.value(isamp);
}
IDetectorElement detector_element = null;
- System.out.println("Creating raw_hit with channel,apv = " + chanaddr + " , " + chanapv + " and adc = " + chanadc[0]);
+ if (VERBOSE > 2) {
+ System.out.println("Creating raw_hit with channel,apv = " + chanaddr + " , " + chanapv + " and adc = " + chanadc[0]);
+ }
int time = 0; // need to find source of this
RawTrackerHit raw_hit = new BaseRawTrackerHit(time, chanaddr, chanadc, sim_hits, detector_element);
@@ -161,62 +179,88 @@
// ro.addHit(raw_hit);
raw_hits.add(raw_hit);
}
-
- 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]);
+
+ 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.getDataTypeEnum()) {
case FLOAT32:
- System.out.println(" FLOAT VALS");
+ if (VERBOSE > 4) {
+ System.out.println(" FLOAT VALS");
+ }
float floatdata[] = structure.getFloatData();
for (float f : floatdata) {
- System.out.println(" " + f);
+ if (VERBOSE > 4) {
+ System.out.println(" " + f);
+ }
}
break;
case DOUBLE64:
- System.out.println(" DOUBLE VALS");
+ if (VERBOSE > 4) {
+ System.out.println(" DOUBLE VALS");
+ }
double doubledata[] = structure.getDoubleData();
for (double d : doubledata) {
- System.out.println(" " + d);
+ if (VERBOSE > 4) {
+ System.out.println(" " + d);
+ }
}
break;
case SHORT16:
- System.out.println(" SHORT VALS");
+ if (VERBOSE > 4) {
+ System.out.println(" SHORT VALS");
+ }
short shortdata[] = structure.getShortData();
for (short i : shortdata) {
- System.out.println(" 0x" + Integer.toHexString(i));
+ if (VERBOSE > 4) {
+ System.out.println(" 0x" + Integer.toHexString(i));
+ }
}
break;
case INT32:
case UINT32:
- System.out.println(" INT VALS");
+ if (VERBOSE > 4) {
+ System.out.println(" INT VALS");
+ }
int intdata[] = structure.getIntData();
for (int i : intdata) {
- System.out.println(" 0x" + Integer.toHexString(i));
+ if (VERBOSE > 4) {
+ System.out.println(" 0x" + Integer.toHexString(i));
+ }
}
break;
case LONG64:
- System.out.println(" LONG VALS");
+ if (VERBOSE > 4) {
+ System.out.println(" LONG VALS");
+ }
long longdata[] = structure.getLongData();
for (long i : longdata) {
- System.out.println(" 0x" + Long.toHexString(i));
+ if (VERBOSE > 4) {
+ System.out.println(" 0x" + Long.toHexString(i));
+ }
}
break;
case CHAR8:
case UCHAR8:
- System.out.println(" BYTE VALS");
+ if (VERBOSE > 4) {
+ System.out.println(" BYTE VALS");
+ }
byte bytedata[] = structure.getByteData();
for (byte i : bytedata) {
- System.out.println(" " + i);
+ if (VERBOSE > 4) {
+ System.out.println(" " + i);
+ }
}
break;
@@ -232,19 +276,25 @@
}
}
- System.out.println("step7");
+ if (VERBOSE > 4) {
+ System.out.println("step7");
+ }
// jump past the block header
buf.position(4 * 8);
// ByteBuffer buf2 = buf.slice();
- System.out.println("step8");
+ if (VERBOSE > 4) {
+ System.out.println("step8");
+ }
// ByteParser parser = new ByteParser();
// buf2.rewind();
EvioEvent event = null;
- System.out.println("step8.1");
+ if (VERBOSE > 4) {
+ System.out.println("step8.1");
+ }
/*
* try {
System.out.println("step8.2");
@@ -256,7 +306,7 @@
}
*/
- System.out.println("step9");
+// System.out.println("step9");
File fileIn = new File(fileName);
File trkIn = new File(TrkFileName);
@@ -276,7 +326,9 @@
int offset = 0;
int IntsRemaining = mappedByteBuffer.remaining() / 4;
- System.out.println("Number of Ints to read is " + IntsRemaining);
+ if (VERBOSE > 4) {
+ System.out.println("Number of Ints to read is " + IntsRemaining);
+ }
ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
mappedByteBuffer.order(byteOrder);
for (int ii = 0; ii < IntsRemaining; ii++) {
@@ -315,7 +367,9 @@
}
// MappedByteBuffer buffer = evioFile.getMappedByteBuffer();
- System.out.println("step10");
+ if (VERBOSE > 4) {
+ System.out.println("step10");
+ }
}
} catch (IOException e) {
System.out.println(e);