Print

Print


Commit in lcsim/src/org/lcsim/util/heprep on MAIN
TrackConverter.java+87-791.5 -> 1.6
JM: Skip display of Tracks if no detector is available.

lcsim/src/org/lcsim/util/heprep
TrackConverter.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- TrackConverter.java	24 Feb 2007 02:28:03 -0000	1.5
+++ TrackConverter.java	24 Aug 2007 20:10:28 -0000	1.6
@@ -18,86 +18,94 @@
 /**
  *
  * @author tonyj
- * @version $Id: TrackConverter.java,v 1.5 2007/02/24 02:28:03 jeremy Exp $
+ * @version $Id: TrackConverter.java,v 1.6 2007/08/24 20:10:28 jeremy Exp $
  */
 class TrackConverter implements HepRepCollectionConverter
 {
-   private static final double[] zero = { 0,0,0 };
-   
-   public boolean canHandle(Class k)
-   {
-      return Track.class.isAssignableFrom(k);
-   }
-   public void convert(EventHeader event, List collection, HepRepFactory factory, HepRepTypeTree typeTree, HepRepInstanceTree instanceTree)
-   {
-      LCMetaData meta = event.getMetaData(collection);
-      String name = meta.getName();
-      int flags = meta.getFlags();
-      Detector detector = event.getDetector();
-      
-      double trackingRMax = detector.getConstants().get("tracking_region_radius").getValue();
-      double trackingZMax = detector.getConstants().get("tracking_region_zmax").getValue();
-      
-      double[] field = detector.getFieldMap().getField(zero);
-      HelixSwimmer helix = new HelixSwimmer(field[2]);
-      
-      HepRepType typeX = factory.createHepRepType(typeTree, name);
-      typeX.addAttValue("layer", LCSimHepRepConverter.PARTICLES_LAYER);
-      typeX.addAttValue("drawAs","Line");
-      
-      typeX.addAttDef("pT","Transverse momentum", "physics", "");      
-      typeX.addAttDef("dedX","de/Dx", "physics", "GeV");
-      typeX.addAttDef("dedX error","", "physics", "GeV");      
-      typeX.addAttDef("Charge","", "physics", "");      
-      typeX.addAttDef("Chi2","", "physics", "");      
-      typeX.addAttDef("pX","Momentum X", "physics", "GeV");
-      typeX.addAttDef("pY","Momentum Y", "physics", "GeV");
-      typeX.addAttDef("pZ","Momentum Z", "physics", "GeV");      
-      typeX.addAttDef("NDF","Number Degrees Freedom","physics","");      
-      typeX.addAttDef("Reference Point X","Reference Point X","physics","mm");
-      typeX.addAttDef("Reference Point Y","Reference Point Y","physics","mm");
-      typeX.addAttDef("Reference Point Z","Reference Point Z","physics","mm");      
-      typeX.addAttDef("d0","d0","physics","");
-      typeX.addAttDef("phi0","phi0","physics","");
-      typeX.addAttDef("omega","omega","physics","");
-      typeX.addAttDef("z0","z0","physics","");
-      typeX.addAttDef("s","s","physics","");
-           
-      for (Track t : (List<Track>) collection)
-      {         
-         helix.setTrack(t);
-         double distanceToCylinder = helix.getDistanceToCylinder(trackingRMax,trackingZMax);
-         
-         HepRepInstance instanceX = factory.createHepRepInstance(instanceTree, typeX);
-         double pt = field[2]*Constants.fieldConversion/Math.abs(t.getTrackParameter(2));
-         
-         instanceX.addAttValue("pT",pt);
-         instanceX.addAttValue("dedX",t.getdEdx());
-         instanceX.addAttValue("dedX error",t.getdEdxError());
-         instanceX.addAttValue("Charge",t.getCharge());
-         instanceX.addAttValue("Chi2",t.getChi2());
-         instanceX.addAttValue("pX",t.getPX());
-         instanceX.addAttValue("pY",t.getPY());
-         instanceX.addAttValue("pZ",t.getPZ());
-         instanceX.addAttValue("NDF",t.getNDF());
-         instanceX.addAttValue("Reference Point X",t.getReferencePointX());
-         instanceX.addAttValue("Reference Point Y",t.getReferencePointY());
-         instanceX.addAttValue("Reference Point Z",t.getReferencePointZ());
-         instanceX.addAttValue("d0",t.getTrackParameter(0));
-         instanceX.addAttValue("phi0",t.getTrackParameter(1));
-         instanceX.addAttValue("omega",t.getTrackParameter(2));
-         instanceX.addAttValue("z0",t.getTrackParameter(3));
-         instanceX.addAttValue("s",t.getTrackParameter(4));
-         
-         double dAlpha = 10; // 1cm
-         
-         for (int k=0;k<200;k++)
-         {
-            double d = k*dAlpha;
-            if (d>distanceToCylinder) break;
-            Hep3Vector point = helix.getPointAtDistance(d);
-            factory.createHepRepPoint(instanceX,point.x(),point.y(),point.z());
-         }
-      }
-   }
+	private static final double[] zero = { 0,0,0 };
+
+	public boolean canHandle(Class k)
+	{
+		return Track.class.isAssignableFrom(k);
+	}
+	public void convert(EventHeader event, List collection, HepRepFactory factory, HepRepTypeTree typeTree, HepRepInstanceTree instanceTree)
+	{	   	   
+		try {
+			event.getDetector();
+		}
+		catch (Exception x)
+		{
+			return;
+		}
+
+		LCMetaData meta = event.getMetaData(collection);
+		String name = meta.getName();
+		int flags = meta.getFlags();
+		Detector detector = event.getDetector();
+
+		double trackingRMax = detector.getConstants().get("tracking_region_radius").getValue();
+		double trackingZMax = detector.getConstants().get("tracking_region_zmax").getValue();
+
+		double[] field = detector.getFieldMap().getField(zero);
+		HelixSwimmer helix = new HelixSwimmer(field[2]);
+
+		HepRepType typeX = factory.createHepRepType(typeTree, name);
+		typeX.addAttValue("layer", LCSimHepRepConverter.PARTICLES_LAYER);
+		typeX.addAttValue("drawAs","Line");
+
+		typeX.addAttDef("pT","Transverse momentum", "physics", "");      
+		typeX.addAttDef("dedX","de/Dx", "physics", "GeV");
+		typeX.addAttDef("dedX error","", "physics", "GeV");      
+		typeX.addAttDef("Charge","", "physics", "");      
+		typeX.addAttDef("Chi2","", "physics", "");      
+		typeX.addAttDef("pX","Momentum X", "physics", "GeV");
+		typeX.addAttDef("pY","Momentum Y", "physics", "GeV");
+		typeX.addAttDef("pZ","Momentum Z", "physics", "GeV");      
+		typeX.addAttDef("NDF","Number Degrees Freedom","physics","");      
+		typeX.addAttDef("Reference Point X","Reference Point X","physics","mm");
+		typeX.addAttDef("Reference Point Y","Reference Point Y","physics","mm");
+		typeX.addAttDef("Reference Point Z","Reference Point Z","physics","mm");      
+		typeX.addAttDef("d0","d0","physics","");
+		typeX.addAttDef("phi0","phi0","physics","");
+		typeX.addAttDef("omega","omega","physics","");
+		typeX.addAttDef("z0","z0","physics","");
+		typeX.addAttDef("s","s","physics","");
+
+		for (Track t : (List<Track>) collection)
+		{         
+			helix.setTrack(t);
+			double distanceToCylinder = helix.getDistanceToCylinder(trackingRMax,trackingZMax);
+
+			HepRepInstance instanceX = factory.createHepRepInstance(instanceTree, typeX);
+			double pt = field[2]*Constants.fieldConversion/Math.abs(t.getTrackParameter(2));
+
+			instanceX.addAttValue("pT",pt);
+			instanceX.addAttValue("dedX",t.getdEdx());
+			instanceX.addAttValue("dedX error",t.getdEdxError());
+			instanceX.addAttValue("Charge",t.getCharge());
+			instanceX.addAttValue("Chi2",t.getChi2());
+			instanceX.addAttValue("pX",t.getPX());
+			instanceX.addAttValue("pY",t.getPY());
+			instanceX.addAttValue("pZ",t.getPZ());
+			instanceX.addAttValue("NDF",t.getNDF());
+			instanceX.addAttValue("Reference Point X",t.getReferencePointX());
+			instanceX.addAttValue("Reference Point Y",t.getReferencePointY());
+			instanceX.addAttValue("Reference Point Z",t.getReferencePointZ());
+			instanceX.addAttValue("d0",t.getTrackParameter(0));
+			instanceX.addAttValue("phi0",t.getTrackParameter(1));
+			instanceX.addAttValue("omega",t.getTrackParameter(2));
+			instanceX.addAttValue("z0",t.getTrackParameter(3));
+			instanceX.addAttValue("s",t.getTrackParameter(4));
+
+			double dAlpha = 10; // 1cm
+
+			for (int k=0;k<200;k++)
+			{
+				double d = k*dAlpha;
+				if (d>distanceToCylinder) break;
+				Hep3Vector point = helix.getPointAtDistance(d);
+				factory.createHepRepPoint(instanceX,point.x(),point.y(),point.z());
+			}
+		}
+	}
 }
\ No newline at end of file
CVSspam 0.2.8