Skip to content

Commit 5af9c1b

Browse files
committed
add "translation table", with additional DetectorType index
1 parent fff385d commit 5af9c1b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.jlab.detector.decode;
2+
3+
import org.jlab.detector.base.DetectorType;
4+
import org.jlab.utils.groups.IndexedTable;
5+
6+
/**
7+
*
8+
* @author baltzell
9+
*/
10+
public class TranslationTable extends IndexedTable {
11+
12+
public TranslationTable() {
13+
super(3,new String[]{"sector/I","layer/I","component/I","order/I","type/I"});
14+
};
15+
16+
public void add(DetectorType dt, IndexedTable it) {
17+
for (Object key : it.getList().getMap().keySet()) {
18+
int crate = IndexedTable.DEFAULT_GENERATOR.getIndex((long) key, 0);
19+
int slot = IndexedTable.DEFAULT_GENERATOR.getIndex((long) key, 1);
20+
int channel = IndexedTable.DEFAULT_GENERATOR.getIndex((long) key, 2);
21+
long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate, slot, channel);
22+
// add row to the new table:
23+
addEntry(crate, slot, channel);
24+
// add all entries to the new row:
25+
int column;
26+
for (column=0; column<it.getEntryMap().values().size(); column++) {
27+
int value = it.getIntValueByHash(column, hash);
28+
setIntValueByHash(value, column, hash);
29+
}
30+
// add the new detector type:
31+
setIntValueByHash(dt.getDetectorId(), column, hash);
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)