@@ -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 ) {
0 commit comments