4 added files
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/infrastructure/heprep
diff -N ClusterNodeHeprepConverter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ClusterNodeHeprepConverter.java 10 Jun 2009 17:53:54 -0000 1.1
@@ -0,0 +1,107 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure.heprep;
+
+import org.lcsim.contrib.onoprien.crux.itc.*;
+import java.awt.Color;
+import java.util.*;
+
+import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepInstance;
+import hep.graphics.heprep.HepRepPoint;
+import hep.graphics.heprep.HepRepType;
+import hep.graphics.heprep.HepRepTypeTree;
+import hep.graphics.heprep.HepRepInstanceTree;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.util.heprep.ColorMap;
+import org.lcsim.util.heprep.HepRepCollectionConverter;
+import org.lcsim.util.heprep.LCSimHepRepConverter;
+import org.lcsim.util.heprep.RainbowColorMap;
+
+/**
+ * HepRep converter for {@link ClusterNode}.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ClusterNodeHeprepConverter.java,v 1.1 2009/06/10 17:53:54 onoprien Exp $
+ */
+public class ClusterNodeHeprepConverter implements HepRepCollectionConverter {
+
+ private Color[] colors;
+
+ public ClusterNodeHeprepConverter() {
+ 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);
+ }
+ // Shuffle the elements in the array
+ Collections.shuffle(Arrays.asList(colors));
+ }
+
+ public boolean canHandle(Class k) {
+ return ClusterNode.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("hits", "Number of hits", "physics", "");
+
+ int i = 0;
+
+ for (ClusterNode node : (List<ClusterNode>) collection) {
+
+ Color clusterColor = colors[i];
+ i = (i + 1) % colors.length;
+ double[] pos;// = rosary.getTrajectory().getPosition().v();
+ HepRepInstance instanceC = factory.createHepRepInstance(instanceTree, typeX);
+ //HepRepPoint cp = factory.createHepRepPoint(instanceC, pos[0], pos[1], pos[2]);
+
+ instanceC.addAttValue("drawAs", "Ellipsoid");
+
+ instanceC.addAttValue("Radius", 1);
+ instanceC.addAttValue("Radius2", 1);
+ instanceC.addAttValue("Radius3", 1);
+
+ instanceC.addAttValue("hits", node.getHits().size());
+
+ instanceC.addAttValue("MarkName", "Star");
+ instanceC.addAttValue("color", clusterColor);
+ instanceC.addAttValue("MarkSize", 10);
+
+ List<CalorimeterHit> hits = node.getHits();
+ for (CalorimeterHit hit : hits) {
+ // FixMe: What if hit doesn't have position?
+ double hitpos[] = null;
+ try {
+ hitpos = hit.getPosition();
+ } catch (Exception x) {
+ }
+
+ if (hitpos != null) {
+ pos = hit.getPosition();
+ HepRepInstance instanceX = factory.createHepRepInstance(instanceC, typeX);
+ instanceX.addAttValue("energy", hit.getRawEnergy());
+ instanceX.addAttValue("MarkSize", 5);
+ instanceX.addAttValue("color", (node.getType() == Node.Type.DOT) ? Color.RED : Color.BLUE);
+ instanceX.addAttValue("showparentattributes", true);
+ instanceX.addAttValue("pickparent", true);
+ HepRepPoint pp = factory.createHepRepPoint(instanceX, pos[0], pos[1], pos[2]);
+ }
+ }
+
+ }
+
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/infrastructure/heprep
diff -N ITrackSeedHeprepConverter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ITrackSeedHeprepConverter.java 10 Jun 2009 17:53:54 -0000 1.1
@@ -0,0 +1,100 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure.heprep;
+
+import java.awt.Color;
+import java.util.*;
+
+import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepInstance;
+import hep.graphics.heprep.HepRepPoint;
+import hep.graphics.heprep.HepRepType;
+import hep.graphics.heprep.HepRepTypeTree;
+import hep.graphics.heprep.HepRepInstanceTree;
+import hep.physics.vec.Hep3Vector;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.util.heprep.ColorMap;
+import org.lcsim.util.heprep.HepRepCollectionConverter;
+import org.lcsim.util.heprep.LCSimHepRepConverter;
+import org.lcsim.util.heprep.RainbowColorMap;
+
+import org.lcsim.contrib.onoprien.util.swim.Trajectory;
+
+import org.lcsim.contrib.onoprien.crux.infrastructure.ITrackSeed;
+
+/**
+ * HepRep converter for {@link ITrackSeed}.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ITrackSeedHeprepConverter.java,v 1.1 2009/06/10 17:53:54 onoprien Exp $
+ */
+public class ITrackSeedHeprepConverter implements HepRepCollectionConverter {
+
+ private Color[] colors;
+
+ public ITrackSeedHeprepConverter() {
+ 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);
+ }
+ // Shuffle the elements in the array
+ Collections.shuffle(Arrays.asList(colors));
+ }
+
+ public boolean canHandle(Class k) {
+ return ITrackSeed.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("hitsTrack", "Number of tracker hits", "physics", "");
+ typeX.addAttDef("hitsCal", "Number of calorimeter hits", "physics", "");
+
+ int i = 0;
+
+ for (ITrackSeed seed : (List<ITrackSeed>) collection) {
+
+ Color clusterColor = colors[i];
+ i = (i + 1) % colors.length;
+ HepRepInstance instanceC = factory.createHepRepInstance(instanceTree, typeX);
+
+ instanceC.addAttValue("drawAs", "Circle");
+ Trajectory traj = seed.getTrajectory();
+ if (traj != null) {
+ Hep3Vector pos = traj.getPosition();
+ factory.createHepRepPoint(instanceC, pos.x(), pos.y(), pos.z());
+ instanceC.addAttValue("Radius", 1);
+ }
+
+ instanceC.addAttValue("hitsTrack", seed.getTrackerHits().size());
+ instanceC.addAttValue("hitsCal", seed.getCalorimeterHits().size());
+
+ List<? extends CalorimeterHit> hits = seed.getCalorimeterHits();
+ for (CalorimeterHit hit : hits) {
+ double[] pos = hit.getPosition();
+ HepRepInstance instanceX = factory.createHepRepInstance(instanceC, typeX);
+ instanceX.addAttValue("energy", hit.getRawEnergy());
+ instanceX.addAttValue("MarkSize", 5);
+ instanceX.addAttValue("color", clusterColor);
+ instanceX.addAttValue("showparentattributes", true);
+ instanceX.addAttValue("pickparent", true);
+ factory.createHepRepPoint(instanceX, pos[0], pos[1], pos[2]);
+ }
+
+ }
+
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/infrastructure/heprep
diff -N RosaryHeprepConverter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ RosaryHeprepConverter.java 10 Jun 2009 17:53:54 -0000 1.1
@@ -0,0 +1,111 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure.heprep;
+
+import org.lcsim.contrib.onoprien.crux.itc.*;
+import java.awt.Color;
+import java.util.*;
+
+import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepInstance;
+import hep.graphics.heprep.HepRepPoint;
+import hep.graphics.heprep.HepRepType;
+import hep.graphics.heprep.HepRepTypeTree;
+import hep.graphics.heprep.HepRepInstanceTree;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.util.heprep.ColorMap;
+import org.lcsim.util.heprep.HepRepCollectionConverter;
+import org.lcsim.util.heprep.LCSimHepRepConverter;
+import org.lcsim.util.heprep.RainbowColorMap;
+
+/**
+ * HepRep converter for {@link Rosary}.
+ *
+ * @author D. Onoprienko
+ * @version $Id: RosaryHeprepConverter.java,v 1.1 2009/06/10 17:53:54 onoprien Exp $
+ */
+public class RosaryHeprepConverter implements HepRepCollectionConverter {
+
+ private Color[] colors;
+
+ public RosaryHeprepConverter() {
+ 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);
+ }
+ // Shuffle the elements in the array
+ Collections.shuffle(Arrays.asList(colors));
+ }
+
+ public boolean canHandle(Class k) {
+ return Rosary.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("dots", "Number of Dots", "physics", "");
+ typeX.addAttDef("beads", "Number of Beads", "physics", "");
+
+ int i = 0;
+
+ for (Rosary rosary : (List<Rosary>) collection) {
+
+ Color clusterColor = colors[i];
+ i = (i + 1) % colors.length;
+ double[] pos;// = rosary.getTrajectory().getPosition().v();
+ HepRepInstance instanceC = factory.createHepRepInstance(instanceTree, typeX);
+ //HepRepPoint cp = factory.createHepRepPoint(instanceC, pos[0], pos[1], pos[2]);
+
+ instanceC.addAttValue("drawAs", "Ellipsoid");
+
+ instanceC.addAttValue("Radius", 1);
+ instanceC.addAttValue("Radius2", 1);
+ instanceC.addAttValue("Radius3", 1);
+
+ instanceC.addAttValue("dots", rosary.getNodeCount(Node.Type.DOT));
+ instanceC.addAttValue("beads", rosary.getNodeCount(Node.Type.BEAD));
+
+ instanceC.addAttValue("MarkName", "Star");
+ instanceC.addAttValue("color", clusterColor);
+ instanceC.addAttValue("MarkSize", 10);
+
+ for (Node node : rosary.getNodes(Node.Type.DOT, Node.Type.BEAD)) {
+ List<CalorimeterHit> hits = node.getHits();
+ for (CalorimeterHit hit : hits) {
+ // FixMe: What if hit doesn't have position?
+ double hitpos[] = null;
+ try {
+ hitpos = hit.getPosition();
+ } catch (Exception x) {
+ }
+
+ if (hitpos != null) {
+ pos = hit.getPosition();
+ HepRepInstance instanceX = factory.createHepRepInstance(instanceC, typeX);
+ instanceX.addAttValue("energy", hit.getRawEnergy());
+ instanceX.addAttValue("MarkSize", 5);
+ instanceX.addAttValue("color", (node.getType() == Node.Type.DOT) ? Color.RED : Color.BLUE);
+ instanceX.addAttValue("showparentattributes", true);
+ instanceX.addAttValue("pickparent", true);
+ HepRepPoint pp = factory.createHepRepPoint(instanceX, pos[0], pos[1], pos[2]);
+ }
+ }
+ }
+
+ }
+
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/infrastructure/heprep
diff -N package-info.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ package-info.java 10 Jun 2009 17:53:54 -0000 1.1
@@ -0,0 +1,7 @@
+/**
+ * HepRep converters for various classes used by the Crux package.
+ *
+ * @author D. Onoprienko
+ */
+package org.lcsim.contrib.onoprien.crux.infrastructure.heprep;
+
CVSspam 0.2.8