7 modified files
lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.11 -r1.12
--- ConfirmerExtender.java 24 Jul 2009 14:37:41 -0000 1.11
+++ ConfirmerExtender.java 19 Aug 2009 22:12:27 -0000 1.12
@@ -110,23 +110,28 @@
// Pull the last seed off the queue (use a LIFO queue to minimize queue length)
SeedCandidate seed = seedlist.poll();
- // See if there are any layers left for confirm/extend
+ // Check if there are enough unchecked layers to meet the minimum number of hits
int lyrsleft = seed.getUncheckedLayers().size();
+ int possiblehits = lyrsleft + seed.getHits().size();
+ if (possiblehits < minhits) continue;
+
+ // See if there are any layers left for confirm/extend
if (lyrsleft == 0) {
+
+ // Take final action on this seed
if (task == Task.CONFIRM) {
+
+ // No more layers and min hit requirement is met, seed is confirmed
_result.add(seed);
+
} else if (task == Task.EXTEND) {
- if (seed.getHits().size() >= minhits) {
- _merger.Merge(_result, seed, strategy);
- }
+
+ // Merge the seed into the list of extended seeds
+ _merger.Merge(_result, seed, strategy);
}
continue;
}
- // Check if there are enough unchecked layers to meet the minimum number of hits
- int possiblehits = lyrsleft + seed.getHits().size();
- if (possiblehits < minhits) continue;
-
// Pull the next layer off the queue
SeedLayer lyr = seed.getNextLayer();
@@ -154,20 +159,20 @@
SortHits comp = new SortHits(seed.getHelix());
Collections.sort(hitlist, comp);
- if (_diag != null) {
- _diag.fireConfirmerExtenderWorkingSeedInfo(task, seed, hitlist);
- }
-
// Loop over the sorted hits in this layer
for (HelicalTrackHit hit : hitlist) {
- // Check that this hit is potentially viable
- if (!checker.CheckHitSeed(hit, seed)) continue;
-
// Make a test seed including the new hit
SeedCandidate test = new SeedCandidate(seed);
test.addHit(hit);
+ // Check that this hit is potentially viable
+ if (!checker.CheckHitSeed(hit, seed)) {
+ if (_diag != null) _diag.fireCheckHitFailed(hit, test);
+ continue;
+ }
+
+
// See if we have a successful fit
boolean success = _fitter.FitCandidate(test, strategy);
@@ -176,20 +181,12 @@
// Attach the fit to the test seed
test.setHelix(_fitter.getHelix());
- if (_diag != null) {
- _diag.fireConfirmerExtenderFitSuccess(task, seed, hit, _fitter, chisqbest, true);
- }
-
// Add the seed to the LIFO queue of seed candidates
seedlist.addFirst(test);
chisqbest = Math.min(chisqbest, _fitter.getHelix().chisqtot());
} else {
- if (_diag != null) {
- _diag.fireConfirmerExtenderFitNoSuccess(task, seed, hit, _fitter, true);
- }
-
// Stop checking hits in this layer if circle chisq increase is too big
if (_fitter.getFitStatus() != FitStatus.CircleFitFailed) {
double circlechisq = _fitter.getCircleFit().chisq();
@@ -202,16 +199,10 @@
// Finished checking hits in the current layer
// If all fit tries for this layer are potentially bad hits, include the starting seed in the list
- if (chisqbest - oldchisq > strategy.getBadHitChisq()) {
- seedlist.addFirst(seed);
-
-// if (diag != null) {
-// diag.fireConfirmerExtenderAllHitsPotentiallyBad(task, seedin, hitlist, chisqbest, oldchisq);
-// }
- }
-
+ if (chisqbest - oldchisq > strategy.getBadHitChisq()) seedlist.addFirst(seed);
}
+
// Finished looping over the seeds in the LIFO candidate queue
- //if (_diag != null) _diag.fireConfirmerExtenderLayerDone(task, n, seedlist);
+ return;
}
}
\ No newline at end of file
lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.6 -r1.7
--- FastCheck.java 19 Feb 2009 22:00:34 -0000 1.6
+++ FastCheck.java 19 Aug 2009 22:12:27 -0000 1.7
@@ -13,13 +13,18 @@
*/
public class FastCheck {
- private HelicalTrackHit _hit1cache;
+// private HelicalTrackHit _hit1cache;
+ private SeedStrategy _strategy;
+ private double _bfield;
private double _RMin;
private double _dMax;
private double _z0Max;
private double _eps = 1.0e-6;
public FastCheck(SeedStrategy strategy, double bfield) {
+ _strategy = strategy;
+ _bfield = bfield;
+
// Calculate the minimum radius of curvature, maximum DCA and Maximum z0
_RMin = strategy.getMinPT() / (Constants.fieldConversion * bfield);
_dMax = strategy.getMaxDCA();
@@ -259,23 +264,4 @@
return phidif;
}
- private boolean CheckMC(HelicalTrackHit hit1, HelicalTrackHit hit2) {
- List<MCParticle> mclist1 = hit1.getMCParticles();
- List<MCParticle> mclist2 = hit2.getMCParticles();
- for (MCParticle mc1 : mclist1) {
- HelixParamCalculator helix = new HelixParamCalculator(mc1, 5.0);
- if (helix.getMCTransverseMomentum() < 0.2) continue;
- if (Math.abs(helix.getDCA()) > 10.) continue;
- if (Math.abs(helix.getZ0()) > 10.) continue;
- if (mclist2.contains(mc1)) {
- System.out.println("pt: "+helix.getMCTransverseMomentum()+" p: "+helix.getMCMomentum());
- System.out.println(" MC z0 origin: "+mc1.getOriginZ()+" p: "+mc1.getMomentum().magnitude());
- double s1 = (hit1.getPosition()[2] - helix.getZ0()) / helix.getSlopeSZPlane();
- double s2 = (hit2.getPosition()[2] - helix.getZ0()) / helix.getSlopeSZPlane();
- System.out.println("s1: "+s1+" s2: "+s2);
- return true;
- }
- }
- return false;
- }
}
\ No newline at end of file
lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.5 -r1.6
--- HelixFitter.java 13 Jan 2009 06:12:44 -0000 1.5
+++ HelixFitter.java 19 Aug 2009 22:12:27 -0000 1.6
@@ -81,7 +81,7 @@
// Check for unrecoverable fit errors and call appropriate diagnostic
if (_status != FitStatus.Success) {
- if(_diag!=null) _diag.fireFitterFitMade(seed, null,_circlefit,_linefit,_zsegmentfit, _status, false);
+ if(_diag!=null) _diag.fireHelixFitFailed(seed, _status, true);
return false;
}
@@ -102,7 +102,7 @@
// Check for unrecoverable fit errors and call appropriate diagnostic
if (_status != FitStatus.Success) {
- if(_diag!=null) _diag.fireFitterFitMade(seed, null,_circlefit,_linefit,_zsegmentfit, _status, false);
+ if(_diag!=null) _diag.fireHelixFitFailed(seed, _status, false);
return false;
}
@@ -115,7 +115,8 @@
// If the total chi square is below the cut, we have a successful fit
boolean success = _helix.chisqtot() <= strategy.getMaxChisq();
- if(_diag!=null) _diag.fireFitterFitMade(seed, _helix, _circlefit, _linefit, _zsegmentfit, _status, success);
+ if (!success)
+ if (_diag != null) _diag.fireFailedChisqCut(seed);
// If fit was successful, set the new multiple scattering angles
if (success) seed.setScatterAngles(_scattering.FindScatters(_helix));
lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.5 -r1.6
--- MergeSeedLists.java 24 Jul 2009 14:05:03 -0000 1.5
+++ MergeSeedLists.java 19 Aug 2009 22:12:27 -0000 1.6
@@ -6,8 +6,8 @@
*/
package org.lcsim.recon.tracking.seedtracker;
+import java.util.ArrayList;
import java.util.List;
-import java.util.ListIterator;
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
import org.lcsim.recon.tracking.seedtracker.diagnostic.ISeedTrackerDiagnostics;
@@ -19,40 +19,58 @@
*/
public class MergeSeedLists {
- private ISeedTrackerDiagnostics diag = null;
+ private ISeedTrackerDiagnostics _diag = null;
/** Creates a new instance of MergeSeedLists */
public MergeSeedLists() {
}
public void setDiagnostic(ISeedTrackerDiagnostics diagnostic) {
- diag = diagnostic;
+ _diag = diagnostic;
}
public void Merge(List<SeedCandidate> seedlist, SeedCandidate newseed, SeedStrategy strategy) {
// if(diag!=null) diag.fireMergeStartDiagnostics(newseedlist);
- ListIterator<SeedCandidate> itr = seedlist.listIterator();
+
+ // Assume the new seed is better than all duplicates
boolean best = true;
- while (itr.hasNext()) {
- SeedCandidate seed = itr.next();
+
+ // Create a list of duplicates that are inferior
+ List<SeedCandidate> duplist = new ArrayList<SeedCandidate>();
+
+ // Loop over all existing seeds
+ for (SeedCandidate seed : seedlist) {
+
+ // See if the new seed is considered a duplicate of the current seed
boolean dupe = isDuplicate(newseed, seed);
- if (diag != null) {
- diag.fireMergeIsDuplicateDiagnostics(newseed, seed, dupe);
- }
+
if (dupe) {
+
+ // Check if the new seed is better than the existing seed
boolean better = isBetter(newseed, seed, strategy);
- if (diag != null) {
- diag.fireMergeIsBetterDiagnostics(newseed, seed, better);
- }
+
if (better) {
- itr.remove();
+
+ // If the new seed is better, add the existing seed to the list for deletion
+ duplist.add(seed);
+
} else {
+
+ // If the new seed is inferior to an existing seed, leave everything unchanged
best = false;
+ if (_diag != null) _diag.fireMergeKillingNewSeed(seed, newseed);
+ break;
}
}
}
+
+ // If the new seed is better than all duplicates, add it to the seed list and remove duplicates
if (best) {
seedlist.add(newseed);
+ for (SeedCandidate seed : duplist) {
+ seedlist.remove(seed);
+ if (_diag != null) _diag.fireMergeKillingOldSeed(seed, newseed);
+ }
}
return;
@@ -90,4 +108,4 @@
}
return false;
}
-}
+}
\ No newline at end of file
lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.4 -r1.5
--- SeedCandidate.java 24 Jul 2009 14:37:41 -0000 1.4
+++ SeedCandidate.java 19 Aug 2009 22:12:27 -0000 1.5
@@ -10,12 +10,17 @@
package org.lcsim.recon.tracking.seedtracker;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.lcsim.event.MCParticle;
import org.lcsim.fit.helicaltrack.HelicalTrackFit;
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+import org.lcsim.fit.helicaltrack.HelixParamCalculator;
import org.lcsim.fit.helicaltrack.MultipleScatter;
/**
@@ -28,18 +33,22 @@
private List<HelicalTrackHit> _hits;
private HelicalTrackFit _helix;
+ private double _bfield;
private SeedStrategy _strategy;
private Map<HelicalTrackHit, MultipleScatter> _msmap;
private List<ScatterAngle> _scatters;
private LinkedList<SeedLayer> _unchecked;
+ private Set<MCParticle> _mcpset;
/**
* Create an empty SeedCandidate.
*/
- public SeedCandidate(SeedStrategy strategy) {
+ public SeedCandidate(SeedStrategy strategy, double bfield) {
_strategy = strategy;
+ _bfield = bfield;
_hits = new LinkedList<HelicalTrackHit>();
_msmap = new HashMap<HelicalTrackHit, MultipleScatter>();
+ _mcpset = new HashSet<MCParticle>();
}
/**
@@ -47,9 +56,10 @@
* @param hits list of hits for this SeedCandidate
* @param strategy strategy used for this SeedCandidate
*/
- public SeedCandidate(List<HelicalTrackHit> hits, SeedStrategy strategy) {
- this(strategy);
+ public SeedCandidate(List<HelicalTrackHit> hits, SeedStrategy strategy, double bfield) {
+ this(strategy, bfield);
_hits.addAll(hits);
+ FindMCParticles();
}
/**
@@ -58,20 +68,27 @@
* @param strategy strategy used for this SeedCandidate
* @param helix HelicalTrackFit associated with the SeedCandidate
*/
- public SeedCandidate(List<HelicalTrackHit> hits, SeedStrategy strategy, HelicalTrackFit helix) {
- this(hits, strategy);
+ public SeedCandidate(List<HelicalTrackHit> hits, SeedStrategy strategy, HelicalTrackFit helix, double bfield) {
+ this(hits, strategy, bfield);
_helix = helix;
}
-
+
+ public SeedCandidate(List<HelicalTrackHit> hits, SeedStrategy strategy) {
+ this(hits, strategy, 0.);
+ }
+
/**
* Creates a clone of an existing instance of SeedCandidate.
* @param seed existing SeedCandidate to be cloned
*/
public SeedCandidate(SeedCandidate seed) {
- this(seed.getHits(), seed.getSeedStrategy(), seed.getHelix());
+ this(seed._strategy, seed._bfield);
+ _hits.addAll(seed.getHits());
+ _helix = seed.getHelix();
_msmap.putAll(seed.getMSMap());
_scatters = seed.getScatterAngles();
_unchecked = seed.getUncheckedLayers();
+ _mcpset.addAll(seed.getMCParticles());
}
/**
@@ -81,6 +98,7 @@
public void setHits(List<HelicalTrackHit> hits) {
_hits.clear();
_hits.addAll(hits);
+ FindMCParticles();
return;
}
@@ -93,7 +111,15 @@
if (!_hits.contains(hit)) {
_hits.add(hit);
UpdateMSMap(hit);
+
+ // If this is the first hit, find the associated MC
+ if (_hits.size() == 1) {
+ FindMCParticles();
+ } else {
+ CheckHit(hit);
+ }
}
+
return;
}
@@ -179,11 +205,75 @@
return _unchecked.poll();
}
+ public Set<MCParticle> getMCParticles() {
+ return _mcpset;
+ }
+
+ public boolean isTrueSeed() {
+ return _mcpset.size() > 0;
+ }
+
private void UpdateMSMap(HelicalTrackHit hit) {
if (_helix == null) return;
if (_scatters == null) return;
_msmap.put(hit, MultipleScattering.CalculateScatter(hit, _helix, _scatters));
return;
}
-
+
+ private void FindMCParticles() {
+
+ if (_hits.size() == 0) return;
+ for (MCParticle mcp : _hits.get(0).getMCParticles()) {
+ boolean good = true;
+ for (HelicalTrackHit hit : _hits) {
+ if (!hit.getMCParticles().contains(mcp)) {
+ good = false;
+ break;
+ }
+ }
+ if (!good) continue;
+ if (CheckMCParticle(mcp)) _mcpset.add(mcp);
+ }
+
+ return;
+ }
+
+ private boolean CheckMCParticle(MCParticle mcp) {
+
+ // Check that we have a strategy defined
+ if (_strategy == null) return false;
+
+ // Get the helix parameters for this MC Particle
+ HelixParamCalculator mchelix = new HelixParamCalculator(mcp, _bfield);
+
+ // Check that the momentum of the MC particle is above the cut
+ if (mchelix.getMCTransverseMomentum() < _strategy.getMinPT()) return false;
+
+ // Check the x-y impact parameter
+ if (Math.abs(mchelix.getDCA()) > _strategy.getMaxDCA()) return false;
+
+ // Check the s-z impact parameter
+ if (Math.abs(mchelix.getZ0()) > _strategy.getMaxZ0()) return false;
+
+ return true;
+ }
+
+ private void CheckHit(HelicalTrackHit hit) {
+
+ // First check if we have any true MCParticles
+ if (_mcpset.size() == 0) return;
+
+ // Get an iterator for the set so we can remove mcp's that don't match
+ Iterator<MCParticle> iter = _mcpset.iterator();
+
+ // Loop over the MCParticles that make this a "true seed"
+ while (iter.hasNext()) {
+ MCParticle mcp = iter.next();
+
+ // Remove MCParticles from the true seed list if they aren't associated with this hit
+ if (!hit.getMCParticles().contains(mcp)) iter.remove();
+ }
+
+ return;
+ }
}
\ No newline at end of file
lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.11 -r1.12
--- SeedTrackFinder.java 7 Aug 2009 23:33:17 -0000 1.11
+++ SeedTrackFinder.java 19 Aug 2009 22:12:27 -0000 1.12
@@ -7,8 +7,11 @@
package org.lcsim.recon.tracking.seedtracker;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import org.lcsim.event.MCParticle;
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
import org.lcsim.recon.tracking.seedtracker.diagnostic.ISeedTrackerDiagnostics;
@@ -41,6 +44,7 @@
// Create a list of track seeds that have been found
_trackseeds = new ArrayList<SeedCandidate>();
+
}
public void setDiagnostic(ISeedTrackerDiagnostics d) {
@@ -55,65 +59,65 @@
// Instantiate the fast hit checker
FastCheck checker = new FastCheck(strategy, bfield);
+ // Create a set of MCParticles that have been found as seeds
+ Set<MCParticle> mcp_seeds = new HashSet<MCParticle>();
+
// Get the SeedLayers for this strategy
List<SeedLayer> seedlayerlist = strategy.getLayers(SeedLayer.SeedType.Seed);
- if (seedlayerlist.size() != 3) return false;
+ if (seedlayerlist.size() != 3)
+ throw new RuntimeException("Illegal Strategy "+strategy.getName()+": Number of Seed Layers is not 3");
// Find the valid sector combinations
SeedSectoring ss = new SeedSectoring(_hitmanager, strategy, bfield, seedlayerlist);
List<List<Sector>> sslist = ss.SeedSectors();
- // Initialize counters
- int nfit = 0;
- int nseed = 0;
- int nconfirm = 0;
- int nextend = 0;
- int nhit0 = _hitmanager.getTrackerHits(seedlayerlist.get(0)).size();
- int nhit1 = _hitmanager.getTrackerHits(seedlayerlist.get(1)).size();
- int nhit2 = _hitmanager.getTrackerHits(seedlayerlist.get(2)).size();
- int maxseeds = nhit0 * nhit1 * nhit2;
-
-// if (maxseeds>0) System.out.println("Number of seed sectors: "+sslist.size()+" Max Seeds: "+maxseeds);
-
- int npairs = 0;
- int ngdpairs = 0;
- int ntrip = 0;
- int nconseeds = 0;
- int nextseeds = 0;
-
// Loop over the first seed layer
for (List<Sector> slist : sslist) {
for (HelicalTrackHit hit1 : slist.get(0).Hits()) {
+ // Construct a seed with the current hit in the first seed layer
+ SeedCandidate seed0 = new SeedCandidate(strategy, bfield);
+ seed0.addHit(hit1);
+
// Loop over the second seed layer and check that we have a hit pair consistent with our strategy
for (HelicalTrackHit hit2 : slist.get(1).Hits()) {
- npairs++;
- if (!checker.CheckHitPair(hit1, hit2)) continue;
- ngdpairs++;
+
+ // Construct a new seed adding in the hit from the second seed layer
+ SeedCandidate seed1 = new SeedCandidate(seed0);
+ seed1.addHit(hit2);
+
+ // Check if the pair of hits is consistent with current strategy
+ if (!checker.CheckHitPair(hit1, hit2)) {
+ if (_diag != null) _diag.fireCheckHitPairFailed(hit1, hit2, seed1);
+ continue;
+ }
// Loop over the third seed layer and check that we have a hit triplet consistent with our strategy
for (HelicalTrackHit hit3 : slist.get(2).Hits()) {
- ntrip++;
- if (!checker.CheckHitPair(hit1, hit3)) continue;
- if (!checker.CheckHitPair(hit2, hit3)) continue;
-
-// System.out.println("Found a new seed candidate");
- // Create a seed candidate from this 3-hit seed
- SeedCandidate seed = new SeedCandidate(strategy);
- seed.addHit(hit1);
- seed.addHit(hit2);
+
+ SeedCandidate seed = new SeedCandidate(seed1);
seed.addHit(hit3);
- nseed++;
+
+ // Check if the new hit is consistent with the other hits
+ if (!checker.CheckHitPair(hit1, hit3)) {
+ if (_diag != null) _diag.fireCheckHitPairFailed(hit1, hit3, seed);
+ continue;
+ }
+ if (!checker.CheckHitPair(hit2, hit3)) {
+ if (_diag != null) _diag.fireCheckHitPairFailed(hit2, hit3, seed);
+ continue;
+ }
+
+ if (_diag != null) {
+ if (seed.isTrueSeed()) mcp_seeds.addAll(seed.getMCParticles());
+ }
// See if we can fit a helix to this seed candidate
boolean success = _helixfitter.FitCandidate(seed, strategy);
if (!success) continue;
-// System.out.println("Fit a seed candidate");
-
// Save the helix fit
seed.setHelix(_helixfitter.getHelix());
- nfit++;
// Check the seed - hook for plugging in external constraint
if ((_trackCheck != null) && (! _trackCheck.checkSeed(seed))) continue;
@@ -121,21 +125,14 @@
// See if we can confirm this seed candidate
success = _confirmer.Confirm(seed, strategy, bfield);
if (!success) continue;
- nconfirm++;
-// System.out.println("Confirmed a seed candidate");
// Try to extend each confirmed seed candidates to make a track candidate
List<SeedCandidate> confirmedlist = _confirmer.getResult();
- nconseeds += confirmedlist.size();
for (SeedCandidate confirmedseed : confirmedlist) {
// See if we can extend this seed candidate
_confirmer.Extend(confirmedseed, strategy, bfield, _trackseeds);
}
-// System.out.println("npair: " + npairs + " Good Pairs: " + ngdpairs +
-// " ntrip: " + ntrip + " nseed: " + nseed);
-// System.out.println("confirmed: " + nconfirm + " con seeds: " + nconseeds +
-// " extended: " + nextend + " ext seeds: " + nextseeds);
}
}
}
@@ -143,7 +140,7 @@
// Done with track finding for this strategy
if (_diag != null)
- _diag.fireFinderDone(maxseeds, nseed, nfit, nconfirm, _trackseeds);
+ _diag.fireFinderDone(_trackseeds, mcp_seeds);
return _trackseeds.size() > 0;
}
lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.9 -r1.10
--- SeedTracker.java 7 Aug 2009 23:33:17 -0000 1.9
+++ SeedTracker.java 19 Aug 2009 22:12:27 -0000 1.10
@@ -80,7 +80,7 @@
// Sort the hits for this event
_hitmanager.OrganizeHits(event);
- // Clear the list of track seeds accumulated in the track finder
+ // Make sure that we have cleared the list of track seeds in the finder
_finder.clearTrackSeedList();
// Loop over strategies and perform track finding
@@ -95,11 +95,13 @@
// Get the list of final list of SeedCandidates
List<SeedCandidate> trackseeds = _finder.getTrackSeeds();
- if (_diag != null) _diag.fireFinalDiagnostics(trackseeds);
// Make tracks from the final list of track seeds
_maketracks.Process(event, trackseeds, _bfield);
+ // Clear the list of track seeds accumulated in the track finder
+ _finder.clearTrackSeedList();
+
return;
}
CVSspam 0.2.8