Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions etc/bankdefs/hipo4/alert.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,19 @@
}, {
"name": "Doca",
"type": "D",
"info": "distance od closest approch (mm)"
"info": "distance od closest approch (mm) is actually the distance from time2distance calibration"
}, {
"name": "residual",
"type": "D",
"info": "residual (mm)"
"info": "residual (mm) is distance from time2distance calibration minus the distance of closest approach computed at the Kalman Filter stage"
}, {
"name": "residual_prefit",
"type": "D",
"info": "residual pre-fit (mm)"
}, {
"name": "time",
"type": "D",
"info": "time (ns) is leadingEdgeTime from AHDC::adc minus t0 from calibration"
}
]
}, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Hit implements Comparable<Hit> {
private final int wireId;
private final double doca;
private final double adc;
private final double time;

private double phi;
private double radius;
Expand All @@ -21,13 +22,14 @@ public class Hit implements Comparable<Hit> {
private double residual;

//updated constructor with ADC
public Hit(int _Id, int _Super_layer, int _Layer, int _Wire, double _Doca, double _ADC) {
public Hit(int _Id, int _Super_layer, int _Layer, int _Wire, double _Doca, double _ADC, double _Time) {
this.id = _Id;
this.superLayerId = _Super_layer;
this.layerId = _Layer;
this.wireId = _Wire;
this.doca = _Doca;
this.adc = _ADC;
this.time = _Time;
wirePosition();
this.residual_prefit = 0.0;
this.residual = 0.0;
Expand Down Expand Up @@ -155,4 +157,8 @@ public void setResidual(double resid) {
public void setResidualPrefit(double resid) {
this.residual_prefit = resid;
}

public double getTime() {
return time;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
import org.jlab.detector.banks.RawDataBank;
import org.jlab.rec.alert.constants.CalibrationConstantsLoader;

public class HitReader {

Expand All @@ -31,11 +32,31 @@ public void fetch_AHDCHits(DataEvent event) {
int number = bankDGTZ.getByte("layer", i);
int layer = number % 10;
int superlayer = (int) (number % 100) / 10;
int sector = bankDGTZ.getInt("sector", i);
int wire = bankDGTZ.getShort("component", i);
double adc = bankDGTZ.getInt("ADC", i);
double doca = bankDGTZ.getShort("ped", i) / 1000.0;

hits.add(new Hit(id, superlayer, layer, wire, doca, adc));
double leadingEdgeTime = bankDGTZ.getFloat("leadingEdgeTime", i);

// use calibration constants
int key_value = sector*10000 + number*100 + wire;
double[] timeOffsets = CalibrationConstantsLoader.AHDC_TIME_OFFSETS.get( key_value );
double[] time2distance = CalibrationConstantsLoader.AHDC_TIME_TO_DISTANCE.get( 10101 ); // the time to distance table has only one row ! (10101 is its only key)
double t0 = timeOffsets[0];
double p0 = time2distance[0];
double p1 = time2distance[1];
double p2 = time2distance[2];
double p3 = time2distance[3];
double p4 = time2distance[4];
double p5 = time2distance[5];

double time = leadingEdgeTime - t0;
// we may prevent time to be too small or too big
// CONDITION TO BE ADDED
// we should also use a flag to prevent to read the ccdb if reconstructed event if from simulation
// TO BE DONE
//double doca = bankDGTZ.getShort("ped", i) / 1000.0;
double doca = p0 + p1*Math.pow(time,1.0) + p2*Math.pow(time,2.0) + p3*Math.pow(time,3.0) + p4*Math.pow(time,4.0) + p5*Math.pow(time, 5.0);
hits.add(new Hit(id, superlayer, layer, wire, doca, adc, time));
}
}
this.set_AHDCHits(hits);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public static synchronized void Load(int runno, String var, ConstantsManager man

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AHDC time to distance
// Caution, this table has only one row
// the corresponding identifers are (sector, layer, component) == (1,1,1)
// but it applies for all AHDC wires !
for( int i = 0; i < ahdc_time2distance.getRowCount(); i++){
int sector = Integer.parseInt((String)ahdc_time2distance.getValueAt(i, 0));
int layer = Integer.parseInt((String)ahdc_time2distance.getValueAt(i, 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.jlab.rec.ahdc.PreCluster.PreClusterFinder;
import org.jlab.rec.ahdc.Track.Track;
import org.jlab.rec.ahdc.Mode;
import org.jlab.rec.alert.constants.CalibrationConstantsLoader;

import java.io.File;
import java.util.*;
Expand Down Expand Up @@ -60,10 +61,22 @@ public boolean init() {
if (mode == Mode.AI_Track_Finding) {
model = new Model();
}

// Requires calibration constants
String[] alertTables = new String[] {
"/calibration/alert/ahdc/time_offsets",
"/calibration/alert/ahdc/time_to_distance",
"/calibration/alert/atof/effective_velocity",
"/calibration/alert/atof/time_walk",
"/calibration/alert/atof/attenuation",
"/calibration/alert/atof/time_offsets"
};
requireConstants(Arrays.asList(alertTables));

return true;
}

int Run = -1;

@Override
public boolean processDataEvent(DataEvent event) {
Expand All @@ -82,6 +95,14 @@ public boolean processDataEvent(DataEvent event) {
System.err.println("RTPCEngine: got run <= 0 in RUN::config, skipping event.");
return false;
}
int newRun = Run;
newRun = runNo;
// Load the constants
//-------------------
if(Run!=newRun) {
CalibrationConstantsLoader.Load(newRun,"default",this.getConstantsManager());
Run = newRun;
}
}

magfield = 50 * magfieldfactor;
Expand Down