4 modified files
lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.1 -r1.2
--- StereoHitMaker.java 2 Jul 2008 23:54:24 -0000 1.1
+++ StereoHitMaker.java 4 Jul 2008 00:07:08 -0000 1.2
@@ -49,7 +49,7 @@
HelicalTrackStrip strip2 = stripcol.get(j);
// Check that these strips are in the same detector and layer
- if (strip1.detector() != strip2.detector()) continue;
+ if (!strip1.detector().equals(strip2.detector())) continue;
if (strip1.layer() != strip2.layer()) continue;
if (strip1.BarrelEndcapFlag() != strip2.BarrelEndcapFlag()) continue;
@@ -62,21 +62,21 @@
if (VecOp.cross(strip1.w(), strip2.w()).magnitude() > _eps) continue;
// Check that the sensor seperation meets requirements
- double seperation = VecOp.dot(dp, strip1.w());
+ double seperation = Math.abs(VecOp.dot(dp, strip1.w()));
if (seperation > _maxsep) continue;
// Check that the strips aren't colinear'
double salpha = VecOp.dot(strip1.v(), strip2.u());
- if (salpha < _eps) continue;
-
+ if (Math.abs(salpha) < _eps) continue;
// Check if we can form a cross within tolerances
double v1 = VecOp.dot(dp, strip2.u()) / salpha;
if (v1 > strip1.vmax() + seperation * _tolerance) continue;
- if (v1 < strip1.vmax() - seperation * _tolerance) continue;
+ if (v1 < strip1.vmin() - seperation * _tolerance) continue;
double v2 = VecOp.dot(dp, strip1.u()) / salpha;
if (v2 > strip2.vmax() + seperation * _tolerance) continue;
- if (v2 < strip2.vmax() - seperation * _tolerance) continue;
+ if (v2 < strip2.vmin() - seperation * _tolerance) continue;
+
// Strip pair passes all requirements, make a new cross
crosscol.add(new HelicalTrackCross(strip1, strip2));
}
lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.3 -r1.4
--- HelicalTrackStrip.java 2 Jul 2008 23:54:24 -0000 1.3
+++ HelicalTrackStrip.java 4 Jul 2008 00:07:08 -0000 1.4
@@ -15,7 +15,6 @@
import org.lcsim.event.MCParticle;
import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
-import org.lcsim.event.TrackerHit;
/**
* Encapsulate strip information used to construct HelicalTrack2DHit and
@@ -77,11 +76,13 @@
double vmiddle = 0.5 * (_vmin + _vmax);
if (Math.abs(vmiddle) > _eps) {
// Relocate the origin to be at the center of the strip
- _origin = VecOp.add(origin, VecOp.mult(vmiddle, _v));
- _vmin += vmiddle;
- _vmax += vmiddle;
+ _origin = VecOp.sub(origin, VecOp.mult(vmiddle, _v));
+ _vmin -= vmiddle;
+ _vmax -= vmiddle;
}
+ assert(Math.abs(_vmin-_vmax)<_eps);
+
// Make sure that vmin < vmax
if (_vmin > _vmax) {
double vtemp = _vmin;
@@ -92,7 +93,7 @@
// Find the sensor normal and make sure it is pointing in the "outgoing" direction
_w = VecOp.cross(_u, _v);
if (VecOp.dot(_w, _origin) < 0) {
- VecOp.mult(-1., v);
+ _v = VecOp.mult(-1., _v);
_w = VecOp.cross(_u, _v);
}
}
lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.11 -r1.12
--- HelicalTrackHitDriver.java 2 Jul 2008 23:54:24 -0000 1.11
+++ HelicalTrackHitDriver.java 4 Jul 2008 00:07:08 -0000 1.12
@@ -15,16 +15,26 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.lcsim.contrib.SiStripSim.SiTrackerHit;
+import org.lcsim.contrib.SiStripSim.SiTrackerHitStrip1D;
+import org.lcsim.contrib.SiStripSim.TrackerHitType.CoordinateSystem;
import org.lcsim.contrib.onoprien.tracking.geom.SegmentationManager;
import org.lcsim.contrib.onoprien.tracking.geom.Sensor;
import org.lcsim.contrib.onoprien.tracking.hit.DigiTrackerHit;
import org.lcsim.contrib.onoprien.tracking.hit.TrackerCluster;
import org.lcsim.contrib.onoprien.tracking.hitmaking.hitmakers.TrackerHitMakerBasic;
-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.identifier.Identifier;
+import org.lcsim.detector.tracker.silicon.SiTrackerModule;
import org.lcsim.event.EventHeader;
import org.lcsim.event.MCParticle;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.SimTrackerHit;
import org.lcsim.event.TrackerHit;
+import org.lcsim.event.base.BaseTrackerHitMC;
import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
import org.lcsim.util.Driver;
@@ -96,10 +106,38 @@
for (TrackerHit hit : hitlist) {
Hep3Vector pos = new BasicHep3Vector(hit.getPosition());
SymmetricMatrix cov = new SymmetricMatrix(3, hit.getCovMatrix(), true);
- HelicalTrackHit hthit = new HelicalTrack3DHit(pos, cov, hit.getdEdx(), hit.getTime(),
- hit.getRawHits(), "Unknown", 0, BarrelEndcapFlag.BARREL);
-// addMCParticles(hit, hthit);
- helhits.add(hthit);
+
+ try {
+ SimTrackerHit simhit = ((BaseTrackerHitMC)hit).getSimHits().get(0);
+ IDetectorElementContainer cont = DetectorElementStore.getInstance().find(new Identifier(simhit.getCellID()));
+ if (cont.isEmpty()) {
+ throw new RuntimeException("Detector Container is empty!");
+ } else {
+ IDetectorElement de = cont.get(0);
+ String detname = ID.getName(de);
+ int lyr = ID.getLayer(de);
+
+ //if (detname.indexOf("ertex") > -1 && event.getDetectorName().indexOf("lanar") > -1)
+ // lyr--;
+
+ // if (lyr < 0 ) throw new RuntimeException("Oops... negative layer number");
+ 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);
+ helhits.add(hthit);
+ }
+
+ } catch(Exception e) {
+ 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);
+ helhits.add(hthit);
+ }
+
+
+
+
}
}
@@ -145,66 +183,40 @@
}
}
+
+ for (String colname : _digcol) {
+
+ List<SiTrackerHit> hitlist = (List<SiTrackerHit>) event.get(colname);
+ List<HelicalTrackStrip> strips = new ArrayList<HelicalTrackStrip>();
+ for (SiTrackerHit hit : hitlist) {
+
+ if (hit instanceof SiTrackerHitStrip1D) {
+ //determine if the hit is stereoed or not
+ SiTrackerHitStrip1D h = (SiTrackerHitStrip1D) hit;
+ SiTrackerModule m = (SiTrackerModule) hit.getSensor().getParent();
+
+ if (m.getChildren().size()==2) //stereo hit
+ strips.add(makeDigiStrip(h));
+ else helhits.add(makeDigiAxialHit(h)); //isolated hit
+ }
+ //for other types, make 3d hits
+ else helhits.add(makeDigi3DHit(hit));
+ }
+
+ //generate Stereo hits
+ List<HelicalTrackCross> stereohits = _crosser.MakeHits(strips);
+// System.out.println(stereohits.size());
+
+ helhits.addAll(stereohits);
+ }
+
// Put the HelicalTrackHits back into the event
event.put(_outname, helhits,HelicalTrackHit.class,0);
return;
}
- //Loop over the digitized collections ~Cosmin
-// for (String colname : _digcol){
-
- //grab the hits from the event
-// List<SiTrackerHit> hitlist = (List<SiTrackerHit>) event.get(colname);
-
-// for (SiTrackerHit hit : hitlist) {
-
-// DetectorIdentifierHelper id = hit.getIdentifierHelper();
-// IIdentifier detid = hit.getSensor().getIdentifier();
-
- //these are barrel strip hits
-// if (hit instanceof SiTrackerHitStrip1D) {
-
- //our current scheme only supports 2d hits in the barrel...
- //if there are 2d hits in the endcap, we'll ignore them
-// if(!id.isBarrel(detid)){
-// continue;
-// }
-
-// SiTrackerHitStrip1D h = (SiTrackerHitStrip1D) hit;
-
-// double z1 = h.getHitSegment().getPoints().get(0).z();
-// double z2 = h.getHitSegment().getPoints().get(1).z();
-// double zmin = Math.min(z1,z2);
-// double zmax = Math.max(z1,z2);
-
-// HelicalTrackHit hthit = new HelicalTrack2DHit(h, zmin, zmax);
-// addMCParticles(h, hthit);
-// helhits.add(hthit);
-// }
-
- //these are stereod strips and pixels
-// else if (hit instanceof SiTrackerHitStrip2D || hit instanceof SiTrackerHitPixel) {
-
-// BarrelEndcapFlag flag;
-
- //decide the flag
-// if(id.isBarrel(detid)) {
-// flag = BarrelEndcapFlag.BARREL;
-// } else if (id.isEndcapNegative(detid)) {
-// flag = BarrelEndcapFlag.ENDCAP_SOUTH;
-// } else if (id.isEndcapPositive(detid)) {
-// flag = BarrelEndcapFlag.ENDCAP_NORTH;
-// } else {
-// flag = BarrelEndcapFlag.UNKNOWN; //perhaps this should throw an error instead?
-// }
-// HelicalTrackHit hthit = new HelicalTrack3DHit(hit, flag);
-// addMCParticles(hit, hthit);
-// helhits.add(hthit);
-// }
-// }
-// }
-// }
+
/**
* Add a TrackerHit collection to be processed.
@@ -217,7 +229,7 @@
} else if (type == HitType.Smeared) {
_smcol.add(name);
} else if (type == HitType.Digitized)
-// _digcol.add(name);
+ _digcol.add(name);
return;
}
@@ -267,6 +279,7 @@
// Divide the layer number by 2 to get the stereo layer number
int lyr = ID.getLayer(de) / 2;
BarrelEndcapFlag beflag = ID.getBarrelEndcapFlag(de);
+
HelicalTrackStrip strip = new HelicalTrackStrip(org, u, v, umeas, du, vmin, vmax, dEdx, time, null,
det, lyr, beflag);
List<MCParticle> mcplist = getMCParticles(hit.getCluster());
@@ -298,21 +311,91 @@
if (mcp != null) mcplist.add(mcp);
}
}
-//<<<<<<< HelicalTrackHitDriver.java
return mcplist;
-//=======
- // This should work for anything subclassing BaseTrackerHit in
- // org.lcsim.contrib.SiStripSim, including all the SiTrackerHit classes
-// else if (hit instanceof BaseTrackerHit){
-// BaseTrackerHit bth = (BaseTrackerHit) hit;
-// for (MCParticle p : bth.getMCParticles()){
-// hthit.addMCParticle(p);
-// }
-// }
-// return;
-//>>>>>>> 1.10
}
+
+
+
+// private static final int[] LAYER_MAP = new int[]{0,1,2,0,1,2,3};
+ private HelicalTrackHit makeDigi3DHit(SiTrackerHit h) {
+
+ IDetectorElement de = h.getSensor();
+ int lyr = ID.getLayer(de)-1;
+ BarrelEndcapFlag be = ID.getBarrelEndcapFlag(de);
+
+ HelicalTrackHit hit = new HelicalTrack3DHit(h.getPositionAsVector(),
+ h.getCovarianceAsMatrix(), h.getdEdx(), h.getTime(),
+ h.getRawHits(), ID.getName(de), lyr, be);
+
+ for (MCParticle p : h.getMCParticles()) hit.addMCParticle(p);
+
+ return hit;
+
+ }
+
+ private HelicalTrackHit makeDigiAxialHit(SiTrackerHitStrip1D h){
+
+ double z1 = h.getHitSegment().getEndPoint().z();
+ double z2 = h.getHitSegment().getStartPoint().z();
+ double zmin = Math.min(z1,z2);
+ double zmax = Math.max(z1,z2);
+ IDetectorElement de = h.getSensor();
+
+ HelicalTrackHit hit = new HelicalTrack2DHit(h.getPositionAsVector(),
+ h.getCovarianceAsMatrix(), h.getdEdx(), h.getTime(),
+ h.getRawHits(), ID.getName(de), ID.getLayer(de)-1,
+ ID.getBarrelEndcapFlag(de), zmin, zmax);
+
+
+ for (MCParticle p : h.getMCParticles()) hit.addMCParticle(p);
+// System.out.println("DigiAxialHit made at "+h.getPositionAsVector().toString());
+ return hit;
+ }
+
+
+ private HelicalTrackStrip makeDigiStrip(SiTrackerHitStrip1D h){
+
+ SiTrackerHitStrip1D local = h.getTransformedHit(CoordinateSystem.SENSOR);
+ SiTrackerHitStrip1D global = h.getTransformedHit(CoordinateSystem.GLOBAL);
+
+ ITransform3D trans = local.getLocalToGlobal();
+ Hep3Vector org = trans.transformed(_orgloc);
+ Hep3Vector u = global.getMeasuredCoordinate();
+ Hep3Vector v = global.getUnmeasuredCoordinate();
+
+// System.out.println(local.getPositionAsVector().toString());
+// System.out.println("start: "+local.getHitSegment().getStartPoint().toString());
+// System.out.println("end: " + local.getHitSegment().getEndPoint().toString());
+// System.out.println("measured: "+local.getMeasuredCoordinate().toString());
+// System.out.println("unmeasured: "+local.getUnmeasuredCoordinate().toString());
+// System.out.println("length: "+local.getHitLength());
+// System.out.println("start dot measured: "+VecOp.dot(local.getUnmeasuredCoordinate(),local.getHitSegment().getStartPoint()));
+// System.out.println("end dot measured: "+VecOp.dot(local.getUnmeasuredCoordinate(),local.getHitSegment().getEndPoint()));
+// System.out.println();
+
+ 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)-1;
+ BarrelEndcapFlag be = ID.getBarrelEndcapFlag(de);
+ //if (!be.isBarrel()) lyr = LAYER_MAP[lyr-1];
+
+ 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);
+
+ for (MCParticle p : h.getMCParticles()) strip.addMCParticle(p);
+ return strip;
+ }
+
+
// Get the hits for this collection and loop over the hits
// List<TrackerHit> hitlist = (List<TrackerHit>) event.get(colname);
// for (TrackerHit hit : hitlist) {
@@ -419,4 +502,4 @@
// return;
// }
-}
\ No newline at end of file
+}
lcsim/src/org/lcsim/util/heprep
diff -u -r1.3 -r1.4
--- HelicalTrackHitConverter.java 3 Jul 2008 00:00:11 -0000 1.3
+++ HelicalTrackHitConverter.java 4 Jul 2008 00:07:08 -0000 1.4
@@ -16,6 +16,7 @@
import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.fit.helicaltrack.HelicalTrack2DHit;
import org.lcsim.fit.helicaltrack.HelicalTrack3DHit;
+import org.lcsim.fit.helicaltrack.HelicalTrackCross;
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
/**
@@ -43,6 +44,9 @@
type3d.addAttDef("dEdx", "Hit dEdx", "physics", "");
type3d.addAttDef("time", "Hit time", "physics", "");
type3d.addAttDef("flagValue", "BarrelEndcapFlag value","physics","");
+ type3d.addAttDef("drphi", "Hit drphi", "physics","");
+ type3d.addAttDef("dr", "Hit dr", "physics","");
+ type3d.addAttDef("hit identifier", "Hit identifier", "physics", "");
HepRepType type2d = factory.createHepRepType(typeTree,name+"2d");
type2d.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
@@ -52,6 +56,8 @@
type2d.addAttDef("time", "Hit time", "physics", "");
type2d.addAttDef("zmin", "Z min", "physics", "");
type2d.addAttDef("zmax", "Z max", "physics", "");
+ type2d.addAttDef("drphi", "Hit drphi", "physics","");
+ type2d.addAttDef("hit identifier", "Hit identifier", "physics", "");
HepRepType typeCenter = factory.createHepRepType(typeTree,name+"2dSegmentCenters");
typeCenter.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
@@ -62,17 +68,26 @@
typeCenter.addAttValue("MarkName","Box");
typeCenter.addAttDef("dEdx", "Hit dEdx", "physics", "");
typeCenter.addAttDef("time", "Hit time", "physics", "");
+ typeCenter.addAttDef("drphi", "Hit drphi", "physics","");
+
for (HelicalTrackHit hit : (List<HelicalTrackHit>)collection){
double[] pos = hit.getPosition();
- if (hit instanceof HelicalTrack3DHit) {
+ if (hit instanceof HelicalTrack3DHit || hit instanceof HelicalTrackCross) {
HepRepInstance instance = factory.createHepRepInstance(instanceTree,type3d);
instance.addAttValue("dEdx",hit.getdEdx());
instance.addAttValue("time",hit.getTime());
- String flagValue=((HelicalTrack3DHit)hit).BarrelEndcapFlag().toString();
+ String flagValue;
+ if (hit instanceof HelicalTrack3DHit)
+ flagValue=((HelicalTrack3DHit)hit).BarrelEndcapFlag().toString();
+ else
+ flagValue=((HelicalTrackCross)hit).BarrelEndcapFlag().toString();
instance.addAttValue("flagValue",flagValue);
+ instance.addAttValue("drphi",hit.drphi());
+ instance.addAttValue("dr",hit.dr());
+ instance.addAttValue("hit identifier",hit.getLayerIdentifier());
factory.createHepRepPoint(instance, pos[0], pos[1], pos[2]);
}
@@ -84,6 +99,8 @@
HelicalTrack2DHit hit2d = (HelicalTrack2DHit) hit;
instance2d.addAttValue("zmin", hit2d.zmin());
instance2d.addAttValue("zmax", hit2d.zmax());
+ instance2d.addAttValue("drphi",hit.drphi());
+ instance2d.addAttValue("hit identifier",hit.getLayerIdentifier());
HelicalTrack2DHit h = (HelicalTrack2DHit) hit;
factory.createHepRepPoint(instance2d, pos[0], pos[1], h.zmin());
factory.createHepRepPoint(instance2d, pos[0], pos[1], h.zmax());
@@ -91,6 +108,7 @@
HepRepInstance instanceCenter = factory.createHepRepInstance(instanceTree,typeCenter);
instanceCenter.addAttValue("dEdx",hit.getdEdx());
instanceCenter.addAttValue("time",hit.getTime());
+ instanceCenter.addAttValue("drphi",hit.drphi());
factory.createHepRepPoint(instanceCenter,pos[0],pos[1],pos[2]);
}
}
CVSspam 0.2.8