Skip to content

Commit 7706a06

Browse files
committed
add more performant accessors and use them in decoding
1 parent bc3a41e commit 7706a06

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ public void translate(List<DetectorDataDgtz> detectorData){
162162
// Found it; now set the detector indexing for this hit:
163163
if (t.hasEntryByHash(hash)) {
164164

165-
int sector = t.getIntValueByHash("sector", hash);
166-
int layer = t.getIntValueByHash("layer", hash);
167-
int component = t.getIntValueByHash("component", hash);
168-
int order = t.getIntValueByHash("order", hash);
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);
169169

170170
data.getDescriptor().setSectorLayerComponent(sector, layer, component);
171171
data.getDescriptor().setOrder(order);

common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ public void setDoubleValue(Double value, String item, int... index){
133133
}
134134
}
135135

136+
public int getIntValueByHash(int index, long hash) {
137+
if (this.entries.hasItemByHash(hash))
138+
return this.entries.getItemByHash(hash).getValue(index).intValue();
139+
return 0;
140+
}
141+
142+
public double getDoubleValueByHash(int index, long hash) {
143+
if (this.entries.hasItemByHash(hash))
144+
return this.entries.getItemByHash(hash).getValue(index).doubleValue();
145+
return 0;
146+
}
147+
136148
public int getIntValueByHash(String item, long hash) {
137149
if (this.entries.hasItemByHash(hash)) {
138150
if (this.entryMap.containsKey(item)) {

0 commit comments

Comments
 (0)