Skip to content

Commit debe538

Browse files
committed
add debugging
1 parent 77a83f8 commit debe538

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

common-tools/clas-detector/src/main/java/org/jlab/detector/decode/TranslationTable.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.jlab.detector.decode;
22

3+
import java.util.stream.Collectors;
4+
import org.jlab.utils.groups.IndexedTable;
35
import org.jlab.detector.base.DetectorType;
46
import org.jlab.detector.calib.utils.ConstantsManager;
5-
import org.jlab.utils.groups.IndexedTable;
67

78
/**
89
*
@@ -24,6 +25,7 @@ public void add(DetectorType dt, IndexedTable it) {
2425
int slot = IndexedTable.DEFAULT_GENERATOR.getIndex(hash, 1);
2526
int channel = IndexedTable.DEFAULT_GENERATOR.getIndex(hash, 2);
2627

28+
// first one wins, print error message for loser:
2729
if (hasEntryByHash(hash)) {
2830
System.err.print("TranslationTable: found CCDB overlap for ");
2931
System.err.println(String.format("type %d/%s versus %s and c/s/c=%d/%d/%d",
@@ -36,17 +38,24 @@ public void add(DetectorType dt, IndexedTable it) {
3638
addEntry(crate, slot, channel);
3739

3840
// add each column's entry to the new row:
39-
for (int column=0; column<it.getEntryMap().values().size(); column++) {
40-
int value = it.getIntValueByHash(column, hash);
41-
setIntValueByHash(value, column, hash);
42-
}
41+
for (int column=0; column<it.getEntryMap().values().size(); column++)
42+
setIntValueByHash(it.getIntValueByHash(column, hash), column, hash);
4343

4444
// add the new detector type, as the last column:
4545
setIntValueByHash(dt.getDetectorId(), it.getEntryMap().values().size(), hash);
4646
}
4747
}
4848
}
4949

50+
public void dump() {
51+
for (Object key : getList().getMap().keySet()) {
52+
int[] idx = IndexedTable.DEFAULT_GENERATOR.getIndices((long)key, 0,1,2);
53+
System.out.print(String.format("%d/%d/%d ", idx[0],idx[1],idx[2]));
54+
System.out.print(getIntegersByHash((long)key).stream().
55+
map(String::valueOf).collect(Collectors.joining("/")));
56+
System.out.print("\n");
57+
}
58+
}
5059

5160
public static final DetectorType[] TYPES = new DetectorType[]{
5261
DetectorType.FTCAL,DetectorType.FTHODO,DetectorType.FTTRK,
@@ -70,8 +79,9 @@ public static void main(String[] args) {
7079
ConstantsManager conman = new ConstantsManager();
7180
conman.init(STYPES);
7281
TranslationTable tt = new TranslationTable();
73-
for (int i=0; i<STYPES.length; i++)
82+
for (int i=0; i<TYPES.length; i++)
7483
tt.add(TYPES[i],conman.getConstants(18779,STYPES[i]));
7584
tt.show();
85+
tt.dump();
7686
}
7787
}

0 commit comments

Comments
 (0)