Skip to content

Commit b65c035

Browse files
committed
add indexed table extension for adding DetectorType
1 parent db78d90 commit b65c035

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
String[] x = new String[entryMap.keySet().size()];
15+
for (String name : entryMap.keySet())
16+
x[entryMap.get(name)] = name + "/" + entryTypes.get(name);
17+
};
18+
19+
public void add(DetectorType dt, IndexedTable it) {
20+
for (Object key : it.getList().getMap().keySet()) {
21+
int crate = IndexedTable.DEFAULT_GENERATOR.getIndex((long) key, 0);
22+
int slot = IndexedTable.DEFAULT_GENERATOR.getIndex((long) key, 1);
23+
int channel = IndexedTable.DEFAULT_GENERATOR.getIndex((long) key, 2);
24+
long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate, slot, channel);
25+
// add row to the new table:
26+
addEntry(crate, slot, channel);
27+
// add all entries to the new row:
28+
int column;
29+
for (column=0; column<it.getEntryMap().values().size(); column++) {
30+
int value = it.getIntValueByHash(column, hash);
31+
setIntValueByHash(value, column, hash);
32+
}
33+
// add the new detector type:
34+
setIntValueByHash(dt.getDetectorId(), column, hash);
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)