|
| 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