Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common-tools/clara-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clara-io</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
20 changes: 10 additions & 10 deletions common-tools/clas-analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,63 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-analysis</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-physics</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-jcsg</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>swim-tools</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-reco</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
10 changes: 5 additions & 5 deletions common-tools/clas-detector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
Expand All @@ -29,13 +29,13 @@
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,92 +3,52 @@
import java.util.Date;
import org.jlab.jnp.hipo4.data.Bank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.jnp.hipo4.io.HipoReader;
import org.jlab.jnp.hipo4.io.HipoWriterSorted;

public class DecoderBoardTest {

public static String toString(int bits) {
StringBuilder s = new StringBuilder();
for (int i=31; i>=0; --i) s.append((bits>>i)&1);
return s.toString();
}

public static String toString(Bank b) {
StringBuilder s = new StringBuilder();
s.append("Timestamp/nPair/seed: ");
s.append(b.getLong("timestamp",0));
s.append("/");
s.append(b.getInt("nPair",0));
s.append("/");
s.append(b.getInt("helicitySeed",0));
s.append("\nPair: ");
s.append(toString(b.getInt("pairArray",0)));
s.append(String.format(" %d",b.getInt("pair",0)));
s.append("\nPattern: ");
s.append(toString(b.getInt("patternArray",0)));
s.append(String.format(" %d",b.getInt("pattern",0)));
s.append("\nHelicity: ");
s.append(toString(b.getInt("helicityArray",0)));
s.append(String.format(" %d",b.getInt("helicity",0)));
s.append("\nHelicityP: ");
s.append(toString(b.getInt("helicityPArray",0)));
s.append("\nHelicityP0:");
StringBuilder s3 = new StringBuilder();
for (int i=31; i>=0; --i) {
if (((b.getInt("patternArray",0)>>i)&1) == 1) {
s3.append((b.getInt("helicityArray",0)>>i)&1);
}
}
s.append(String.format("%32s",s3));
s.append("\nHelicityP1:");
StringBuilder s2 = new StringBuilder();
for (int i=31; i>=0; --i) {
if (((b.getInt("patternArray",0)>>i)&1) == 0) {
s2.append((b.getInt("helicityArray",0)>>i)&1);
}
}
s.append(String.format("%32s",s2));
s.append("\n");
return s.toString();
}

public static void main(String args[]) {
String filename = "/Users/baltzell/Software/coatjava/iss166+167-eventordering+maurik/clas_019400.evio.00040.hipo";
HelicitySequenceManager hsm = new HelicitySequenceManager(8, filename);
try (HipoWriterSorted writer = new HipoWriterSorted()) {
writer.getSchemaFactory().initFromDirectory("/Users/baltzell/Software/coatjava/iss171-heldecoder/etc/bankdefs/hipo4");
writer.setCompressionType(2);
writer.open(String.format("/Users/baltzell/xx-%d.hipo",(new Date()).getTime()));
String inputFile = args.length>0?args[0]:"/Users/baltzell/Software/coatjava/nab-cleanup/0.hipo";
String outputFile = true ? null : String.format("/Users/baltzell/xx-%d.hipo",(new Date()).getTime());
//HelicitySequenceManager hsm = new HelicitySequenceManager(8, inputFile);
HipoWriterSorted writer = new HipoWriterSorted();
if (outputFile != null) {
writer.getSchemaFactory().initFromDirectory("/Users/baltzell/Software/coatjava/nab-cleanup/etc/bankdefs/hipo4");
writer.setCompressionType(2);
writer.open(outputFile);
}
HipoReader reader = new HipoReader();
SchemaFactory schema = writer.getSchemaFactory();
reader.open(filename);
Bank decoder = new Bank(schema.getSchema("HEL::decoder"));
Bank online = new Bank(schema.getSchema("HEL::online"));
Bank config = new Bank(schema.getSchema("RUN::config"));
Bank compare = new Bank(schema.getSchema("hel"));
reader.open(inputFile);
Event event = new Event();
Bank decoder = new Bank(reader.getSchemaFactory().getSchema("HEL::decoder"));
Bank online = new Bank(reader.getSchemaFactory().getSchema("HEL::online"));
Bank config = new Bank(reader.getSchemaFactory().getSchema("RUN::config"));
//Bank compare = new Bank(writer.getSchemaFactory().getSchema("hel"));
int n=0;
while (reader.hasNext()) {
reader.nextEvent(event);
if (event.hasBank(schema.getSchema("HEL::decoder"))) {
if (event.hasBank(reader.getSchemaFactory().getSchema("HEL::decoder"))) {
event.read(decoder);
event.read(config);
event.read(online);
decoder.copyTo(compare);
//decoder.copyTo(compare);
//compare.putByte("board", 0, DecoderBoardUtil.QUARTET.getWindowHelicity(decoder,8));
compare.putByte("online", 0, online.getByte("helicityRaw",0));
compare.putByte("offline", 0, hsm.search(event).value());
compare.putLong("timestamp", 0, config.getLong("timestamp",0));
Event e = new Event();
e.write(compare);
writer.addEvent(e,event.getEventTag());
System.out.println(toString(decoder));
if (!DecoderBoardUtil.QUARTET.check(decoder)) break;
//System.out.println(hsm.search(event));
//compare.putByte("online", 0, online.getByte("helicityRaw",0));
//compare.putByte("offline", 0, hsm.search(event).value());
//compare.putLong("timestamp", 0, config.getLong("timestamp",0));
//Event e = new Event();
//e.write(compare);
//if (outputFile != null) writer.addEvent(e,event.getEventTag());
System.out.println(DecoderBoardUtil.toString(decoder));
if (!DecoderBoardUtil.QUARTET.check(decoder)) {
System.out.println(DecoderBoardUtil.toString(decoder));
++n;
}//System.out.println(hsm.search(event));
//break;
//if (++n>100) break;
}
}
}
System.out.format("____________________________________________ %d ERRORS\n",n);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,45 @@ else if (bank instanceof Bank)
throw new IllegalArgumentException();
}

/**
* Get a string representation of a HEL::decoder bank for human consumption.
* @param b the HEL::decoder bank to stringify
* @return
*/
public static String toString(Bank b) {
StringBuilder s = new StringBuilder();
s.append("Timestamp/nPair/seed: ");
s.append(b.getLong("timestamp",0));
s.append("/");
s.append(b.getInt("nPair",0));
s.append("/");
s.append(b.getInt("helicitySeed",0));
s.append("\nPair: ");
s.append(toString(b.getInt("pairArray",0)));
s.append("\nPattern: ");
s.append(toString(b.getInt("patternArray",0)));
s.append("\nHelicity: ");
s.append(toString(b.getInt("helicityArray",0)));
s.append("\nHelicityP: ");
s.append(toString(b.getInt("helicityPArray",0)));
s.append("\nHelicityP0:");
StringBuilder s3 = new StringBuilder();
for (int i=31; i>=0; --i) {
if (((b.getInt("patternArray",0)>>i)&1) == 1) {
s3.append((b.getInt("helicityArray",0)>>i)&1);
}
}
s.append(String.format("%32s",s3));
s.append("\nHelicityP1:");
StringBuilder s2 = new StringBuilder();
for (int i=31; i>=0; --i) {
if (((b.getInt("patternArray",0)>>i)&1) == 0) {
s2.append((b.getInt("helicityArray",0)>>i)&1);
}
}
s.append(String.format("%32s",s2));
s.append("\n");
return s.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public class SequenceUtil {
// Whether to invert the bits during error-checking, for debugging:
static boolean INVERT_BITS_CHECK = false;

/**
* Just convert bits to string, fixed-width, left-buffered with zeroes,
* since that doesn't seem to be included in the standard Java library.
* @param bits
* @return
*/
public static String toString(int bits) {
StringBuilder s = new StringBuilder();
for (int i=SEQUENCE_LENGTH-1; i>=0; --i) s.append((bits>>i)&1);
return s.toString();
}

/**
* Pattern delay correction, as specified by JLab's injector group.
* @param helicities the first helicity of the previous SEQUENCE_LENGTH patterns
Expand All @@ -33,8 +45,9 @@ public class SequenceUtil {
public static byte getPatternHelicity(int helicities, byte patternDelay) {
int bit = 0;
int register = 0;
for (int i=RNG_REGISTER_SIZE-1; i>=0; --i)
for (int i=RNG_REGISTER_SIZE-1; i>=0; --i) {
register = ( ((helicities>>i)&1) | (register<<1) ) & 0x3FFFFFFF;
}
for (int i=0; i<patternDelay; ++i) {
int bit7 = (register>>6) & 1;
int bit28 = (register>>27) & 1;
Expand Down Expand Up @@ -70,7 +83,7 @@ public static boolean checkHelicities(int patterns, int helicities, byte pattern
if ( ((helicities>>(i-j))&1) !=
SequenceUtil.getWindowHelicity((byte)((helicities>>i)&1),(byte)j) ) {
Logger.getLogger(SequenceUtil.class.getName()).log(Level.WARNING,
"Bad pattern/helicity: {0}/{1}", new Object[]{patterns, helicities});
"Bad pattern / helicity: {0} / {1}", new Object[]{toString(patterns), toString(helicities)});
return false;
}
}
Expand All @@ -87,7 +100,7 @@ public static boolean checkPairs(int pairs) {
for (int i=0; i<SEQUENCE_LENGTH-1; ++i) {
if ( Integer.bitCount((pairs>>i) & 0x3) != 1) {
Logger.getLogger(SequenceUtil.class.getName()).log(Level.WARNING,
"Bad pairs: {0}", pairs);
"Bad pairs: {0}", toString(pairs));
return false;
}
}
Expand All @@ -104,7 +117,7 @@ public static boolean checkPatterns(int patterns, byte patternLength) {
for (int i=0; i<(SEQUENCE_LENGTH-patternLength+1); ++i) {
if (Integer.bitCount((patterns>>i) & mask) != (INVERT_BITS_CHECK?patternLength-1:1)) {
Logger.getLogger(SequenceUtil.class.getName()).log(Level.WARNING,
"Bad patterns: {0}", patterns);
"Bad patterns: {0}", toString(patterns));
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions common-tools/clas-geometry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>10.0.7-SNAPSHOT</version>
<version>10.0.8-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Loading