Print

Print


Commit in lcsim/sandbox/RobKutschke/TRFTests/v1 on MAIN
AddFitKalman.java+37-41.1 -> 1.2
FullFitKalman.java+56-71.1 -> 1.2
RKTrackFitDiag.java+41-231.1 -> 1.2
+134-34
3 modified files
Improved diagnostics.

lcsim/sandbox/RobKutschke/TRFTests/v1
AddFitKalman.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- AddFitKalman.java	30 Aug 2007 14:16:33 -0000	1.1
+++ AddFitKalman.java	7 Sep 2007 19:00:40 -0000	1.2
@@ -1,4 +1,6 @@
 //package org.lcsim.recon.tracking.trffit;
+import org.lcsim.util.aida.AIDA;
+
 import java.util.List;
 import java.util.ArrayList;
 import org.lcsim.recon.tracking.trfutil.Assert;
@@ -6,6 +8,8 @@
 import org.lcsim.recon.tracking.trfbase.Hit;
 import org.lcsim.recon.tracking.trfbase.TrackVector;
 import org.lcsim.recon.tracking.trfbase.TrackError;
+import org.lcsim.recon.tracking.trfbase.Surface;
+import org.lcsim.recon.tracking.trfbase.PropDir;
 import Jama.Matrix;
 
 import org.lcsim.recon.tracking.trffit.AddFitter;
@@ -22,13 +26,15 @@
  *
  * 
  *@author $Author: kutschke $
- *@version $Id: AddFitKalman.java,v 1.1 2007/08/30 14:16:33 kutschke Exp $
+ *@version $Id: AddFitKalman.java,v 1.2 2007/09/07 19:00:40 kutschke Exp $
  *
- * Date $Date: 2007/08/30 14:16:33 $
+ * Date $Date: 2007/09/07 19:00:40 $
  */
 
 public class AddFitKalman extends AddFitter
 {
+
+    private AIDA aida = AIDA.defaultInstance();
     
     
     // Maximum allowed hit dimension.
@@ -227,6 +233,7 @@
      */
     public int addHitFit(ETrack tre, double chsq,  Hit hit)
     {
+
         // Update the hit with the input track.
         hit.update(tre);
         
@@ -310,6 +317,7 @@
             for ( int i=0; i<5; ++i )
             {
                 if ( new_err.get(i,i) < 0.0 ) {
+		    if ( nbad == 0 ) System.out.println("");
 		    System.out.println ( "Bad on: " + i + " " + new_err.get(i,i) );
 		    ++nbad;
 		}
@@ -320,6 +328,7 @@
                     double eij = new_err.get(j,i);
                     if ( Math.abs(eij*eij) >= eii*ejj  ) {
 			double delta = -Math.abs(eij*eij) + eii*ejj;
+			if ( nbad == 0 ) System.out.println("");
 			System.out.println( "Bad off: " + i + " " 
 					    + j + " "
 					    + eii + " "
@@ -333,7 +342,12 @@
             }
 	    if ( nbad > 0 ){
 		RKPrintSymMatrix psm = new RKPrintSymMatrix();
-		System.out.println ("Bad error in addfitkalman: \n" );
+		System.out.println ("Illegal cov in addfitkalman: " 
+				    + RKDebug.Instance().getTrack() + " "
+				    + RKDebug.Instance().getPropDir() + " "
+				    );
+		System.out.println ("Surface:   " + tre.surface() );
+		
 		System.out.println ("old_err \n" );
 		psm.Print(tre.error());
 
@@ -388,7 +402,26 @@
 	// Warn about bad chisquared contribution, ignoring small problems that might
 	// well be just round off error.
 	if ( dchsq <   -0.001 ){
-	    System.out.println ("dchisq: " + dchsq );
+	    System.out.println ("\ndchisq: " 
+				+ RKDebug.Instance().getTrack() + " "
+				+ RKDebug.Instance().getPropDir() + " "
+				+ dchsq + " "
+				+ tre.surface() + " "
+				+ RKDebug.Instance().getRKTrack().cz() + " "
+				);
+	    if ( RKDebug.Instance().getPropDir() == PropDir.BACKWARD ){
+		aida.histogram1D( "Backward: cz for tracks with bad dchisquared",100,-1.,1.)
+		    .fill( RKDebug.Instance().getRKTrack().cz() );
+		aida.histogram1D( "Backward: bad dchisquared",100,-20.,0.).fill( dchsq );
+		aida.cloud2D( "Backward: dch vs cz for tracks with bad dchisquared",-1)
+		    .fill( RKDebug.Instance().getRKTrack().cz(), dchsq );
+	    }else{
+		aida.histogram1D( "Forward: cz for tracks with bad dchisquared",100,-1.,1.)
+		    .fill( RKDebug.Instance().getRKTrack().cz() );
+		aida.histogram1D( "Forward: bad dchisquared",100,-20.,0.).fill( dchsq );
+		aida.cloud2D( "Forward: dch vs cz for tracks with bad dchisquared",-1)
+		    .fill( RKDebug.Instance().getRKTrack().cz(), dchsq );
+	    }
 	}
         chsq = chsq + dchsq;
         setChisquared(chsq);

lcsim/sandbox/RobKutschke/TRFTests/v1
FullFitKalman.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- FullFitKalman.java	30 Aug 2007 14:16:33 -0000	1.1
+++ FullFitKalman.java	7 Sep 2007 19:00:40 -0000	1.2
@@ -3,6 +3,7 @@
 import org.lcsim.recon.tracking.trfbase.PropDir;
 import org.lcsim.recon.tracking.trfbase.PropStat;
 import org.lcsim.recon.tracking.trfbase.Hit;
+import org.lcsim.recon.tracking.trfbase.Surface;
 import java.util.*;
 
 import org.lcsim.recon.tracking.trffit.HTrack;
@@ -23,9 +24,9 @@
  * a single track.
  *
  *@author $Author: kutschke $
- *@version $Id: FullFitKalman.java,v 1.1 2007/08/30 14:16:33 kutschke Exp $
+ *@version $Id: FullFitKalman.java,v 1.2 2007/09/07 19:00:40 kutschke Exp $
  *
- * Date $Date: 2007/08/30 14:16:33 $
+ * Date $Date: 2007/09/07 19:00:40 $
  *
  */
 
@@ -116,19 +117,19 @@
         // Set direction to be nearest.
         //PropDir dir = PropDir.NEAREST;
         PropDir dir = PropDir.FORWARD;
+	RKDebug.Instance().setPropDir(dir);
         
         // Loop over hits and fit.
         int icount = 0;
         for ( Iterator ihit=hits.iterator(); ihit.hasNext(); )
         {
-            
+
             // Extract the next hit pointer.
             Hit hit = (Hit)ihit.next();
             //System.out.println("Hit "+icount+" is: \n"+hit);
             // propagate to the surface
 	    //System.out.println ("Before prop: " + trh.newTrack() );
             PropStat pstat = trh.propagate(_pprop,hit.surface(),dir);
-            if ( ! pstat.success() ) return icount;
             
 	    //System.out.println ("After prop: " + trh.newTrack() );
             // fit track
@@ -147,6 +148,7 @@
     public int fitForward(HTrack trh)
     {
         PropDir dir = PropDir.FORWARD;
+	RKDebug.Instance().setPropDir(dir);
 
         // Copy the hits from the track.
         List hits = trh.hits();
@@ -159,15 +161,33 @@
         int icount = 0;
         for ( Iterator ihit=hits.iterator(); ihit.hasNext(); )
         {
+	    Surface s_save = trh.newTrack().surface().newPureSurface();
+            
             // Extract the next hit pointer.
             Hit hit = (Hit)ihit.next();
 
 	    // Propagate to the next surface.
             PropStat pstat = trh.propagate(_pprop,hit.surface(),dir);
-            if ( ! pstat.success() ) return icount;
+            if ( ! pstat.success() ) {
+		System.out.println ("Error:        "  
+				    + RKDebug.Instance().getTrack() + " " 
+				    + RKDebug.Instance().getPropDir() + " " 
+				    );
+		System.out.println ("From surface 5: " + s_save );
+		System.out.println ("To surface 5:   " + hit.surface());
+		return icount;
+	    }
 
 	    // Add the hit.
             int fstat = _addfit.addHit(trh,hit);
+	    if ( fstat>0 ){
+		System.out.println ("Error:        "  
+				    + RKDebug.Instance().getTrack() + " " 
+				    + RKDebug.Instance().getPropDir() + " " 
+				    );
+		System.out.println ("From surface 4: " + s_save );
+		System.out.println ("To surface 4:   " + hit.surface());		
+	    }
             if ( fstat>0 ) return 10000 + 1000*fstat + icount;
             
         }
@@ -178,6 +198,7 @@
     public int fitBackward(HTrack trh)
     {
         PropDir dir = PropDir.BACKWARD;
+	RKDebug.Instance().setPropDir(dir);
 
 	//RKPrintSymMatrix psm = new RKPrintSymMatrix();
 
@@ -186,12 +207,16 @@
 
         // Delete the list of hits from the track.
         while ( trh.hits().size()>0 ) trh.dropHit();
+
+	double chold = 0.;
                 
         // Loop over hits and fit.
         int icount = 0;
         for ( Iterator ihit=hits.iterator(); ihit.hasNext(); )
         {
             
+	    Surface s_save = trh.newTrack().surface().newPureSurface();
+            
             // Extract the next hit pointer.
             Hit hit = (Hit)ihit.next();
 
@@ -206,8 +231,15 @@
 	    //System.out.println ("Pstat: " + pstat.success() );
 	    //System.out.println ("After prop: \n" );
 	    // psm.Print( trh.newTrack().error() );
-
-            if ( ! pstat.success() ) return icount;
+            if ( ! pstat.success() ) {
+		System.out.println ("Error:        "  
+				    + RKDebug.Instance().getTrack() + " " 
+				    + RKDebug.Instance().getPropDir() + " " 
+				    );
+		System.out.println ("From surface 1: " + s_save );
+		System.out.println ("To surface 1:   " + hit.surface());
+		return icount;
+	    }
 
 	    // Add the hit.
             int fstat = _addfit.addHit(trh,hit);
@@ -216,7 +248,24 @@
 	    //System.out.println ("After addhit: \n" );
 	    //psm.Print( trh.newTrack().error() );
 
+	    if ( fstat>0 ){
+		System.out.println ("Error:        "  
+				    + RKDebug.Instance().getTrack() + " " 
+				    + RKDebug.Instance().getPropDir() + " " 
+				    );
+		System.out.println ("From surface 2: " + s_save );
+		System.out.println ("To surface 2:   " + hit.surface());		
+	    }
             if ( fstat>0 ) return 10000 + 1000*fstat + icount;
+
+	    double chnew = trh.chisquared();
+	    double dch = chnew - chold;
+
+	    if( dch < -0.001 ){
+		System.out.println ("From surface 3: " + s_save );
+		System.out.println ("To surface 3:   " + hit.surface());				
+	    }
+	    chold = chnew;
             ++icount;
 
         }

lcsim/sandbox/RobKutschke/TRFTests/v1
RKTrackFitDiag.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- RKTrackFitDiag.java	30 Aug 2007 14:16:33 -0000	1.1
+++ RKTrackFitDiag.java	7 Sep 2007 19:00:40 -0000	1.2
@@ -1,6 +1,7 @@
 import org.lcsim.util.aida.AIDA;
 import hep.aida.IHistogram1D;
 import hep.aida.ICloud1D;
+import hep.aida.ICloud2D;
 
 import org.lcsim.recon.tracking.trfbase.VTrack;
 import org.lcsim.recon.tracking.trfbase.ETrack;
@@ -21,9 +22,9 @@
  * Make some diagnostic histograms a fitted track.
  *
  *@author $Author: kutschke $
- *@version $Id: RKTrackFitDiag.java,v 1.1 2007/08/30 14:16:33 kutschke Exp $
+ *@version $Id: RKTrackFitDiag.java,v 1.2 2007/09/07 19:00:40 kutschke Exp $
  *
- * Date $Date: 2007/08/30 14:16:33 $
+ * Date $Date: 2007/09/07 19:00:40 $
  *
  */
 
@@ -41,9 +42,12 @@
 	    isAzimuth[i] = false;
 	}
 	cl        = aida.histogram1D( tag + " Confidence Level", nbins, 0, 1.);
+	clvcz     = aida.cloud2D( tag + " Confidence Level vs cz", -1);
+	czbadcl   = aida.histogram1D( tag + " Cz for bad CL", nbins, -1., 1.);
 	nDof      = aida.cloud1D( tag + " nDof");
 	errorCode = aida.histogram1D( tag + " Error codes", 20, 0., 20.);
 	sType     = aida.histogram1D( tag + " Comparison Surface Type", 10, 0., 10.);
+	startType = aida.histogram1D( tag + " Start Type", 5, 0., 5.);
 
 	// Mark which parameters are azimuths.
 	if ( type.compareToIgnoreCase("Cyl") == 0 ){
@@ -54,13 +58,30 @@
 	}
     }
     
-    public void fill( int fstat, HTrack ht, VTrack vt, int ndof, TrackError vstart){
+    public void fill( int fstat, HTrack ht, VTrack vt, int ndof, TrackError vstart, RKTrack rkt){
 
 	if ( fstat != 0 ){
 	    errorCode.fill(5.5);
 	    System.out.println ("Fitter " + tag + " returned non-zero status code: " + fstat);
 	    return;
 	}
+
+	double cz = rkt.cz();
+
+	// Compute confidence level.
+	ChisqProb prob = new ChisqProb();
+	double chisq = ht.chisquared();
+
+	// Why does this happen?
+	if ( chisq < 0. ){
+	    System.out.println( "Prob: " + ndof + " " + ht.chisquared() );
+	    errorCode.fill(15.5);
+	    chisq = 0.;
+	}
+
+	double c = prob.gammq( ndof, chisq );
+
+	boolean czcut = ( Math.abs(cz)>0.65 && Math.abs(cz)<0.85);
 	
 	// Fill per parameter histograms.
 	ETrack et = ht.newTrack();
@@ -94,22 +115,16 @@
 	    
 	}
 
-	// Compute confidence level.
-	ChisqProb prob = new ChisqProb();
-	double chisq = ht.chisquared();
-
-	// Why does this happen?
-	if ( chisq < 0. ){
-	    System.out.println( "Prob: " + ndof + " " + ht.chisquared() );
-	    errorCode.fill(15.5);
-	    chisq = 0.;
-	}
-
-	double c = prob.gammq( ndof, chisq );
-
 	// Fill remaining histograms.
 	cl.fill(c);
 	nDof.fill(ndof);
+	clvcz.fill( cz, c );
+	if ( c < 0.005 ) {
+	    czbadcl.fill( cz );
+	    if ( czcut ){
+		startType.fill( RKDebug.Instance().getStartType() );
+	    }
+	}
 
 	// Type of the surface at which the comparison is made.
 	int stype = 0;
@@ -131,13 +146,16 @@
     private String tag = null;
 
     // Histograms for residuals, pulls, sigams, ndof, confidence level and error codes.
-    private IHistogram1D[] resid = new IHistogram1D[5];
-    private IHistogram1D[] pull  = new IHistogram1D[5];
-    private IHistogram1D[] sigma = new IHistogram1D[5];
-    private IHistogram1D[] ratio = new IHistogram1D[5];
-    private IHistogram1D   cl    = null;
-    private ICloud1D       nDof  = null;
-    private IHistogram1D   sType = null;
+    private IHistogram1D[] resid     = new IHistogram1D[5];
+    private IHistogram1D[] pull      = new IHistogram1D[5];
+    private IHistogram1D[] sigma     = new IHistogram1D[5];
+    private IHistogram1D[] ratio     = new IHistogram1D[5];
+    private IHistogram1D   cl        = null;
+    private IHistogram1D   czbadcl   = null;
+    private ICloud2D       clvcz     = null;
+    private ICloud1D       nDof      = null;
+    private IHistogram1D   sType     = null;
+    private IHistogram1D   startType = null;
 
     private IHistogram1D   errorCode = null;
 
CVSspam 0.2.8