lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.5 -r1.6
--- SeedTrackerTrackStateDriver.java 8 Oct 2010 18:28:32 -0000 1.5
+++ SeedTrackerTrackStateDriver.java 17 Nov 2010 00:23:52 -0000 1.6
@@ -1,10 +1,9 @@
-// $Id: SeedTrackerTrackStateDriver.java,v 1.5 2010/10/08 18:28:32 grefe Exp $
package org.lcsim.recon.tracking.seedtracker;
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
-
import hep.physics.vec.VecOp;
+
import java.util.ArrayList;
import java.util.List;
@@ -16,9 +15,9 @@
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
import org.lcsim.fit.helicaltrack.HelixUtils;
import org.lcsim.fit.helicaltrack.TrackDirection;
+import org.lcsim.geometry.Calorimeter;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.Calorimeter.CalorimeterType;
-import org.lcsim.recon.util.CalorimeterInformation;
import org.lcsim.spacegeom.SpacePoint;
import org.lcsim.spacegeom.SpaceVector;
import org.lcsim.util.Driver;
@@ -26,52 +25,60 @@
/**
* This Driver creates the three TrackState collections expected by slicPandora
- * by using information from the SeedTracker objects. It must be run in the same
+ * by using information from the SeedTracker objects. It must be run in the same
* job as SeedTracker, NOT by reading in a persisted LCIO file, which will not
- * work due to lost data and type information. And (obviously) it must be run
- * after SeedTracker itself.
+ * work due to lost data and type information. And it must be run the
+ * SeedTracker Driver.
*
* @author richp
* @author jeremym
+ * @author ngraf
+ *
+ * @version $Id: SeedTrackerTrackStateDriver.java,v 1.6 2010/11/17 00:23:52 jeremy Exp $
*/
public class SeedTrackerTrackStateDriver extends Driver
{
+ // protected CalorimeterInformation calInfo;
+ protected double ecalRadius;
+ protected int ecalNumSides;
+ protected double ecalZ;
+ protected double magField;
+ protected HelixSwimmer swimmer;
- protected CalorimeterInformation calInfo;
- protected double ecalRadius;
- protected int ecalNumSides;
- protected double ecalZ;
- protected double magField;
- protected HelixSwimmer swimmer;
-
- public SeedTrackerTrackStateDriver() {
- calInfo = CalorimeterInformation.instance();
- ecalRadius = 0.;
- ecalNumSides = 0;
- ecalZ = 0.;
- magField = 0.;
- swimmer = null;
- }
-
- @Override
- protected void detectorChanged(Detector detector) {
- // get the magnetic field and set up the helix swimmer
- magField = detector.getFieldMap().getField(new BasicHep3Vector(0, 0, 0)).magnitude();
- swimmer = new HelixSwimmer(magField);
-
- // get the Ecal geometry
- calInfo = CalorimeterInformation.instance();
- ecalRadius = calInfo.getRMin(CalorimeterType.EM_BARREL);
- ecalNumSides = calInfo.getNSides(CalorimeterType.EM_BARREL);
- ecalZ = calInfo.getZMin(CalorimeterType.EM_ENDCAP);
- //System.out.println("ECAL: radius " + ecalRadius + " nsides " + ecalNumSides + " z " + ecalZ);
- }
-
- @Override
- public void process(EventHeader event)
+ public SeedTrackerTrackStateDriver()
+ {}
+
+ protected void detectorChanged( Detector detector )
+ {
+ // get the magnetic field and set up the helix swimmer
+ magField = detector.getFieldMap().getField( new BasicHep3Vector( 0, 0, 0 ) ).magnitude();
+ swimmer = new HelixSwimmer( magField );
+
+ // Get calorimeter parameters from Detector.
+ Calorimeter ecalBarrel = null;
+ Calorimeter ecalEndcap = null;
+
+ // Get the EM Barrel.
+ ecalBarrel = detector.getCalorimeterByType( CalorimeterType.EM_BARREL );
+ if ( ecalBarrel == null )
+ throw new RuntimeException( "Missing EM_BARREL subdetector in compact description." );
+
+ // Get the EM Endcap.
+ ecalEndcap = detector.getCalorimeterByType( CalorimeterType.EM_ENDCAP );
+ if ( ecalEndcap == null )
+ throw new RuntimeException( "Missing EM_ENDCAP subdetector in compact description." );
+
+ ecalRadius = ecalBarrel.getInnerRadius();
+ ecalNumSides = ecalBarrel.getInnerNumberOfSides();
+ ecalZ = ecalEndcap.getInnerZ();
+
+ //System.out.println( "ECAL: radius " + ecalRadius + " nsides " + ecalNumSides + " z " + ecalZ );
+ }
+
+ public void process( EventHeader event )
{
// Get the Tracks from the event. Collection name is SeedTracker's default.
- List<Track> tracks = event.get(Track.class, "Tracks");
+ List<Track> tracks = event.get( Track.class, "Tracks" );
// TrackState lists.
List<GenericObject> startObjs = new ArrayList<GenericObject>();
@@ -79,68 +86,68 @@
List<GenericObject> ecalObjs = new ArrayList<GenericObject>();
// Loop over all the Tracks in the collection.
- for (Track track : tracks)
+ for ( Track track : tracks )
{
SeedTrack strk = (SeedTrack) track;
SeedCandidate scand = strk.getSeedCandidate();
HelicalTrackFit helix = scand.getHelix();
- Hep3Vector ptrk = new BasicHep3Vector(strk.getMomentum());
+ Hep3Vector ptrk = new BasicHep3Vector( strk.getMomentum() );
double smax = -9999.;
HelicalTrackHit last = null;
- for (HelicalTrackHit hit : scand.getHits())
+ for ( HelicalTrackHit hit : scand.getHits() )
{
- double s = helix.PathMap().get(hit);
- if (s > smax)
+ double s = helix.PathMap().get( hit );
+ if ( s > smax )
{
smax = s;
last = hit;
}
}
- TrackDirection trkdir = HelixUtils.CalculateTrackDirection(helix,
- smax);
+ TrackDirection trkdir = HelixUtils.CalculateTrackDirection( helix, smax );
Hep3Vector dir = trkdir.Direction();
Hep3Vector pos = null;
- if (last instanceof HelicalTrackCross)
+ if ( last instanceof HelicalTrackCross )
{
HelicalTrackCross cross = (HelicalTrackCross) last;
- cross.setTrackDirection(trkdir, helix.covariance());
+ cross.setTrackDirection( trkdir, helix.covariance() );
pos = cross.getCorrectedPosition();
- } else
+ }
+ else
{
pos = last.getCorrectedPosition();
}
// Set the End TrackState from the outermost hit on the track.
- Hep3Vector xmomentum = VecOp.mult(ptrk.magnitude(), dir);
-
+ Hep3Vector xmomentum = VecOp.mult( ptrk.magnitude(), dir );
+
// Set the End TrackState to the point of closest approach to the last hit
- swimmer.setTrack(track);
- double s = swimmer.getDistanceToPoint(pos);
- Hep3Vector corPos = swimmer.getPointAtLength(s);
-
- TrackState endState = new TrackState(corPos, xmomentum);
- endObjs.add(endState);
+ swimmer.setTrack( track );
+ double s = swimmer.getDistanceToPoint( pos );
+ Hep3Vector corPos = swimmer.getPointAtLength( s );
+
+ TrackState endState = new TrackState( corPos, xmomentum );
+ endObjs.add( endState );
// Calculate the Start state and add to list.
double[] smom = ptrk.v();
- double[] spos = HelixUtils.PointOnHelix(helix, 0.).v();
- TrackState startState = new TrackState(spos[0], spos[1], spos[2], smom[0], smom[1], smom[2]);
- startObjs.add(startState);
+ double[] spos = HelixUtils.PointOnHelix( helix, 0. ).v();
+ TrackState startState = new TrackState( spos[0], spos[1], spos[2], smom[0], smom[1], smom[2] );
+ startObjs.add( startState );
- //TODO Should set the ECal TrackState by propagating from the outermost hit on the track.
- s = Math.min(swimmer.getDistanceToZ(ecalZ), swimmer.getDistanceToPolyhedra(ecalRadius, ecalNumSides));
+ // TODO Should set the ECal TrackState by propagating from the outermost hit on the track.
+ s = Math.min( swimmer.getDistanceToZ( ecalZ ), swimmer.getDistanceToPolyhedra( ecalRadius, ecalNumSides ) );
- SpacePoint ecalPos = swimmer.getPointAtLength(s);
- SpaceVector ecalMom = swimmer.getMomentumAtLength(s);
+ SpacePoint ecalPos = swimmer.getPointAtLength( s );
+ SpaceVector ecalMom = swimmer.getMomentumAtLength( s );
- TrackState ecalState = new TrackState(ecalPos.x(), ecalPos.y(), ecalPos.z(), ecalMom.x(), ecalMom.y(), ecalMom.z());
- ecalObjs.add(ecalState);
+ TrackState ecalState = new TrackState( ecalPos.x(), ecalPos.y(), ecalPos.z(), ecalMom.x(), ecalMom.y(), ecalMom.z() );
+ ecalObjs.add( ecalState );
}
// Add the lists to the event.
- event.put("StateAtStart", startObjs, GenericObject.class, 0);
- event.put("StateAtECal", ecalObjs, GenericObject.class, 0);
- event.put("StateAtEnd", endObjs, GenericObject.class, 0);
+ event.put( "StateAtStart", startObjs, GenericObject.class, 0 );
+ event.put( "StateAtECal", ecalObjs, GenericObject.class, 0 );
+ event.put( "StateAtEnd", endObjs, GenericObject.class, 0 );
}
-}
+}
\ No newline at end of file