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

Commit

Permalink
Iss827 cvt track eff dev m5 (#1025)
Browse files Browse the repository at this point in the history
* Merge branch 'development' into iss827-CVTTrackEff

# Conflicts:
#	reconstruction/cvt/src/main/java/org/jlab/rec/cvt/bmt/CCDBConstantsLoader.java
#	reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTEngine.java

* New track seeding algorithm
Improved cross selection

* class for seed selection

* remove un-used import

* Fix null BMT cross on track list exception

* Added key for overlap remover algo.

* runCA first; does good job at 90 deg.

* Fix which MC bank to read to flag true hits

* Fix which MC bank to read to flag true hits for BMT too

* Fix BST matching 
Tune cuts

* Remove unused imports

* New line finder
Cleanup of unused variables and imports

* Tighter chi2 cut for seeds
Improved RZ finder and linker algorithms

* Fix the issue with cluster seeds
Fix the issue with missing crosses

* CONTRA algorithm for missing clusters on track recovery

* Tighter resi cut in AKFitter

* SLA cuts in YAML settings

* Revert resi cut in KF

* handling null helix in KF

* Get list of overlapping seeds for debugging in recUtil class

* In RZ seeder, sort by Z; add functionality for bg crosses in a layer when 3 regions are present.

* Comment out un-used code line

* Save global fit track if KF fails

* Get svt strip charge dep in middle of the bin

* Add getZ to cross
Fix printouts

* Fix null stateVec in getHelix

* resi cut update in KF

* Merge with development.
Update printouts for YAML config.

* Cut on cluster size.  Can be set in YAML.

* Cut on cluster size for pattern recognition. Only accepted clusters make it into a cross which is used in tracking.  Can be set in YAML.

* Cut on cluster size for pattern recognition. Only accepted clusters make it into a cross which is used in tracking.  Can be set in YAML.

* Added bank for AI inference.
Added prob fields to Seed banks for AI studies.

* Added bank for AI inference.
Added prob fields to Seed banks for AI studies.

* Order crosses in Seed and Track banks according to layer

* Functionality to flag the seeds
Fix in pattern rec to skip BMT-C layer

* Functionality to provide cluster on track information and perform MC studies added

* Remove the requirement to choose the closest cross in PR to match the dipangle line to the SVT crosses.

* Fix issue with counting truth hits where there is no MC Particle bank.

* Improve XY Seeding to allow for fewer crosses and reject seeds with no BST crosses.

* Fix for track matching probs.

* More debug statements

* Fixes to SVT Standalone

* Bug fix to set max clus size from YAML

* Tune SVTStandalone

* Flag seed on

* Looser Doca cuts

* version bump to 8.3.2

* More explicit comments on default YAML settings for CVT

* version update

* Fix for flip of solenoid polarity in tracking

* Fix for flip of solenoid polarity in tracking
Settings for pt cut and cut on helix parameter (z0) configurable in YAML.

* Remove unused class

* Remove unused imports

* Fix polarity in Projector matrix

* Oops...accidental charge flip. Fixed!

* Version bump

* Reading and setting BMT strip statuses according to HV tables.

* Fix in SVTStandalone when there are multiple candidate BMT crosses matched to the seed

* Tune cuts for SVTSTANDALONE

* fix trackseeder memory leak

* Read the tracks and not the seeds at second pass tracking.
Fix the pid bug that was overwriting the pid.

* Same cuts for SSA and SLA

* Ability to use CA in tracking.  Default is SLA.

* Added check on maxpathlength in all swim-tools SetParameters methods (#981)

* Memory optimization for SSA.
Fix in overlap remover.
Selection on accepted number of seeds for large number of seeds.
Debug comments
Associated track index from track bank persisted in pass 2

* Turn off passing of tracks that fail KF fit.
Setting for Seed cutting on helix radius instead of pt.
Default value set to 12 cm.

* In Constants,setting for Seed cutting on helix radius instead of pt.
Reading the track index in the track bank.  This set the track id value for pass 2.

* Fix in seed overlap remover.

* Fix for running without the BMT.

* version bump

* version update for tag prep.

* Recover missing svt cross in SSA

* Code cleanup in overlap remover

* comment out unused vars.

* Add seed type in track status word.

* version bump

* version bump

* version bump

* Merge branch 'development' into iss827-CVTTrackEff-DevM4
version 8c.4.0

* Debug statements

* KFFail recovery is set to false

* Status with 4 digits for Straight tracks to be consistent with helical tracks' status.
Fix to initialize the seed using the seed helix parameters instead for the track (which is corrected for Eloss) helical track parameters at pass 2.

* Fix to revert to unfilted track when the track parameters diverge.

* Going back to using track for pass2 init

* Use global fit parameters when KF fails for non-deuteron tracks.

* Algorithm to recover low pt tracks by searching for missing clusters
Fix in missing clusters on track recovery used in fit by updating the surfaces to take them into account
Slightly looser cut to pass clusters on track in cluster search

* Adding config for KF tracks recovery and extract recovery part to code to new method in utility class
Revert back to old SVTSTANDALONE algo and keep new one as a test class
modification to status word of track to flag KF failed tracks and remove the NB of KF iterations from first digit

* Fix status word output for tracks

* Track bank modification for NKF iterations

* Remove Test SSA seeder;
version change

* Bug fix for final state output
Method for fail-safe track recovery

* fix ndf init for failsafe recovery

* Fix reading of status of the track at second pass tracking

* Fix for track recovery of very low pt tracks that fail the first recovery algorithm.

* Fix to reject tracks with helix with NaNs parameters.

* bug fix

* Functionality to allow BMT with ADC=0 to be included in the list of hits used for tracking.  This is for dedicated AI studies and is off by default.

Co-authored-by: veronique <veronique@localhost>
Co-authored-by: raffaelladevita <[email protected]>
  • Loading branch information
3 people authored Jan 19, 2023
1 parent d7a89df commit 0269a19
Show file tree
Hide file tree
Showing 43 changed files with 3,184 additions and 824 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class AKFitter {
// parameters
private double _Xb; //beam axis pars
private double _Yb;
private double resiCut = 100;//residual cut for the measurements
private double resiCut = 50;//residual cut for the measurements

// return variables
public boolean setFitFailed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public void updateHelix(double x, double y, double z, double px, double py, doub
public Helix getHelix(double xref, double yref) {
StateVec vec = new StateVec(0, xref, yref, 0, this);

int turningSign = (int) Math.signum(vec.kappa) * KFitter.polarity;
int turningSign = (int) Math.signum(vec.kappa) * KFitter.polarity;
double bfield = 1 / vec.alpha / lightVel;
double R = vec.alpha / Math.abs(vec.kappa);
double phi0 = vec.phi0 + Math.PI / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,44 @@ public final void init(Helix helix, double[][] cov,
this.setYb(Yb);
sv.init( helix, cov, Xb, Yb, Zref, mass, this.getSwimmer());
}
/**
* Fail safe mode for low pt tracks that fail filtering and smoothing
*/
public void runFitterNoFiltFailSafe() {
int k0 = 0;
int kf = mv.measurements.size() - 1;

boolean init = this.initIter(sv, mv);
if(!init) return;

//re-init state vector and cov mat for forward
//this.initOneWayIter(sv, k0);

// transport in forward direction
boolean forward = this.runOneWayFitterIter(sv, mv, k0, kf);
if (!forward) return;

finalSmoothedStateVec = this.setFinalStateVector(sv.initSV);
finalTransportedStateVec = this.setFinalStateVector(sv.initSV);
double chisq = 0;
this.NDF=-5;
for(int k = 0; k< mv.measurements.size(); k++) {
int index = mv.measurements.get(k).layer;
int layer = mv.measurements.get(k).surface.getLayer();
int sector = mv.measurements.get(k).surface.getSector();

if(!mv.measurements.get(k).surface.passive) {
double dh = mv.dh(k, sv.transported().get(k));
double error = mv.measurements.get(k).error;
chisq += dh*dh / error/error;
this.NDF++;
trajPoints.put(index, new HitOnTrack(layer, sector, sv.transported().get(k), dh,dh,dh));
} else {
trajPoints.put(index, new HitOnTrack(layer, sector, sv.transported().get(k), -999, -999, -999));
}
}
this.chi2 = chisq;
}
public void runFitter() {
this.runFitter(sv, mv);
}
Expand Down Expand Up @@ -105,16 +142,26 @@ public StateVec getStateVec(int mode) {
}

public Helix getHelix() {
return this.getHelix(0);
Helix hlx = this.getHelix(0);
if(hlx!=null) {
if(Double.isNaN(hlx.getD0()) || Double.isNaN(hlx.getPhi0()) || Double.isNaN(hlx.getOmega())
|| Double.isNaN(hlx.getTanL()) || Double.isNaN(hlx.getZ0()))
return null;
}
return hlx;
}

public Helix getHelix(int mode) {
Helix helx = null;
if(mode==1) {
return finalTransportedStateVec.getHelix(this.getXb(), this.getYb());
if(finalTransportedStateVec!=null)
helx = finalTransportedStateVec.getHelix(this.getXb(), this.getYb());
}
else {
return finalSmoothedStateVec.getHelix(this.getXb(), this.getYb());
if(finalSmoothedStateVec!=null)
helx = finalSmoothedStateVec.getHelix(this.getXb(), this.getYb());
}
return helx;
}

private StateVec setFinalStateVector(StateVec onPivot) {
Expand All @@ -140,8 +187,8 @@ public void runFitter(AStateVecs sv, AMeasVecs mv) {
sv.smoothed().get(0)==null ||
sv.smoothed().get(0).kappa==0 ||
Double.isNaN(sv.smoothed().get(0).kappa)) {
this.setFitFailed = true;
break;
this.setFitFailed = true;
break;
}
// if chi2 improved and curvature is non-zero, save fit results but continue iterating
else if(newchisq < this.chi2) {
Expand Down Expand Up @@ -177,7 +224,7 @@ public StateVec filter(int k, StateVec vec, AMeasVecs mv) {
//get the projector Matrix
double[] H = mv.H(fVec, sv, mv.measurements.get(k), this.getSwimmer());
// System.out.println(k + " " + mv.measurements.get(k).layer + " " + H[0] + " " + H[1] + " " + H[2] + " " + H[3] + " " + H[4] + " " +dh );

double[][] CaInv = this.getMatrixOps().filterCovMat(H, fVec.covMat, V);
if (CaInv != null) {
fVec.covMat = CaInv;
Expand All @@ -189,7 +236,7 @@ public StateVec filter(int k, StateVec vec, AMeasVecs mv) {
// the gain matrix
K[j] = 0;
for (int i = 0; i < 5; i++) {
K[j] += H[i] * fVec.covMat[j][i] / V;
K[j] += H[i] * fVec.covMat[j][i] / V;
}
}
if(sv.straight) {
Expand All @@ -213,7 +260,7 @@ public StateVec filter(int k, StateVec vec, AMeasVecs mv) {
fVec.dz -= K[3] * dh;
fVec.tanL -= K[4] * dh;
}

if(this.getSwimmer()!=null && !sv.straight) fVec.rollBack(mv.rollBackAngle);
fVec.updateFromHelix();
// sv.printlnStateVec(fVec);
Expand All @@ -226,6 +273,9 @@ public StateVec filter(int k, StateVec vec, AMeasVecs mv) {
|| Math.abs(fVec.residual)/Math.sqrt(V)>this.getResidualsCut()) {
this.NDF--;
mv.measurements.get(k).skip = true;
fVec = sv.new StateVec(vec);
if(this.getSwimmer()!=null && !sv.straight) fVec.rollBack(mv.rollBackAngle);
fVec.updateFromHelix();
}
}
return fVec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ else if(mv.surface.cylinder!=null) {
else {
swim.SetSwimParameters(sv.x/units.value(), sv.y/units.value(), sv.z/units.value(),
dir*sv.px, dir*sv.py, dir*sv.pz,
KFitter.polarity*(int) Math.signum(sv.kappa)*dir);
KFitter.polarity*(int) Math.signum(sv.kappa)*dir);
if(mv.surface.plane!=null) {
Vector3D norm = mv.surface.plane.normal();
Point3D point = new Point3D(mv.surface.plane.point().x()/units.value(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Helix(double d0, double phi0, double omega, double z0, double tanL,

public Helix(double x0, double y0, double z0, double px0, double py0, double pz0,
int q, double B, double xb, double yb, Units unit) {
_turningSign = q;
_turningSign = q;
_B = B;
units = unit;
double pt = Math.sqrt(px0*px0 + py0*py0);
Expand Down
62 changes: 55 additions & 7 deletions etc/bankdefs/hipo4/cvt.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
{"name":"Cross8_ID", "type":"S", "info":"ID of cross in the track"},
{"name":"Cross9_ID", "type":"S", "info":"ID of cross in the track"},
{"name":"xb", "type":"F", "info":"x offset "},
{"name":"yb", "type":"F", "info":"y offset "}
{"name":"yb", "type":"F", "info":"y offset "},
{"name":"fracmctru", "type":"F", "info":"percentage of hits on track truth matched "},
{"name":"fracmcmatch", "type":"F", "info":"percentage of hits on track truth matched over total nb true hits "}
]
},
{
Expand All @@ -47,7 +49,7 @@
"info": "reconstructed CVT tracks",
"entries": [
{"name":"ID", "type":"S", "info":"ID"},
{"name":"fittingMethod", "type":"B", "info":"fitting method (1 for global fit, 2 for Kalman Filter)"},
{"name":"nKFIters", "type":"B", "info":"number of kalman filter iterations"},
{"name":"c_x", "type":"F", "info":"x-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)"},
{"name":"c_y", "type":"F", "info":"y-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)"},
{"name":"c_z", "type":"F", "info":"z-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)b"},
Expand Down Expand Up @@ -96,7 +98,7 @@
"info": "reconstructed CVT tracks",
"entries": [
{"name":"ID", "type":"S", "info":"ID"},
{"name":"fittingMethod", "type":"B", "info":"fitting method (1 for global fit, 2 for Kalman Filter)"},
{"name":"nKFIters", "type":"B", "info":"number of kalman filter iterations"},
{"name":"c_x", "type":"F", "info":"x-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)"},
{"name":"c_y", "type":"F", "info":"y-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)"},
{"name":"c_z", "type":"F", "info":"z-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)b"},
Expand Down Expand Up @@ -355,7 +357,9 @@
{"name":"Cross8_ID", "type":"S", "info":"ID of cross in the track"},
{"name":"Cross9_ID", "type":"S", "info":"ID of cross in the track"},
{"name":"xb", "type":"F", "info":"x offset "},
{"name":"yb", "type":"F", "info":"y offset "}
{"name":"yb", "type":"F", "info":"y offset "},
{"name":"fracmctru", "type":"F", "info":"percentage of hits on track truth matched "},
{"name":"fracmcmatch", "type":"F", "info":"percentage of hits on track truth matched over total nb true hits "}
]
},
{
Expand All @@ -365,7 +369,7 @@
"info": "reconstructed CVT tracks",
"entries": [
{"name":"ID", "type":"S", "info":"ID"},
{"name":"fittingMethod", "type":"B", "info":"fitting method (1 for global fit, 2 for Kalman Filter)"},
{"name":"nKFIters", "type":"B", "info":"fitting method (1 for global fit, 2 for Kalman Filter)"},
{"name":"c_x", "type":"F", "info":"x-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)"},
{"name":"c_y", "type":"F", "info":"y-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)"},
{"name":"c_z", "type":"F", "info":"z-coordinate of a helical trk point extrapolated to a cylinder at 25 cm radius from the lab origin (cm unit)b"},
Expand Down Expand Up @@ -489,6 +493,50 @@
{"name":"filteredRes", "type":"F", "info":"filtered residual (-999 for passive layer)"},
{"name":"smoothedRes", "type":"F", "info":"smoothed residual (-999 for passive layer)"}
]
},
{
"name": "CVT::SeedClusters",
"group": 20500,
"item" : 43,
"info": "Ids of clusters on track for 12 layers of CVT",
"entries": [
{"name":"id", "type":"S", "info":"id of the track"},
{"name":"Clus1_ID", "type":"S", "info":"ID of cluster on track in layer 1"},
{"name":"Clus2_ID", "type":"S", "info":"ID of cluster on track in layer 2"},
{"name":"Clus3_ID", "type":"S", "info":"ID of cluster on track in layer 3"},
{"name":"Clus4_ID", "type":"S", "info":"ID of cluster on track in layer 4"},
{"name":"Clus5_ID", "type":"S", "info":"ID of cluster on track in layer 5"},
{"name":"Clus6_ID", "type":"S", "info":"ID of cluster on track in layer 6"},
{"name":"Clus7_ID", "type":"S", "info":"ID of cluster on track in layer 7"},
{"name":"Clus8_ID", "type":"S", "info":"ID of cluster on track in layer 8"},
{"name":"Clus9_ID", "type":"S", "info":"ID of cluster on track in layer 9"},
{"name":"Clus10_ID", "type":"S", "info":"ID of cluster on track in layer 10"},
{"name":"Clus11_ID", "type":"S", "info":"ID of cluster on track in layer 11"},
{"name":"Clus12_ID", "type":"S", "info":"ID of cluster on track in layer 12"},
{"name":"prob", "type":"F", "info":"AI seed probability"}
]
},
{
"name": "CVTRec::SeedClusters",
"group": 20500,
"item" : 44,
"info": "Ids of clusters on track for 12 layers of CVT",
"entries": [
{"name":"id", "type":"S", "info":"id of the track"},
{"name":"Clus1_ID", "type":"S", "info":"ID of cluster on track in layer 1"},
{"name":"Clus2_ID", "type":"S", "info":"ID of cluster on track in layer 2"},
{"name":"Clus3_ID", "type":"S", "info":"ID of cluster on track in layer 3"},
{"name":"Clus4_ID", "type":"S", "info":"ID of cluster on track in layer 4"},
{"name":"Clus5_ID", "type":"S", "info":"ID of cluster on track in layer 5"},
{"name":"Clus6_ID", "type":"S", "info":"ID of cluster on track in layer 6"},
{"name":"Clus7_ID", "type":"S", "info":"ID of cluster on track in layer 7"},
{"name":"Clus8_ID", "type":"S", "info":"ID of cluster on track in layer 8"},
{"name":"Clus9_ID", "type":"S", "info":"ID of cluster on track in layer 9"},
{"name":"Clus10_ID", "type":"S", "info":"ID of cluster on track in layer 10"},
{"name":"Clus11_ID", "type":"S", "info":"ID of cluster on track in layer 11"},
{"name":"Clus12_ID", "type":"S", "info":"ID of cluster on track in layer 12"},
{"name":"prob", "type":"F", "info":"AI seed probability"}
]
}

]
]
Loading

0 comments on commit 0269a19

Please sign in to comment.