GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd/util
diff -u -r1.1 -r1.2
--- LCDDFactory.java 19 Jan 2006 01:57:02 -0000 1.1
+++ LCDDFactory.java 21 Jan 2006 02:30:01 -0000 1.2
@@ -1,44 +1,26 @@
package org.lcsim.geometry.compact.converter.lcdd.util;
-import org.lcsim.geometry.compact.converter.lcdd.util.*;
import java.util.List;
/*
*
- * LCDD object factory.
+ * A collection of static utility methods for creating objects
+ * in the org.lcsim.geometry.compact.converter.lcdd.util package.
*
* @author jeremym
- * @version $Id: LCDDFactory.java,v 1.1 2006/01/19 01:57:02 jeremy Exp $
+ * @version $Id: LCDDFactory.java,v 1.2 2006/01/21 02:30:01 jeremy Exp $
*/
public final class LCDDFactory
{
- private LCDD _lcdd;
-
- boolean _autoAdd = false;
-
- public void setLCDD(LCDD lcdd)
- {
- _lcdd = lcdd;
- }
-
- public void setAutoAdd(boolean autoAdd)
- {
- _autoAdd = autoAdd;
- }
-
- // top-level LCDD container element
-
- public LCDD createLCDD()
+ /** Create the top-level LCDD container element. */
+ public static LCDD createLCDD()
{
LCDD lcdd = new LCDD();
return lcdd;
}
- // header elements
-
- public Detector createDetector(
- String title,
- String version,
+ /** Create the detector element for the header. */
+ public static Detector createDetector(String title, String version,
String url)
{
Detector det = new Detector();
@@ -48,9 +30,8 @@
return det;
}
- public Author createAuthor(
- String name,
- String email)
+ /** Create the author element for the header. */
+ public static Author createAuthor(String name, String email)
{
Author author = new Author();
author.setName(name);
@@ -58,11 +39,9 @@
return author;
}
- public Generator createGenerator(
- String title,
- String version,
- String file,
- long checksum)
+ /** Create the generator element for the header. */
+ public static Generator createGenerator(String title, String version,
+ String file, long checksum)
{
Generator generator = new Generator();
generator.setTitle(title);
@@ -72,14 +51,16 @@
return generator;
}
- public Header createHeader(String comment)
+ /** Create the header element. */
+ public static Header createHeader(String comment)
{
Header header = new Header();
header.setComment(comment);
return header;
}
- public Box createBox(String name, double x, double y, double z)
+ /** Create a box solid. */
+ public static Box createBox(String name, double x, double y, double z)
{
Box box = new Box(name);
box.setX(x);
@@ -88,8 +69,9 @@
return box;
}
- public Tube createTube(String name, double rmin, double rmax, double z,
- double deltaphi)
+ /** Create a tube solid. */
+ public static Tube createTube(String name, double rmin, double rmax,
+ double z, double deltaphi)
{
Tube tube = new Tube(name);
tube.setRMax(rmax);
@@ -99,13 +81,9 @@
return tube;
}
- public Trapezoid createTrapezoid(
- String name,
- double x1,
- double x2,
- double y1,
- double y2,
- double z)
+ /** Create a trapezoid solid. */
+ public static Trapezoid createTrapezoid(String name, double x1, double x2,
+ double y1, double y2, double z)
{
Trapezoid trd = new Trapezoid(name);
trd.setX1(x1);
@@ -116,12 +94,9 @@
return trd;
}
- public SubtractionSolid createSubtractionSolid(
- String name,
- Solid first,
- Solid second,
- Position pos,
- Rotation rot)
+ /** Create a boolean solid using subtraction. */
+ public static SubtractionSolid createSubtractionSolid(String name,
+ Solid first, Solid second, Position pos, Rotation rot)
{
SubtractionSolid sub = new SubtractionSolid(name);
sub.setFirstSolid(first);
@@ -131,9 +106,42 @@
return sub;
}
- // Volume
+ /** Create a polycone solid. */
+ public static Polycone createPolycone(String name, double startPhi,
+ double deltaPhi, List<ZPlane> zplanes)
+ {
+ Polycone polycone = new Polycone(name);
+ polycone.setStartPhi(startPhi);
+ polycone.setDeltaPhi(deltaPhi);
+ if (zplanes != null)
+ {
+ for (ZPlane zplane : zplanes)
+ {
+ polycone.addZPlane(zplane);
+ }
+ }
+ return polycone;
+ }
- public Volume createVolume(String name, Material material, Solid solid)
+ /** Create a regular polyhedra solid. */
+ public static PolyhedraRegular createPolyhedraRegular(String name,
+ int nsides, double rmin, double rmax, double zlength)
+ {
+ PolyhedraRegular polyhedra = new PolyhedraRegular(name, nsides, rmin,
+ rmax, zlength);
+ return polyhedra;
+ }
+
+ /** Create a zplane for use by Polycone. */
+ public static ZPlane createZPlane(double rmin, double rmax, double z)
+ {
+ ZPlane zplane = new ZPlane(rmin, rmax, z);
+ return zplane;
+ }
+
+ /** Create a basic Volume. */
+ public static Volume createVolume(String name, Material material,
+ Solid solid)
{
Volume volume = new Volume(name);
volume.setMaterial(material);
@@ -141,15 +149,24 @@
return volume;
}
- public Volume createVolume(String name, Material material, Solid solid,
- SensitiveDetector sd, Region region, LimitSet limits,
+ /** Create a Volume with all parameters. */
+ public static Volume createVolume(String name, Material material,
+ Solid solid, SensitiveDetector sd, Region region, LimitSet limits,
List<PhysVol> pvs)
{
Volume volume = createVolume(name, material, solid);
volume.setSensitiveDetector(sd);
- volume.setRegion(region);
- volume.setRegion(region);
+
+ if ( region != null )
+ {
+ volume.setRegion(region);
+ }
+
+ if ( limits != null )
+ {
+ volume.setLimitSet(limits);
+ }
if (pvs != null)
{
@@ -162,19 +179,33 @@
return volume;
}
- public Constant createConstant(String name, double value)
+ /** Create a Volume with all parameters, but copy the name from the Solid. */
+ public static Volume createVolume(Material material, Solid solid,
+ SensitiveDetector sd, Region region, LimitSet limits,
+ List<PhysVol> pvs)
+ {
+ Volume volume = createVolume(solid.getSolidName(), material, solid, sd,
+ region, limits, pvs);
+
+ return volume;
+ }
+
+ /** Create a named double constant. */
+ public static Constant createConstant(String name, double value)
{
Constant constant = new Constant(name, value);
return constant;
}
- public Constant createConstant(String name, String value)
+ /** Create a named string constant. */
+ public static Constant createConstant(String name, String value)
{
Constant constant = new Constant(name, value);
return constant;
}
- public IDField createIDField(String label, int start, int length,
+ /** Create an ID field. */
+ public static IDField createIDField(String label, int start, int length,
boolean signed)
{
IDField field = new IDField();
@@ -185,7 +216,9 @@
return field;
}
- public IDSpec createIDSpec(String name, int length, List<IDField> fields)
+ /** Create an IDSpec. */
+ public static IDSpec createIDSpec(String name, int length,
+ List<IDField> fields)
{
IDSpec spec = new IDSpec(name);
spec.setLength(length);
@@ -199,11 +232,9 @@
return spec;
}
- public Limit createLimit(
- String name,
- String particles,
- double value,
- String unit)
+ /** Create a single physics limit. */
+ public static Limit createLimit(String name, String particles,
+ double value, String unit)
{
Limit limit = new Limit(name);
limit.setParticles(particles);
@@ -212,7 +243,8 @@
return limit;
}
- public LimitSet createLimitSet(String name, List<Limit> limits)
+ /** Create a set of physics limits. */
+ public static LimitSet createLimitSet(String name, List<Limit> limits)
{
LimitSet limitset = new LimitSet(name);
if (limits != null)
@@ -225,19 +257,30 @@
return limitset;
}
- public Material createMaterial(String name)
+ /** Create a material. */
+ public static Material createMaterial(String name)
{
Material material = new Material(name);
return material;
}
- public PhysVol createPhysVol(Volume volume, Position position,
- Rotation rotation, List<PhysVolID> ids)
+ /** Create a physical volume (placement). */
+ public static PhysVol createPhysVol(Volume volume, Position position,
+ Rotation rotation)
{
PhysVol pv = new PhysVol();
pv.setVolume(volume);
pv.setPosition(position);
pv.setRotation(rotation);
+ return pv;
+ }
+
+ /** Create a physical volume (placement) with a list of physical volume ids. */
+ public static PhysVol createPhysVol(Volume volume, Position position,
+ Rotation rotation, List<PhysVolID> ids)
+ {
+ PhysVol pv = createPhysVol(volume, position, rotation);
+
if (ids != null)
{
for (PhysVolID id : ids)
@@ -248,37 +291,16 @@
return pv;
}
- public Polycone createPolycone(String name, double startPhi,
- double deltaPhi, List<ZPlane> zplanes)
- {
- Polycone polycone = new Polycone(name);
- polycone.setStartPhi(startPhi);
- polycone.setDeltaPhi(deltaPhi);
- if (zplanes != null)
- {
- for (ZPlane zplane : zplanes)
- {
- polycone.addZPlane(zplane);
- }
- }
- return polycone;
- }
-
- public PolyhedraRegular createPolyhedraRegular(String name, int nsides,
- double rmin, double rmax, double zlength)
+ /** Create a physical volume identifier. */
+ public static PhysVolID createPhysVolID(String name, int value)
{
- PolyhedraRegular polyhedra = new PolyhedraRegular(name, nsides, rmin,
- rmax, zlength);
- return polyhedra;
+ PhysVolID id = new PhysVolID(name, value);
+ return id;
}
- public ZPlane createZPlane(double rmin, double rmax, double z)
- {
- ZPlane zplane = new ZPlane(rmin, rmax, z);
- return zplane;
- }
-
- public Position createPosition(String name, double x, double y, double z)
+ /** Create an XYZ position. */
+ public static Position createPosition(String name, double x, double y,
+ double z)
{
Position position = new Position(name);
position.setX(x);
@@ -287,24 +309,24 @@
return position;
}
- // detectors
-
- public Calorimeter createCalorimeter(String name, Segmentation seg)
+ /** Create a calorimeter-type sensitive detector. */
+ public static Calorimeter createCalorimeter(String name, Segmentation seg)
{
Calorimeter cal = new Calorimeter(name);
cal.setSegmentation(seg);
return cal;
}
-
- public Tracker createTracker(String name)
+
+ /** Create a tracker-type sensitive detector. */
+ public static Tracker createTracker(String name)
{
Tracker trk = new Tracker(name);
return trk;
}
- // segmentations
-
- public ProjectiveCylinder createProjectiveCylinder(int ntheta, int nphi)
+ /** Create a projective cylinder segmentation. */
+ public static ProjectiveCylinder createProjectiveCylinder(int ntheta,
+ int nphi)
{
ProjectiveCylinder seg = new ProjectiveCylinder();
seg.setNTheta(ntheta);
@@ -312,7 +334,8 @@
return seg;
}
- public ProjectiveZPlane createProjectiveZPlane(int ntheta, int nphi)
+ /** Create a projective zplane segmentation. */
+ public static ProjectiveZPlane createProjectiveZPlane(int ntheta, int nphi)
{
ProjectiveZPlane seg = new ProjectiveZPlane();
seg.setNTheta(ntheta);
@@ -320,7 +343,8 @@
return seg;
}
- public GridXYZ createGridXYZ(double x, double y, double z)
+ /** Create a Cartesian grid segmentation. */
+ public static GridXYZ createGridXYZ(double x, double y, double z)
{
GridXYZ seg = new GridXYZ();
seg.setGridSizeX(x);
@@ -329,8 +353,9 @@
return seg;
}
- public NonprojectiveCylinder createNonprojectiveCylinder(double gridSizeZ,
- double gridSizePhi)
+ /** Create a nonprojective cylinder segmentation. */
+ public static NonprojectiveCylinder createNonprojectiveCylinder(
+ double gridSizeZ, double gridSizePhi)
{
NonprojectiveCylinder seg = new NonprojectiveCylinder();
seg.setGridSizeZ(gridSizeZ);
@@ -338,13 +363,9 @@
return seg;
}
- public Region createRegion(
- String name,
- boolean storeSecondaries,
- double energyCut,
- double rangeCut,
- String eunit,
- String lunit)
+ /** Create a region. */
+ public static Region createRegion(String name, boolean storeSecondaries,
+ double energyCut, double rangeCut, String eunit, String lunit)
{
Region region = new Region(name);
region.setStoreSecondaries(storeSecondaries);
@@ -355,10 +376,8 @@
return region;
}
- public Rotation createRotation(
- String name,
- double x,
- double y,
+ /** Create a rotation with XYZ parameters. */
+ public static Rotation createRotation(String name, double x, double y,
double z)
{
Rotation rot = new Rotation(name);
@@ -368,33 +387,22 @@
return rot;
}
- // mag field
-
- public Solenoid createSolenoid(
- String name,
- double BInner,
- double BOuter,
- double rInner,
- double zMax)
+ /** Create a solenoid field. */
+ public static Solenoid createSolenoid(String name, double BInner,
+ double BOuter, double rInner, double zMax)
{
- Solenoid sol = new Solenoid(name);
+ Solenoid sol = new Solenoid(name);
sol.setInnerField(BInner);
sol.setOuterField(BOuter);
sol.setInnerRadius(rInner);
sol.setZMax(zMax);
- return sol;
+ return sol;
}
-
- public RZFieldMap createRZFieldMap(
- String name,
- int numBinsR,
- int numBinsZ,
- double gridSizeR,
- double gridSizeZ,
- String lunit,
- String funit,
- List<RZBData> data
- )
+
+ /** Create an RZB field map. */
+ public static RZFieldMap createRZFieldMap(String name, int numBinsR,
+ int numBinsZ, double gridSizeR, double gridSizeZ, String lunit,
+ String funit, List<RZBData> data)
{
RZFieldMap field = new RZFieldMap(name);
field.setNumBinsR(numBinsR);
@@ -403,9 +411,9 @@
field.setGridSizeZ(gridSizeZ);
field.setLengthUnit(lunit);
field.setFieldUnit(funit);
- if ( data != null )
+ if (data != null)
{
- for ( RZBData rzb : data )
+ for (RZBData rzb : data)
{
field.addRZBData(rzb);
}