lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.22 -r1.23
--- HelicalTrackHitDriver.java 25 Aug 2008 21:43:31 -0000 1.22
+++ HelicalTrackHitDriver.java 2 Oct 2008 17:13:38 -0000 1.23
@@ -13,6 +13,7 @@
import hep.physics.vec.VecOp;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -25,12 +26,15 @@
import org.lcsim.contrib.onoprien.tracking.geom.sensortypes.Cylinder;
import org.lcsim.contrib.onoprien.tracking.hit.DigiTrackerHit;
import org.lcsim.contrib.onoprien.tracking.hit.TrackerCluster;
+import org.lcsim.contrib.onoprien.tracking.hitmaking.OldTrackerHit;
import org.lcsim.detector.DetectorElementStore;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.IDetectorElementContainer;
import org.lcsim.detector.ITransform3D;
import org.lcsim.detector.tracker.silicon.SiTrackerModule;
+import org.lcsim.digisim.MyLCRelation;
import org.lcsim.event.EventHeader;
+import org.lcsim.event.LCRelation;
import org.lcsim.event.MCParticle;
import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.SimTrackerHit;
@@ -76,9 +80,6 @@
* Digitized (SiTrackerHit)
*/
Digitized
-
-
-
}
private StereoHitMaker _crosser = new StereoHitMaker(10., 10.);
private HitIdentifier ID = new HitIdentifier();
@@ -87,6 +88,7 @@
private List<String> _bscol = new ArrayList<String>();
private List<String> _digcol = new ArrayList<String>();
private String _outname = "HelicalTrackHits";
+ private String _relname = "HelicalTrackHitRelations";
private Hep3Vector _uloc = new BasicHep3Vector(1., 0., 0.);
private Hep3Vector _vloc = new BasicHep3Vector(0., 1., 0.);
private Hep3Vector _zhat = new BasicHep3Vector(0., 0., 1.);
@@ -109,23 +111,26 @@
List<HelicalTrackHit> helhits = new ArrayList<HelicalTrackHit>();
Hep3Vector lz = new BasicHep3Vector(0., 0., 1.);
-
+ // Create a List of LCRelations to relate HelicalTrackHits to the original hits
+ List<LCRelation> hitrelations = new ArrayList<LCRelation>();
+
for (String colname : _bscol) {
List<TrackerHit> hitlist = (List<TrackerHit>) event.get(colname);
for (TrackerHit hit : hitlist) {
Hep3Vector pos = new BasicHep3Vector(hit.getPosition());
SymmetricMatrix cov = new SymmetricMatrix(3, hit.getCovMatrix(), true);
+ TrackerHit ohit = hit;
try {
//create a BaseTrackerHitMC from a BaseTrackerHit if necessary
if (!(hit instanceof BaseTrackerHitMC)){
- List<SimTrackerHit> thesehits = new ArrayList<SimTrackerHit>();
- List<RawTrackerHit> rawhits = (List<RawTrackerHit>)hit.getRawHits();
+ List<SimTrackerHit> thesehits = new ArrayList<SimTrackerHit>();
+ List<RawTrackerHit> rawhits = (List<RawTrackerHit>)hit.getRawHits();
for (RawTrackerHit raw : rawhits) {
- thesehits.addAll(raw.getSimTrackerHits());
+ thesehits.addAll(raw.getSimTrackerHits());
}
- hit = new BaseTrackerHitMC(hit.getPosition(), hit.getCovMatrix(),
- hit.getTime(), hit.getdEdx(), hit.getType(), thesehits);
+ hit = new BaseTrackerHitMC(hit.getPosition(), hit.getCovMatrix(),
+ hit.getTime(), hit.getdEdx(), hit.getType(), thesehits);
((BaseTrackerHitMC)hit).addRawTrackerHits(rawhits);
}
@@ -138,20 +143,21 @@
IDetectorElement de = cont.get(0);
String detname = ID.getName(de);
int lyr = ID.getLayer(de);
- BarrelEndcapFlag be = ID.getBarrelEndcapFlag(de);
-
+ BarrelEndcapFlag be = ID.getBarrelEndcapFlag(de);
+
//Kludgy fix for layer numbering in sid01
if (!(detname.indexOf("Vertex") ==-1 && detname.indexOf("Vtx") == -1) && be.isEndcap()) {
if (event.getDetectorName().indexOf("planar")==-1) {
-// System.out.println(detname);
-// System.out.println("Layer divided by two");
- lyr/=2;
+// System.out.println(detname);
+// System.out.println("Layer divided by two");
+ lyr/=2;
}
}
HelicalTrackHit hthit = new HelicalTrack3DHit(pos, cov, hit.getdEdx(), hit.getTime(), hit.getRawHits(),
detname, lyr, ID.getBarrelEndcapFlag(de));
for (MCParticle p : ((BaseTrackerHitMC)hit).mcParticles()) hthit.addMCParticle(p);
+ hitrelations.add(new MyLCRelation(hthit, ohit));
helhits.add(hthit);
}
@@ -159,6 +165,7 @@
System.out.println("Warning, could not complete Identification for smeared hits. Reason: "+e.getMessage());
HelicalTrackHit hthit = new HelicalTrack3DHit(pos, cov, hit.getdEdx(), hit.getTime(),
hit.getRawHits(), "Unknown", 0, BarrelEndcapFlag.BARREL);
+ hitrelations.add(new MyLCRelation(hthit, ohit));
helhits.add(hthit);
}
}
@@ -170,8 +177,9 @@
// Get the segmentation manager if we haven't already done so
if (_segman == null) _segman = (SegmentationManager) event.get("SegmentationManager");
- // Make a list of stereo strips
- List<HelicalTrackStrip> striplist = new ArrayList<HelicalTrackStrip>();
+ // Make a mapping between the stereo strips and corresponding hits
+ Map<HelicalTrackStrip, org.lcsim.contrib.onoprien.tracking.hit.TrackerHit> stripmap =
+ new HashMap<HelicalTrackStrip, org.lcsim.contrib.onoprien.tracking.hit.TrackerHit>();
// Get the hit map that gives the list of hits on a particular sensor
Map<Sensor, List<org.lcsim.contrib.onoprien.tracking.hit.TrackerHit>> hitmap =
@@ -182,30 +190,43 @@
// Get a list of hits for this sensor and loop over the hits
List<org.lcsim.contrib.onoprien.tracking.hit.TrackerHit> sensorhits = hitmap.get(sensor);
for (org.lcsim.contrib.onoprien.tracking.hit.TrackerHit hit : sensorhits) {
+ // Convert to an old tracker hit for reference
+ ArrayList<TrackerCluster> parents = new ArrayList<TrackerCluster>(1);
+ parents.add(hit.getCluster());
// Check if we have a strip or pixel hit
if (sensor.getType().getHitDimension() == 1) {
// Strip hit - now check if this hit is part of a stereo pair
if (_segman.getStereoPartners(sensor) == null) {
// Isolated axial hit - convert it and add to the hit list
HelicalTrackHit axialhit = MakeAxialHit(hit);
- if (axialhit != null) helhits.add(axialhit);
+ if (axialhit != null) {
+ hitrelations.add(new MyLCRelation(axialhit, hit));
+ helhits.add(axialhit);
+ }
} else {
// Stereo hit - convert it and add it to the list of stereo strips
- striplist.add(MakeStrip(hit));
+ HelicalTrackStrip strip = MakeStrip(hit);
+ stripmap.put(strip, hit);
}
- } else
+ } else {
// Pixel hit - convert it and add to the hit list
- helhits.add(MakePixelHit(hit));
+ HelicalTrackHit pixelhit = MakePixelHit(hit);
+ hitrelations.add(new MyLCRelation(pixelhit, hit));
+ helhits.add(pixelhit);
+ }
}
}
// Make the stereo hits
+ List<HelicalTrackStrip> striplist = new ArrayList<HelicalTrackStrip>(stripmap.keySet());
List<HelicalTrackCross> stereohits = _crosser.MakeHits(striplist);
- for (HelicalTrackHit hit : stereohits) {
+ for (HelicalTrackCross hit : stereohits) {
+ for (HelicalTrackStrip strip : hit.getStrips()) {
+ hitrelations.add(new MyLCRelation(hit, stripmap.get(strip)));
+ }
helhits.add(hit);
}
- }
-
+ }
for (String colname : _digcol) {
@@ -231,12 +252,12 @@
helhits.addAll(stereohits);
}
-
- // Put the HelicalTrackHits back into the event
- event.put(_outname, helhits,HelicalTrackHit.class,0);
+ // Put the HelicalTrackHits back into the event
+ event.put(_outname, helhits, HelicalTrackHit.class, 0);
+ event.put(_relname, hitrelations, LCRelation.class, 0);
return;
- }
+ }
/**
* Add a TrackerHit collection to be processed.
@@ -262,6 +283,11 @@
return;
}
+ public void RelationCollection(String relname) {
+ _relname = relname;
+ return;
+ }
+
private HelicalTrackHit MakeAxialHit(org.lcsim.contrib.onoprien.tracking.hit.TrackerHit hit) {
HelicalTrackStrip strip = MakeStrip(hit);
if (VecOp.cross(strip.v(), _zhat).magnitude() > _eps) return null;
@@ -348,7 +374,7 @@
}
return mcplist;
}
-
+
private HelicalTrackHit makeDigi3DHit(SiTrackerHit h) {
IDetectorElement de = h.getSensor();