Author: [log in to unmask] Date: Thu Jun 9 19:36:52 2016 New Revision: 4401 Log: Allow subdetector name to be set in TrackerReconDriver and the classes it uses; apply code formatting Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/MaterialSupervisor.java java/trunk/tracking/src/main/java/org/hps/recon/tracking/SeedTracker.java java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackerReconDriver.java Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/MaterialSupervisor.java ============================================================================= --- java/trunk/tracking/src/main/java/org/hps/recon/tracking/MaterialSupervisor.java (original) +++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/MaterialSupervisor.java Thu Jun 9 19:36:52 2016 @@ -23,73 +23,75 @@ import org.lcsim.geometry.Detector; /** - * Material manager using the detector geometry. - * - * Uses a private class to set up detector volumes. This can probably make use - * of the DetectorGeometry classes from lcsim instead for the model. Something - * to consider in the future. + * Material manager using the detector geometry. Uses a private class to set up detector volumes. This can probably make + * use of the DetectorGeometry classes from lcsim instead for the model. Something to consider in the future. * * @author Per Hansson <[log in to unmask]> */ -public class MaterialSupervisor extends MaterialManager -{ +public class MaterialSupervisor extends MaterialManager { private List<ScatteringDetectorVolume> _detectorVolumes = new ArrayList<ScatteringDetectorVolume>(); - - public MaterialSupervisor() - { + private String subdetectorName = "Tracker"; + + public MaterialSupervisor() { super(); this._includeMS = true; - } - - public MaterialSupervisor(boolean includeMS) - { + } + + public MaterialSupervisor(boolean includeMS) { super(includeMS); } @Override - public void setDebug(boolean debug) - { + public void setDebug(boolean debug) { super.setDebug(debug); } - - public List<ScatteringDetectorVolume> getMaterialVolumes() - { + + public void setSubdetectorName(String subdetectorName) { + this.subdetectorName = subdetectorName; + } + + public List<ScatteringDetectorVolume> getMaterialVolumes() { return _detectorVolumes; } @Override - public void buildModel(Detector det) - { + public void buildModel(Detector det) { boolean local_debug = false; // super.buildModel(det); if (DEBUG || local_debug) { - System.out.printf("%s: ###########################################################\n", this.getClass().getSimpleName()); + System.out.printf("%s: ###########################################################\n", this.getClass() + .getSimpleName()); System.out.printf("%s: Build detector model\n", this.getClass().getSimpleName()); } - List<SiSensor> sensors = det.getSubdetector("Tracker").getDetectorElement().findDescendants(SiSensor.class); - // List<SiTrackerModule> modules = - // det.getDetectorElement().findDescendants(SiTrackerModule.class); + + List<SiSensor> sensors = det.getSubdetector(subdetectorName).getDetectorElement() + .findDescendants(SiSensor.class); + if (DEBUG || local_debug) { System.out.printf("%s: %d SiSensors:\n", this.getClass().getSimpleName(), sensors.size()); - System.out.printf("%s: %45s %35s %35s %35s %35s\n", this.getClass().getSimpleName(), "DE", "Origin", "u", "v", "w"); + System.out.printf("%s: %45s %35s %35s %35s %35s\n", this.getClass().getSimpleName(), "DE", "Origin", "u", + "v", "w"); } for (SiSensor module : sensors) { SiStripPlane plane = new SiStripPlane(module); if (DEBUG || local_debug) { - System.out.printf("%s: %45s %35s %35s %35s %35s\n", this.getClass().getSimpleName(), plane.getDetectorElement().getName(), plane.getGeometry().getPosition().toString(), plane.getMeasuredCoordinate().toString(), plane.getUnmeasuredCoordinate().toString(),plane.getPsidePlane().getNormal().toString()); + System.out.printf("%s: %45s %35s %35s %35s %35s\n", this.getClass().getSimpleName(), plane + .getDetectorElement().getName(), plane.getGeometry().getPosition().toString(), plane + .getMeasuredCoordinate().toString(), plane.getUnmeasuredCoordinate().toString(), plane + .getPsidePlane().getNormal().toString()); } _detectorVolumes.add(plane); } if (DEBUG || local_debug) { - System.out.printf("%s: ###########################################################\n", this.getClass().getSimpleName()); - } - } - - public interface ScatteringDetectorVolume - { + System.out.printf("%s: ###########################################################\n", this.getClass() + .getSimpleName()); + } + } + + public interface ScatteringDetectorVolume { public String getName(); @@ -103,8 +105,7 @@ } // public abstract class DetectorPlane extends SiSensor { - public interface DetectorPlane extends ScatteringDetectorVolume - { + public interface DetectorPlane extends ScatteringDetectorVolume { public double getThickness(); @@ -122,14 +123,12 @@ } - private abstract class SiPlane implements DetectorPlane - { + private abstract class SiPlane implements DetectorPlane { abstract void addMaterial(); } - public class SiStripPlane extends SiPlane - { + public class SiStripPlane extends SiPlane { private Hep3Vector _org = null; // origin private Hep3Vector _w = null; // normal to plane @@ -140,8 +139,7 @@ private double _length; private double _width; - public SiStripPlane(SiSensor module) - { + public SiStripPlane(SiSensor module) { _sensor = module; setOrigin(); setNormal(); @@ -153,39 +151,32 @@ } @Override - public IDetectorElement getDetectorElement() - { + public IDetectorElement getDetectorElement() { return getSensor(); } - private SiTrackerModule getModule() - { + private SiTrackerModule getModule() { return (SiTrackerModule) getGeometry().getDetectorElement().getParent(); } - private IGeometryInfo getGeometry() - { + private IGeometryInfo getGeometry() { return getSensor().getGeometry(); } - public SiSensor getSensor() - { + public SiSensor getSensor() { return _sensor; } - public Polygon3D getPsidePlane() - { + public Polygon3D getPsidePlane() { return getSensor().getBiasSurface(ChargeCarrier.HOLE); } - public Polygon3D getNsidePlane() - { + public Polygon3D getNsidePlane() { return getSensor().getBiasSurface(ChargeCarrier.ELECTRON); } @Override - public double getMaterialTraversed(Hep3Vector dir) - { + public double getMaterialTraversed(Hep3Vector dir) { // the distance inside the plane (note I don't care about sign of unit vector only // projection distance) double cth = Math.abs(VecOp.dot(dir, _w)); @@ -194,8 +185,7 @@ } @Override - public double getMaterialTraversedInRL(Hep3Vector dir) - { + public double getMaterialTraversedInRL(Hep3Vector dir) { // the distance inside the plane (note I don't care about sign of unit vector only // projection distance) double cth = Math.abs(VecOp.dot(dir, _w)); @@ -204,8 +194,7 @@ } @Override - protected void addMaterial() - { + protected void addMaterial() { IPhysicalVolume parent = getModule().getGeometry().getPhysicalVolume(); IPhysicalVolumeContainer daughters = parent.getLogicalVolume().getDaughters(); @@ -222,25 +211,21 @@ } } - public void addMaterial(String type, double density, double radLen, double t) - { + public void addMaterial(String type, double density, double radLen, double t) { _materials.add(type, density, radLen, t); } @Override - public double getThickness() - { + public double getThickness() { return _materials.getThickness(); } @Override - public double getThicknessInRL() - { + public double getThicknessInRL() { return _materials.getThicknessInRL(); } - private void setDimensions() - { + private void setDimensions() { // The dimensions are taken from the full module IPhysicalVolume physVol_parent = getModule().getGeometry().getPhysicalVolume(); ILogicalVolume logVol_parent = physVol_parent.getLogicalVolume(); @@ -257,176 +242,162 @@ } @Override - public Hep3Vector origin() - { + public Hep3Vector origin() { return _org; } - public void setOrigin(Hep3Vector org) - { + public void setOrigin(Hep3Vector org) { this._org = org; } - private void setOrigin() - { + private void setOrigin() { // Use origin of p-side surface Hep3Vector origin = VecOp.mult(CoordinateTransformations.getMatrix(), _sensor.getGeometry().getPosition()); // transform to p-side Polygon3D psidePlane = this.getPsidePlane(); - Translation3D transformToPside = new Translation3D(VecOp.mult(-1 * psidePlane.getDistance(), psidePlane.getNormal())); + Translation3D transformToPside = new Translation3D(VecOp.mult(-1 * psidePlane.getDistance(), + psidePlane.getNormal())); this._org = transformToPside.translated(origin); } @Override - public Hep3Vector normal() - { + public Hep3Vector normal() { if (_w == null) { _w = this.getPsidePlane().getNormal(); System.out.printf("setting normal from pside normal %s\n", _w.toString()); - _w = VecOp.mult(VecOp.mult(CoordinateTransformations.getMatrix(), getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getLocalToGlobal().getRotation().getRotationMatrix()), _w); + _w = VecOp.mult( + VecOp.mult(CoordinateTransformations.getMatrix(), + getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getLocalToGlobal().getRotation() + .getRotationMatrix()), _w); System.out.printf("normal after local to global to tracking rotation %s\n", _w.toString()); } return this._w; } - private void setNormal() - { + private void setNormal() { _w = this.getPsidePlane().getNormal(); - _w = VecOp.mult(VecOp.mult(CoordinateTransformations.getMatrix(), getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getLocalToGlobal().getRotation().getRotationMatrix()), _w); - } - - public void setNormal(Hep3Vector w) - { + _w = VecOp.mult( + VecOp.mult(CoordinateTransformations.getMatrix(), + getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getLocalToGlobal().getRotation() + .getRotationMatrix()), _w); + } + + public void setNormal(Hep3Vector w) { this._w = w; } @Override - public void print() - { - System.out.printf("DetectorPlane: org %s normal vector %s %.2fx%.2fmm thickness %f R.L. (%fmm)\n", origin().toString(), normal().toString(), getLength(), getWidth(), getThicknessInRL(), getThickness()); - } - - @Override - public int getId() - { + public void print() { + System.out.printf("DetectorPlane: org %s normal vector %s %.2fx%.2fmm thickness %f R.L. (%fmm)\n", + origin().toString(), normal().toString(), getLength(), getWidth(), getThicknessInRL(), + getThickness()); + } + + @Override + public int getId() { return _sensor.getSensorID(); } @Override - public String getName() - { + public String getName() { return _sensor.getName(); } @Override - public double getLength() - { + public double getLength() { return _length; } @Override - public double getWidth() - { + public double getWidth() { return _width; } - public double getMeasuredDimension() - { + public double getMeasuredDimension() { return getLength(); } - public double getUnmeasuredDimension() - { + public double getUnmeasuredDimension() { return getWidth(); } - public Hep3Vector getUnmeasuredCoordinate() - { + public Hep3Vector getUnmeasuredCoordinate() { return _v; } - public Hep3Vector getMeasuredCoordinate() - { + public Hep3Vector getMeasuredCoordinate() { return _u; } - private void setMeasuredCoordinate() - { + private void setMeasuredCoordinate() { // p-side unit vector ITransform3D electrodes_to_global = getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getLocalToGlobal(); - Hep3Vector measuredCoordinate = getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getMeasuredCoordinate(0); - measuredCoordinate = VecOp.mult(VecOp.mult(CoordinateTransformations.getMatrix(), electrodes_to_global.getRotation().getRotationMatrix()), measuredCoordinate); + Hep3Vector measuredCoordinate = getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getMeasuredCoordinate( + 0); + measuredCoordinate = VecOp.mult(VecOp.mult(CoordinateTransformations.getMatrix(), electrodes_to_global + .getRotation().getRotationMatrix()), measuredCoordinate); _u = measuredCoordinate; } - private void setUnmeasuredCoordinate() - { + private void setUnmeasuredCoordinate() { // p-side unit vector ITransform3D electrodes_to_global = getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getLocalToGlobal(); - Hep3Vector unmeasuredCoordinate = getSensor().getReadoutElectrodes(ChargeCarrier.HOLE).getUnmeasuredCoordinate(0); - unmeasuredCoordinate = VecOp.mult(VecOp.mult(CoordinateTransformations.getMatrix(), electrodes_to_global.getRotation().getRotationMatrix()), unmeasuredCoordinate); + Hep3Vector unmeasuredCoordinate = getSensor().getReadoutElectrodes(ChargeCarrier.HOLE) + .getUnmeasuredCoordinate(0); + unmeasuredCoordinate = VecOp.mult(VecOp.mult(CoordinateTransformations.getMatrix(), electrodes_to_global + .getRotation().getRotationMatrix()), unmeasuredCoordinate); _v = unmeasuredCoordinate; } } - private static class Material - { + private static class Material { private String _name; private double _X0; private double _density; private double _thickness; - public Material(String _name, double _X0, double _density, double _thickness) - { + public Material(String _name, double _X0, double _density, double _thickness) { this._name = _name; this._X0 = _X0; this._density = _density; this._thickness = _thickness; } - private void add(double t) - { + private void add(double t) { _thickness += t; } - public double getThickness() - { + public double getThickness() { return _thickness; } - public double getDensity() - { + public double getDensity() { return _density; } - public double getX0() - { + public double getX0() { return _X0; } } - private static class Materials - { + private static class Materials { private List<Material> _materials = new ArrayList<Material>(); private double _tot_X0 = -1; - public Materials() - { - } - - public int numberOfMaterials() - { + public Materials() { + } + + public int numberOfMaterials() { return _materials.size(); } - public void add(String mat, double density, double radLen, double t) - { + public void add(String mat, double density, double radLen, double t) { boolean found = false; for (Material m : _materials) { if (m._name == mat) { @@ -442,8 +413,7 @@ } - public double getThicknessInRL() - { + public double getThicknessInRL() { if (_materials.isEmpty()) { return 0; } @@ -464,8 +434,7 @@ return _tot_X0; } - private double getThickness() - { + private double getThickness() { double t_tot = 0.; for (Material m : _materials) { t_tot += m.getThickness(); Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/SeedTracker.java ============================================================================= --- java/trunk/tracking/src/main/java/org/hps/recon/tracking/SeedTracker.java (original) +++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/SeedTracker.java Thu Jun 9 19:36:52 2016 @@ -14,38 +14,40 @@ * @author Per Hansson Adrian <[log in to unmask]> */ public class SeedTracker extends org.lcsim.recon.tracking.seedtracker.SeedTracker { - + public SeedTracker(List<SeedStrategy> strategylist) { // use base class only if this constructor is called! super(strategylist); } - public SeedTracker(List<SeedStrategy> strategylist,boolean includeMS) { + public SeedTracker(List<SeedStrategy> strategylist, boolean includeMS) { super(strategylist); initialize(strategylist, true, includeMS); } - public SeedTracker(List<SeedStrategy> strategylist,boolean useHPSMaterialManager, boolean includeMS) { + public SeedTracker(List<SeedStrategy> strategylist, boolean useHPSMaterialManager, boolean includeMS) { super(strategylist); initialize(strategylist, useHPSMaterialManager, includeMS); } - private void initialize(List<SeedStrategy> strategylist,boolean useHPSMaterialManager, boolean includeMS) { + private void initialize(List<SeedStrategy> strategylist, boolean useHPSMaterialManager, boolean includeMS) { - // Explicitly only replace the objects that might change to avoid getting the lcsim versions + // Explicitly only replace the objects that might change to avoid getting the lcsim versions - // Instantiate the material manager for HPS, the helix fitter and seed track finder as tey depends on the material manager - if(useHPSMaterialManager) { - MaterialSupervisor materialSupervisor = new MaterialSupervisor(includeMS); - _materialmanager = materialSupervisor; - _helixfitter = new HelixFitter(materialSupervisor); - } else { - MaterialManager materialmanager = new MaterialManager(includeMS); - _materialmanager = materialmanager; //mess around with types here... - _helixfitter = new HelixFitter(materialmanager); - } - // Instantiate the helix finder since it depends on the material manager - _finder = new SeedTrackFinder(_hitmanager, _helixfitter); + // Instantiate the material manager for HPS, the helix fitter and seed track finder as tey depends on the material manager + if(useHPSMaterialManager) { + MaterialSupervisor materialSupervisor = new MaterialSupervisor(includeMS); + materialSupervisor.setDebug(true); + _materialmanager = materialSupervisor; + _helixfitter = new HelixFitter(materialSupervisor); + } else { + MaterialManager materialmanager = new MaterialManager(includeMS); + _materialmanager = materialmanager; //mess around with types here... + _helixfitter = new HelixFitter(materialmanager); + } + + // Instantiate the helix finder since it depends on the material manager + _finder = new SeedTrackFinder(_hitmanager, _helixfitter); } /** @@ -67,7 +69,10 @@ */ public void setApplySectorBinning(boolean applySectorBinning) { _finder.setApplySectorBinning(applySectorBinning); - _finder.getConfirmer().setApplySectorBinning(applySectorBinning); - + _finder.getConfirmer().setApplySectorBinning(applySectorBinning); + } + + public void setSubdetectorName(String subdetectorName) { + ((MaterialSupervisor) this._materialmanager).setSubdetectorName(subdetectorName); } } Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackerReconDriver.java ============================================================================= --- java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackerReconDriver.java (original) +++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackerReconDriver.java Thu Jun 9 19:36:52 2016 @@ -36,32 +36,48 @@ private static final Logger LOGGER = Logger.getLogger(TrackerReconDriver.class.getPackage().getName()); + private String subdetectorName = "Tracker"; + // Debug flag. private boolean debug = false; + // Tracks found across all events. int ntracks = 0; + // Number of events processed. int nevents = 0; + // Cache detector object. Detector detector = null; + // Default B-field value. private double bfield = 0.5; + // Tracking strategies resource path. private String strategyResource = "HPS-Test-4pt1.xml"; + // Output track collection. private String trackCollectionName = "MatchedTracks"; + // HelicalTrackHit input collection. private String stInputCollectionName = "RotatedHelicalTrackHits"; + // Include MS (done by removing XPlanes from the material manager results) private boolean includeMS = true; + // number of repetitive fits on confirmed/extended tracks private int _iterativeConfirmed = 3; + // use HPS implementation of material manager private boolean _useHPSMaterialManager = true; + // enable the use of sectoring using sector binning in SeedTracker private boolean _applySectorBinning = true; + private double rmsTimeCut = -1; + private boolean rejectUncorrectedHits = true; + private boolean rejectSharedHits = false; public TrackerReconDriver() { @@ -69,6 +85,10 @@ public void setDebug(boolean debug) { this.debug = debug; + } + + public void setSubdetectorName(String subdetectorName) { + this.subdetectorName = subdetectorName; } /** @@ -158,14 +178,14 @@ */ private void initialize() { - // - // 1) Driver to run Seed Tracker. - // + System.out.println("TrackerReconDriver: initializing"); + if (!strategyResource.startsWith("/")) { strategyResource = "/org/hps/recon/tracking/strategies/" + strategyResource; } List<SeedStrategy> sFinallist = StrategyXMLUtils.getStrategyListFromInputStream(this.getClass().getResourceAsStream(strategyResource)); SeedTracker stFinal = new SeedTracker(sFinallist, this._useHPSMaterialManager, this.includeMS); + stFinal.setSubdetectorName(subdetectorName); stFinal.setApplySectorBinning(_applySectorBinning); stFinal.setUseDefaultXPlane(false); stFinal.setDebug(this.debug); @@ -185,7 +205,7 @@ HitTimeTrackCheck timeCheck = new HitTimeTrackCheck(rmsTimeCut); timeCheck.setDebug(debug); stFinal.setTrackCheck(timeCheck); - } + } } /**