Skip to content

Commit b95f5aa

Browse files
committed
use global /daq/tt translation table
1 parent 76d9a65 commit b95f5aa

File tree

1 file changed

+18
-34
lines changed

1 file changed

+18
-34
lines changed

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

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class DetectorEventDecoder {
3434
private ExtendedFADCFitter extendedFitter = new ExtendedFADCFitter();
3535
private MVTFitter mvtFitter = new MVTFitter();
3636

37+
private TranslationTable translator = new TranslationTable();
38+
3739
public DetectorEventDecoder(boolean development){
3840
if(development==true){
3941
this.initDecoderDev();
@@ -55,6 +57,11 @@ public void setVariation(String variation) {
5557
}
5658

5759
public void setRunNumber(int run){
60+
if (run != this.runNumber) {
61+
translator = new TranslationTable();
62+
for (int i=0; i<keysTrans.size(); i++)
63+
translator.add(keysTrans.get(i), translationManager.getConstants(run, tablesTrans.get(i)));
64+
}
5865
this.runNumber = run;
5966
}
6067

@@ -140,44 +147,21 @@ public void checkTables() {
140147
*/
141148
public void translate(List<DetectorDataDgtz> detectorData){
142149

143-
// Preload CCDB tables:
144-
ArrayList<IndexedTable> tables = new ArrayList<>();
145-
for (String name : tablesTrans) {
146-
tables.add(translationManager.getConstants(runNumber, name));
147-
}
150+
for (DetectorDataDgtz d : detectorData) {
148151

149-
for (DetectorDataDgtz data : detectorData) {
152+
// Get the hardware indexing for this detector data object:
153+
long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(d.getDescriptor().getCrate(),
154+
d.getDescriptor().getSlot(), d.getDescriptor().getChannel());
150155

151-
// Get the hardware indexing for this detector hit:
152-
int crate = data.getDescriptor().getCrate();
153-
int slot = data.getDescriptor().getSlot();
154-
int channel = data.getDescriptor().getChannel();
155-
long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate,slot,channel);
156-
157-
// Try to find it in the translation tables:
158-
for (int j=0; j<tablesTrans.size(); ++j) {
159-
160-
IndexedTable t = tables.get(j);
161-
162-
// Found it; now set the detector indexing for this hit:
163-
if (t.hasEntryByHash(hash)) {
156+
if (translator.hasEntryByHash(hash)) {
164157

165-
int sector = t.getIntValueByHash(0, hash);
166-
int layer = t.getIntValueByHash(1, hash);
167-
int component = t.getIntValueByHash(2, hash);
168-
int order = t.getIntValueByHash(3, hash);
158+
// The tanslated detector indexing:
159+
List<Integer> x = translator.getIntegersByHash(hash);
169160

170-
data.getDescriptor().setSectorLayerComponent(sector, layer, component);
171-
data.getDescriptor().setOrder(order);
172-
data.getDescriptor().setType(keysTrans.get(j));
173-
174-
for(int i = 0; i < data.getADCSize(); i++) data.getADCData(i).setOrder(order);
175-
for(int i = 0; i < data.getTDCSize(); i++) data.getTDCData(i).setOrder(order);
176-
177-
// Assume there's only one instance of this crate/slot/channel
178-
// in all translation tables, and we found it, so stop:
179-
break;
180-
}
161+
// Set the translated detector indexing:
162+
d.getDescriptor().setSectorLayerComponentOrderType(x.get(0),x.get(1),x.get(2),x.get(3),x.get(4));
163+
for (int i=0; i<d.getADCSize(); i++) d.getADCData(i).setOrder(x.get(3));
164+
for (int i=0; i<d.getTDCSize(); i++) d.getTDCData(i).setOrder(x.get(3));
181165
}
182166
}
183167
}

0 commit comments

Comments
 (0)