Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2daa3f5
add routine to clean bad hits
ftouchte Feb 10, 2026
4abf947
make some methods public
ftouchte Feb 10, 2026
a7bafad
uncomment
ftouchte Feb 10, 2026
49d1368
save error covariance matrix in Track
ftouchte Feb 10, 2026
74cd6d2
remove the constraint x,y = 0 when KF counter > 2
ftouchte Feb 10, 2026
39811d7
fix vz_constraint
ftouchte Feb 13, 2026
7b5a5d4
fix error from last commit
ftouchte Feb 13, 2026
9c0503e
use atof bar hit in the kalman filter
ftouchte Feb 16, 2026
83bb9fa
fix bug
ftouchte Feb 16, 2026
b3091eb
update noise for atof hit
ftouchte Feb 18, 2026
44c7540
propagate from the atof to the last ahdc layer
ftouchte Feb 18, 2026
6b027da
select the first bar and propagate to the surface
ftouchte Feb 18, 2026
33b49a8
use atof wedges instead of bars
ftouchte Feb 18, 2026
4f26a3f
add atof ahdc vz shift
ftouchte Feb 19, 2026
253be6a
fix key value access issue
ftouchte Feb 19, 2026
f76628c
create an interface for the hit used int the Kalman Filter
ftouchte Feb 19, 2026
860e03d
rename Hit_beam RadialKFHit
ftouchte Feb 20, 2026
9742dd8
improve the consistency of the code
ftouchte Feb 20, 2026
b6dd780
remove comments or non used imports
ftouchte Feb 20, 2026
66268b9
Merge branch 'development' into clean/hits
ftouchte Feb 20, 2026
bc38c18
rename variable
ftouchte Feb 24, 2026
cd7038d
project AHDC track to the ATOF and predict wedges
ftouchte Feb 24, 2026
b5643a2
start projection on the 3 surfaces of the ATOF
ftouchte Feb 25, 2026
876ea6e
Merge branch 'development' into clean/hits
ftouchte Feb 25, 2026
658e9fe
fill kftrack before propagation to ATOF
ftouchte Feb 25, 2026
9f92d8f
remove redundancy of Stepper in KFitter
ftouchte Feb 25, 2026
f855a2d
define the hit of the beam once
ftouchte Feb 25, 2026
b033b77
clean
ftouchte Feb 25, 2026
88938f0
keep the precision of the stepper at the end of the propagation
ftouchte Feb 25, 2026
b6bd418
add position, momentum, path of the track when crossing atof material
ftouchte Feb 26, 2026
c3aaf81
fix bugs
ftouchte Feb 27, 2026
bfd2471
store predicted atof components for each surfaces
ftouchte Feb 27, 2026
34dcc68
fix array access bug
ftouchte Feb 27, 2026
eaa8f0a
do not modify initial state and error matrix
ftouchte Mar 2, 2026
75d1b46
save error in x,y,z for the atof projections
ftouchte Mar 2, 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
112 changes: 112 additions & 0 deletions etc/bankdefs/hipo4/alert.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,118 @@
"name": "sum_residuals",
"type": "F",
"info": "Sum of residuals (mm)"
}, {
"name": "atof_region",
"type": "I",
"info": "a flag to know if a track reach S1, S2, or S3; is n if Sn is reached; is 0 otherwise"
}, {
"name": "atof_s1_x",
"type": "F",
"info": "x position of the track if it reaches the surface s1"
}, {
"name": "atof_s1_y",
"type": "F",
"info": "y position of the track if it reaches the surface s1"
}, {
"name": "atof_s1_z",
"type": "F",
"info": "z position of the track if it reaches the surface s1"
}, {
"name": "atof_s1_path",
"type": "F",
"info": "total path from the beamline to the surface s1"
}, {
"name": "atof_s1_p",
"type": "F",
"info": "momentum whith which the track reaches the surface s1"
}, {
"name": "atof_s2_x",
"type": "F",
"info": "x position of the track if it reaches the surface s2"
}, {
"name": "atof_s2_y",
"type": "F",
"info": "y position of the track if it reaches the surface s2"
}, {
"name": "atof_s2_z",
"type": "F",
"info": "z position of the track if it reaches the surface s2"
}, {
"name": "atof_s2_path",
"type": "F",
"info": "total path from the beamline to the surface s2"
}, {
"name": "atof_s2_p",
"type": "F",
"info": "momentum whith which the track reaches the surface s2"
}, {
"name": "atof_s3_x",
"type": "F",
"info": "x position of the track if it reaches the surface s3"
}, {
"name": "atof_s3_y",
"type": "F",
"info": "y position of the track if it reaches the surface s3"
}, {
"name": "atof_s3_z",
"type": "F",
"info": "z position of the track if it reaches the surface s3"
}, {
"name": "atof_s3_path",
"type": "F",
"info": "total path from the beamline to the surface s3"
}, {
"name": "atof_s3_p",
"type": "F",
"info": "momentum whith which the track reaches the surface s3"
}, {
"name": "atof_s1_comp",
"type": "I",
"info": "sector*10000 + layer*100 + component : atof component on s1"
}, {
"name": "atof_s2_comp",
"type": "I",
"info": "sector*10000 + layer*100 + component : atof component on s1"
}, {
"name": "atof_s3_comp",
"type": "I",
"info": "sector*10000 + layer*100 + component : atof component on s1"
}, {
"name": "atof_s1_sigma_x",
"type": "F",
"info": "error in atof_s1_x"
}, {
"name": "atof_s1_sigma_y",
"type": "F",
"info": "error in atof_s1_y"
}, {
"name": "atof_s1_sigma_z",
"type": "F",
"info": "error in atof_s1_z"
}, {
"name": "atof_s2_sigma_x",
"type": "F",
"info": "error in atof_s2_x"
}, {
"name": "atof_s2_sigma_y",
"type": "F",
"info": "error in atof_s2_y"
}, {
"name": "atof_s2_sigma_z",
"type": "F",
"info": "error in atof_s2_z"
}, {
"name": "atof_s3_sigma_x",
"type": "F",
"info": "error in atof_s3_x"
}, {
"name": "atof_s3_sigma_y",
"type": "F",
"info": "error in atof_s3_y"
}, {
"name": "atof_s3_sigma_z",
"type": "F",
"info": "error in atof_s3_z"
}
]
}, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.jlab.rec.ahdc.Banks;

import org.apache.commons.math3.linear.RealMatrix;
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
import org.jlab.rec.ahdc.AI.InterCluster;
import org.jlab.rec.ahdc.AI.TrackPrediction;
import org.jlab.rec.ahdc.Cluster.Cluster;
import org.jlab.rec.ahdc.DocaCluster.DocaCluster;
import org.jlab.rec.ahdc.Hit.Hit;
import org.jlab.rec.ahdc.KalmanFilter.Stepper;
import org.jlab.rec.ahdc.PreCluster.PreCluster;
import org.jlab.rec.ahdc.Track.Track;

Expand Down Expand Up @@ -153,6 +155,63 @@ public DataBank fillAHDCKFTrackBank(DataEvent event, ArrayList<Track> tracks) {
bank.setFloat("chi2", row, (float) track.get_chi2());
bank.setFloat("sum_residuals", row, (float) track.get_sum_residuals());

// track projection on ATOF surface S1
Stepper stepper_s1 = track.get_ATOF_S1_stepper();
if (stepper_s1 != null) {
bank.setFloat("atof_s1_x", row, (float) stepper_s1.y[0]);
bank.setFloat("atof_s1_y", row, (float) stepper_s1.y[1]);
bank.setFloat("atof_s1_z", row, (float) stepper_s1.y[2]);
bank.setFloat("atof_s1_path", row, (float) stepper_s1.sTot);
bank.setFloat("atof_s1_p", row, (float) stepper_s1.p());
}

// track projection on ATOF surface S2
Stepper stepper_s2 = track.get_ATOF_S2_stepper();
if (stepper_s2 != null) {
bank.setFloat("atof_s2_x", row, (float) stepper_s2.y[0]);
bank.setFloat("atof_s2_y", row, (float) stepper_s2.y[1]);
bank.setFloat("atof_s2_z", row, (float) stepper_s2.y[2]);
bank.setFloat("atof_s2_path", row, (float) stepper_s2.sTot);
bank.setFloat("atof_s2_p", row, (float) stepper_s2.p());
}

// track projection on ATOF surface S3
Stepper stepper_s3 = track.get_ATOF_S3_stepper();
if (stepper_s3 != null) {
bank.setFloat("atof_s3_x", row, (float) stepper_s3.y[0]);
bank.setFloat("atof_s3_y", row, (float) stepper_s3.y[1]);
bank.setFloat("atof_s3_z", row, (float) stepper_s3.y[2]);
bank.setFloat("atof_s3_path", row, (float) stepper_s3.sTot);
bank.setFloat("atof_s3_p", row, (float) stepper_s3.p());
}

bank.setInt("atof_region", row, track.get_ATOF_region());

// tmp
bank.setInt("atof_s1_comp", row, track.get_ATOF_S1_component());
bank.setInt("atof_s2_comp", row, track.get_ATOF_S2_component());
bank.setInt("atof_s3_comp", row, track.get_ATOF_S3_component());

// error on atof_sn_(x,y,z)
RealMatrix atof_s1_errorMatrix = track.get_ATOF_S1_errorMatrix();
RealMatrix atof_s2_errorMatrix = track.get_ATOF_S2_errorMatrix();
RealMatrix atof_s3_errorMatrix = track.get_ATOF_S3_errorMatrix();
if (atof_s1_errorMatrix != null) {
bank.setFloat("atof_s1_sigma_x", row, (float) Math.sqrt(atof_s1_errorMatrix.getEntry(0, 0)));
bank.setFloat("atof_s1_sigma_y", row, (float) Math.sqrt(atof_s1_errorMatrix.getEntry(1, 1)));
bank.setFloat("atof_s1_sigma_z", row, (float) Math.sqrt(atof_s1_errorMatrix.getEntry(2, 2)));
}
if (atof_s2_errorMatrix != null) {
bank.setFloat("atof_s2_sigma_x", row, (float) Math.sqrt(atof_s2_errorMatrix.getEntry(0, 0)));
bank.setFloat("atof_s2_sigma_y", row, (float) Math.sqrt(atof_s2_errorMatrix.getEntry(1, 1)));
bank.setFloat("atof_s2_sigma_z", row, (float) Math.sqrt(atof_s2_errorMatrix.getEntry(2, 2)));
}
if (atof_s3_errorMatrix != null) {
bank.setFloat("atof_s3_sigma_x", row, (float) Math.sqrt(atof_s3_errorMatrix.getEntry(0, 0)));
bank.setFloat("atof_s3_sigma_y", row, (float) Math.sqrt(atof_s3_errorMatrix.getEntry(1, 1)));
bank.setFloat("atof_s3_sigma_z", row, (float) Math.sqrt(atof_s3_errorMatrix.getEntry(2, 2)));
}

row++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.MatrixUtils;
import org.apache.commons.math3.linear.RealMatrix;
import org.apache.commons.math3.linear.RealVector;
import org.jlab.detector.calib.utils.DatabaseConstantProvider;
import org.jlab.geom.detector.alert.AHDC.AlertDCDetector;
import org.jlab.geom.prim.Line3D;
import org.jlab.geom.prim.Point3D;
import org.jlab.geom.detector.alert.AHDC.AlertDCFactory;
import org.jlab.rec.ahdc.KalmanFilter.KFHit;

public class Hit implements Comparable<Hit> {
public class Hit implements Comparable<Hit>, KFHit {

private final int id;
private final int superLayerId;
Expand Down Expand Up @@ -106,10 +108,12 @@ public double getDoca() {
return doca;
}

@Override
public Line3D getLine() {
return wireLine;
}

@Override
public double getRadius() {
return radius;
}
Expand Down Expand Up @@ -174,11 +178,13 @@ public void setTrackId(int _trackId) {
this.trackId = _trackId;
}

public RealVector get_Vector() {
@Override
public RealVector MeasurementVector() {
return new ArrayRealVector(new double[]{this.doca});
}

public RealMatrix get_MeasurementNoise() {
@Override
public RealMatrix MeasurementNoiseMatrix() {
double mean_error = 0.471; // mm (no difference between adc and time)
double error_on_adc = (1.15146*raw_adc + 437.63)/(3.21187*raw_adc + 878.855); // mm
double error_on_time = (0.4423*time + 13.7215)/(0.846038*time + 31.9867); // mm
Expand All @@ -188,11 +194,43 @@ public RealMatrix get_MeasurementNoise() {
//return new Array2DRowRealMatrix(new double[][]{{0.09}});
}

// a signature for KalmanFilter.Hit_beam
public RealVector get_Vector_beam() {
return null;
// Projection function
@Override
public RealVector ProjectionFunction(RealVector x) {
double d = this.distance(new Point3D(x.getEntry(0), x.getEntry(1), x.getEntry(2)));
return MatrixUtils.createRealVector(new double[]{d});
}

// Jacobian matrix of the measurement with respect to (x, y, z, px, py, pz)
@Override
public RealMatrix ProjectionMatrix(RealVector x) {

double ddocadx = partialProjectionMatrix(x, 0);
double ddocady = partialProjectionMatrix(x, 1);
double ddocadz = partialProjectionMatrix(x, 2);
double ddocadpx = partialProjectionMatrix(x, 3);
double ddocadpy = partialProjectionMatrix(x, 4);
double ddocadpz = partialProjectionMatrix(x, 5);

return MatrixUtils.createRealMatrix(new double[][]{
{ddocadx, ddocady, ddocadz, ddocadpx, ddocadpy, ddocadpz}});
}

private double partialProjectionMatrix(RealVector x, int i) {
double h = 1e-8;// in mm
RealVector x_plus = x.copy();
RealVector x_minus = x.copy();

x_plus.setEntry(i, x_plus.getEntry(i) + h);
x_minus.setEntry(i, x_minus.getEntry(i) - h);

double doca_plus = this.ProjectionFunction(x_plus).getEntry(0);
double doca_minus = this.ProjectionFunction(x_minus).getEntry(0);

return (doca_plus - doca_minus) / (2 * h);
}

@Override
public double distance(Point3D point3D) {
return this.wireLine.distance(point3D).length();
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.jlab.rec.ahdc.KalmanFilter;

import org.apache.commons.math3.linear.RealMatrix;
import org.apache.commons.math3.linear.RealVector;
import org.jlab.geom.prim.Line3D;
import org.jlab.geom.prim.Point3D;
/**
* An interface to unify the hits used the Kalman Filter (e.g AHDC hits, ATOF hits, beamline)
*
* @author Felix Touchte Codjo
*/
public interface KFHit {
public Line3D getLine();
public double distance(Point3D point3D);
public double getRadius();
/** Return the measurement encoded in this KFHit */
public RealVector MeasurementVector();
/** Return the measurement noise matrix for this this KFHit */
public RealMatrix MeasurementNoiseMatrix();
/** Compute the measure for a given state vector */
public RealVector ProjectionFunction(RealVector x);
/** Compute the Jacobian matrix of the {@link #ProjectionFunction(RealVector)} with respect of the components of the state vector */
public RealMatrix ProjectionMatrix(RealVector x);
}
Loading