Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
HelicalTrackHitDriver.java | +472 | -136 | 1.2 -> 1.3 |
Use geometry and utils to build sensor stereo pairs.
diff -u -r1.2 -r1.3 --- HelicalTrackHitDriver.java 11 Apr 2013 19:16:06 -0000 1.2 +++ HelicalTrackHitDriver.java 12 Jul 2013 20:44:43 -0000 1.3 @@ -12,6 +12,7 @@
import java.util.Map; import org.lcsim.detector.IDetectorElement; import org.lcsim.detector.ITransform3D;
+import org.lcsim.detector.tracker.silicon.SiSensor;
import org.lcsim.detector.tracker.silicon.SiTrackerModule; import org.lcsim.digisim.MyLCRelation; import org.lcsim.event.EventHeader;
@@ -40,20 +41,14 @@
private List<String> _colnames = new ArrayList<String>(); private boolean _doTransformToTracking = true; private HPSTransformations _detToTrk = new HPSTransformations();
+ private SimpleDetector _det;
public enum LayerGeometryType {
- /* - * Each Layer in the geometry is a separate sensor - */
Split,
- /* - * Each layer in the geometry comprises top and bottom sensor - */
Common }
- private LayerGeometryType _layerGeometryType;
+ private LayerGeometryType _layerGeometryType = LayerGeometryType.Split;
public HelicalTrackHitDriver() {
- this.setLayerGeometryType("Common");
this.addCollection("StripClusterer_SiTrackerHitStrip1D"); } public void setLayerGeometryType(String geomType) {
@@ -96,141 +91,326 @@
public void process(EventHeader event) { //super.process(event);
- // Initialize the list of HelicalTrackHits - List<HelicalTrackCross> stereoCrosses = new ArrayList<HelicalTrackCross>(); - List<HelicalTrackHit> helhits = new ArrayList<HelicalTrackHit>(); - - // Create a List of LCRelations to relate HelicalTrackHits to the original hits - List<LCRelation> hitrelations = new ArrayList<LCRelation>(); - // Create a List of LCRelations to relate HelicalTrackHits to the MC particle - List<LCRelation> mcrelations = new ArrayList<LCRelation>();
+ + if(LayerGeometryType.Common==_layerGeometryType) { +
+ // Initialize the list of HelicalTrackHits + List<HelicalTrackCross> stereoCrosses = new ArrayList<HelicalTrackCross>(); + List<HelicalTrackHit> helhits = new ArrayList<HelicalTrackHit>();
+ // Create a List of LCRelations to relate HelicalTrackHits to the original hits + List<LCRelation> hitrelations = new ArrayList<LCRelation>(); + // Create a List of LCRelations to relate HelicalTrackHits to the MC particle + List<LCRelation> mcrelations = new ArrayList<LCRelation>();
- for (String _colname : this._colnames) {
- if (!event.hasCollection(SiTrackerHit.class, _colname)) { - continue; - }
- // Get the list of SiTrackerHits for this collection - List<SiTrackerHit> hitlist = (List<SiTrackerHit>) event.get(_colname); - if (_debug) { - System.out.printf("%s: found %d SiTrackerHits = ", this.getClass().getSimpleName(), hitlist.size()); - }
+ for (String _colname : this._colnames) {
- // 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>();
+ if (!event.hasCollection(SiTrackerHit.class, _colname)) { + continue; + } + + // Get the list of SiTrackerHits for this collection + List<SiTrackerHit> hitlist = (List<SiTrackerHit>) event.get(_colname); + if (_debug) { + System.out.printf("%s: found %d SiTrackerHits\n", this.getClass().getSimpleName(), hitlist.size()); + }
- for (SiTrackerHit hit : hitlist) {
+ // 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>(); + + for (SiTrackerHit hit : hitlist) { + + 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; + IDetectorElement de = h.getSensor(); + String id = this.makeID(_ID.getName(de), _ID.getLayer(de)); + + // This hit should be a on a stereo pair! + if (!_stereomap.containsKey(id) && !_stereomap.containsValue(id)) { + throw new RuntimeException(this.getClass().getSimpleName() + ": this " + id + " was not among the stereo modules!"); + }
- if (hit instanceof SiTrackerHitStrip1D) {
+ // Create a HelicalTrackStrip for this hit + HelicalTrackStrip strip = makeDigiStrip(h);
- // 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));
+ // 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 + 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()); + } + } + } else {
- // This hit should be a on a stereo pair! - if (!_stereomap.containsKey(id) && !_stereomap.containsValue(id)) { - throw new RuntimeException(this.getClass().getSimpleName() + ": this " + id + " was not among the stereo modules!");
+ // If not a 1D strip hit, make a pixel hit + HelicalTrackHit hit3d = this.makeDigi3DHit(hit); + helhits.add(hit3d); + hitrelations.add(new MyLCRelation(hit3d, hit));
}
- // Create a HelicalTrackStrip for this hit - HelicalTrackStrip strip = makeDigiStrip(h);
+ } // Loop over SiTrackerHits
- // 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 - stripmap.put(strip, h);
+ // Create a list of stereo hits + //List<HelicalTrackCross> stereohits = new ArrayList<HelicalTrackCross>();
- if (_debug) { - System.out.printf("%s: added strip (org=%s,umeas=%.3f) at layer %d with time %.3f\n", this.getClass().getSimpleName(), strip.origin().toString(), strip.umeas(), strip.layer(),strip.time());
+ if (_debug)System.out.printf("%s: Create stereo hits from %d strips \n", this.getClass().getSimpleName(), striplistmap.size()); + + // Loop over the stereo layer pairs + for (String id1 : _stereomap.keySet()) { + + // 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()); + } + + /* + * 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) { + 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)));
}
+
}
- } else {
- // If not a 1D strip hit, make a pixel hit - HelicalTrackHit hit3d = this.makeDigi3DHit(hit); - helhits.add(hit3d); - hitrelations.add(new MyLCRelation(hit3d, hit));
+ } // Loop over stereo pairs + + if (_debug) { + System.out.printf("%s: added %d stereo hits from %s collection \n", this.getClass().getSimpleName(), stereoCrosses.size(), _colname);
}
- } // Loop over SiTrackerHits
+ } // Loop over collection names
- // Create a list of stereo hits - //List<HelicalTrackCross> stereohits = new ArrayList<HelicalTrackCross>();
if (_debug) {
- System.out.println(this.getClass().getSimpleName() + ": Create stereo hits from " + striplistmap.size() + " strips (map size)");
+ 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 + helhits.addAll(stereoCrosses); + event.put(_outname, helhits, HelicalTrackHit.class, 0); + event.put(_hitrelname, hitrelations, LCRelation.class, 0); + event.put(_mcrelname, mcrelations, LCRelation.class, 0); + if (_doTransformToTracking) { + addRotatedHitsToEvent(event, stereoCrosses);
}
+ + } else if(LayerGeometryType.Split==_layerGeometryType) { + + // Initialize the list of HelicalTrackHits + List<HelicalTrackCross> stereoCrosses = new ArrayList<HelicalTrackCross>(); + List<HelicalTrackHit> helhits = new ArrayList<HelicalTrackHit>(); + + // Create a List of LCRelations to relate HelicalTrackHits to the original hits + List<LCRelation> hitrelations = new ArrayList<LCRelation>(); + // Create a List of LCRelations to relate HelicalTrackHits to the MC particle + List<LCRelation> mcrelations = new ArrayList<LCRelation>();
- // Loop over the stereo layer pairs - for (String id1 : _stereomap.keySet()) {
- // Get the second layer - String id2 = _stereomap.get(id1);
+ for (String _colname : this._colnames) { + + if (!event.hasCollection(SiTrackerHit.class, _colname)) { + continue; + } + + // Get the list of SiTrackerHits for this collection + List<SiTrackerHit> hitlist = (List<SiTrackerHit>) event.get(_colname);
if (_debug) {
- if (striplistmap.get(id1) != null && striplistmap.get(id2) != null) { - System.out.println(this.getClass().getSimpleName() + ": Form stereo hits from " + id1 + " and " + id2); - //for(HelicalTrackStrip strip: striplistmap.get(id1)) System.out.printf("%s: stripid1 at origin %s\n",this.getClass().getSimpleName(),strip.origin().toString()); - //for(HelicalTrackStrip strip: striplistmap.get(id2)) System.out.printf("%s: stripid2 at origin %s\n",this.getClass().getSimpleName(),strip.origin().toString()); - }
+ System.out.printf("%s: found %d SiTrackerHits\n", this.getClass().getSimpleName(), hitlist.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 - */ - - List<HelicalTrackCross> cross_list = _crosser.MakeHits(striplistmap.get(id1), striplistmap.get(id2)); - - for (HelicalTrackCross cross : cross_list) { - stereoCrosses.add(cross); - if (cross.getMCParticles() != null) { - for (MCParticle mcp : cross.getMCParticles()) { - mcrelations.add(new MyLCRelation((HelicalTrackHit) cross, mcp));
+ // 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) { + + 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);
}
+ + // This hit should be a on a stereo pair! + if(_det.findSensor(sensor)==false) { + throw new RuntimeException(this.getClass().getSimpleName() + ": this " +sensor.getName()+ " was not in the detector!?"); + } + + // Create a HelicalTrackStrip for this hit + HelicalTrackStrip strip = makeDigiStrip(h); + + 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()); + } + + } else { + + // If not a 1D strip hit, make a pixel hit + HelicalTrackHit hit3d = this.makeDigi3DHit(hit); + helhits.add(hit3d); + hitrelations.add(new MyLCRelation(hit3d, hit));
}
- for (HelicalTrackStrip strip : cross.getStrips()) { - hitrelations.add(new MyLCRelation(cross, stripmap.get(strip))); - }
+ } // 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 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()); +
}
- } // Loop over stereo pairs
+ for(StereoPair pair : _det.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...? + + + if((SvtUtils.getInstance().getLayerNumber(pair.getAxialSensor()) + SvtUtils.getInstance().getLayerNumber(pair.getStereoSensor())) % 2 ==0) { + throw new RuntimeException(String.format("%s: axial and stereo are both even layers (%d,%d)?!", + this.getClass().getSimpleName(),SvtUtils.getInstance().getLayerNumber(pair.getAxialSensor()), + SvtUtils.getInstance().getLayerNumber(pair.getStereoSensor()))); + } + + 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)); + + + 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(), cross_list.size(), + this.getClass().getSimpleName(), + pair.getAxialSensor().getName(),striplistmap.get(pair.getAxialSensor())==null?0:striplistmap.get(pair.getAxialSensor()).size(), + this.getClass().getSimpleName(), + pair.getStereoSensor().getName(),striplistmap.get(pair.getStereoSensor())==null?0:striplistmap.get(pair.getStereoSensor()).size()); + + + for (HelicalTrackCross cross : cross_list) { + 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))); + } + if (_debug) System.out.printf("%s: cross at %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0],cross.getPosition()[1],cross.getPosition()[2]); + + }
- if (_debug) { - System.out.printf("%s: added %d stereo hits from %s collection ", this.getClass().getSimpleName(), stereoCrosses.size(), _colname); - }
+ } // 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 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]); + } + }
- // Add things to the event - // Cast crosses to HTH - helhits.addAll(stereoCrosses); - event.put(_outname, helhits, HelicalTrackHit.class, 0); - event.put(_hitrelname, hitrelations, LCRelation.class, 0); - event.put(_mcrelname, mcrelations, LCRelation.class, 0); - if (_doTransformToTracking) { - addRotatedHitsToEvent(event, stereoCrosses);
+ // Add things to the event + // Cast crosses to HTH + helhits.addAll(stereoCrosses); + event.put(_outname, helhits, HelicalTrackHit.class, 0); + event.put(_hitrelname, hitrelations, LCRelation.class, 0); + event.put(_mcrelname, mcrelations, LCRelation.class, 0); + 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()
@@ -257,62 +437,57 @@
/* * Setup default pairing */
- if (_debug) { - System.out.printf("%s: Setup stereo hit pair modules ", 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."); }
- int nLayersTotal = detector.getSubdetector(subdetectorName).getLayering().getLayers().getNumberOfLayers(); - if (_debug) { - System.out.printf("%s: %d layers ", this.getClass().getSimpleName(), nLayersTotal); - } - if (nLayersTotal % 2 != 0) { - throw new RuntimeException(this.getClass().getName() + ": Don't know how to do stereo pairing for odd number of modules."); - } - if (this._layerGeometryType == LayerGeometryType.Split) { - int nLayers = nLayersTotal / 2; - for (int i = 1; i <= nLayers; ++i) { - int ly1 = i; - int ly2 = i + 10; - if (_debug) { - System.out.printf("%s: adding stereo pair from layer %d and %d ", this.getClass().getSimpleName(), ly1, ly2); - } - this.setStereoPair(subdetectorName, ly1, ly2);
+ + 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) { + + + int nLayersTotal = detector.getSubdetector(subdetectorName).getLayering().getLayers().getNumberOfLayers(); + if (_debug) { + System.out.printf("%s: %d layers \n", this.getClass().getSimpleName(), nLayersTotal); + } + if (nLayersTotal % 2 != 0) { + throw new RuntimeException(this.getClass().getName() + ": Don't know how to do stereo pairing for odd number of modules.");
}
- } else if (this._layerGeometryType == LayerGeometryType.Common) {
List<int[]> pairs = new ArrayList<int[]>(); for (int i = 1; i <= (nLayersTotal) - 1; i += 2) { int[] pair = {i, i + 1};
- if (_debug) { - System.out.println("Adding stereo pair: " + pair[0] + ", " + pair[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 ", 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) {
- if (_debug) { - System.out.println(this.getClass().getSimpleName() + ": makeDigiStrip--"); - } -
+
SiTrackerHitStrip1D local = h.getTransformedHit(TrackerHitType.CoordinateSystem.SENSOR); SiTrackerHitStrip1D global = h.getTransformedHit(TrackerHitType.CoordinateSystem.GLOBAL);
@@ -400,9 +575,170 @@
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 }
+ + + 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 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(); + } + + 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 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; + } + + 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; + } + } + + + + private static class StereoPair { + private int _layer=-1; + private SiSensor _axialSensor = null; + private SiSensor _stereoSensor = null; + + public StereoPair(int layer) { + this._layer = layer; + } + + public void setAxialSensor(SiSensor axialSensor) { + if(this._axialSensor!=null) throw new RuntimeException(String.format("Try to add another axial sensor to layer %d",_layer)); + this._axialSensor = axialSensor; + } + + public void setStereoSensor(SiSensor stereoSensor) { + if(this._stereoSensor!=null) throw new RuntimeException(String.format("Try to add another stereo sensor to layer %d",_layer)); + this._stereoSensor = stereoSensor; + } + + + public SiSensor getStereoSensor() { + return this._stereoSensor; + } + + + + public SiSensor getAxialSensor() { + return this._axialSensor; + } + public void setLayerNr(int _layer) { + this._layer = _layer; + } + + public int getLayerNr() { + return this._layer; + } + + private void print() { + String name_Ax = this.getAxialSensor()==null?"NONE":this.getAxialSensor().getName(); + String name_St = this.getStereoSensor()==null?"NONE":this.getStereoSensor().getName(); + System.out.printf("Layer %d Axial: %s StereoSensor: %s\n",getLayerNr(),name_Ax,name_St); + } + } + +
}
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