Author: [log in to unmask]
Date: Sun Dec 18 15:18:10 2016
New Revision: 4640
Log:
Recalculate the track state at the Ecal and add the track states at SVT layer 1 and 2.
Modified:
java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackTweakDriver.java
Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackTweakDriver.java
=============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackTweakDriver.java (original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackTweakDriver.java Sun Dec 18 15:18:10 2016
@@ -2,12 +2,16 @@
import java.util.List;
+import org.lcsim.detector.converter.compact.subdetector.HpsTracker2;
+import org.lcsim.detector.converter.compact.subdetector.SvtStereoLayer;
+import org.lcsim.detector.tracker.silicon.HpsSiSensor;
import org.lcsim.event.EventHeader;
import org.lcsim.event.Track;
import org.lcsim.event.TrackState;
import org.lcsim.event.base.BaseTrack;
import org.lcsim.fit.helicaltrack.HelicalTrackFit;
import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.FieldMap;
import org.lcsim.util.Driver;
/**
@@ -18,18 +22,56 @@
*/
public final class TrackTweakDriver extends Driver {
+ /**
+ * Name of the constant denoting the position of the Ecal face in the
+ * compact description.
+ */
+ private static final String ECAL_POSITION_CONSTANT_NAME = "ecal_dface";
+
+ /** Name of the SVT subdetector volume. */
+ private static final String SUBDETECTOR_NAME = "Tracker";
+
+ /** Layer 1 track state index. */
+ private static final int LAYER1_TS_INDEX = 6;
+
+ /** Layer 2 track state index. */
+ private static final int LAYER2_TS_INDEX = 7;
+
+ /** The B field map */
+ FieldMap bFieldMap = null;
+
/** The magnitude of the B field used. */
private double bField = 0.24; // Tesla
+ /** Position along the beamline of the Ecal face */
+ private double ecalPosition = 0; // mm
+
+ /** Z position to start extrapolation from */
+ private double extStartPos = 700; // mm
+
+ /** The extrapolation step size */
+ private double stepSize = 5.0; // mm
+
+ /** Top SVT layer 1 z position */
+ private double topLayer1Z = 0;
+
+ /** Bot SVT layer 1 z position */
+ private double botLayer1Z = 0;
+
+ /** Top SVT layer 2 z position */
+ private double topLayer2Z = 0;
+
+ /** Bot SVT layer 2 z position */
+ private double botLayer2Z = 0;
+
/** Name of the collection of tracks to apply corrections to. */
private String trackCollectionName = "GBLTracks";
-
+
/**
* The track parameter corrections that will be applied to all top
* tracks.
*/
private double[] topTrackCorrection = {0, 0, 0, 0, 0};
-
/**
* The track parameter corrections that will be applied to all bottom
@@ -39,7 +81,7 @@
/** List of collections to remove from an event. */
private String[] removeCollections = {};
-
+
/** Default constructor */
public TrackTweakDriver() {}
@@ -113,9 +155,43 @@
@Override
protected void detectorChanged(Detector detector) {
-
- /** Get the B-field from the geometry description */
+
+ // Get the field map from the detector object
+ bFieldMap = detector.getFieldMap();
+
+ // Get the B-field from the geometry description
bField = TrackUtils.getBField(detector).magnitude();
+
+ // Get the position of the Ecal from the compact description
+ ecalPosition = detector.getConstants().get(ECAL_POSITION_CONSTANT_NAME).getValue();
+
+ // Get the stereo layers from the geometry and build the stereo
+ // layer maps
+ List<SvtStereoLayer> stereoLayers
+ = ((HpsTracker2) detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement()).getStereoPairs();
+
+ // Loop through all of the stereo layers and find the midpoint between
+ // the sensors of layers 1 & 2. This will be used to set the track
+ // states at those layers.
+ for (SvtStereoLayer stereoLayer : stereoLayers) {
+ System.out.println("Layer: " + stereoLayer.getLayerNumber());
+ if (stereoLayer.getLayerNumber() > 2) continue;
+
+ HpsSiSensor axialSensor = stereoLayer.getAxialSensor();
+ HpsSiSensor stereoSensor = stereoLayer.getStereoSensor();
+
+ double axialZ = axialSensor.getGeometry().getPosition().z();
+ double stereoZ = stereoSensor.getGeometry().getPosition().z();
+ double z = (axialZ + stereoZ)/2;
+
+ if (stereoLayer.getLayerNumber() == 1) {
+ if (axialSensor.isTopLayer()) topLayer1Z = z;
+ else botLayer1Z = z;
+ } else if(stereoLayer.getLayerNumber() == 2) {
+ if (axialSensor.isTopLayer()) topLayer2Z = z;
+ else botLayer2Z = z;
+ }
+ }
}
@Override
@@ -123,7 +199,7 @@
// If the event doesn't have the specified collection of tracks, throw
// an exception.
- if(!event.hasCollection(Track.class, trackCollectionName)) {
+ if (!event.hasCollection(Track.class, trackCollectionName)) {
throw new RuntimeException("Track collection " + trackCollectionName + " doesn't exist");
}
@@ -145,8 +221,30 @@
}
// Override the old track parameters with the tweaked parameters
((BaseTrack) track).setTrackParameters(tweakedTrackParameters, bField);
- }
-
+
+ // Extrapolate the tweaked track to the face of the Ecal and get the
+ // track state
+ TrackState stateIP = TrackUtils.getTrackStateAtLocation(track, TrackState.AtIP);
+ if (stateIP == null) {
+ throw new RuntimeException("IP track state for GBL track was not found");
+ }
+ TrackState stateEcalIP = TrackUtils.extrapolateTrackUsingFieldMap(stateIP, extStartPos, ecalPosition, stepSize, bFieldMap);
+
+ // Replace the existing track state at the Ecal
+ int ecalTrackStateIndex = track.getTrackStates().indexOf(TrackUtils.getTrackStateAtLocation(track, TrackState.AtCalorimeter));
+ track.getTrackStates().set(ecalTrackStateIndex, stateEcalIP);
+
+ // Get the track state at the first layer
+ double layer1Z = trackState.getTanLambda() > 0 ? topLayer1Z : botLayer1Z;
+ TrackState stateLayer1 = TrackUtils.extrapolateTrackUsingFieldMap(stateIP, extStartPos, layer1Z, stepSize, bFieldMap);
+ track.getTrackStates().add(stateLayer1);
+
+ // Get the track state at the first layer
+ double layer2Z = trackState.getTanLambda() > 0 ? topLayer2Z : botLayer2Z;
+ TrackState stateLayer2 = TrackUtils.extrapolateTrackUsingFieldMap(stateIP, extStartPos, layer2Z, stepSize, bFieldMap);
+ track.getTrackStates().add(stateLayer2);
+ }
+
for (String collection : removeCollections) {
event.remove(collection);
}
|