lcsim/src/org/lcsim/contrib/seedtracker
diff -N SortHits.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SortHits.java 4 Apr 2008 23:41:33 -0000 1.1
@@ -0,0 +1,40 @@
+/*
+ * SortHits.java
+ *
+ * Created on February 13, 2008, 12:55 PM
+ *
+ */
+
+package org.lcsim.contrib.seedtracker;
+
+import java.util.Comparator;
+
+import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+
+/**
+ *
+ * @author Richard Partridge
+ * @version 1.0
+ */
+public class SortHits implements Comparator<HelicalTrackHit> {
+ private double _xc;
+ private double _yc;
+ private double _R;
+
+ /** Creates a new instance of SortHits */
+ public SortHits(HelicalTrackFit helix) {
+ // Find the helix center, radius, error
+ _xc = helix.xc();
+ _yc = helix.yc();
+ _R = helix.R();
+ }
+
+ public int compare(HelicalTrackHit a, HelicalTrackHit b) {
+ double difa = Math.pow(a.x() - _xc, 2) + Math.pow(a.y() - _yc, 2) - _R * _R;
+ double difb = Math.pow(b.x() - _xc, 2) + Math.pow(b.y() - _yc, 2) - _R * _R;
+ if (difa * difa > difb * difb) return 1;
+ if (difa * difa == difb * difb) return 0;
+ return -1;
+ }
+}
\ No newline at end of file
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.3 -r1.4
--- ExtendSeeds.java 12 Feb 2008 17:10:10 -0000 1.3
+++ ExtendSeeds.java 4 Apr 2008 23:41:33 -0000 1.4
@@ -8,9 +8,14 @@
package org.lcsim.contrib.seedtracker;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+import org.lcsim.fit.helicaltrack.HelicalTrackFitter.FitStatus;
+
/**
*
@@ -53,22 +58,42 @@
// Loop over the seeds in the working seed list
for (SeedCandidate seedin : seedlist) {
-
+
+ SortHits comp = new SortHits(seedin.getHelix());
+ Collections.sort(hitlist, comp);
+
// Retrieve the chisq for the last fit and initialize the best fit chisq for this layer
double oldchisq = seedin.getHelix().chisqtot();
+ double oldcirclechisq = seedin.getHelix().chisq()[0];
double chisqbest = 1.e6;
-
+// System.out.println("Oldcirclechisq: "+oldcirclechisq);
+// System.out.println("Oldchisq: "+oldchisq);
+// System.out.println("Oldhits: "+seedin.getHits().size());
+// System.out.println("Old Helix: "+seedin.getHelix().toString());
// For each hit in this confirmation layer, make a test seed including the new hit
for (HelicalTrackHit hit : hitlist) {
+
SeedCandidate test = new SeedCandidate(seedin);
test.addHit(hit);
// See if we have a successful fit
boolean success = _helixfitter.FitCandidate(test, strategy);
+ if (!success) {
+ if (_helixfitter.getFitStatus() != FitStatus.CircleFitFailed) {
+ double circlechisq = _helixfitter.getCircleFit().chisq();
+// System.out.println("Circlechissq: "+circlechisq);
+ if (circlechisq > oldcirclechisq + strategy.getMaxChisq()) break;
+ }
+ continue;
+ }
if (success) {
// Attach the fit to the test seed and add it to the list
test.setHelix(_helixfitter.getHelix());
+// System.out.println("Good fit");
+// System.out.println("Chisq: "+_helixfitter.getHelix().chisqtot());
+// System.out.println("Circle Chisq: "+_helixfitter.getHelix().chisq()[0]);
+// System.out.println("New Helix: "+_helixfitter.getHelix().toString());
newlist.add(test);
chisqbest = Math.min(chisqbest, _helixfitter.getHelix().chisqtot());
}
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.5 -r1.6
--- HelixFitter.java 29 Feb 2008 18:48:22 -0000 1.5
+++ HelixFitter.java 4 Apr 2008 23:41:33 -0000 1.6
@@ -11,10 +11,14 @@
import java.util.List;
import java.util.Map;
+import org.lcsim.fit.circle.CircleFit;
import org.lcsim.fit.helicaltrack.HelicalTrackFit;
import org.lcsim.fit.helicaltrack.HelicalTrackFitter;
+import org.lcsim.fit.helicaltrack.HelicalTrackFitter.FitStatus;
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
import org.lcsim.fit.helicaltrack.MultipleScatter;
+import org.lcsim.fit.line.SlopeInterceptLineFit;
+import org.lcsim.fit.zsegment.ZSegmentFit;
/**
*
@@ -26,7 +30,12 @@
private MultipleScattering _scattering;
private HelicalTrackFit _helix;
private MaterialManager _materialmanager;
+ private ConstrainHelix _constrain;
private double _bfield;
+ private CircleFit _circlefit;
+ private SlopeInterceptLineFit _linefit;
+ private ZSegmentFit _zsegmentfit;
+ private FitStatus _status;
/**
* Creates a new instance of HelixFitter
@@ -35,12 +44,13 @@
_materialmanager = materialmanager;
_bfield = bfield;
_scattering = new MultipleScattering(_materialmanager, _bfield);
+ _constrain = new ConstrainHelix(_bfield);
}
public boolean FitCandidate(SeedCandidate seed, SeedStrategy strategy) {
-
- // Declare fit status variatle
- boolean status;
+
+ // Initialize fit results to null objects
+ _helix = null;
// Retrieve list of hits to be fit
List<HelicalTrackHit> hitlist = seed.getHits();
@@ -50,11 +60,10 @@
// If this is the candidate's first helix fit, first do a fit without MS errors
if (oldhelix == null) {
- status = _fitter.fit(hitlist);
- if (!status) {
- _helix = null;
- return false;
- }
+ _status = _fitter.fit(hitlist);
+ checkfit();
+ if (_status != FitStatus.Success) return false;
+
// Retrieve the helix parameters from this fit
oldhelix = _fitter.getFit();
}
@@ -63,34 +72,16 @@
Map<HelicalTrackHit, MultipleScatter> msmap = _scattering.HelixScatters(oldhelix, hitlist);
// Do a helix fit including MS errors
- status = _fitter.fit(hitlist, msmap);
- if (!status) {
- _helix = null;
- return false;
- }
+ _status = _fitter.fit(hitlist, msmap);
+ checkfit();
+ if (_status != FitStatus.Success) return false;
// Retrieve and save the new helix fit
_helix = _fitter.getFit();
- // Check if we have passed the helix cuts
- if (!HelixCuts(strategy, _helix)) return false;
-
- // Success!
- return true;
- }
-
- public HelicalTrackFit getHelix() {
- return _helix;
- }
-
- private boolean HelixCuts(SeedStrategy strategy, HelicalTrackFit helix) {
-
- // Retrieve the helix parameters
- double[] params = helix.parameters();
-
- // Sum the chisq for the circle (x-y) and line (s-z) fits
- double chisq = helix.chisqtot();
-
+ // Set the non-holonomic constraint chi square
+ _constrain.setConstraintChisq(strategy, _helix);
+
// System.out.println(" circle chisq "+helix.chisq()[0]);
// System.out.println(" line fit chisq "+helix.chisq()[1]);
// System.out.println(" total chisq "+chisq);
@@ -100,33 +91,43 @@
// System.out.println(" z0 "+helix.z0());
// System.out.println(" slope "+helix.slope());
// System.out.println(" pT "+helix.pT(_bfield));
-
- // Inflate chisq if |curvature| is too large
- double curvmax = 0.0003 * _bfield / strategy.getMinPT();
- double curv = Math.abs(params[2]);
- if (curv > curvmax) {
- chisq += Math.pow(curv - curvmax, 2) / helix.covariance().e(2, 2);
- }
-
- // Inflate chisq if |DCA| is too large
- double dcamax = strategy.getMaxDCA();
- double dca = Math.abs(params[0]);
- if (dca > dcamax) {
- chisq += Math.pow(dca - dcamax, 2) / helix.covariance().e(0, 0);
- }
-
- // Inflate chisq if |z0| is too large
- double z0max = strategy.getMaxZ0();
- double z0 = Math.abs(params[3]);
- if (z0 > z0max) {
- chisq += Math.pow(z0 - z0max, 2) / helix.covariance().e(3, 3);
- }
-
-// System.out.println(" inflated chisq: "+chisq);
- // Make the chi squared cut
- if (chisq > strategy.getMaxChisq()) return false;
-// System.out.println(" Good track found");
- return true;
+
+ return _helix.chisqtot() <= strategy.getMaxChisq();
+ }
+
+ public HelicalTrackFit getHelix() {
+ return _helix;
+ }
+
+ public FitStatus getFitStatus() {
+ return _status;
+ }
+
+ public CircleFit getCircleFit() {
+ return _circlefit;
+ }
+
+ public SlopeInterceptLineFit getLineFit() {
+ return _linefit;
}
-}
+ public ZSegmentFit getZSegmentFit() {
+ return _zsegmentfit;
+ }
+
+ private void checkfit() {
+ _circlefit = null;
+ _linefit = null;
+ _zsegmentfit = null;
+ if (_status == FitStatus.CircleFitFailed) return;
+ else {
+ _circlefit = _fitter.getCircleFit();
+ }
+ if (_status == FitStatus.LineFitFailed) return;
+ if (_status == FitStatus.ZSegmentFitFailed) return;
+ _linefit = _fitter.getLineFit();
+ _zsegmentfit = _fitter.getZSegmentFit();
+
+ return;
+ }
+}
\ No newline at end of file