Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fbbc437
add more helpful helper method
baltzell Aug 12, 2026
bef3cad
simplify
baltzell Aug 12, 2026
a2857f8
add occupancy table
baltzell Aug 10, 2026
72fd63a
complete OccupancyTable class
baltzell Aug 11, 2026
a9f5031
cleanup
baltzell Aug 11, 2026
25dbc4b
cleanup
baltzell Aug 11, 2026
9f5d4a2
add bank
baltzell Aug 11, 2026
dd905d0
make it work
baltzell Aug 12, 2026
e016f69
cleanup
baltzell Aug 12, 2026
8d51bad
cleanup
baltzell Aug 12, 2026
310e8d7
more
baltzell Aug 13, 2026
06bb8bf
claraify it
baltzell Aug 13, 2026
07c6aae
untagged periodic instead
baltzell Aug 13, 2026
c3349a4
cleanup
baltzell Aug 13, 2026
251c6ed
go long
baltzell Aug 13, 2026
36bb119
cleanup
baltzell Aug 13, 2026
88099ba
cleanup
baltzell Aug 13, 2026
46ec581
cleanup
baltzell Aug 13, 2026
009daca
cleanup
baltzell Aug 13, 2026
69ae7ec
cleanup
baltzell Aug 13, 2026
7a1e184
doc
baltzell Aug 13, 2026
4c26270
cleanup
baltzell Aug 14, 2026
83c1af1
rename
baltzell Aug 14, 2026
dfa2a6a
cleanup
baltzell Aug 14, 2026
f94e5c5
add more detectors
baltzell Aug 14, 2026
a3c2f29
update
baltzell Aug 14, 2026
b370735
revert unrelated changes
baltzell Aug 14, 2026
e5c59d1
add occupancy banks to dst (all) schema
baltzell Aug 14, 2026
e0473eb
debug
baltzell Aug 14, 2026
567d19a
fix bank name
baltzell Aug 14, 2026
f022e8d
remove printouts
baltzell Aug 14, 2026
99e84e7
debug
baltzell Aug 14, 2026
a7797e2
ignore negative indices (BMT?)
baltzell Aug 14, 2026
4dc4701
cleanup
baltzell Aug 14, 2026
534cda6
fix counter, add DC::tdc
baltzell Aug 16, 2026
9472515
change default occupancy prescale to 100
baltzell Aug 16, 2026
884c553
cleanup
baltzell Aug 16, 2026
23fa50b
cleanup
baltzell Aug 16, 2026
b8e3741
rename occupancy banks
baltzell Aug 17, 2026
c999bdd
this should be final
baltzell Aug 17, 2026
9197667
fix bank name
baltzell Aug 17, 2026
c06f59e
cleanup
baltzell Aug 17, 2026
5ace9ba
use filtered banks
baltzell Aug 17, 2026
5cc41e0
fix bank names
baltzell Aug 17, 2026
33c8df3
add occupancy to uber engine
baltzell Aug 22, 2026
a43594b
change yaml variable name
baltzell Aug 25, 2026
d361dc3
cleanup, make it thread-safe
baltzell Aug 25, 2026
b1be734
fix build
baltzell Aug 26, 2026
b4fe565
read banks
baltzell Aug 26, 2026
27a7939
cleanup
baltzell Aug 26, 2026
40b1c1a
fix
baltzell Aug 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package org.jlab.detector.calib.utils;

import java.util.Map;
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
import org.jlab.utils.groups.IndexedTable;
import org.jlab.utils.groups.IndexedTable.IndexedEntry;
import org.jlab.detector.banks.RawDataBank;

/**
* Occupancy bookkeeper based on IndexedTable, with I/O helpers for indexed banks.
*
* @author baltzell
*/
public class OccupanceTable {

String hitBank;
String occBank;
IndexedTable table;

/**
* A 3-index table, e.g., sector/layer/component.
* @param hitBank name of the hit bank
*/
public OccupanceTable(String hitBank) {
this.hitBank = hitBank;
occBank = "OCC::" + hitBank;
table = new IndexedTable(3, new String[]{"occ/F"});
}

/**
* An N-index table.
* @param hitBank name of the hit bank
* @param indexCount number of inidices in the hit bank
*/
public OccupanceTable(String hitBank, int indexCount) {
this.hitBank = hitBank;
occBank = "OCC::" + hitBank;
table = new IndexedTable(indexCount, new String[]{"occ/F"});
}

public String getHitBank() { return hitBank; }
public String getOccBank() { return occBank; }
public final IndexedTable getTable() { return table; }

/**
* Zero the occupancy table.
*/
public final void reset() {
table = new IndexedTable(table.getList().getIndexSize(), new String[]{"occ/F"});
}

/**
* Get the occupancy table, normalized by number of events.
* @param events
* @return
*/
public final IndexedTable getOccupancy(long events) {
IndexedTable t = new IndexedTable(table.getList().getIndexSize(), new String[]{"occ/F"});
for (long hash : ((Map<Long,IndexedEntry>)table.getList().getMap()).keySet()) {
t.addEntry(IndexedTable.DEFAULT_GENERATOR.getIndices(hash, table.getList().getIndexSize()));
t.setDoubleValueByHash((table.getDoubleValueByHash(0, hash))/events, 0, hash);
}
return t;
}

/**
* Fill the occupancy table.
* @param weight
* @param index
*/
public synchronized final void fill(float weight, int... index) {
for (int i=0; i<index.length; i++) if (index[i] < 0) return;
final long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(index);
if (!table.hasEntryByHash(hash)) {
table.addEntry(index);
table.setDoubleValueByHash(0.0d, 0, hash);
}
table.setDoubleValueByHash(table.getDoubleValueByHash(0, hash) + weight, 0, hash);
}

/**
* Fill occupancy table from a user-defined bank.
* @param bank
* @param weighted
*/
public void fill(RawDataBank bank, boolean weighted) {
if (bank != null) {
final int rows = bank.rows();
int[] idx = new int[table.getList().getIndexSize()];
for (int i=0; i<rows; i++) {
for (int j=0; j<table.getList().getIndexSize(); j++) {
if (j==2) idx[j] = bank.getShort(j,i);
else idx[j] = bank.getByte(j,i);
}
if (weighted) fill(bank.getFloat(table.getList().getIndexSize(),i),idx);
else fill(1.0f, idx);
}
}
}

/**
* Get an occupancy bank, normalized by number of events.
* @param events
* @param event
* @return
*/
public DataBank create(long events, DataEvent event) {
DataBank b = event.createBank(occBank, table.getRowCount());
int i = 0;
Map<Long,IndexedEntry> m = table.getList().getMap();
for (long hash : m.keySet()) {
int[] idx = IndexedTable.DEFAULT_GENERATOR.getIndices(hash, table.getList().getIndexSize());
for (int j=0; j<table.getList().getIndexSize(); j++) {
if (j == 2) b.setShort(j, i, (short)idx[j]);
else b.setByte(j, i, (byte)idx[j]);
}
b.setFloat(table.getList().getIndexSize(), i, ((float)m.get(hash).getValue(0).intValue())/events);
i++;
}
return b;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void initDefault(){
String[] names = new String[]{
"MAGFIELDS",
"DCCR","DCHB","FTOFHB","EC","HTCC","EBHB",
"DCTB","FTOFTB","EBTB","VTX"
"DCTB","FTOFTB","EBTB","OCC"
};

String[] services = new String[]{
Expand All @@ -144,7 +144,7 @@ public void initDefault(){
"org.jlab.service.dc.DCTBEngine",
"org.jlab.service.ftof.FTOFTBEngine",
"org.jlab.service.eb.EBTBEngine",
"org.jlab.rec.service.vtx.VTXEngine"
"org.jlab.calibration.service.OccupanceEngine",
};

for(int i = 0; i < names.length; i++){
Expand All @@ -160,7 +160,7 @@ public void initAll(){
"CVTFP","CTOF","CND","BAND",
"HTCC","LTCC","EBHB",
"DCTB","FMT","FTOFTB","CVT","EBTB",
"RICHEB","RTPC","AHDC","ATOF","ALERT", "MC","VTX"
"RICHEB","RTPC","AHDC","ATOF","ALERT", "MC","VTX","OCC"
};

String[] services = new String[]{
Expand Down Expand Up @@ -193,7 +193,8 @@ public void initAll(){
"org.jlab.service.atof.ATOFEngine",
"org.jlab.service.alert.ALERTEngine",
"org.jlab.service.mc.TruthMatch",
"org.jlab.rec.service.vtx.VTXEngine"
"org.jlab.rec.service.vtx.VTXEngine",
"org.jlab.calibration.service.OccupanceEngine",
};
if(names.length!=services.length)
LOGGER.log(Level.SEVERE, "initAll : the list of services does not match the list of service names... ");
Expand Down
Loading
Loading