Commit in hps-java/src on MAIN | |||
main/java/org/lcsim/hps/recon/tracking/HelicalTrackHitDriver.java | +182 | -373 | 1.7 -> 1.8 |
test/java/org/lcsim/hps/recon/tracking/HelicalTrackHitDriverTest.java | +128 | added 1.1 | |
+310 | -373 |
Minor cleanup; Add a test for HelicalTrackHitDriver ... work in progress
diff -u -r1.7 -r1.8 --- HelicalTrackHitDriver.java 15 Oct 2013 00:33:53 -0000 1.7 +++ HelicalTrackHitDriver.java 17 Oct 2013 06:24:23 -0000 1.8 @@ -32,40 +32,41 @@
import org.lcsim.recon.tracking.digitization.sisim.TrackerHitType; /**
- *
+ *
* @author Mathew Graham <[log in to unmask]> * @author Per Hansson <[log in to unmask]> * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HelicalTrackHitDriver.java,v 1.7 2013/10/15 00:33:53 phansson Exp $
+ * @version $Id: HelicalTrackHitDriver.java,v 1.7 2013/10/15 00:33:53 phansson + * Exp $
*/ public class HelicalTrackHitDriver extends org.lcsim.fit.helicaltrack.HelicalTrackHitDriver {
- - // TODO: This driver needs to be cleaned up. The classes SimpleDetectors, Layers ... need to be removed - - private boolean _debug = false; - private double _clusterTimeCut = -99; // if negative, don't cut..otherwise, dt cut time in ns
+ + private boolean _debug = false; + private double _clusterTimeCut = -99; // if negative, don't cut..otherwise, + // dt cut time in ns
private String _subdetectorName = "Tracker";
-
+ private String _clusterCollectionName = "StripClusterer_SiTrackerHitStrip1D"; +
private Map<String, String> _stereomap = new HashMap<String, String>(); private List<String> _colnames = new ArrayList<String>();
- private boolean _doTransformToTracking = true; private SimpleDetector _det;
+ private boolean _doTransformToTracking = true; +
public enum LayerGeometryType {
- Split, - Common
+ Split, Common
}
+
private LayerGeometryType _layerGeometryType = LayerGeometryType.Split;
-
+
/** * Default Ctor */ public HelicalTrackHitDriver() { this.addCollection("StripClusterer_SiTrackerHitStrip1D"); }
- - - //--- Setters ---// - //---------------// -
+ + // --- Setters ---// + // ---------------// +
/** * * @param geomType
@@ -140,18 +141,18 @@
@Override public void process(EventHeader event) {
- //super.process(event);
- // Instantiate the list of HelicalTrackCrosses and HelicalTrackHits - List<HelicalTrackCross> stereoCrosses = new ArrayList<HelicalTrackCross>();
+ // Instantiate the list of HelicalTrackCrosses and HelicalTrackHits + List<HelicalTrackCross> stereoCrosses = new ArrayList<HelicalTrackCross>();
List<HelicalTrackHit> helhits = new ArrayList<HelicalTrackHit>();
-
+
// Create an LCRelation from a HelicalTrackHit to List<LCRelation> hitrelations = new ArrayList<LCRelation>();
- - // Create an LCRelation from a HelicalTrackHit to an MC particle used to create it
+ + // Create an LCRelation from a HelicalTrackHit to an MC particle used to + // create it
List<LCRelation> mcrelations = new ArrayList<LCRelation>();
-
+
RelationalTable hittomc = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); if (event.hasCollection(LCRelation.class, "SVTTrueHitRelations")) { List<LCRelation> trueHitRelations = event.get(LCRelation.class, "SVTTrueHitRelations");
@@ -161,21 +162,23 @@
} } }
- - if(LayerGeometryType.Common==_layerGeometryType) { -
+ + if (LayerGeometryType.Common == _layerGeometryType) { +
for (String _colname : this._colnames) {
- if (!event.hasCollection(SiTrackerHit.class, _colname)) continue;
+ if (!event.hasCollection(SiTrackerHit.class, _colname)) + continue;
- // Get the list of SiTrackerHits for this collection
+ // Get the list of SiTrackerHits for this collection
List<SiTrackerHit> hitlist = event.get(SiTrackerHit.class, _colname);
-
+
if (_debug) { System.out.printf("%s: found %d SiTrackerHits\n", this.getClass().getSimpleName(), hitlist.size()); }
- // Create collections for strip hits by layer and hit cross references
+ // Create collections for strip hits by layer and hit cross + // references
Map<String, List<HelicalTrackStrip>> striplistmap = new HashMap<String, List<HelicalTrackStrip>>(); Map<HelicalTrackStrip, SiTrackerHitStrip1D> stripmap = new HashMap<HelicalTrackStrip, SiTrackerHitStrip1D>();
@@ -183,13 +186,14 @@
if (hit instanceof SiTrackerHitStrip1D) {
- // Cast the hit as a 1D strip hit and find the identifier for the detector/layer combo
+ // Cast the hit as a 1D strip hit and find the + // identifier for the detector/layer combo
SiTrackerHitStrip1D h = (SiTrackerHitStrip1D) hit; IDetectorElement de = h.getSensor(); String id = this.makeID(_ID.getName(de), _ID.getLayer(de)); // This hit should be a on a stereo pair!
- // With our detector setup, when is this not true?
+ // With our detector setup, when is this not true?
if (!_stereomap.containsKey(id) && !_stereomap.containsValue(id)) { throw new RuntimeException(this.getClass().getSimpleName() + ": this " + id + " was not among the stereo modules!"); }
@@ -202,30 +206,32 @@
} }
- // Get the list of strips for this layer - create a new list if one doesn't already exist
+ // Get the list of strips for this layer - create a new + // list if one doesn't already exist
List<HelicalTrackStrip> lyrhits = striplistmap.get(id); if (lyrhits == null) { lyrhits = new ArrayList<HelicalTrackStrip>(); striplistmap.put(id, lyrhits); }
- - if ((_clusterTimeCut > 0 && Math.abs(h.getTime()) < _clusterTimeCut)||_clusterTimeCut<0) { - // Add the strip to the list of strips on this sensor - lyrhits.add(strip);
- // Map a reference back to the hit needed to create the stereo hit LC relations
+ if ((_clusterTimeCut > 0 && Math.abs(h.getTime()) < _clusterTimeCut) || _clusterTimeCut < 0) { + // Add the strip to the list of strips on this + // sensor + lyrhits.add(strip); + + // Map a reference back to the hit needed to create + // the stereo hit LC relations
stripmap.put(strip, h); if (_debug) {
- System.out.printf("%s: added strip org %s layer %d\n", - this.getClass().getSimpleName(), strip.origin().toString(), strip.layer());
+ System.out.printf("%s: added strip org %s layer %d\n", this.getClass().getSimpleName(), strip.origin().toString(), strip.layer());
} } } else { // If not a 1D strip hit, make a pixel hit // This should be removed as it is never used.
- HelicalTrackHit hit3d = this.makeDigi3DHit(hit);
+ HelicalTrackHit hit3d = this.makeDigi3DHit(hit);
helhits.add(hit3d); hitrelations.add(new MyLCRelation(hit3d, hit)); }
@@ -233,29 +239,26 @@
} // Loop over SiTrackerHits
- // Create a list of stereo hits - //List<HelicalTrackCross> stereohits = new ArrayList<HelicalTrackCross>(); - - if (_debug)System.out.printf("%s: Create stereo hits from %d strips \n", this.getClass().getSimpleName(), striplistmap.size());
+ if (_debug) + System.out.printf("%s: Create stereo hits from %d strips \n", this.getClass().getSimpleName(), striplistmap.size());
- // Loop over the stereo layer pairs - // TODO: Change this so that it makes use of StereoPairs
+ // Loop over the stereo layer pairs + // TODO: Change this so that it makes use of StereoPairs
for (String id1 : _stereomap.keySet()) {
- // Get the second layer
+ // Get the second layer
String id2 = _stereomap.get(id1); if (_debug) {
- System.out.printf("%s: Form stereo hits from sensor id %s with %d hits and %s with %d hits\n", - this.getClass().getSimpleName(),id1, - striplistmap.get(id1)==null?0:striplistmap.get(id1).size(),id2,striplistmap.get(id2)==null?0:striplistmap.get(id2).size());
+ System.out.printf("%s: Form stereo hits from sensor id %s with %d hits and %s with %d hits\n", this.getClass().getSimpleName(), id1, striplistmap.get(id1) == null ? 0 + : striplistmap.get(id1).size(), id2, striplistmap.get(id2) == null ? 0 : striplistmap.get(id2).size());
} /*
- * Form the stereo hits and add them to our hit list Add LC - * relations for stereo hit to SiTrackHitStrip1D object Add LC - * relation between MC particle and stereo hit - */
+ * Form the stereo hits and add them to our hit list Add LC + * relations for stereo hit to SiTrackHitStrip1D object Add + * LC relation between MC particle and stereo hit + */
List<HelicalTrackCross> cross_list = _crosser.MakeHits(striplistmap.get(id1), striplistmap.get(id2)); for (HelicalTrackCross cross : cross_list) {
@@ -276,16 +279,14 @@
System.out.printf("%s: added %d stereo hits from %s collection \n", this.getClass().getSimpleName(), stereoCrosses.size(), _colname); }
-
} // End of loop over collection names
-
if (_debug) {
- System.out.printf("%s: totally added %d stereo hits:\n", this.getClass().getSimpleName(), stereoCrosses.size()); - for(HelicalTrackCross cross : stereoCrosses) { - System.out.printf("%s: %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0],cross.getPosition()[1],cross.getPosition()[2]); - }
+ System.out.printf("%s: totally added %d stereo hits:\n", this.getClass().getSimpleName(), stereoCrosses.size()); + for (HelicalTrackCross cross : stereoCrosses) { + System.out.printf("%s: %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0], cross.getPosition()[1], cross.getPosition()[2]);
}
+ }
// Add things to the event // Cast crosses to HTH
@@ -296,173 +297,128 @@
if (_doTransformToTracking) { addRotatedHitsToEvent(event, stereoCrosses); }
- - } else if(LayerGeometryType.Split==_layerGeometryType) { - - - for (String _colname : this._colnames) {
- if (!event.hasCollection(SiTrackerHit.class, _colname)) continue;
+ } else if (LayerGeometryType.Split == _layerGeometryType) {
- // Get the list of SiTrackerHits for this collection - List<SiTrackerHit> hitlist = event.get(SiTrackerHit.class, _colname); - - if (_debug) { - System.out.printf("%s: found %d SiTrackerHits\n", this.getClass().getSimpleName(), hitlist.size());
+ // If the event does not have hit clusters, skip it. + if (!event.hasCollection(SiTrackerHit.class, _clusterCollectionName)){ + if(_debug){ + System.out.println("Event: " + event.getRunNumber() + " does not contain the collection " + _clusterCollectionName);
}
+ return; + }
- // Create collections for strip hits by layer and hit cross references - //Map<String, List<HelicalTrackStrip>> striplistmap = new HashMap<String, List<HelicalTrackStrip>>(); - Map<HelicalTrackStrip, SiTrackerHitStrip1D> stripmap = new HashMap<HelicalTrackStrip, SiTrackerHitStrip1D>(); - Map<SiSensor, List<HelicalTrackStrip>> striplistmap = new HashMap<SiSensor, List<HelicalTrackStrip>>(); - for (SiTrackerHit hit : hitlist) {
+ // Get the list of SiTrackerHits for this collection + List<SiTrackerHit> hitlist = event.get(SiTrackerHit.class, _clusterCollectionName);
- if (hit instanceof SiTrackerHitStrip1D) {
- // Cast the hit as a 1D strip hit and find the identifier for the detector/layer combo - SiTrackerHitStrip1D h = (SiTrackerHitStrip1D) hit; - SiSensor sensor = h.getSensor(); - - List<HelicalTrackStrip> hitsOnSensor = striplistmap.get(sensor); - - // If no hits on that sensor yet -> create the list - if(hitsOnSensor == null) { - hitsOnSensor = new ArrayList<HelicalTrackStrip>(); - striplistmap.put(sensor, hitsOnSensor); - }
+ if (_debug) { + System.out.printf("%s: found %d SiTrackerHits\n", this.getClass().getSimpleName(), hitlist.size()); + }
- // This hit should be a on a stereo pair! - //====> Is this check really necessary? - //if(_det.findSensor(sensor)==false) { - // throw new RuntimeException(this.getClass().getSimpleName() + ": this " +sensor.getName()+ " was not in the detector!?"); - //}
+ Map<HelicalTrackStrip, SiTrackerHitStrip1D> stripmap = new HashMap<HelicalTrackStrip, SiTrackerHitStrip1D>(); + Map<SiSensor, List<HelicalTrackStrip>> striplistmap = new HashMap<SiSensor, List<HelicalTrackStrip>>(); + for (SiTrackerHit hit : hitlist) {
- // Create a HelicalTrackStrip for this hit - HelicalTrackStrip strip = makeDigiStrip(h); - for (RawTrackerHit rth : h.getRawHits()) { - for (Object simHit : hittomc.allFrom(rth)) { - strip.addMCParticle(((SimTrackerHit) simHit).getMCParticle()); - } - }
+ if (hit instanceof SiTrackerHitStrip1D) {
- if ((_clusterTimeCut > 0 && Math.abs(h.getTime()) < _clusterTimeCut)||_clusterTimeCut<0) { - // Add the strip to the list of strips on this sensor - hitsOnSensor.add(strip);
+ // Cast the hit as a 1D strip hit and find the identifier + // for the detector/layer combo + SiTrackerHitStrip1D h = (SiTrackerHitStrip1D) hit; + SiSensor sensor = h.getSensor();
- // Map a reference back to the hit needed to create the stereo hit LC relations - stripmap.put(strip, h);
+ List<HelicalTrackStrip> hitsOnSensor = striplistmap.get(sensor); + + // If no hits on that sensor yet -> create the list + if (hitsOnSensor == null) { + hitsOnSensor = new ArrayList<HelicalTrackStrip>(); + striplistmap.put(sensor, hitsOnSensor); + }
- if (_debug) System.out.printf("%s: added strip org %s layer %d\n", - this.getClass().getSimpleName(), strip.origin().toString(), strip.layer());
+ // Create a HelicalTrackStrip for this hit + HelicalTrackStrip strip = makeDigiStrip(h); + for (RawTrackerHit rth : h.getRawHits()) { + for (Object simHit : hittomc.allFrom(rth)) { + strip.addMCParticle(((SimTrackerHit) simHit).getMCParticle());
}
- - } else {
+ }
- // If not a 1D strip hit, make a pixel hit - // This should be removed. - HelicalTrackHit hit3d = this.makeDigi3DHit(hit); - helhits.add(hit3d); - hitrelations.add(new MyLCRelation(hit3d, hit));
+ if ((_clusterTimeCut > 0 && Math.abs(h.getTime()) < _clusterTimeCut) || _clusterTimeCut < 0) { + // Add the strip to the list of strips on this sensor + hitsOnSensor.add(strip); + + // Map a reference back to the hit needed to create the + // stereo hit LC relations + stripmap.put(strip, h); + + if (_debug) + System.out.printf("%s: added strip org %s layer %d\n", this.getClass().getSimpleName(), strip.origin().toString(), strip.layer());
}
- } // Loop over SiTrackerHits
+ } else {
- // Create a list of stereo hits - //List<HelicalTrackCross> stereohits = new ArrayList<HelicalTrackCross>();
+ // If not a 1D strip hit, make a pixel hit + // This should be removed. + HelicalTrackHit hit3d = this.makeDigi3DHit(hit); + helhits.add(hit3d); + hitrelations.add(new MyLCRelation(hit3d, hit)); + } + } // Loop over SiTrackerHits + + + // for(StereoPair pair : _det.getStereoPairs()) { + for (StereoPair stereoPair : SvtUtils.getInstance().getStereoPairs()) {
/*
- if (_debug) { - System.out.printf("%s: Create stereo hits from %d sensors being hit \n", this.getClass().getSimpleName(), striplistmap.size()); - System.out.printf("%s: %d and %d stereo pairs in top and bottom resp. and %d together\n", - this.getClass().getSimpleName(), _det._top.getStereoPairs().size(),_det._bot.getStereoPairs().size(),_det.getStereoPairs().size()); - - }*/ - -// for(StereoPair pair : _det.getStereoPairs()) { - for(StereoPair stereoPair : SvtUtils.getInstance().getStereoPairs()){ - - /* - * Form the stereo hits and add them to our hit list Add LC - * relations for stereo hit to SiTrackHitStrip1D object Add LC - * relation between MC particle and stereo hit - */ - - // this is really stupid but the cross get layer name based on the first strip in the argument - // turns out that this is the uneven one and many places depends on this e.g. seeding so we keep it - // for now. Obviously not the right way to do stuff I think, the stereo layer and sensor layer should - // be decoupled...? - // - // They should ... - - // Is this check really necessary? This is guaranteed by the manner in which stereo pairs are created. - // If anything, this really belongs in a unit test. - if((SvtUtils.getInstance().getLayerNumber(stereoPair.getAxialSensor()) + SvtUtils.getInstance().getLayerNumber(stereoPair.getStereoSensor())) % 2 ==0) { - throw new RuntimeException(String.format("%s: axial and stereo are both even layers (%d,%d)?!", - this.getClass().getSimpleName(),SvtUtils.getInstance().getLayerNumber(stereoPair.getAxialSensor()), - SvtUtils.getInstance().getLayerNumber(stereoPair.getStereoSensor()))); - } - - - List<HelicalTrackCross> helicalTrackCrosses = null; - if(stereoPair.getDetectorVolume() == detectorVolume.Top){ - helicalTrackCrosses = _crosser.MakeHits(striplistmap.get(stereoPair.getAxialSensor()), striplistmap.get(stereoPair.getStereoSensor())); - } else if(stereoPair.getDetectorVolume() == detectorVolume.Bottom){ - helicalTrackCrosses = _crosser.MakeHits(striplistmap.get(stereoPair.getStereoSensor()), striplistmap.get(stereoPair.getAxialSensor())); - } - - /* - SiSensor s1,s2; - - if(SvtUtils.getInstance().getLayerNumber(pair.getAxialSensor()) % 2 ==0) { - s2 = pair.getAxialSensor(); - s1 = pair.getStereoSensor(); - } else { - s1 = pair.getAxialSensor(); - s2 = pair.getStereoSensor(); - } - List<HelicalTrackCross> cross_list = _crosser.MakeHits(striplistmap.get(s1), striplistmap.get(s2)); */
+ * Form the stereo hits and add them to our hit list Add LC + * relations for stereo hit to SiTrackHitStrip1D object Add LC + * relation between MC particle and stereo hit + */ + + // Is this check really necessary? This is guaranteed by the + // manner in which stereo pairs are created. + // If anything, this really belongs in a unit test. + if ((SvtUtils.getInstance().getLayerNumber(stereoPair.getAxialSensor()) + SvtUtils.getInstance().getLayerNumber(stereoPair.getStereoSensor())) % 2 == 0) { + throw new RuntimeException(String.format("%s: axial and stereo are both even layers (%d,%d)?!", this.getClass().getSimpleName(), + SvtUtils.getInstance().getLayerNumber(stereoPair.getAxialSensor()), SvtUtils.getInstance().getLayerNumber(stereoPair.getStereoSensor()))); + }
- - if (_debug) System.out.printf("%s: Found %d stereo hits from sensors\n%s: %s : %d hits\n%s: %s with %d hits\n", - this.getClass().getSimpleName(), helicalTrackCrosses.size(), - this.getClass().getSimpleName(), - stereoPair.getAxialSensor().getName(),striplistmap.get(stereoPair.getAxialSensor())==null?0:striplistmap.get(stereoPair.getAxialSensor()).size(), - this.getClass().getSimpleName(), - stereoPair.getStereoSensor().getName(),striplistmap.get(stereoPair.getStereoSensor())==null?0:striplistmap.get(stereoPair.getStereoSensor()).size()); - - - for (HelicalTrackCross cross : helicalTrackCrosses) { - stereoCrosses.add(cross); - if (cross.getMCParticles() != null) { - for (MCParticle mcp : cross.getMCParticles()) { - mcrelations.add(new MyLCRelation((HelicalTrackHit) cross, mcp)); - } - } - for (HelicalTrackStrip strip : cross.getStrips()) { - hitrelations.add(new MyLCRelation(cross, stripmap.get(strip)));
+ List<HelicalTrackCross> helicalTrackCrosses = null; + if (stereoPair.getDetectorVolume() == detectorVolume.Top) { + helicalTrackCrosses = _crosser.MakeHits(striplistmap.get(stereoPair.getAxialSensor()), striplistmap.get(stereoPair.getStereoSensor())); + } else if (stereoPair.getDetectorVolume() == detectorVolume.Bottom) { + helicalTrackCrosses = _crosser.MakeHits(striplistmap.get(stereoPair.getStereoSensor()), striplistmap.get(stereoPair.getAxialSensor())); + } + + if (_debug) + System.out.printf("%s: Found %d stereo hits from sensors\n%s: %s : %d hits\n%s: %s with %d hits\n", this.getClass().getSimpleName(), helicalTrackCrosses.size(), this.getClass() + .getSimpleName(), stereoPair.getAxialSensor().getName(), striplistmap.get(stereoPair.getAxialSensor()) == null ? 0 : striplistmap.get(stereoPair.getAxialSensor()).size(), + this.getClass().getSimpleName(), stereoPair.getStereoSensor().getName(), + striplistmap.get(stereoPair.getStereoSensor()) == null ? 0 : striplistmap.get(stereoPair.getStereoSensor()).size()); + + for (HelicalTrackCross cross : helicalTrackCrosses) { + stereoCrosses.add(cross); + if (cross.getMCParticles() != null) { + for (MCParticle mcp : cross.getMCParticles()) { + mcrelations.add(new MyLCRelation((HelicalTrackHit) cross, mcp));
}
- if (_debug) System.out.printf("%s: cross at %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0],cross.getPosition()[1],cross.getPosition()[2]); -
}
+ for (HelicalTrackStrip strip : cross.getStrips()) { + hitrelations.add(new MyLCRelation(cross, stripmap.get(strip))); + } + if (_debug) + System.out.printf("%s: cross at %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0], cross.getPosition()[1], cross.getPosition()[2]);
- } // Loop over stereo pairs - - if (_debug) { - System.out.printf("%s: added %d stereo hits from %s collection:\n", this.getClass().getSimpleName(), stereoCrosses.size(), _colname); - //for(HelicalTrackCross cross : stereoCrosses) { - // System.out.printf("%s: %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0],cross.getPosition()[1],cross.getPosition()[2]); - //}
}
- - } // Loop over collection names
+ } // Loop over stereo pairs
if (_debug) {
- System.out.printf("%s: totally added %d stereo hits:\n", this.getClass().getSimpleName(), stereoCrosses.size()); - for(HelicalTrackCross cross : stereoCrosses) { - System.out.printf("%s: %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0],cross.getPosition()[1],cross.getPosition()[2]); - }
+ System.out.printf("%s: totally added %d stereo hits:\n", this.getClass().getSimpleName(), stereoCrosses.size()); + for (HelicalTrackCross cross : stereoCrosses) { + System.out.printf("%s: %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0], cross.getPosition()[1], cross.getPosition()[2]);
}
+ }
// Add things to the event // Cast crosses to HTH
@@ -473,15 +429,10 @@
if (_doTransformToTracking) { addRotatedHitsToEvent(event, stereoCrosses); }
+ + }
- - } else { - System.out.printf("geometry from %s\n",LayerGeometryType.Common==_layerGeometryType ? "Common" : (LayerGeometryType.Split==_layerGeometryType ? "Split" : "Unknown")); - System.out.printf("This layer geometry type is not supported\n"); - System.exit(1); - //throw new TypeNotPresentException("This layer geometry type is not supported",null); - } - } //Process()
+ } // Process()
public void addCollection(String colname) { _colnames.add(colname);
@@ -502,37 +453,22 @@
@Override protected void detectorChanged(Detector detector) {
- - /*
+ + /*
* Setup default pairing */
- if (_debug) System.out.printf("%s: Setup stereo hit pair modules \n", this.getClass().getSimpleName()); -
+ if (_debug) + System.out.printf("%s: Setup stereo hit pair modules \n", this.getClass().getSimpleName()); +
List<SiTrackerModule> modules = detector.getSubdetector(this._subdetectorName).getDetectorElement().findDescendants(SiTrackerModule.class);
-
+
if (modules.isEmpty()) { throw new RuntimeException(this.getClass().getName() + ": No SiTrackerModules found in detector."); }
- - - if (LayerGeometryType.Split==this._layerGeometryType) { - /* - - _det = new SimpleDetector(); - for(SiTrackerModule module : modules) { - - List<SiSensor> sensors = module.findDescendants(SiSensor.class); - - for(SiSensor sensor : sensors) { - _det.addSensor(sensor); - } - } - _det.print(); - */ - - } else if(LayerGeometryType.Common==this._layerGeometryType) { - -
+ + + if (LayerGeometryType.Common == this._layerGeometryType) { +
int nLayersTotal = detector.getSubdetector(_subdetectorName).getLayering().getLayers().getNumberOfLayers(); if (_debug) { System.out.printf("%s: %d layers \n", this.getClass().getSimpleName(), nLayersTotal);
@@ -542,26 +478,28 @@
} List<int[]> pairs = new ArrayList<int[]>(); for (int i = 1; i <= (nLayersTotal) - 1; i += 2) {
- int[] pair = {i, i + 1}; - if (_debug) System.out.printf("%s: Adding stereo pair: %d,%d\n",this.getClass().getSimpleName(), pair[0], pair[1]);
+ int[] pair = { i, i + 1 }; + if (_debug) + System.out.printf("%s: Adding stereo pair: %d,%d\n", this.getClass().getSimpleName(), pair[0], pair[1]);
pairs.add(pair); } for (int[] pair : pairs) {
- if (_debug) System.out.printf("%s: adding stereo pair from layer %d and %d \n", this.getClass().getSimpleName(), pair[0], pair[1]);
+ if (_debug) + System.out.printf("%s: adding stereo pair from layer %d and %d \n", this.getClass().getSimpleName(), pair[0], pair[1]);
setStereoPair(_subdetectorName, pair[0], pair[1]); }
-
+
} else { throw new RuntimeException(this.getClass().getSimpleName() + ": this layer geometry is not implemented!"); }
- if (_debug) System.out.printf("%s: %d stereo modules added", this.getClass().getSimpleName(), this._stereomap.size()); -
+ if (_debug) + System.out.printf("%s: %d stereo modules added", this.getClass().getSimpleName(), this._stereomap.size()); +
} private HelicalTrackStrip makeDigiStrip(SiTrackerHitStrip1D h) {
-
SiTrackerHitStrip1D local = h.getTransformedHit(TrackerHitType.CoordinateSystem.SENSOR); SiTrackerHitStrip1D global = h.getTransformedHit(TrackerHitType.CoordinateSystem.GLOBAL);
@@ -570,15 +508,11 @@
Hep3Vector u = global.getMeasuredCoordinate(); Hep3Vector v = global.getUnmeasuredCoordinate();
- -
double umeas = local.getPosition()[0]; double vmin = VecOp.dot(local.getUnmeasuredCoordinate(), local.getHitSegment().getStartPoint()); double vmax = VecOp.dot(local.getUnmeasuredCoordinate(), local.getHitSegment().getEndPoint()); double du = Math.sqrt(local.getCovarianceAsMatrix().diagonal(0));
- -
IDetectorElement de = h.getSensor(); String det = _ID.getName(de); int lyr = _ID.getLayer(de);
@@ -587,8 +521,7 @@
double dEdx = h.getdEdx(); double time = h.getTime(); List<RawTrackerHit> rawhits = h.getRawHits();
- HelicalTrackStrip strip = new HelicalTrackStrip(org, u, v, umeas, du, - vmin, vmax, dEdx, time, rawhits, det, lyr, be);
+ HelicalTrackStrip strip = new HelicalTrackStrip(org, u, v, umeas, du, vmin, vmax, dEdx, time, rawhits, det, lyr, be);
try { if (h.getMCParticles() != null) {
@@ -652,132 +585,8 @@
event.put("Rotated" + _outname, rotatedhits, HelicalTrackHit.class, 0); event.put("Rotated" + _hitrelname, hthrelations, LCRelation.class, 0); event.put("Rotated" + _mcrelname, mcrelations, LCRelation.class, 0);
-
- // Create the LCRelations between HelicalTrackHits and MC particles
+ // Create the LCRelations between HelicalTrackHits and MC particles
}
- - - @Deprecated - private static class SimpleDetector { - //private static final HelicalTrackHitDriver hthDriver = HelicalTrackHitDriver.this; - - private Layers _top = new Layers(); - private Layers _bot = new Layers(); - - private void addSensor(SiSensor sensor) { - if(SvtUtils.getInstance().isTopLayer(sensor) ) { - System.out.printf("Adding top sensor at tracker layer %d\n",getModuleLevelLayerNumber(sensor)); - _top.addSensor(sensor); - } else { - System.out.printf("Adding bot sensor at tracker layer %d\n",getModuleLevelLayerNumber(sensor)); - _bot.addSensor(sensor); - } - } - - private void checkDetector() { - if((_top._layers.size() % 2 != 0) || (_bot._layers.size() % 2 != 0) ) { - throw new RuntimeException("Uneven nr of sensors!?"); - } - } - - private boolean findSensor(SiSensor sensor) { - if(!_top.findSensor(sensor) && !_bot.findSensor(sensor)) { - return false; - } else { - return true; - } - } - - private List<StereoPair> getStereoPairs() { - List<StereoPair> list = _top.getStereoPairs(); - list.addAll(_bot.getStereoPairs()); - return list; - } - - private void print() { - System.out.printf("HelicalTrackHitDriver Stereo pair setup:\n"); - System.out.printf("Top half:\n"); - _top.print(); - System.out.printf("Bottom half:\n"); - _bot.print(); - } - - } - - - @Deprecated - private static int getModuleLevelLayerNumber(SiSensor sensor) { - int l = SvtUtils.getInstance().getLayerNumber(sensor); - - if(SvtUtils.getInstance().isTopLayer(sensor)) { - if (SvtUtils.getInstance().isAxial(sensor)) { - l = (l + 1)/2; - } else { - l = l/2; - } - } else { - if(SvtUtils.getInstance().isAxial(sensor)) { - l = l/2; - } else { - l = (l+1)/2; - } - } - return l; - } - - @Deprecated - private static class Layers { - - public List<StereoPair> _layers = new ArrayList<StereoPair>(); - - private StereoPair getLayer(int l) { - for(StereoPair layer : _layers) { - // if(layer.getLayerNr() == l) return layer; - } - return null; - } - - private void addLayer(StereoPair layer) { - // if(getLayer(layer.getLayerNr())!=null) throw new RuntimeException(String.format("Layer %d exists!",layer.getLayerNr())); - _layers.add(layer); - } - - private void addSensor(SiSensor sensor) { - - int l = getModuleLevelLayerNumber(sensor); - - StereoPair layer = getLayer(l); - if(layer==null) { - layer = new StereoPair(l); - _layers.add(layer); - } - boolean isAx = SvtUtils.getInstance().isAxial(sensor); - if(isAx) layer.setAxialSensor(sensor); - else layer.setStereoSensor(sensor); - - } - - private boolean findSensor(SiSensor sensor) { - for(StereoPair layer : _layers) { - if(layer.getAxialSensor().equals(sensor) || layer.getStereoSensor().equals(sensor)) { - return true; - } - } - return false; - } - - private void print() { - for(StereoPair l : _layers) { -// l.print(); - } - } - - private List<StereoPair> getStereoPairs() { - List<StereoPair> pairs = new ArrayList<StereoPair>(); - for(StereoPair layer : _layers) pairs.add(layer); - return pairs; - } - }
}
diff -N HelicalTrackHitDriverTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HelicalTrackHitDriverTest.java 17 Oct 2013 06:24:23 -0000 1.1 @@ -0,0 +1,128 @@
+package org.lcsim.hps.recon.tracking; + +import hep.aida.IHistogram1D; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.MalformedURLException; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import junit.framework.TestCase; + +import org.lcsim.event.EventHeader; +import org.lcsim.hps.monitoring.CalibrationDriver; +import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit; +import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D; +import org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup; +import org.lcsim.util.Driver; +import org.lcsim.util.loop.LCSimLoop; +import org.lcsim.util.aida.AIDA; +import org.lcsim.util.cache.FileCache; +import org.freehep.record.loop.RecordLoop.Command; +import org.lcsim.util.test.TestUtil.TestOutputFile; + + +/** + * + * @author Omar Moreno <[log in to unmask]> + * $Id: HelicalTrackHitDriverTest.java,v 1.1 2013/10/17 06:24:23 omoreno Exp $ + */ +public class HelicalTrackHitDriverTest extends TestCase { + + /** + * + */ + public void setUp() throws Exception { + System.out.println("setting up test"); + + // Input File + String testURLPath = "http://www.slac.stanford.edu/~phansson/files/hps_java_test/HPSTestRunv3/hps-java-1.7-SNAPSHOT-050113"; + String testFileName = "egs_5.5gev_0.016x0_500mb_recoil_recon_1_hpsTestRunTrackingTest.slcio"; + URL testURL = new URL(testURLPath + "/" + testFileName); + FileCache fileCache = new FileCache(); + File lcioInputFile = fileCache.getCachedFile(testURL); + int nEvents = 500; + + // Setup the drivers + HPSRawTrackerHitFitterDriver hitFitter = new HPSRawTrackerHitFitterDriver(); + hitFitter.setFitAlgorithm("Analytic"); + hitFitter.setCorrectT0Shift(true); + + // Process the input file + LCSimLoop lcsimLoop = new LCSimLoop(); + lcsimLoop.setLCIORecordSource(lcioInputFile); + lcsimLoop.add(new CalibrationDriver()); + lcsimLoop.add(new RawTrackerHitSensorSetup()); + lcsimLoop.add(hitFitter); + + HelicalTrackHitDriver hthDriver = new HelicalTrackHitDriver(); + hthDriver.setMaxSeperation(20.0); + hthDriver.setTolerance(1.0); + hthDriver.setLayerGeometryType("Common"); + + ComparisonPlotsDriver plotsDriver = new ComparisonPlotsDriver(); + + System.out.println("Running with Common geometry"); + lcsimLoop.add(hthDriver); + lcsimLoop.add(plotsDriver); + lcsimLoop.loop(nEvents, null); + lcsimLoop.execute(Command.REWIND); + lcsimLoop.remove(plotsDriver); + lcsimLoop.remove(hthDriver); + + System.out.println("Running with Split geometry"); + hthDriver.setLayerGeometryType("Split"); + lcsimLoop.add(hthDriver); + lcsimLoop.add(plotsDriver); + lcsimLoop.loop(nEvents, null); + lcsimLoop.dispose(); + + } + + class ComparisonPlotsDriver extends Driver { + + private AIDA aida = AIDA.defaultInstance(); + private IHistogram1D nTopClusters = aida.histogram1D("Number of Top Clusters", 20, 0, 20); + private IHistogram1D nBotClusters = aida.histogram1D("Number of Bottom Clusters", 20, 0, 20); + private String clusterCollectionName = "StripClusterer_SiTrackerHitStrip1D"; + private String outputFileName = "default.aida"; + + @Override + protected void process(EventHeader event) { + super.process(event); + + if(!event.hasCollection(SiTrackerHit.class, clusterCollectionName)); + + List<SiTrackerHit> clusters = event.get(SiTrackerHit.class, clusterCollectionName); + + } + + @Override + protected void endOfData(){ + super.endOfData(); + + File outputFile = new TestOutputFile(outputFileName); + try { + aida.saveAs(outputFile); + } catch(IOException exception){ + Logger.getLogger(ComparisonPlotsDriver.class.getName()).log(Level.SEVERE, "Unable to save to file " + outputFileName); + } + } + + + public void setOutputFileName(String outputFileName) { + this.outputFileName = outputFileName; + } + + } + + /** + * + */ + public void testLayerGeometry() { + } + +}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1