14 using namespace dd4hep;
17 Detector& oddd, SensitiveDetector& sens,
const xml_comp_t& x_module) {
19 Assembly moduleAssembly(
"module");
21 moduleAssembly.setVisAttributes(oddd, x_module.visStr());
24 DetElement moduleElement(
"ModuleElementTemplate", 0);
27 unsigned int compNum = 0;
28 unsigned int sensorNum = 0;
30 for (xml_coll_t comp(x_module, _U(module_component)); comp;
32 xml_comp_t x_comp = comp;
36 _toString((
int)compNum,
"component%d") + x_comp.materialStr();
38 Trapezoid trapShape(x_comp.x1(), x_comp.x2(), 0.5 * x_comp.thickness(),
39 0.5 * x_comp.thickness(), x_comp.length());
41 Volume componentVolume(compName, trapShape,
42 oddd.material(x_comp.materialStr()));
43 componentVolume.setVisAttributes(oddd, x_comp.visStr());
46 if (x_comp.hasChild(_U(subtraction))) {
47 xml_comp_t x_sub = x_comp.child(_U(subtraction));
48 Tube tubeCutout(x_sub.rmin(), x_sub.rmax(), 1.1 * x_comp.length());
51 componentVolume = Volume(
54 trapShape, tubeCutout,
55 Position(x_sub.x_offset(), x_sub.y_offset(), x_sub.z_offset())),
56 oddd.material(x_comp.materialStr()));
59 if (x_comp.hasChild(_U(tube))) {
60 xml_comp_t x_pipe = x_comp.child(_U(tube));
61 Tube coolingPipe(x_pipe.rmin(), x_pipe.rmax(), x_comp.length());
63 Volume pipeVolume(
"CoolingPipe", coolingPipe,
64 oddd.material(x_pipe.materialStr()));
65 pipeVolume.setVisAttributes(oddd, x_pipe.visStr());
67 componentVolume.placeVolume(
69 Position(x_pipe.x_offset(), x_pipe.y_offset(), x_pipe.z_offset()));
74 double stereoAlpha = x_comp.alpha();
75 PlacedVolume placedComponent = moduleAssembly.placeVolume(
78 RotationY(stereoAlpha),
79 Position(x_comp.x_offset(), x_comp.y_offset(), x_comp.z_offset())));
82 if (x_comp.isSensitive()) {
83 componentVolume.setSensitiveDetector(sens);
84 placedComponent.addPhysVolID(
"sensor", sensorNum++);
87 string sensorName = _toString((
int)sensorNum,
"sensor%d");
88 DetElement sensorElement(moduleElement, sensorName, sensorNum);
89 sensorElement.setPlacement(placedComponent);
93 sensorExtension->
addType(
"sensor",
"detector");
94 sensorExtension->
addType(
"axes",
"definitions",
"XZY");
101 return std::pair<Assembly, DetElement>(moduleAssembly, moduleElement);
105 Detector& oddd, SensitiveDetector& sens,
const xml_comp_t& x_module,
108 Assembly moduleAssembly(
"module");
110 moduleAssembly.setVisAttributes(oddd, x_module.visStr());
113 DetElement moduleElement(
"ModuleElementTemplate", 0);
116 unsigned int compNum = 0;
117 unsigned int sensorNum = 0;
119 for (xml_coll_t comp(x_module, _U(module_component)); comp;
121 xml_comp_t x_comp = comp;
124 string componentName = _toString((
int)compNum,
"component%d");
125 Box boxShape(0.5 * x_comp.dx(), 0.5 * x_comp.dy(), 0.5 * x_comp.dz());
127 Volume componentVolume(componentName, boxShape,
128 oddd.material(x_comp.materialStr()));
131 if (x_comp.hasChild(_U(subtraction))) {
132 xml_comp_t x_sub = x_comp.child(_U(subtraction));
133 Tube tubeCutout(x_sub.rmin(), x_sub.rmax(), x_comp.dy());
137 Volume(componentName,
139 boxShape, tubeCutout,
141 Position(x_sub.x_offset(), x_sub.y_offset(),
143 oddd.material(x_comp.materialStr()));
146 if (x_comp.hasChild(_U(tube))) {
147 xml_comp_t x_pipe = x_comp.child(_U(tube));
148 Tube coolingPipe(x_pipe.rmin(), x_pipe.rmax(), 0.5 * x_comp.dy());
150 Volume pipeVolume(
"CoolingPipe", coolingPipe,
151 oddd.material(x_pipe.materialStr()));
152 pipeVolume.setVisAttributes(oddd, x_pipe.visStr());
154 componentVolume.placeVolume(
157 Position(x_pipe.x_offset(), x_pipe.y_offset(),
158 x_pipe.z_offset())));
161 componentVolume.setVisAttributes(oddd, x_comp.visStr());
165 2. *
abs(std::copysign(0.5 * x_comp.dy(), x_comp.y_offset()) +
167 ylength = cylength > ylength ? cylength : ylength;
170 componentVolume.setVisAttributes(oddd, x_comp.visStr());
172 double stereoAlpha = x_comp.alpha();
173 PlacedVolume placedComponent = moduleAssembly.placeVolume(
176 RotationZ(stereoAlpha),
177 Position(x_comp.x_offset(), x_comp.y_offset(), x_comp.z_offset())));
180 if (x_comp.isSensitive()) {
181 componentVolume.setSensitiveDetector(sens);
182 placedComponent.addPhysVolID(
"sensor", sensorNum++);
185 string sensorName = _toString((
int)sensorNum,
"sensor%d");
186 DetElement sensorElement(moduleElement, sensorName, sensorNum);
187 sensorElement.setPlacement(placedComponent);
191 sensorExtension->
addType(
"sensor",
"detector");
192 sensorExtension->
addType(
"axes",
"definitions",
"XYZ");
199 return std::pair<Assembly, DetElement>(moduleAssembly, moduleElement);