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

Commit

Permalink
Merge pull request #77 from sly2j/master
Browse files Browse the repository at this point in the history
FEATURE/BUGFIX: added LTCC calibration
  • Loading branch information
fxgirod authored Mar 3, 2018
2 parents ad1d641 + 28190e4 commit c7b3219
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.jlab.clas.reco.ReconstructionEngine;
import org.jlab.io.base.DataEvent;
import java.util.List;
import java.util.Arrays;

/**
* LTCC Reconstruction Engine.
Expand All @@ -11,6 +12,8 @@
*/
public class LTCCEngine extends ReconstructionEngine {
private static final boolean DEBUG = false;
private static final List<String> CC_TABLES =
Arrays.asList("/calibration/ltcc/spe");

public LTCCEngine() {
super("LTCC", "joosten", "1.0");
Expand All @@ -37,6 +40,7 @@ public boolean processDataEvent(DataEvent event) {

@Override
public boolean init() {
this.requireConstants(CC_TABLES);
System.out.println("[LTCC] --> initialization successful...");
return true;
}
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void setStyle() {
* @param args ignored
*/
public static void main(String[] args) {
String inputfile = "/Users/sly2j/Data/CLAS12/pass0_4/out_clas_002053.evio.1.hipo";
String inputfile = "/Users/sly2j/Data/CLAS12/rg-a/filtered/ltcc_3432.hipo";

DataSource reader = new HipoDataSource();
reader.open(inputfile);
Expand Down

0 comments on commit c7b3219

Please sign in to comment.