GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -u -r1.20 -r1.21
--- SiTrackerEndcap.java 6 Feb 2009 19:09:14 -0000 1.20
+++ SiTrackerEndcap.java 12 Feb 2009 00:19:18 -0000 1.21
@@ -21,6 +21,7 @@
import org.lcsim.geometry.compact.converter.lcdd.util.Trap;
import org.lcsim.geometry.compact.converter.lcdd.util.Trapezoid;
import org.lcsim.geometry.compact.converter.lcdd.util.Tube;
+import org.lcsim.geometry.compact.converter.lcdd.util.VisAttributes;
import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
public class SiTrackerEndcap extends LCDDSubdetector
@@ -154,6 +155,12 @@
Volume wedgeLV = makeWedge(subdetElement, layerElement, innerR, outerR, thickness, nwedges, layerN, lcdd);
lcdd.add(wedgeLV);
+ // Turn off wedges. Show daughters.
+ if (lcdd.getVisAttributes("InvisibleWithDaughters") != null)
+ {
+ wedgeLV.setVisAttributes(lcdd.getVisAttributes("InvisibleWithDaughters"));
+ }
+
double r = (innerR + outerR) / 2;
String wedgeName = wedgeLV.getVolumeName();
for (int i=0; i<nwedges; i++)
@@ -172,14 +179,23 @@
lcdd.add(p);
lcdd.add(rot);
- PhysVol wedgePV = new PhysVol(wedgeLV, layerLV, p, rot);
- wedgePV.addPhysVolID("wedge", i);
+ new PhysVol(wedgeLV, layerLV, p, rot);
}
+ // Set layer visualization.
+ setVisAttributes(lcdd, layerElement, layerLV);
+
// Set the layer envelope to invisible to help Geant4 visualization.
- //if (lcdd.getVisAttributes("InvisibleWithDaughters") != null)
+ //if (layerLV.getAttribute("vis") == null)
//{
- // layerLV.setVisAttributes(lcdd.getVisAttributes("InvisibleWithDaughters"));
+ // if (lcdd.getVisAttributes("InvisibleWithDaughters") != null)
+ // {
+ // layerLV.setVisAttributes(lcdd.getVisAttributes("InvisibleWithDaughters"));
+ // }
+ //}
+ //else
+ //{
+ //
//}
return layerLV;
@@ -218,6 +234,7 @@
lcdd.add(wedgeTrd);
Volume wedgeLV = new Volume(name, wedgeTrd, material);
+ //lcdd.add(wedgeLV);
Attribute moduleref = layerElement.getAttribute("module");
@@ -253,6 +270,12 @@
throw new RuntimeException(x);
}
+ VisAttributes vis = null;
+ if (module.getVis() != null)
+ {
+ vis = lcdd.getVisAttributes(module.getVis());
+ }
+
Trapezoid wedgeTrd = (Trapezoid)lcdd.getSolid(wedgeLV.getSolidRef());
double dz = wedgeTrd.z();
double dx1 = wedgeTrd.x1();
@@ -293,10 +316,10 @@
xsizes2.add(xsize2);
}
- Material sliceMaterial;
+ Material moduleMaterial;
try
{
- sliceMaterial = lcdd.getMaterial("Air");
+ moduleMaterial = lcdd.getMaterial("Air");
}
catch (JDOMException x)
{
@@ -353,31 +376,33 @@
xmin += 2*xsize_box;
xmax += 2*xsize_box;
- String sliceName = subdetElement.getAttributeValue("name") + "_layer" + layerN + "_module" + imodule;
+ String moduleName = subdetElement.getAttributeValue("name") + "_layer" + layerN + "_module" + imodule;
// FIXME: Multiply by 2 to conform to GDML convention of dividing inputs by 2.
- Box sliceBox = new Box(sliceName + "_box");
+ Box sliceBox = new Box(moduleName + "_box");
sliceBox.setX(xsize_box*2);
sliceBox.setY(dy*2);
sliceBox.setZ(zsizes.get(i)*2);
lcdd.add(sliceBox);
- Volume sliceLV = new Volume(sliceName, sliceBox, sliceMaterial);
+ Volume moduleLV = new Volume(moduleName, sliceBox, moduleMaterial);
// Make the box module.
- makeBoxModule(sliceLV, module, lcdd);
+ makeBoxModule(moduleLV, module, lcdd);
+
+ moduleLV.setVisAttributes(vis);
- lcdd.add(sliceLV);
+ lcdd.add(moduleLV);
- Position p = new Position(sliceName + "_position");
+ Position p = new Position(moduleName + "_position");
p.setX(xcenter);
p.setZ(zcenters.get(i));
lcdd.add(p);
- Rotation rot = new Rotation(sliceName + "_rotation");
+ Rotation rot = new Rotation(moduleName + "_rotation");
lcdd.add(rot);
- PhysVol slicePV = new PhysVol(sliceLV, wedgeLV, p, rot);
- slicePV.addPhysVolID("module", imodule);
+ PhysVol modulePV = new PhysVol(moduleLV, wedgeLV, p, rot);
+ modulePV.addPhysVolID("module", imodule);
imodule++;
}
@@ -385,25 +410,27 @@
// Small symmetric trapezoids
if (ntraps == 1)
{
- String sliceName = subdetElement.getAttributeValue("name") + "_layer" + layerN + "_module" + imodule;
+ String moduleName = subdetElement.getAttributeValue("name") + "_layer" + layerN + "_module" + imodule;
+
+ Trapezoid moduleTrd = new Trapezoid(moduleName+"_trapezoid", xsizes1.get(i), xsizes2.get(i), dy, dy, zsizes.get(i));
+ lcdd.add(moduleTrd);
- Trapezoid sliceTrd = new Trapezoid(sliceName+"_trapezoid", xsizes1.get(i), xsizes2.get(i), dy, dy, zsizes.get(i));
- lcdd.add(sliceTrd);
+ Volume moduleLV = new Volume(moduleName, moduleTrd, moduleMaterial);
- Volume sliceLV = new Volume(sliceName, sliceTrd, sliceMaterial);
+ makeTrdModule(moduleLV, module, lcdd);
- makeTrdModule(sliceLV, module, lcdd);
+ moduleLV.setVisAttributes(vis);
- lcdd.add(sliceLV);
+ lcdd.add(moduleLV);
- Position p = new Position(sliceName + "_position");
+ Position p = new Position(moduleName + "_position");
p.setZ(zcenters.get(i));
lcdd.add(p);
- Rotation rot = new Rotation(sliceName + "_rotation");
+ Rotation rot = new Rotation(moduleName + "_rotation");
lcdd.add(rot);
- PhysVol slicePV = new PhysVol(sliceLV, wedgeLV, p, rot);
+ PhysVol slicePV = new PhysVol(moduleLV, wedgeLV, p, rot);
slicePV.addPhysVolID("module", imodule);
imodule++;
@@ -424,26 +451,28 @@
for (int ix = -1; ix <=1; ix=ix+2)
{
- String sliceName = subdetElement.getAttributeValue("name") + "_layer" + layerN + "_module" + imodule;
+ String moduleName = subdetElement.getAttributeValue("name") + "_layer" + layerN + "_module" + imodule;
- Trap sliceTrap = new Trap(sliceName+"_trap",zsizes.get(i),theta*ix,0.0,dy,xsize1,xsize1,0.0,dy,xsize2,xsize2,0.0);
- lcdd.add(sliceTrap);
+ Trap moduleTrap = new Trap(moduleName+"_trap",zsizes.get(i),theta*ix,0.0,dy,xsize1,xsize1,0.0,dy,xsize2,xsize2,0.0);
+ lcdd.add(moduleTrap);
- Volume sliceLV = new Volume(sliceName, sliceTrap, sliceMaterial);
+ Volume moduleLV = new Volume(moduleName, moduleTrap, moduleMaterial);
- makeTrapModule(sliceLV, module, lcdd);
+ makeTrapModule(moduleLV, module, lcdd);
- lcdd.add(sliceLV);
+ moduleLV.setVisAttributes(vis);
- Position p = new Position(sliceName + "_position");
+ lcdd.add(moduleLV);
+
+ Position p = new Position(moduleName + "_position");
p.setX(ix*xcenter);
p.setZ(zcenters.get(i));
lcdd.add(p);
- Rotation rot = new Rotation(sliceName + "_rotation");
+ Rotation rot = new Rotation(moduleName + "_rotation");
lcdd.add(rot);
- PhysVol slicePV = new PhysVol(sliceLV, wedgeLV, p, rot);
- slicePV.addPhysVolID("module", imodule);
+ PhysVol modulePV = new PhysVol(moduleLV, wedgeLV, p, rot);
+ modulePV.addPhysVolID("module", imodule);
imodule++;
}
@@ -471,7 +500,10 @@
String moduleName = moduleVolume.getVolumeName();
int sensor=0;
-
+
+ VisAttributes vis = null;
+ if (moduleParameters.getVis() != null)
+ vis = lcdd.getVisAttributes(moduleParameters.getVis());
for (SiTrackerModuleComponentParameters component : moduleParameters)
{
@@ -496,6 +528,7 @@
lcdd.add(sliceBox);
Volume volume = new Volume(componentName, sliceBox, material);
+ volume.setVisAttributes(vis);
lcdd.add(volume);
Position position = new Position(componentName + "_position", 0., posY, 0.);
@@ -517,6 +550,8 @@
++sensor;
}
+ volume.setVisAttributes(vis);
+
posY += thickness / 2;
}
}
@@ -585,6 +620,10 @@
++sensor;
}
+ // Set vis attributes of module component.
+ if (component.getVis() != null)
+ volume.setVisAttributes(lcdd.getVisAttributes(component.getVis()));
+
posY += thickness / 2;
}
}
@@ -592,7 +631,7 @@
public void makeTrapModule(Volume module, SiTrackerModuleParameters moduleParameters, LCDD lcdd)
{
Trap trap = (Trap)lcdd.getSolid(module.getSolidRef());
-
+
double a1 = trap.getAlpha1();
double a2 = trap.getAlpha2();
double x1 = trap.getXHalfLength1();
@@ -627,7 +666,7 @@
{
throw new RuntimeException(x);
}
- boolean sensitive = component.isSensitive();
+
int componentNumber = component.getComponentNumber();
posY += thickness / 2;
@@ -648,17 +687,23 @@
PhysVol pv = new PhysVol(volume, module, position, rotation);
pv.addPhysVolID("component", componentNumber);
- if (sensitive)
+ // Set component sensitive detector.
+ if (component.isSensitive())
{
if (sensor > 1)
{
throw new RuntimeException("Maximum of 2 sensors per module.");
}
+ //System.out.println(volume.getVolumeName() + " - " + this.sd.getRefName());
volume.setSensitiveDetector(this.sd);
pv.addPhysVolID("sensor", sensor);
++sensor;
}
+ // Set vis attributes of module component.
+ if (component.getVis() != null)
+ volume.setVisAttributes(lcdd.getVisAttributes(component.getVis()));
+
posY += thickness / 2;
}
}