Commit in lcsim/src/org/lcsim/util/heprep on MAIN
ClusterConverter.java+62-511.3 -> 1.4
Added marker for cluster centroid.

lcsim/src/org/lcsim/util/heprep
ClusterConverter.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- ClusterConverter.java	4 Aug 2005 08:04:29 -0000	1.3
+++ ClusterConverter.java	9 Aug 2005 23:11:45 -0000	1.4
@@ -17,60 +17,71 @@
 /**
  *
  * @author tonyj
- * @version $Id: ClusterConverter.java,v 1.3 2005/08/04 08:04:29 ngraf Exp $
+ * @version $Id: ClusterConverter.java,v 1.4 2005/08/09 23:11:45 ngraf Exp $
  */
 class ClusterConverter implements HepRepCollectionConverter
 {
-   private Color[] colors;
-   
-   ClusterConverter()
-   {
-      ColorMap cm = new RainbowColorMap();
-      colors = new Color[20];
-      for (int i=0; i<colors.length; i++) colors[i] = cm.getColor(((double) i)/colors.length,1);
-   }
-   public boolean canHandle(Class k)
-   {
-      return Cluster.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();
-      
-      HepRepType typeX = factory.createHepRepType(typeTree, name);
-      typeX.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
-      typeX.addAttValue("drawAs","Point");
-      typeX.addAttValue("color",Color.RED);
-      typeX.addAttValue("fill",true);
-      typeX.addAttValue("fillColor",Color.RED);
-      typeX.addAttValue("MarkName","Box");            
-      typeX.addAttDef("energy", "Hit Energy", "physics", "");
-      typeX.addAttDef("cluster", "Cluster Energy", "physics", "");
-      
-      int i = 0;
-      
-      for (Cluster cluster : (List<Cluster>) collection)
-      {
-         Color clusterColor = colors[i];
-         i = (i+1) % colors.length;
-         // Some clusters (for example created by the FastMC) may not have hits
-         // For now they won't get displayed
-         List<CalorimeterHit> hits = cluster.getCalorimeterHits();
-         if (hits != null) 
-         {   
-            for (CalorimeterHit hit : hits)
+    private Color[] colors;
+    
+    ClusterConverter()
+    {
+        ColorMap cm = new RainbowColorMap();
+        colors = new Color[20];
+        for (int i=0; i<colors.length; i++) colors[i] = cm.getColor(((double) i)/colors.length,1);
+    }
+    public boolean canHandle(Class k)
+    {
+        return Cluster.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();
+        
+        HepRepType typeX = factory.createHepRepType(typeTree, name);
+        typeX.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
+        typeX.addAttValue("drawAs","Point");
+        typeX.addAttValue("color",Color.RED);
+        typeX.addAttValue("fill",true);
+        typeX.addAttValue("fillColor",Color.RED);
+        typeX.addAttValue("MarkName","Box");
+        typeX.addAttDef("energy", "Hit Energy", "physics", "");
+        typeX.addAttDef("cluster", "Cluster Energy", "physics", "");
+        
+        int i = 0;
+        
+        for (Cluster cluster : (List<Cluster>) collection)
+        {
+            Color clusterColor = colors[i];
+            i = (i+1) % colors.length;
+            // Some clusters (for example created by the FastMC) may not have hits
+            // now draw cluster centroid as star
+            double[]  pos = cluster.getPosition();
+            HepRepInstance instanceC = factory.createHepRepInstance(instanceTree, typeX);
+            HepRepPoint cp = factory.createHepRepPoint(instanceC, pos[0],pos[1],pos[2]);
+            instanceC.addAttValue("MarkName","Star");
+            instanceC.addAttValue("cluster",cluster.getEnergy());
+            instanceC.addAttValue("color",clusterColor);
+            instanceC.addAttValue("MarkSize",10);
+            
+            List<CalorimeterHit> hits = cluster.getCalorimeterHits();
+            if (hits != null)
             {
-               // FixMe: What if hit doesn't have position?
-               double[] pos = hit.getPosition();
-               HepRepInstance instanceX = factory.createHepRepInstance(instanceTree, typeX);
-               instanceX.addAttValue("energy",hit.getRawEnergy());
-               instanceX.addAttValue("cluster",cluster.getEnergy());
-               instanceX.addAttValue("color",clusterColor);
-               HepRepPoint pp = factory.createHepRepPoint(instanceX,pos[0],pos[1],pos[2]);
+                for (CalorimeterHit hit : hits)
+                {
+                    // FixMe: What if hit doesn't have position?
+                    pos = hit.getPosition();
+                    HepRepInstance instanceX = factory.createHepRepInstance(instanceC, typeX);
+                    instanceX.addAttValue("energy",hit.getRawEnergy());
+                    instanceX.addAttValue("MarkSize",5);
+                    //instanceX.addAttValue("cluster",cluster.getEnergy());
+                    instanceX.addAttValue("color",clusterColor);
+                    instanceX.addAttValue("showparentattributes", true);
+                    instanceX.addAttValue("pickparent", true);
+                    HepRepPoint pp = factory.createHepRepPoint(instanceX,pos[0],pos[1],pos[2]);
+                }
             }
-         }
-      }
-   }
+        }
+    }
 }
CVSspam 0.2.8