Skip to content

Commit 6fc421f

Browse files
authored
Merge pull request #1148 from JeffersonLab/iss1147
Iss1147 -- Add hole-accounting to tracks
2 parents 8ae66e0 + e4fba71 commit 6fc421f

File tree

3 files changed

+41
-26
lines changed

3 files changed

+41
-26
lines changed

tracking/src/main/java/org/hps/recon/tracking/kalman/KalTrack.java

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -295,27 +295,49 @@ public Pair<Double[], Double> unbiasedIntersect(MeasurementSite site, boolean lo
295295
Vec intPnt = HelixState.atPhi(site.aS.helix.X0, aStar, phiInt, site.aS.helix.alpha);
296296
// Transform the intersection back into the global coordinates
297297
Vec globalInt = site.aS.helix.toGlobal(intPnt);
298+
// System.out.println("KalTrack::unbiasedIntersect global x = "+globalInt.v[0]+
299+
// " y = "+globalInt.v[1]+
300+
// " z = "+globalInt.v[2]);
301+
298302
if (!local) {
299-
new Pair<>(new Double[]{globalInt.v[0], globalInt.v[1], globalInt.v[2]}, 999); //I didn't include global variance since I'm lazy
303+
new Pair<>(new Double[]{globalInt.v[0], globalInt.v[1], globalInt.v[2]}, 999); //I didn't include global variance since I'm lazy
300304
} // Transform the intersection point to the local sensor system
301305
Vec localInt = site.m.toLocal(globalInt);
302306
CommonOps_DDRM.mult(Cstar, site.H, tempV);
303307
Double varUmeas = CommonOps_DDRM.dot(site.H, tempV);
304308
return new Pair<>(new Double[]{localInt.v[0], localInt.v[1], localInt.v[2]}, varUmeas);
305309
} else {
306-
if(debug)System.out.println("no phi-interect with this layer found!");
310+
if(debug)System.out.println("KalTrack::unbiasedIntersect no phi-interect with this layer found!");
307311
}
308312

309313
return new Pair<>(new Double[]{666., 666., 666.}, 666.);
310314
}
311315

316+
public boolean isTrackHole(int layer){
317+
if (lyrMap == null) {
318+
makeLyrMap();
319+
}
320+
if (lyrMap.containsKey(layer)) {
321+
MeasurementSite ms=lyrMap.get(layer);
322+
return isTrackHole(ms);
323+
}else{
324+
return false;
325+
}
326+
}
327+
public boolean isTrackHole(MeasurementSite ms){
328+
if(ms.hitID >=0 && ms.m.hits.size()>0)
329+
return false; //track has a hit in this layer
330+
Pair<Double[], Double> lInt=unbiasedIntersect(ms,true);
331+
boolean trkInSensor=ms.isInSensor(lInt.getFirstElement());
332+
return trkInSensor;
333+
}
312334
private void makeLyrMap() {
313335
lyrMap = new HashMap<Integer, MeasurementSite>(nHits);
314336
for (MeasurementSite site : SiteList) {
315337
lyrMap.put(site.m.Layer, site);
316338
}
317339
}
318-
340+
319341
private void makeMillipedeMap() {
320342
millipedeMap = new HashMap<Integer, MeasurementSite>(nHits);
321343
for (MeasurementSite site : SiteList) {
@@ -512,7 +534,9 @@ public Pair<Double, Double> unbiasedResidual(MeasurementSite site) {
512534

513535
CommonOps_DDRM.mult(Cstar, site.H, tempV);
514536
varResid = sigma * sigma + CommonOps_DDRM.dot(site.H, tempV);
515-
}
537+
}else{
538+
System.out.println("KalTrack::unbiasedResidual phiInt is NaN");
539+
}
516540
}
517541
return new Pair<Double, Double>(resid, varResid);
518542
}
@@ -908,26 +932,7 @@ public HelixState originConstraint(double[] vtx, double[][] vtxCov) {
908932
Vec v = helixAtOrigin.toLocal(new Vec(3, vtx));
909933
SquareMatrix Cov = helixAtOrigin.Rot.rotate(new SquareMatrix(3, vtxCov));
910934
Vec X0 = helixAtOrigin.X0;
911-
double phi = phiDOCA(helixAtOrigin.a, v, X0, alpha);
912-
/* if (debug) { // Test the DOCA algorithm
913-
Vec rDoca = HelixState.atPhi(X0, helixAtOrigin.a, phi, alpha);
914-
System.out.format("originConstraint: phi of DOCA=%10.5e\n", phi);
915-
rDoca.print(" DOCA point");
916-
double doca = rDoca.dif(v).mag();
917-
System.out.format(" Minimum doca=%10.7f\n", doca);
918-
for (double p=phi-0.0001; p<phi+0.0001; p += 0.000001) {
919-
rDoca = HelixState.atPhi(X0, helixAtOrigin.a, p, alpha);
920-
doca = rDoca.dif(v).mag();
921-
System.out.format(" phi=%10.5e, doca=%10.7f\n", p,doca);
922-
}
923-
924-
double delPhi = 0.00001;
925-
double f = fDOCA(phi, helixAtOrigin.a, v, X0, alpha);
926-
double df1 = fDOCA(phi + delPhi, helixAtOrigin.a, v, X0, alpha) - f;
927-
double deriv = dfDOCAdPhi(phi, helixAtOrigin.a, v, X0, alpha);
928-
double df2 = deriv * delPhi;
929-
System.out.format("Test of fDOCA derivative: df exact = %11.7f; df from derivative = %11.7f\n", df1, df2);
930-
}*/
935+
double phi = phiDOCA(helixAtOrigin.a, v, X0, alpha);
931936
double[][] H = buildH(helixAtOrigin.a, v, X0, phi, alpha);
932937
Vec pntDOCA = HelixState.atPhi(X0, helixAtOrigin.a, phi, alpha);
933938
if (debug) {

tracking/src/main/java/org/hps/recon/tracking/kalman/KalmanInterface.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,11 @@ public BaseTrack createTrack(KalTrack kT, boolean storeTrackStates) {
652652
MeasurementSite site = kT.SiteList.get(i);
653653
ts = null;
654654
int loc = TrackState.AtOther;
655-
655+
//add holes to hitpattern
656+
boolean isTrkHole=kT.isTrackHole(site);
657+
if(isTrkHole){
658+
Array.set(hitPattern,site.m.Layer,-1);
659+
}
656660
//HpsSiSensor hssd = (HpsSiSensor) moduleMap.get(site.m).getSensor();
657661
//int lay = hssd.getMillepedeId();
658662
// System.out.printf("ssp id %d \n", hssd.getMillepedeId());

tracking/src/main/java/org/hps/recon/tracking/kalman/MeasurementSite.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ String toString(String s) {
7676
}
7777
return str;
7878
}
79-
8079
MeasurementSite(int thisSite, SiModule data, KalmanParams kPar) {
8180
this.thisSite = thisSite;
8281
this.kPar = kPar;
@@ -717,6 +716,13 @@ private void buildH(StateVector S, DMatrixRMaj H) {
717716
}
718717
}
719718

719+
public boolean isInSensor(Double[] rLocal){
720+
double tol = kPar.edgeTolerance; // Tolerance on the check, in mm
721+
if (rLocal[0] < m.xExtent[0] - tol || rLocal[0] > m.xExtent[1] + tol) return false;
722+
if (rLocal[1] < m.yExtent[0] - tol || rLocal[1] > m.yExtent[1] + tol) return false;
723+
return true;
724+
}
725+
720726
// Comparator functions for sorting measurement sites by layer number
721727
static Comparator<MeasurementSite> SiteComparatorUp = new Comparator<MeasurementSite>() {
722728
public int compare(MeasurementSite s1, MeasurementSite s2) {

0 commit comments

Comments
 (0)