lcsim/src/org/lcsim/contrib/seedtracker/strategybuilder
diff -u -r1.7 -r1.8
--- RunStrategyBuilder.java 18 Aug 2008 18:54:05 -0000 1.7
+++ RunStrategyBuilder.java 27 Aug 2008 17:26:47 -0000 1.8
@@ -123,6 +123,8 @@
if (lwfn.length() > 0)
builder.setLayerWeight(LayerWeight.getLayerWeightFromFile(new File(lwfn)));
+
+ // if a non-default MCParticle Filter is set, then try to load it and assign it.
if (filterClassName.length() > 0){
try {
builder.setParticleFilter((IParticleFilter) Class.forName(filterClassName).newInstance());
@@ -141,6 +143,7 @@
}
}
+ // check data file existence
File file = new File(filename);
if (!file.exists()) {
System.out.println("Cannot find data file "+file.toString()+". Exiting. ");
@@ -152,6 +155,8 @@
System.out.println("Starting... Reading Geometry");
}
+
+ //load the driver and run it.
try {
LCSimLoop loop = new LCSimLoop();
lcsim/src/org/lcsim/contrib/seedtracker/strategybuilder
diff -u -r1.10 -r1.11
--- StrategyBuilder.java 18 Aug 2008 18:54:05 -0000 1.10
+++ StrategyBuilder.java 27 Aug 2008 17:26:47 -0000 1.11
@@ -86,8 +86,8 @@
}
}
- //In the process step, we build two maps lists of sets:
- // The set list is a list of the sets of layers hit by MCParticles hitting over 7 layers
+ //In the process step, we build two lists of collections:
+ // The set list is a list of the sets of layers hit by MCParticles hitting over min layers layers
// The adjacence list is a list of a list of hits that are determined to be adjacent based on MCParticle trajectory
@Override
protected void process(EventHeader event){
@@ -101,39 +101,8 @@
filter.setEvent(event);
- //Build MC Map from SimTrackerHits
- Map<MCParticle, List<SimTrackerHit>> mcmap = new HashMap<MCParticle, List<SimTrackerHit>>();
- List<SimTrackerHit> allhits = new ArrayList<SimTrackerHit>();
-
-
- for (List<SimTrackerHit> l : event.get(SimTrackerHit.class)) {
-
- /**
- * We simulate inefficiency in SimTrackerHit => TrackerHit conversion,
- * otherwise the strategies will miss certain classes of hits
- */
-
- EventHeader.LCMetaData meta = event.getMetaData(l);
- String readout = meta.getName();
- double efficiency = weighter.getReadoutEfficiency(readout);
- for (SimTrackerHit h : l) {
- if (random.nextDouble() < efficiency)
- allhits.add(h);
- }
- }
-
- for (SimTrackerHit h : allhits){
- MCParticle p = h.getMCParticle();
- List<SimTrackerHit> these_hits;
- if (mcmap.containsKey(p)) {
- these_hits = mcmap.get(p);
- } else {
- these_hits = new ArrayList<SimTrackerHit>();
- }
-
- these_hits.add(h);
- mcmap.put(p, these_hits);
- }
+ //Build MCMap from SimTrackerHits, including inefficiency modeling
+ Map<MCParticle, List<SimTrackerHit>> mcmap = buildMCMap(event);
//filter MCs
Iterator<MCParticle> mciter = mcmap.keySet().iterator();
@@ -148,7 +117,7 @@
for(List<SimTrackerHit> l : mcmap.values()) {
Set<DumbLayer> set = new HashSet<DumbLayer>();
- //sort by time, which allows creation of adjacent lists.
+ //sort by time, which allows creation of adjacence lists.
Collections.sort(l, new Comparator() {
public int compare(Object o1, Object o2) {
@@ -353,18 +322,9 @@
//if these layers aren't adjacent, just use the weights to figure out which layers to confirm with
if (adjacenceInfo == null || oldConfirm) {
//sort the list from smallest to largest weight. Use smallest weight(s) for confirmation layer(s).
- Collections.sort(dlyrlst, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- DumbLayer dl1 = (DumbLayer) o1;
- DumbLayer dl2 = (DumbLayer) o2;
- double s1 = weighter.getWeight(dl1);
- double s2 = weighter.getWeight(dl2);
- return Double.compare(s1, s2);
- }
- });
-
+ Collections.sort(dlyrlst, weighter.getComparator());
}
+
//If all layers are adjacent, we use either the first or last layers to confirm, depending on the layer weights
else if (adjacenceInfo.size() == dlyrlst.size()) {
dlyrlst = adjacenceInfo;
@@ -381,11 +341,18 @@
List<SeedLayer> lyrlst = new ArrayList<SeedLayer>();
- //get extension layers
- for (DumbLayer lyr : extendmap.get(s)){
- lyrlst.add(new SeedLayer(lyr.detectorName, lyr.layer, lyr.be, SeedType.Extend));
+ //get extension layers...sort from smallest weight to largest weight
+ // because the list will be reversed.
+ List<SeedLayer> extendlyr = new ArrayList<SeedLayer>();
+ List<DumbLayer> dumbextendlyr = new ArrayList<DumbLayer>();
+ dumbextendlyr.addAll(extendmap.get(s));
+ Collections.sort(dumbextendlyr, weighter.getComparator());
+
+ for (DumbLayer lyr : dumbextendlyr) {
+ extendlyr.add(new SeedLayer(lyr.detectorName, lyr.layer, lyr.be, SeedType.Extend));
}
+ lyrlst.addAll(extendlyr);
//get seed/confirmation layers
for (DumbLayer lyr : dlyrlst){
SeedType type;
@@ -484,8 +451,46 @@
symmetrize = set;
}
-
//========privates ============//
+ private Map<MCParticle, List<SimTrackerHit>> buildMCMap(EventHeader event) {
+
+ //Build MC Map from SimTrackerHits
+ Map<MCParticle, List<SimTrackerHit>> mcmap = new HashMap<MCParticle, List<SimTrackerHit>>();
+ List<SimTrackerHit> allhits = new ArrayList<SimTrackerHit>();
+
+
+ for (List<SimTrackerHit> l : event.get(SimTrackerHit.class)) {
+
+ /**
+ * We simulate inefficiency in SimTrackerHit => TrackerHit conversion,
+ * otherwise the strategies will miss certain classes of hits
+ */
+
+ EventHeader.LCMetaData meta = event.getMetaData(l);
+ String readout = meta.getName();
+ double efficiency = weighter.getReadoutEfficiency(readout);
+ for (SimTrackerHit h : l) {
+ if (random.nextDouble() < efficiency) {
+ allhits.add(h);
+ }
+ }
+ }
+
+ for (SimTrackerHit h : allhits) {
+ MCParticle p = h.getMCParticle();
+ List<SimTrackerHit> these_hits;
+ if (mcmap.containsKey(p)) {
+ these_hits = mcmap.get(p);
+ } else {
+ these_hits = new ArrayList<SimTrackerHit>();
+ }
+
+ these_hits.add(h);
+ mcmap.put(p, these_hits);
+ }
+
+ return mcmap;
+ }
private boolean startingCanFind(Set<DumbLayer> set){
lcsim/src/org/lcsim/contrib/seedtracker/strategybuilder
diff -u -r1.7 -r1.8
--- LayerWeight.java 18 Aug 2008 18:54:05 -0000 1.7
+++ LayerWeight.java 27 Aug 2008 17:26:48 -0000 1.8
@@ -9,6 +9,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -174,6 +175,19 @@
}
+ public Comparator getComparator(){
+ return new Comparator(){
+ public int compare(Object o1, Object o2) {
+ DumbLayer dl1 = (DumbLayer) o1;
+ DumbLayer dl2 = (DumbLayer) o2;
+ double s1 = LayerWeight.this.getWeight(dl1);
+ double s2 = LayerWeight.this.getWeight(dl2);
+ return Double.compare(s1, s2);
+ }
+ };
+ }
+
+
/**
* Loads LayerWeight definitions from the specified input stream
* @param in an input stream corresponding to a valid XML file
lcsim/src/org/lcsim/contrib/seedtracker/strategybuilder
diff -u -r1.4 -r1.5
--- DefaultLayerWeight.java 18 Aug 2008 18:54:05 -0000 1.4
+++ DefaultLayerWeight.java 27 Aug 2008 17:26:48 -0000 1.5
@@ -21,13 +21,26 @@
private LayerWeight weight;
public DefaultLayerWeight(String detectorName){
try {
+
+ // This is kind of screwy: if the detector name has a period in it,
+ // then loading the resource would normally throw an exception.
+ // We can fix this by replacing "." with "%2E" (URL encoding).
+ // It's probably best to avoid having periods in detector names
+ // though.
+
+ detectorName = detectorName.replace(".","%2E");
weight = LayerWeight.getLayerWeightFromResource(LayerWeight.getDefaultResourcePrefix()+prefix+detectorName+suffix);
} catch(Exception e) {
System.out.println("WARNING: could not find default layer weights for detector "+detectorName+". Falling back to empty layer weights with possibly insane default parameters.");
weight = new LayerWeight();
}
}
-
+ /**
+ * Return the constructed weight for the detector.
+ * @return The default weight for the detector name specified in the
+ * constructor, or, if nothing is found, then an unmodified LayerWeight
+ * object.
+ */
public LayerWeight getWeight(){
return weight;
}