Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
added calibration routine, fixed bug were LTCC side was set to (0, 1)…
Browse files Browse the repository at this point in the history
… instead of (1, 2)
  • Loading branch information
sly2j committed Mar 2, 2018
1 parent 5a089f9 commit 46dee25
Showing 1 changed file with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,22 @@ private boolean isGood() {

// load a list of all good hits
public static List<LTCCHit> loadHits(DataEvent event, ConstantsManager ccdb) {
int run = 11; // TODO how to get run number?\
IndexedTable gain = null;
int run = -1;
if (event.hasBank("RUN::config")) {
DataBank header = event.getBank("RUN::config");
run = header.getInt("run", 0);
}
IndexedTable spe = null;
IndexedTable timing_offset = null;
if (ccdb != null) {
//gain = ccdb.getConstants(run, "/calibration/ltcc/gain");
if (ccdb != null && run > 0) {
spe = ccdb.getConstants(run, "/calibration/ltcc/spe");
//timing_offset = ccdb.getConstants(run, "/calibration/ltcc/timing_offset");
}
DataBank bank = event.getBank("LTCC::adc");

List<LTCCHit> hits = new LinkedList<>();
for (int i = 0; i < bank.rows(); ++i) {
LTCCHit hit = new LTCCHit(bank, i, gain, timing_offset);
LTCCHit hit = new LTCCHit(bank, i, spe, timing_offset);
if (hit.isGood()) {
hits.add(hit);
}
Expand All @@ -79,14 +83,17 @@ public static List <LTCCHit> loadHits(DataEvent event) {
return loadHits(event, null);
}

LTCCHit(DataBank bank, int index, IndexedTable gain, IndexedTable timing_offset) {
LTCCHit(DataBank bank,
int index,
IndexedTable spe,
IndexedTable timing_offset) {
this.sector = bank.getByte("sector", index);
this.segment = bank.getShort("component", index);
this.side = bank.getByte("order", index);
this.side = bank.getByte("order", index) + 1;
this.adc = bank.getInt("ADC", index);
this.rawTime = bank.getFloat("time", index);
//this.pedestal = bank.getShort("ped", index);
this.nphe = calcNphe(gain);
this.nphe = calcNphe(spe);
this.time = calcTime(timing_offset);
this.iLTCCPhi = calcLTCCPhiIndex();
this.status = calcStatus();
Expand Down Expand Up @@ -164,15 +171,17 @@ public boolean isNeighbor(LTCCHit hit, double dTimeMax) {
}


private double calcNphe(IndexedTable gain) {
// TODO: verify with Maurizio if this is indeed the format
//gain.getDoubleValue("gain", sector, side, segment);
if (gain != null) {
return (this.adc > 0 ? this.adc / 100 : -1); // hard-coded for now
} else {
// fallback
return (this.adc > 0 ? this.adc / 100 : -1);
private double calcNphe(IndexedTable spe) {
// sane default in case there is no ccdb
double calibration = 1. / 200.;
// load value from CCDB
if (spe != null) {
calibration = spe.getDoubleValue("mean", sector, side, segment);
if (calibration > 0) {
calibration = 1 / calibration;
}
}
return (this.adc > 0 ? this.adc * calibration : -1);
}

private double calcTime(IndexedTable timing) {
Expand Down

0 comments on commit 46dee25

Please sign in to comment.