lcsim/src/org/lcsim/contrib/SiStripSim
diff -N SiTrackerHitStrip1DConverter.java
--- SiTrackerHitStrip1DConverter.java 27 Dec 2007 02:08:40 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,85 +0,0 @@
-/*
- * SiTrackerHitStrip1DConverter.java
- *
- * Created on December 26, 2007, 4:09 PM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package org.lcsim.contrib.SiStripSim;
-
-import hep.graphics.heprep.HepRepFactory;
-import hep.graphics.heprep.HepRepInstance;
-import hep.graphics.heprep.HepRepInstanceTree;
-import hep.graphics.heprep.HepRepType;
-import hep.graphics.heprep.HepRepTypeTree;
-import java.awt.Color;
-import java.util.List;
-import org.lcsim.event.TrackerHit;
-import org.lcsim.detector.solids.Point3D;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.EventHeader.LCMetaData;
-import org.lcsim.util.heprep.HepRepCollectionConverter;
-import org.lcsim.util.heprep.LCSimHepRepConverter;
-
-/**
- *
- * @author cozzy
- *
- * This is a converter for SiTrackerHit1D objects. It draws the hit segment
- * for each instance.
- *
- * 1) To enable this converter, you must modify org.lcsim.util.heprep.LCSimHepRepConverter
- * by adding the line "register(new SiTrackerHitStrip1DConverter());" where
- * all the other register statements are (you'll also have to import this class)
- *
- * 2) Since SiTrackerHitStrip1D implements TrackerHit, TrackerHitConverter will
- * also fire and draw a marker for each of these. This can be disabled by
- * modifying org.lcsim.util.heprep.TrackerHitConverter so that it ignores
- * any hits that may be cast as SiTrackerHitStrip1DConverter (try-catch is
- * your friend).
- *
- */
-public class SiTrackerHitStrip1DConverter implements HepRepCollectionConverter {
-
- /** Creates a new instance of SiTrackerHitStrip1DConverter */
- public SiTrackerHitStrip1DConverter() {
- }
-
- public boolean canHandle(Class k){
- return TrackerHit.class.isAssignableFrom(k);
- }
-
- public void convert(EventHeader event, List collection, HepRepFactory factory, HepRepTypeTree typeTree, HepRepInstanceTree instanceTree) {
-
- //Check if the TrackerHit can be cast as an SiTrackerHitStrip1D
- try { ((List<SiTrackerHitStrip1D>)collection).get(0); }
- catch (ClassCastException cce) { return; }
-
- LCMetaData meta = event.getMetaData(collection);
- String name = meta.getName()+"_Strip1D"; //added string because TrackerHitConverter will also fire on this collection...
-
- HepRepType type = factory.createHepRepType(typeTree,name);
- type.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
- type.addAttValue("drawAs","Line");
- type.addAttValue("color",Color.GREEN);
-
- type.addAttDef("dEdx","Hit dEdx", "physics","");
- type.addAttDef("time","Hit time", "physics","");
-
-
- for (SiTrackerHitStrip1D hit : (List<SiTrackerHitStrip1D>) collection) {
-
- HepRepInstance instance = factory.createHepRepInstance(instanceTree,type);
- instance.addAttValue("dEdx",hit.getdEdx());
- instance.addAttValue("time",hit.getTime());
-
- for (Point3D p : hit.getHitSegment().getPoints()) {
-
- factory.createHepRepPoint(instance,p.x(),p.y(),p.z());
- }
- }
- }
-
-}
lcsim/src/org/lcsim/contrib/CosminDeaconu
diff -N DisplayHitModules.java
--- DisplayHitModules.java 27 Dec 2007 20:53:04 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,117 +0,0 @@
-/*
- * DisplayHitModules.java
- *
- * Created on December 14, 2007, 1:43 PM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package org.lcsim.contrib.CosminDeaconu;
-
-import hep.graphics.heprep.HepRepFactory;
-import hep.graphics.heprep.HepRepInstance;
-import hep.graphics.heprep.HepRepInstanceTree;
-import hep.graphics.heprep.HepRepType;
-import hep.graphics.heprep.HepRepTypeTree;
-import hep.physics.vec.Hep3Vector;
-import java.awt.Color;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.lcsim.detector.DetectorElementStore;
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.IDetectorElementContainer;
-import org.lcsim.detector.IGeometryInfo;
-import org.lcsim.detector.identifier.IIdentifier;
-import org.lcsim.detector.identifier.Identifier;
-import org.lcsim.detector.solids.IPolyhedron;
-import org.lcsim.detector.solids.ISolid;
-import org.lcsim.detector.solids.Point3D;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.SimTrackerHit;
-import org.lcsim.util.heprep.HepRepCollectionConverter;
-import org.lcsim.util.heprep.LCSimHepRepConverter;
-
-/**
- * Converter that draws modules and sensors that have hits in them.
- * Everything is drawn in the event layer.
- *
- * To enable, modify org.lcsim.util.heprep.LCSimHepRepConverter so that it
- * contains "register(new DisplayHitModules());" along with all the other
- * register statements (and you'll have to import this class too).
- "
- * The string DETECTOR_NAME gives the name of the detector for which this will activate
- *
- * @author cozzy
- */
-public class DisplayHitModules implements HepRepCollectionConverter{
-
- private static final String DETECTOR_NAME = "SiTrackerBarrelTest00"; //only accept this type of detector
-
- /** Creates a new instance of DisplayHitModules */
- public DisplayHitModules() {
- }
-
-
- public boolean canHandle(Class k) {
- return (SimTrackerHit.class.isAssignableFrom(k));
- }
-
- public void convert(EventHeader event, List collection, HepRepFactory factory, HepRepTypeTree typeTree, HepRepInstanceTree instanceTree) {
-
- if (!event.getDetectorName().equals(DETECTOR_NAME)) return; //make sure it's the right detector
-
- //sensor type
- HepRepType typeS = factory.createHepRepType(typeTree,"HitSensor");
- typeS.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
- typeS.addAttValue("drawAs","prism");
- typeS.addAttValue("color",Color.WHITE);
-
- //module type
- HepRepType typeM = factory.createHepRepType(typeTree,"HitModule");
- typeM.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
- typeM.addAttValue("drawAs","prism");
- typeM.addAttValue("color",Color.WHITE);
-
- Set<Integer> alreadyMade = new HashSet<Integer>(); //don't want to draw the same thing multiple times if there are multiple SimHits in a sensor.
-
- for (SimTrackerHit h : (List<SimTrackerHit>) collection) {
-
- //get the right sensor
- IIdentifier id = new Identifier(h.getCellID());
- IDetectorElementContainer de = DetectorElementStore.getInstance().find(id);
- IDetectorElement sensor = de.get(0);
-
- //make sure we don't have repeats
- Integer hash = Integer.valueOf(sensor.hashCode());
- if (alreadyMade.contains(hash)) continue;
- alreadyMade.add(hash);
-
- //get the module from the sensor
- IDetectorElement module = sensor.getParent();
-
- drawPolyhedron(sensor,typeS,instanceTree,factory);
- drawPolyhedron(module,typeM,instanceTree,factory);
-
- }
- }
-
- private void drawPolyhedron(IDetectorElement detelem, HepRepType type,HepRepInstanceTree instanceTree, HepRepFactory factory) {
-
- ISolid solid = detelem.getGeometry().getLogicalVolume().getSolid();
- if (!(solid instanceof IPolyhedron)) return;
- IPolyhedron poly = (IPolyhedron) solid;
-
- List<Point3D> points = poly.getVertices();
- int[] point_ordering = poly.getHepRepVertexOrdering();
-
- HepRepInstance instance = factory.createHepRepInstance(instanceTree,type);
-
- for (int i = 0; i< point_ordering.length; i++) {
- Hep3Vector p = detelem.getGeometry().transformLocalToGlobal(points.get(point_ordering[i]));
- factory.createHepRepPoint(instance,p.x(),p.y(),p.z());
- }
- }
-
-}