projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java 2014-08-02 15:59:58 UTC (rev 3212)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java 2014-08-04 16:36:12 UTC (rev 3213)
@@ -118,13 +118,16 @@
makeHalfModule("axial", module);
- /*
-
makeColdBlock(module);
makeHalfModule("stereo", module);
- */
+
+ if(isDebug()) {
+ System.out.printf("%s: created module bundle:\n", this.getClass().getSimpleName());
+ bundle.print();
+ }
+
}
@@ -174,15 +177,18 @@
int layer = mother.getLayer();
ModuleBundle bundle = getModuleBundle(mother);
+ HalfModuleBundle halfModuleBundle;
// Build the half-module
HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModule;
if(side == "axial") {
halfModule = new HPSTestRunTracker2014GeomDef.TestRunHalfModuleAxial(volName, mother, layer, half);
- bundle.halfModuleAxial = halfModule;
+ halfModuleBundle = new HalfModuleBundle(halfModule);
+ bundle.halfModuleAxial = halfModuleBundle;
} else if(side == "stereo") {
halfModule = new HPSTestRunTracker2014GeomDef.TestRunHalfModuleStereo(volName, mother, layer, half);
- bundle.halfModuleStereo = halfModule;
+ halfModuleBundle = new HalfModuleBundle(halfModule);
+ bundle.halfModuleStereo = halfModuleBundle;
} else {
throw new IllegalArgumentException("not a valid half-module side " + side);
}
@@ -215,9 +221,13 @@
// Build the half-module
HPSTestRunTracker2014GeomDef.Hybrid hybrid = new HPSTestRunTracker2014GeomDef.Hybrid(volName,mother);
hybrid.setMaterial("G10");
+
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother(), mother.getName());
+ hm.hybrid = hybrid;
- getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother()).hybrid = hybrid;
-
+ if(isDebug()) System.out.printf("%s: added hybrid to half-module with name %s \n", this.getClass().getSimpleName(), hm.halfModule.getName());
+
+
}
@@ -233,8 +243,9 @@
HPSTestRunTracker2014GeomDef.CarbonFiber cf = new HPSTestRunTracker2014GeomDef.CarbonFiber(volName,mother);
cf.setMaterial("CarbonFiber");
- getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother()).carbonFiber = cf;
-
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother(), mother.getName());
+ hm.carbonFiber = cf;
+
}
@@ -247,11 +258,12 @@
String volName = mother.getName() + "_lamination";
// Build the half-module
- HPSTestRunTracker2014GeomDef.HalfModuleLamination kapton = new HPSTestRunTracker2014GeomDef.HalfModuleLamination(volName,mother);
- kapton.setMaterial("Kapton");
-
- getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother()).lamination = kapton;
+ HPSTestRunTracker2014GeomDef.HalfModuleLamination lamination = new HPSTestRunTracker2014GeomDef.HalfModuleLamination(volName,mother);
+ lamination.setMaterial("Kapton");
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother(), mother.getName());
+ hm.lamination = lamination;
+
}
@@ -267,7 +279,9 @@
//
HPSTestRunTracker2014GeomDef.Sensor sensor = new HPSTestRunTracker2014GeomDef.Sensor(volName, mother, sensor_number);
sensor.setMaterial("Silicon");
- getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother()).sensor = sensor;
+
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother(), mother.getName());
+ hm.sensor = sensor;
makeHalfModuleComponentActiveSensor(sensor);
@@ -294,8 +308,8 @@
// physVolume.addPhysVolID("layer", layer);
// physVolume.addPhysVolID("module", layer);
//
-
- getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother().getMother()).activeSensor = active_sensor;
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother().getMother(), mother.getMother().getName());
+ hm.activeSensor = active_sensor;
}
@@ -395,17 +409,12 @@
*/
protected static class ModuleBundle {
protected HPSTestRunTracker2014GeomDef.TestRunModule module = null;
- protected HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModuleAxial = null;
- protected HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModuleStereo = null;
- protected HPSTestRunTracker2014GeomDef.Sensor sensor = null;
- protected HPSTestRunTracker2014GeomDef.ActiveSensor activeSensor = null;
- protected HPSTestRunTracker2014GeomDef.HalfModuleLamination lamination = null;
- protected HPSTestRunTracker2014GeomDef.CarbonFiber carbonFiber = null;
- protected HPSTestRunTracker2014GeomDef.Hybrid hybrid = null;
- protected HPSTestRunTracker2014GeomDef.TestRunColdBlock coldBlock;
+ protected HalfModuleBundle halfModuleAxial = null;
+ protected HalfModuleBundle halfModuleStereo = null;
+ protected HPSTestRunTracker2014GeomDef.TestRunColdBlock coldBlock = null;
ModuleBundle(HPSTestRunTracker2014GeomDef.TestRunModule m) {
module = m;
- }
+ }
int getLayer() {
if(module==null) throw new RuntimeException("Need to add module to bundle first!");
return getLayerFromVolumeName(module.getName());
@@ -422,7 +431,27 @@
if(module==null) throw new RuntimeException("Need to add module to bundle first!");
return module.getMother();
}
+ public void print() {
+ System.out.printf("%s: %s\n", this.getClass().getSimpleName(),module.getName());
+ halfModuleAxial.print();
+ System.out.printf("%s: %s\n", this.getClass().getSimpleName(),coldBlock.getName());
+ halfModuleStereo.print();
+ }
}
+ protected static class HalfModuleBundle {
+ protected HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModule = null;
+ protected HPSTestRunTracker2014GeomDef.Sensor sensor = null;
+ protected HPSTestRunTracker2014GeomDef.ActiveSensor activeSensor = null;
+ protected HPSTestRunTracker2014GeomDef.HalfModuleLamination lamination = null;
+ protected HPSTestRunTracker2014GeomDef.CarbonFiber carbonFiber = null;
+ protected HPSTestRunTracker2014GeomDef.Hybrid hybrid = null;
+ HalfModuleBundle(HPSTestRunTracker2014GeomDef.TestRunHalfModule hm) {
+ halfModule = hm;
+ }
+ public void print() {
+ System.out.printf("%s: %s\n", this.getClass().getSimpleName(),halfModule.getName());
+ }
+ }
/**
* Find module among the existing bundles.
@@ -450,6 +479,24 @@
}
/**
+ * Find half module among the existing bundles.
+ * @param module - to find
+ * @return bundle
+ */
+ protected HalfModuleBundle getHalfModuleBundle(HPSTestRunTracker2014GeomDef.TestRunModule module, String halfModuleName) {
+ ModuleBundle m = getModuleBundle(module.getLayer(), module.getHalf());
+ HalfModuleBundle hm = null;
+ if(m!=null) {
+ if(halfModuleName.contains("axial")) hm = m.halfModuleAxial;
+ else if(halfModuleName.contains("stereo")) hm = m.halfModuleStereo;
+ else throw new RuntimeException("NO axial or stereo string found in half module bundle name " + halfModuleName);
+ } else {
+ throw new RuntimeException("No module found for " + module.getLayer() + " and half " + module.getHalf());
+ }
+ return hm;
+ }
+
+ /**
* Add module to list.
* @param bundle - module to add.
*/
projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java 2014-08-02 15:59:58 UTC (rev 3212)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java 2014-08-04 16:36:12 UTC (rev 3213)
@@ -73,7 +73,10 @@
if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName());
for(HPSTestRunTracker2014Builder.ModuleBundle m : modules) {
- if(isDebug()) System.out.printf("%s: module layer %d half %s\n", getClass().getSimpleName(),m.getLayer(),m.getHalf());
+ if(isDebug()) {
+ System.out.printf("%s: module layer %d half %s\n", getClass().getSimpleName(),m.getLayer(),m.getHalf());
+ m.print();
+ }
String name_mother = m.getMother().getName();
LCDDBaseGeom mother = null;
//find the mother among the LCDD objects using name...
@@ -107,12 +110,24 @@
* @param mother - mother LCDD geometry object
*/
private void addModule(ModuleBundle bundle, LCDDBaseGeom mother) {
- // This could perhaps be fixed if there is a relation in geometry definition
+ // This could perhaps be fixed if there is a relation with daughters in geometry definition?
// create the module
LCDDBaseGeom lcddM = new LCDDBaseGeom(bundle.module, lcdd, mother);
add(lcddM);
+ addHalfModule(bundle.halfModuleAxial,lcddM);
+ addHalfModule(bundle.halfModuleStereo,lcddM);
+
+ }
+
+ /**
+ * Rules for adding the LCDD half module geometry.
+ * @param bundle - module to be added
+ * @param mother - mother LCDD geometry object
+ */
+ private void addHalfModule(HalfModuleBundle bundle, LCDDBaseGeom mother) {
+ // This could perhaps be fixed if there is a relation with daughters in geometry definition?
// create the half-module
- LCDDBaseGeom lcddHM = new LCDDBaseGeom(bundle.halfModuleAxial, lcdd, lcddM);
+ LCDDBaseGeom lcddHM = new LCDDBaseGeom(bundle.halfModule, lcdd, mother);
add(lcddHM);
// create the sensor
LCDDBaseGeom lcddS = new LCDDBaseGeom(bundle.sensor, lcdd, lcddHM);