Print

Print


Commit in lcsim/src/org/lcsim on MAIN
plugin/browser/MCParticleTableModel.java+25-171.3 -> 1.4
util/heprep/MCParticleConverter.java+67-601.4 -> 1.5
+92-77
2 modified files
Protect against UnknownParticleIDException

lcsim/src/org/lcsim/plugin/browser
MCParticleTableModel.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- MCParticleTableModel.java	21 Jun 2005 18:19:53 -0000	1.3
+++ MCParticleTableModel.java	22 Aug 2005 18:42:59 -0000	1.4
@@ -1,5 +1,6 @@
 package org.lcsim.plugin.browser;
 
+import hep.physics.particle.properties.UnknownParticleIDException;
 import javax.swing.table.AbstractTableModel;
 import java.util.List;
 import org.lcsim.event.EventHeader.LCMetaData;
@@ -45,24 +46,31 @@
    public Object getValueAt(int row, int column)
    {
       MCParticle p = (MCParticle) particles.get(row);
-      switch (column)
+      try
       {
-         case 0: return row;
-         case 1: return p.getType().getName();
-         case 2: return convert(p.getGeneratorStatus());
-         case 3: return parents(p);
-         case 4: return p.getEnergy();
-         case 5: return p.getMomentum().v();
-         case 6: return p.getOrigin().v();
-         case 7: 
-            try
-            {
-               return p.getEndPoint().v();
-            }
-            catch (Exception x) { return null; }
-         case 8: return p.getMass();
-         case 9: return p.getCharge();
-         default: return " ";
+         switch (column)
+         {
+            case 0: return row;
+            case 1: return p.getType().getName();
+            case 2: return convert(p.getGeneratorStatus());
+            case 3: return parents(p);
+            case 4: return p.getEnergy();
+            case 5: return p.getMomentum().v();
+            case 6: return p.getOrigin().v();
+            case 7: 
+               try
+               {
+                  return p.getEndPoint().v();
+               }
+               catch (Exception x) { return null; }
+            case 8: return p.getMass();
+            case 9: return p.getCharge();
+            default: return " ";
+         }
+      }
+      catch (UnknownParticleIDException x)
+      {
+         return "id="+x.getPDGID()+"?";
       }
    }
    static String convert(int status)

lcsim/src/org/lcsim/util/heprep
MCParticleConverter.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- MCParticleConverter.java	20 Aug 2005 23:25:41 -0000	1.4
+++ MCParticleConverter.java	22 Aug 2005 18:42:59 -0000	1.5
@@ -5,6 +5,7 @@
 import hep.graphics.heprep.HepRepType;
 import hep.graphics.heprep.HepRepTypeTree;
 import hep.graphics.heprep.HepRepInstanceTree;
+import hep.physics.particle.properties.UnknownParticleIDException;
 import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
 import hep.physics.vec.VecOp;
@@ -16,11 +17,10 @@
 import org.lcsim.geometry.Detector;
 import org.lcsim.util.swim.HelixSwimmer;
 
-
 /**
  *
  * @author tonyj
- * @version $Id: MCParticleConverter.java,v 1.4 2005/08/20 23:25:41 tonyj Exp $
+ * @version $Id: MCParticleConverter.java,v 1.5 2005/08/22 18:42:59 tonyj Exp $
  */
 class MCParticleConverter implements HepRepCollectionConverter
 {
@@ -62,79 +62,86 @@
       
       for (MCParticle p : (List<MCParticle>) collection)
       {
-         Hep3Vector start = p.getOrigin();
-         Hep3Vector momentum = p.getMomentum();
-         double charge = p.getCharge();
-         helix.setTrack(momentum, start, (int) charge);
-         Hep3Vector stop;
-
          try
          {
-            stop = p.getEndPoint();
-            // Workaround for simdet
-            if (stop.x() == 0 && stop.y() == 0 && stop.z() == 0)
+            Hep3Vector start = p.getOrigin();
+            Hep3Vector momentum = p.getMomentum();
+            double charge = p.getCharge();
+            helix.setTrack(momentum, start, (int) charge);
+            Hep3Vector stop;
+
+            try
             {
-                if(p.getGeneratorStatus()==MCParticle.FINAL_STATE) stop = helix.getPointAtDistance(trackingRMax);
+               stop = p.getEndPoint();
+               // Workaround for simdet
+               if (stop.x() == 0 && stop.y() == 0 && stop.z() == 0)
+               {
+                   if(p.getGeneratorStatus()==MCParticle.FINAL_STATE) stop = helix.getPointAtDistance(trackingRMax);
+               }
             }
-         }
-         catch (RuntimeException x)
-         {
-            // Use the helix swimmer to swim to end of tracking region
-            if(p.getGeneratorStatus()==MCParticle.FINAL_STATE)
+            catch (RuntimeException x)
             {
-                stop = helix.getPointAtDistance(trackingRMax);
+               // Use the helix swimmer to swim to end of tracking region
+               if(p.getGeneratorStatus()==MCParticle.FINAL_STATE)
+               {
+                   stop = helix.getPointAtDistance(trackingRMax);
+               }
+               else
+               {
+                   stop = new BasicHep3Vector();
+               }
             }
-            else
+            if (charge == 0 || field[2] == 0)
             {
-                stop = new BasicHep3Vector();
+               HepRepInstance instanceX = factory.createHepRepInstance(charge == 0 ? neutral : charged, charge == 0 ? neutralType : chargedType);
+               factory.createHepRepPoint(instanceX,start.x(),start.y(),start.z());
+               factory.createHepRepPoint(instanceX,stop.x(),stop.y(),stop.z());
+               instanceX.addAttValue("energy",p.getEnergy());
+               instanceX.addAttValue("type",p.getType().getName());
             }
-         }
-         if (charge == 0 || field[2] == 0)
-         {
-            HepRepInstance instanceX = factory.createHepRepInstance(charge == 0 ? neutral : charged, charge == 0 ? neutralType : chargedType);
-            factory.createHepRepPoint(instanceX,start.x(),start.y(),start.z());
-            factory.createHepRepPoint(instanceX,stop.x(),stop.y(),stop.z());
-            instanceX.addAttValue("energy",p.getEnergy());
-            instanceX.addAttValue("type",p.getType().getName());
-         }
-         else
-         {
-            double pT = Math.sqrt(momentum.x()*momentum.x()+momentum.y()*momentum.y());
-            // if particle starts at origin and has no apprecaible pT, don't draw
-            double r = Math.sqrt(start.x()*start.x()+start.y()*start.y());
-            if(pT>ptMinCut || (pT<ptMinCut && r>rCut))
+            else
             {
-               double dAlpha = 10; // 1cm
-               HepRepInstance instanceX = factory.createHepRepInstance(charged, chargedType);
-               instanceX.addAttValue("energy",p.getEnergy());
-               instanceX.addAttValue("pdgid",p.getType().getName());
-               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();
-               Hep3Vector point = start;
-               
-               for (int k = 1;k<200;k++)
+               double pT = Math.sqrt(momentum.x()*momentum.x()+momentum.y()*momentum.y());
+               // if particle starts at origin and has no apprecaible pT, don't draw
+               double r = Math.sqrt(start.x()*start.x()+start.y()*start.y());
+               if(pT>ptMinCut || (pT<ptMinCut && r>rCut))
                {
-                  double d = VecOp.sub(point,stop).magnitudeSquared();
-                  
-                  if (d < 2)
-                  {
-                     factory.createHepRepPoint(instanceX,stop.x(),stop.y(),stop.z());
-                     break;
-                  }
-                  else if (Math.abs(point.z()) > absZ ||
-                          point.x()*point.x()+point.y()*point.y() > rSquared)
-                  {
-                     break;
-                  }
-                  else
+                  double dAlpha = 10; // 1cm
+                  HepRepInstance instanceX = factory.createHepRepInstance(charged, chargedType);
+                  instanceX.addAttValue("energy",p.getEnergy());
+                  instanceX.addAttValue("pdgid",p.getType().getName());
+                  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();
+                  Hep3Vector point = start;
+
+                  for (int k = 1;k<200;k++)
                   {
-                     point = helix.getPointAtDistance(k*dAlpha);
-                     factory.createHepRepPoint(instanceX,point.x(),point.y(),point.z());
+                     double d = VecOp.sub(point,stop).magnitudeSquared();
+
+                     if (d < 2)
+                     {
+                        factory.createHepRepPoint(instanceX,stop.x(),stop.y(),stop.z());
+                        break;
+                     }
+                     else if (Math.abs(point.z()) > absZ ||
+                             point.x()*point.x()+point.y()*point.y() > rSquared)
+                     {
+                        break;
+                     }
+                     else
+                     {
+                        point = helix.getPointAtDistance(k*dAlpha);
+                        factory.createHepRepPoint(instanceX,point.x(),point.y(),point.z());
+                     }
                   }
                }
             }
          }
+         catch (UnknownParticleIDException x)
+         {
+            // Just ignore it for now.
+         }
       }
    }
 }
\ No newline at end of file
CVSspam 0.2.8