Commit in lcsim/src/org/lcsim/util/heprep on MAIN
MCParticleConverter.java+19-61.6 -> 1.7
JM: Fix LCSIM-144.  Add pT, momentum, and time to displayed particle attributes.

lcsim/src/org/lcsim/util/heprep
MCParticleConverter.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- MCParticleConverter.java	5 Apr 2006 11:54:14 -0000	1.6
+++ MCParticleConverter.java	22 Feb 2007 21:33:59 -0000	1.7
@@ -20,7 +20,7 @@
 /**
  *
  * @author tonyj
- * @version $Id: MCParticleConverter.java,v 1.6 2006/04/05 11:54:14 tonyj Exp $
+ * @version $Id: MCParticleConverter.java,v 1.7 2007/02/22 21:33:59 jeremy Exp $
  */
 class MCParticleConverter implements HepRepCollectionConverter
 {
@@ -91,13 +91,13 @@
                    stop = new BasicHep3Vector();
                }
             }
+                        
             if (charge == 0 || field[2] == 0)
             {
                HepRepInstance instanceX = factory.createHepRepInstance(charge == 0 ? neutral : charged, charge == 0 ? neutralType : chargedType);
+               setDefaultAttValues(instanceX,p);
                factory.createHepRepPoint(instanceX,start.x(),start.y(),start.z());
                factory.createHepRepPoint(instanceX,stop.x(),stop.y(),stop.z());
-               instanceX.addAttValue("momentum",p.getEnergy());
-               instanceX.addAttValue("type",p.getType().getName());
             }
             else
             {
@@ -108,8 +108,8 @@
                {
                   double dAlpha = 10; // 1cm
                   HepRepInstance instanceX = factory.createHepRepInstance(charged, chargedType);
-                  instanceX.addAttValue("momentum",p.getEnergy());
-                  instanceX.addAttValue("pdgid",p.getType().getName());
+                  setDefaultAttValues(instanceX,p);
+                  
                   factory.createHepRepPoint(instanceX,start.x(),start.y(),start.z());
                   double absZ = Math.abs(stop.z());
                   double rSquared = stop.x()*stop.x()+stop.y()*stop.y();
@@ -136,7 +136,7 @@
                      }
                   }
                }
-            }
+            }                       
          }
          catch (UnknownParticleIDException x)
          {
@@ -144,4 +144,17 @@
          }
       }
    }
+   
+   private void setDefaultAttValues(HepRepInstance instanceX, MCParticle p)
+   {
+       double x = p.getMomentum().x();
+       double y = p.getMomentum().y();
+       double pT = Math.sqrt(x*x + y*y);
+       
+       instanceX.addAttValue("pT",pT);
+       instanceX.addAttValue("particle",p.getType().getName());
+       instanceX.addAttValue("energy",p.getEnergy());
+       instanceX.addAttValue("momentum",p.getMomentum().magnitude());
+       instanceX.addAttValue("time",p.getProductionTime());
+   }
 }
\ No newline at end of file
CVSspam 0.2.8