2 added + 14 modified, total 16 files
lcsim/src/org/lcsim/contrib/seedtracker
diff -N MakeTracks.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MakeTracks.java 7 Feb 2008 18:20:50 -0000 1.1
@@ -0,0 +1,51 @@
+/*
+ * MakeTracks.java
+ *
+ * Created on February 6, 2008, 11:40 AM
+ *
+ */
+
+package org.lcsim.contrib.seedtracker;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.event.base.BaseTrack;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.Track;
+import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+
+/**
+ *
+ * @author Richard Partridge
+ * @version 1.0
+ */
+public class MakeTracks {
+
+ /** Creates a new instance of MakeTracks */
+ public MakeTracks() {
+ }
+
+ public void Process(EventHeader event, List<SeedCandidate> seedlist, double bfield) {
+ List<Track> tracks = new ArrayList<Track>();
+ double[] ref = new double[3];
+ ref[0] = 0.;
+ ref[1] = 0.;
+ ref[2] = 0.;
+ for (SeedCandidate trackseed : seedlist) {
+ BaseTrack trk = new BaseTrack();
+ trk.addHits(trackseed.getTrackerHits());
+ HelicalTrackFit helix = trackseed.getHelix();
+ trk.setChisq(helix.chisqtot());
+ trk.setCovarianceMatrix(helix.covariance());
+ trk.setFitSuccess(true);
+ trk.setNDF(helix.ndf()[0]+helix.ndf()[1]);
+ trk.setRefPointIsDCA(true);
+ trk.setTrackParameters(helix.parameters(), bfield);
+ trk.setReferencePoint(ref);
+ tracks.add((Track) trk);
+ }
+ event.put(event.TRACKS, tracks, Track.class, 0);
+ return;
+ }
+}
lcsim/src/org/lcsim/contrib/seedtracker
diff -N MergeSeedLists.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MergeSeedLists.java 7 Feb 2008 18:20:50 -0000 1.1
@@ -0,0 +1,67 @@
+/*
+ * MergeSeedLists.java
+ *
+ * Created on February 6, 2008, 9:54 AM
+ *
+ */
+
+package org.lcsim.contrib.seedtracker;
+
+import java.util.List;
+import java.util.ListIterator;
+
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+
+/**
+ *
+ * @author partridge
+ * @version __VERSION__
+ */
+public class MergeSeedLists {
+
+ /** Creates a new instance of MergeSeedLists */
+ public MergeSeedLists() {
+ }
+
+ public void Merge(List<SeedCandidate> seedlist, List<SeedCandidate> newseedlist, SeedStrategy strategy) {
+ for (SeedCandidate newseed : newseedlist ) {
+ ListIterator<SeedCandidate> itr = seedlist.listIterator();
+ boolean duplicate = false;
+ while (itr.hasNext()) {
+ SeedCandidate seed = itr.next();
+ if (isDuplicate(newseed, seed)) {
+ duplicate = true;
+ if (isBetter(newseed, seed, strategy)) {
+ itr.set(newseed);
+ }
+ break;
+ }
+ }
+ if (!duplicate) seedlist.add(newseed);
+ }
+ return;
+ }
+
+ private boolean isDuplicate(SeedCandidate seed1, SeedCandidate seed2) {
+ int nduplicate = 0;
+ for (HelicalTrackHit hit1 : seed1.getHits()) {
+ for (HelicalTrackHit hit2 : seed2.getHits()) {
+ if (hit1 == hit2) {
+ nduplicate++;
+ if (nduplicate > 1) return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isBetter(SeedCandidate newseed, SeedCandidate oldseed, SeedStrategy strategy) {
+ int hitdif = newseed.getHits().size() - oldseed.getHits().size();
+ double chisqdif = newseed.getHelix().chisqtot() - oldseed.getHelix().chisqtot();
+ if (hitdif > 1) return true;
+ if (hitdif == 1) return chisqdif < strategy.getBadHitChisq();
+ if (hitdif == 0) return chisqdif < 0.;
+ if (hitdif == -1) return chisqdif < -strategy.getBadHitChisq();
+ return false;
+ }
+}
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.2 -r1.3
--- ConfirmSeeds.java 6 Feb 2008 02:33:25 -0000 1.2
+++ ConfirmSeeds.java 7 Feb 2008 18:20:50 -0000 1.3
@@ -49,7 +49,6 @@
// Create a list for seeds that are confirmed using the current layer
List<SeedCandidate> newlist = new ArrayList<SeedCandidate>();
- System.out.print("Started a new list");
// Loop over the seeds in the working seed list
for (SeedCandidate seedin : seedlist) {
@@ -69,14 +68,12 @@
// Attach the fit to the test seed and add it to the list
test.setHelix(_helixfitter.getHelix());
newlist.add(test);
- System.out.println(" Added a seed to the new list");
chisqbest = Math.min(chisqbest, _helixfitter.getHelix().chisqtot());
}
}
// If all fit tries for this layer are potentially bad hits, include the starting seed in the list
if (chisqbest - oldchisq > strategy.getBadHitChisq()) {
- System.out.println(" Added the old seed to the new list");
newlist.add(seedin);
}
}
@@ -87,7 +84,6 @@
// Check for seeds with sufficient numbers of confirmed hits
for (SeedCandidate candidate : seedlist) {
int hits = candidate.getHits().size();
- System.out.println(" seed with nhits: "+hits);
if (hits >= inhits + strategy.getMinConfirm()) {
_confirmedseeds.add(candidate);
}
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.1 -r1.2
--- ExtendSeeds.java 4 Feb 2008 20:51:32 -0000 1.1
+++ ExtendSeeds.java 7 Feb 2008 18:20:50 -0000 1.2
@@ -7,76 +7,93 @@
package org.lcsim.contrib.seedtracker;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+
/**
*
- * @author partridge
- * @version __VERSION__
+ * @author Richard Partridge
+ * @version 1.0
*/
public class ExtendSeeds {
+ private HitManager _hitmanager;
+ private HelixFitter _helixfitter;
+ private List<SeedCandidate> _extendedseeds;
- /** Creates a new instance of ExtendSeeds */
- public ExtendSeeds() {
+ /** Creates a new instance of ConfirmSeeds */
+ public ExtendSeeds(HitManager hitmanager, HelixFitter helixfitter) {
+ _hitmanager = hitmanager;
+ _helixfitter = helixfitter;
}
-
-// private List<SeedCandidate> FindExtendedSeeds(SeedStrategy strategy, SeedCandidate seed) {
-// List<SeedCandidate> extendedseeds = new ArrayList<SeedCandidate>();
- // For now, just pass along the input seed
-// extendedseeds.add(seed);
-// return extendedseeds;
-// }
-// private void PurgeDuplicateSeeds(List<SeedCandidate> trackseeds, SeedCandidate extseed) {
- // Ignore duplicates for now
-// trackseeds.add(extseed);
-// return;
-// }
-// private boolean isDuplicate(List<TrackerHit> hitlist, List<Track> tracklist) {
-// boolean isDuplicate = false;
-// for (Track track : tracklist) {
-// List<TrackerHit> hitlist2 = track.getTrackerHits();
-// boolean matchall = true;
-// if (hitlist.size() <= hitlist2.size()) {
-// for (TrackerHit hit1 : hitlist) {
-// boolean match = false;
-// for (TrackerHit hit2 : hitlist2) {
-// if (hit1 == hit2) {
-// match = true;
-// break;
-// }
-// }
-// if (!match) {
-// matchall = false;
-// break;
-// }
-// }
-// if (matchall) {
-// isDuplicate = true;
-// break;
-// }
-// }
-// }
-// return isDuplicate;
-// }
-// private void MakeTracks(EventHeader event, List<SeedCandidate> trackseeds) {
- // Create a list of tracks
-// List<Track> tracklist = new ArrayList<Track>();
-// for (SeedCandidate seed : trackseeds) {
-// BaseTrack track = new BaseTrack();
-// track.setReferencePoint(_IP.v());
-// track.setRefPointIsDCA(false);
-// HelicalTrackFit helix = seed.getHelix();
-// track.setTrackParameters(helix.parameters(), _BField);
-// track.setChisq(helix.chisq()[0]+helix.chisq()[1]);
-// track.setNDF(helix.ndf()[0]+helix.ndf()[1]);
-// track.setCovarianceMatrix(helix.covariance());
-// track.setTrackType(0);
-// track.addHits(seed.getTrackerHits());
-// tracklist.add(track);
-// }
-// System.out.println(" Tracks found: "+tracklist.size());
-// event.put(EventHeader.TRACKS, tracklist, Track.class, 0);
-// List<Track> test = event.getTracks();
-// return;
-// }
-
-}
+ public boolean Extend(List<SeedCandidate> confirmed, SeedStrategy strategy) {
+
+ // Retrieve the extension layers to be used and initialize the list of extended seeds
+ List<SeedLayer> extendlyrs = strategy.getLayers(SeedLayer.SeedType.Extend);
+ _extendedseeds = new ArrayList<SeedCandidate>();
+
+ // Loop over the confirmed seeds
+ for (SeedCandidate seed : confirmed) {
+
+ // Start a working seed list and add the input seed
+ List<SeedCandidate> seedlist = new ArrayList<SeedCandidate>();
+ seedlist.add(seed);
+
+ // Loop over the extension layers
+ for (SeedLayer lyr : extendlyrs) {
+
+ // Get the hits on this extension layer
+ List<HelicalTrackHit> hitlist = _hitmanager.getTrackerHits(lyr);
+
+ // Create a list for seeds that are extended using the current layer
+ List<SeedCandidate> newlist = new ArrayList<SeedCandidate>();
+
+ // Loop over the seeds in the working seed list
+ for (SeedCandidate seedin : seedlist) {
+
+ // Retrieve the chisq for the last fit and initialize the best fit chisq for this layer
+ double oldchisq = seedin.getHelix().chisqtot();
+ double chisqbest = 1.e6;
+
+ // 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) {
+
+ // Attach the fit to the test seed and add it to the list
+ test.setHelix(_helixfitter.getHelix());
+ newlist.add(test);
+ chisqbest = Math.min(chisqbest, _helixfitter.getHelix().chisqtot());
+ }
+ }
+
+ // If all fit tries for this layer are potentially bad hits, include the starting seed in the list
+ if (chisqbest - oldchisq > strategy.getBadHitChisq()) {
+ newlist.add(seedin);
+ }
+ }
+ // Use the new list of seeds as input to the next layer search
+ seedlist = newlist;
+ }
+
+ // Check for seeds with sufficient numbers of confirmed hits
+ for (SeedCandidate candidate : seedlist) {
+ int hits = candidate.getHits().size();
+ if (hits >= strategy.getMinHits()) {
+ _extendedseeds.add(candidate);
+ }
+ }
+ }
+ return _extendedseeds.size()>0;
+ }
+
+ public List<SeedCandidate> getExtendedSeeds() {
+ return _extendedseeds;
+ }
+}
\ No newline at end of file
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.2 -r1.3
--- FindSeeds.java 6 Feb 2008 02:33:25 -0000 1.2
+++ FindSeeds.java 7 Feb 2008 18:20:50 -0000 1.3
@@ -42,9 +42,6 @@
// double dMax = strategy.getMaxDCA();
// Todo: add code to limit seeds to those that satisfy cuts
-// System.out.println("layer 0 hits: "+_HM.getTrackerHits(seedlayerlist.get(0)).size());
-// System.out.println("layer 1 hits: "+_HM.getTrackerHits(seedlayerlist.get(1)).size());
-// System.out.println("layer 2 hits: "+_HM.getTrackerHits(seedlayerlist.get(2)).size());
for (HelicalTrackHit hit1 : _hitmanager.getTrackerHits(seedlayerlist.get(0))) {
// double[] pos1 = s1.getPosition();
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.2 -r1.3
--- HelixFitter.java 6 Feb 2008 02:33:25 -0000 1.2
+++ HelixFitter.java 7 Feb 2008 18:20:50 -0000 1.3
@@ -53,8 +53,7 @@
if (oldhelix == null) {
status = _fitter.fit(hitlist);
if (!status) {
- System.out.println(" failed initial helix fit");
- _helix = null;
+ _helix = null;
return false;
}
// Retrieve the helix parameters from this fit
@@ -67,7 +66,6 @@
// Do a helix fit including MS errors
status = _fitter.fit(hitlist, msmap);
if (!status) {
- System.out.println(" failed helix fit with ms errors");
_helix = null;
return false;
}
@@ -94,15 +92,15 @@
// Sum the chisq for the circle (x-y) and line (s-z) fits
double chisq = helix.chisqtot();
- System.out.println(" circle chisq "+helix.chisq()[0]);
- System.out.println(" line fit chisq "+helix.chisq()[1]);
- System.out.println(" total chisq "+chisq);
- System.out.println(" dca "+helix.dca());
- System.out.println(" phi0 "+helix.phi0());
- System.out.println(" curvatures "+helix.curvature());
- System.out.println(" z0 "+helix.z0());
- System.out.println(" slope "+helix.slope());
- System.out.println(" pT "+helix.pT(_bfield));
+// System.out.println(" circle chisq "+helix.chisq()[0]);
+// System.out.println(" line fit chisq "+helix.chisq()[1]);
+// System.out.println(" total chisq "+chisq);
+// System.out.println(" dca "+helix.dca());
+// System.out.println(" phi0 "+helix.phi0());
+// System.out.println(" curvatures "+helix.curvature());
+// 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();
@@ -125,10 +123,10 @@
chisq += Math.pow(z0 - z0max, 2) / helix.covariance().e(3, 3);
}
- System.out.println(" inflated chisq: "+chisq);
+// System.out.println(" inflated chisq: "+chisq);
// Make the chi squared cut
if (chisq > strategy.getMaxChisq()) return false;
- System.out.println(" Good track found");
+// System.out.println(" Good track found");
return true;
}
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.4 -r1.5
--- HitManager.java 4 Feb 2008 20:51:32 -0000 1.4
+++ HitManager.java 7 Feb 2008 18:20:50 -0000 1.5
@@ -51,10 +51,8 @@
_zmin = new HashMap<String, Double>();
_zmax = new HashMap<String, Double>();
List<HelicalTrackHit> hitcol = (List<HelicalTrackHit>) event.get("HelicalTrackHits");
-// for (List<TrackerHit> hitcol : hitcollections) {
for (HelicalTrackHit hit : hitcol) {
String identifier = ID.Identifier(hit);
-// System.out.println("Hit Found and identified: "+identifier);
if (!_hitlist.containsKey(identifier)) {
_hitlist.put(identifier, new ArrayList<HelicalTrackHit>());
_rmin.put(identifier,9999999.);
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.4 -r1.5
--- MultipleScattering.java 6 Feb 2008 02:33:25 -0000 1.4
+++ MultipleScattering.java 7 Feb 2008 18:20:50 -0000 1.5
@@ -86,7 +86,6 @@
// Get the multiple scattering plane angle for this scatter
double angle = scat.Angle();
-// System.out.println(" s: "+scatpath+" angle "+angle);
// Sum in quadrature the r-phi ms errors. It is assumed that we
// can ignore track curvature in calculating these errors during
@@ -104,7 +103,6 @@
// Create a new MultipleScatter object and store it in the map of ms errors
MultipleScatter ms = new MultipleScatter(Math.sqrt(rphi_ms2), Math.sqrt(z_ms2));
- System.out.println(" r: "+hit.r()+" z "+hit.z()+" r-phi ms: "+ms.drphi()+" s-z ms: "+ms.dz());
msmap.put(hit, ms);
}
@@ -139,8 +137,6 @@
smax = Math.min(smax, s);
}
-// System.out.println(" smax: "+smax);
-
for (MaterialDisk disk : matdsk) {
double s = _hutil.PathToZPlane(helix, disk.z());
if (s > 0. && s < smax) {
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.3 -r1.4
--- SeedCandidate.java 4 Feb 2008 20:51:32 -0000 1.3
+++ SeedCandidate.java 7 Feb 2008 18:20:50 -0000 1.4
@@ -10,6 +10,7 @@
package org.lcsim.contrib.seedtracker;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import org.lcsim.event.TrackerHit;
@@ -23,7 +24,7 @@
*/
public class SeedCandidate {
- private List<HelicalTrackHit> _hits = new ArrayList<HelicalTrackHit>();
+ private List<HelicalTrackHit> _hits = new LinkedList<HelicalTrackHit>();
private HelicalTrackFit _helix;
public SeedCandidate() {
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.3 -r1.4
--- SeedStrategy.java 6 Feb 2008 02:33:25 -0000 1.3
+++ SeedStrategy.java 7 Feb 2008 18:20:50 -0000 1.4
@@ -26,7 +26,7 @@
private double _MaxChisq = 100.;
private double _BadHitChisq = 15.;
private int _MinConfirm = 1;
- private int _MinHits = 5;
+ private int _MinHits = 6;
/**
* Fully qualified constructor
lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.7 -r1.8
--- SeedTracker.java 4 Feb 2008 20:51:32 -0000 1.7
+++ SeedTracker.java 7 Feb 2008 18:20:50 -0000 1.8
@@ -67,14 +67,19 @@
FindSeeds finder = new FindSeeds(hitmanager, helixfitter);
// Instantiate the Seed Extender
-// ExtendSeeds extender = new ExtendSeeds(hitman, matman);
+ ExtendSeeds extender = new ExtendSeeds(hitmanager, helixfitter);
+
+ // Instantiate the Seed Merger
+ MergeSeedLists mergeseedlists = new MergeSeedLists();
+
+ // Instantiate the Track Maker
+ MakeTracks maketracks = new MakeTracks();
// Create the list of final track seeds
List<SeedCandidate> trackseeds = new ArrayList<SeedCandidate>();
// Loop over all strategies
for (SeedStrategy strategy : _strategylist) {
-// System.out.println(" Strategy "+strategy.getName());
// Find the confirmed seeds for this strategy
boolean success = finder.FindConfirmedSeeds(strategy);
@@ -82,16 +87,16 @@
List<SeedCandidate> confirmed = finder.getConfirmedSeeds();
// Extend the confirmed seeds
-// success = _Extender.CheckSeeds(strategy, _HitMan, _MatMan, confirmed);
-// if (!success) continue;
-// List<SeedCandidate> extended = _Extender.getSeeds();
+ success = extender.Extend(confirmed, strategy);
+ if (!success) continue;
+ List<SeedCandidate> extended = extender.getExtendedSeeds();
- // Merge the new seeds into the list of found track seeds, eliminating duplicates
-// MergeSeedList(trackseeds, extended);
+ // Merge the extended seeds into the list of found track seeds, eliminating duplicates
+ mergeseedlists.Merge(trackseeds, extended, strategy);
}
// Make tracks from the final list of track seeds
-// MakeTracks(event, trackseeds);
+ maketracks.Process(event, trackseeds, bfield);
return;
}
lcsim/src/org/lcsim/fit/circle
diff -u -r1.1 -r1.2
--- CircleFit.java 5 May 2005 04:48:38 -0000 1.1
+++ CircleFit.java 7 Feb 2008 18:20:51 -0000 1.2
@@ -20,7 +20,7 @@
private double[] _covrfd; // covariance matrix of fit
// parameters in lower triangular form
//Constructor
- CircleFit(double x, double y, double rho, double phi, double dca, double chi2, double[] cov)
+ public CircleFit(double x, double y, double rho, double phi, double dca, double chi2, double[] cov)
{
_xref = x;
_yref = y;
lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.15 -r1.16
--- HelicalTrackFitter.java 5 Feb 2008 17:09:29 -0000 1.15
+++ HelicalTrackFitter.java 7 Feb 2008 18:20:51 -0000 1.16
@@ -4,7 +4,7 @@
*
* Created on March 25, 2006, 6:11 PM
*
- * $Id: HelicalTrackFitter.java,v 1.15 2008/02/05 17:09:29 partridge Exp $
+ * $Id: HelicalTrackFitter.java,v 1.16 2008/02/07 18:20:51 partridge Exp $
*/
import hep.physics.matrix.SymmetricMatrix;
@@ -92,6 +92,7 @@
List<HelicalTrackHit> circle_hits = new ArrayList<HelicalTrackHit>();
List<HelicalTrackHit> pixel_hits = new ArrayList<HelicalTrackHit>();
List<HelicalTrackHit> strip_hits = new ArrayList<HelicalTrackHit>();
+
// Sort the hits into the appropriate lists
for (HelicalTrackHit hit : hitcol) {
// Hits to be used in the circle fit
@@ -102,6 +103,16 @@
if (hit instanceof HelicalTrack2DHit) strip_hits.add(hit);
}
+ // Sort the hits to be monotonic in z so that we can follow a curling track
+ // It is assumed that the first hit on a track is closer to the origin than the last hit
+ // It is also assumed that the track won't curl through an angle > 180 degrees between
+ // neighboring points. This might be a problem for curlers with small dip angle.
+ int nhits = circle_hits.size();
+ Collections.sort(circle_hits);
+ double zfirst = circle_hits.get(0).z();
+ double zlast = circle_hits.get(nhits-1).z();
+ if (Math.abs(zfirst) > Math.abs(zlast)) Collections.reverse(circle_hits);
+
// Create the arrays that will hold the fit output
double[] chisq = new double[2];
int[] ndof = new int[2];
@@ -115,6 +126,14 @@
double[] y = new double[nc];
double[] wrphi = new double[nc];
+ // Make sure that r is increaseing for the first two hits so that
+ // the circle gives an outward trajectory
+// if (circle_hits.get(0).r() > circle_hits.get(1).r()) {
+// HelicalTrackHit temp = circle_hits.get(0);
+// circle_hits.set(0, circle_hits.get(1));
+// circle_hits.set(1, temp);
+// }
+
// Store the hit coordinates and weights in arrays for the circle fitter
for(int i=0; i<nc; i++) {
HelicalTrackHit hit = circle_hits.get(i);
@@ -123,7 +142,6 @@
double drphi_ms = 0.;
if (msmap.containsKey(hit)) drphi_ms = msmap.get(hit).drphi();
double r = Math.sqrt(x[i]*x[i]+y[i]*y[i]);
- System.out.println(" r: "+r+" drphi - res: "+hit.drphi()+" drphi - ms: "+drphi_ms);
wrphi[i] = 1. / (Math.pow(hit.drphi(),2) + Math.pow(drphi_ms,2));
}
@@ -131,19 +149,21 @@
boolean success = _cfitter.fit(x, y, wrphi, nc);
if(!success) return false;
- // Store the circle fit output
- CircleFit cfit = _cfitter.getfit();
+ // If we are going around the circle in the wrong direction, fix it
+ CircleFit cfit = CircleFix(_cfitter.getfit(), circle_hits);
+
chisq[0] = cfit.chisq();
ndof[0] = nc - 3;
par[0] = -cfit.dca();
par[1] = cfit.phi();
par[2] = cfit.curvature();
cov.setElement(0, 0, cfit.cov()[0]);
- cov.setElement(0, 1, cfit.cov()[1]);
+ cov.setElement(0, 1, -cfit.cov()[1]);
cov.setElement(1, 1, cfit.cov()[2]);
- cov.setElement(0, 2, cfit.cov()[3]);
+ cov.setElement(0, 2, -cfit.cov()[3]);
cov.setElement(1, 2, cfit.cov()[4]);
cov.setElement(2, 2, cfit.cov()[5]);
+
// Calculate the arc lengths from the DCA to each hit
Map<HelicalTrackHit, Double> smap = getPathLengths(cfit, hitcol);
@@ -246,26 +266,16 @@
*/
public Map<HelicalTrackHit, Double> getPathLengths(CircleFit cfit, List<HelicalTrackHit> hits) {
- // Sort the hits to be monotonic in z so that we can follow a curling track
- // It is assumed that the first hit on a track is closer to the origin than the last hit
- // It is also assumed that the track won't curl through an angle > 180 degrees between
- // neighboring points. This might be a problem for curlers with small dip angle.
- int nhits = hits.size();
- Collections.sort(hits);
- double zfirst = hits.get(0).z();
- double zlast = hits.get(nhits-1).z();
- if (Math.abs(zfirst) > Math.abs(zlast)) Collections.reverse(hits);
-
// Create a map to store the arc lengths
Map<HelicalTrackHit, Double> smap = new HashMap<HelicalTrackHit, Double>();
-
+
// Loop over the hits and store the arc lengths
double s = 0.;
- for(int i=0; i<nhits; i++) {
+ for(int i=0; i<hits.size(); i++) {
if (i == 0) {
// For the first hit, measure from the DCA
- s += _hutil.PathLength(cfit, hits.get(i));
+ s += _hutil.PathLength(cfit, hits.get(i));
} else {
// For subsequent hits, add in the arc length from the previous hit
@@ -277,4 +287,25 @@
}
return smap;
}
+
+ private CircleFit CircleFix(CircleFit oldfit, List<HelicalTrackHit> hitlist) {
+
+ // Check if we are going around the circle in the right direction by getting
+ // the path length to the first hit and checking that it is positive
+ double s = _hutil.PathLength(oldfit, hitlist.get((0)));
+ if (s > 0.) return oldfit;
+
+ // Reverse the direction by changing the sign of dca, curv, and adding pi to phi0
+ double dca = -oldfit.dca();
+ double phi0 = oldfit.phi() + Math.PI;
+ if (phi0 > 2. * Math.PI) phi0 -= 2. * Math.PI;
+ double curv = -oldfit.curvature();
+
+ // Also fix the affected covariance matrix elements
+ double[] cov = oldfit.cov();
+ cov[1] = -cov[1];
+ cov[4] = -cov[4];
+
+ return new CircleFit(oldfit.xref(), oldfit.yref(), curv, phi0, dca, oldfit.chisq(), cov);
+ }
}
\ No newline at end of file
lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.3 -r1.4
--- HelicalTrackHit.java 6 Feb 2008 02:33:50 -0000 1.3
+++ HelicalTrackHit.java 7 Feb 2008 18:20:51 -0000 1.4
@@ -41,8 +41,6 @@
_z = pos[2];
setPolarCoordinates();
double[] cov = hit.getCovMatrix();
-// System.out.println(" dx: "+Math.sqrt(cov[0])+" dy: "+Math.sqrt(cov[2])+
-// " rho: "+cov[1]/Math.sqrt(cov[0]*cov[2]));
// _drphi = Math.sqrt(_y * _y * cov[0] + _x * _x * cov[2] - 2. * _x * _y * cov[1]) / _r;
// _dr = Math.sqrt(_x * _x * cov[0] + _y * _y * cov[2] + 2. * _x * _y * cov[1]) / _r;
if (_r > 100) {
lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.3 -r1.4
--- HelicalTrackHitDriver.java 6 Feb 2008 02:33:50 -0000 1.3
+++ HelicalTrackHitDriver.java 7 Feb 2008 18:20:51 -0000 1.4
@@ -74,10 +74,7 @@
List<TrackerHit> hitlist = (List<TrackerHit>) event.get(colname);
for (TrackerHit hit : hitlist) {
double[] ps = hit.getPosition();
- System.out.println("Hit x: "+ps[0]+" y: "+ps[1]+" z: "+ps[2]);
double[] cov = hit.getCovMatrix();
-// System.out.println("Cov xx: "+cov[0]+" xy: "+cov[1]+" yy "+cov[2]);
-// System.out.println("Cov xz: "+cov[3]+" Cov yz: "+cov[4]+" Cov zz: "+cov[5]);
// Check that these hits are actually instances of OldTrackerHit and cast accordingly
if (hit instanceof OldTrackerHit) {
lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.3 -r1.4
--- HelixUtils.java 6 Feb 2008 02:33:50 -0000 1.3
+++ HelixUtils.java 7 Feb 2008 18:20:51 -0000 1.4
@@ -156,7 +156,7 @@
if (_cfit != cfit) {
_cfit = cfit;
_helix = null;
- _dca = _cfit.dca();
+ _dca = -_cfit.dca();
_phi0 = _cfit.phi();
_RC = 1.0 / _cfit.curvature();
_xr = _cfit.xref();
CVSspam 0.2.8