13 using namespace dd4hep;
18 Assembly moduleAssembly(
"module");
20 moduleAssembly.setVisAttributes(oddd, x_module.visStr());
23 DetElement moduleElement(
"ModuleElementTemplate", 0);
26 unsigned int compNum = 0;
27 unsigned int sensorNum = 0;
29 for (xml_coll_t comp(x_module, _U(module_component)); comp;
31 xml_comp_t x_comp = comp;
35 _toString((
int)compNum,
"component%d") + x_comp.materialStr();
37 Trapezoid trapShape(x_comp.x1(), x_comp.x2(), 0.5 * x_comp.thickness(),
38 0.5 * x_comp.thickness(), x_comp.length());
40 Volume componentVolume(compName, trapShape,
41 oddd.material(x_comp.materialStr()));
42 componentVolume.setVisAttributes(oddd, x_comp.visStr());
45 if (x_comp.hasChild(_U(subtraction))) {
46 xml_comp_t x_sub = x_comp.child(_U(subtraction));
47 Tube tubeCutout(x_sub.rmin(), x_sub.rmax(), 1.1 * x_comp.length());
50 componentVolume = Volume(
53 trapShape, tubeCutout,
54 Position(x_sub.x_offset(), x_sub.y_offset(), x_sub.z_offset())),
55 oddd.material(x_comp.materialStr()));
58 if (x_comp.hasChild(_U(tube))) {
59 xml_comp_t x_pipe = x_comp.child(_U(tube));
60 Tube coolingPipe(x_pipe.rmin(), x_pipe.rmax(), x_comp.length());
62 Volume pipeVolume(
"CoolingPipe", coolingPipe,
63 oddd.material(x_pipe.materialStr()));
64 pipeVolume.setVisAttributes(oddd, x_pipe.visStr());
66 componentVolume.placeVolume(
68 Position(x_pipe.x_offset(), x_pipe.y_offset(), x_pipe.z_offset()));
73 double stereoAlpha = x_comp.alpha();
74 PlacedVolume placedComponent = moduleAssembly.placeVolume(
77 RotationY(stereoAlpha),
78 Position(x_comp.x_offset(), x_comp.y_offset(), x_comp.z_offset())));
81 if (x_comp.isSensitive()) {
82 componentVolume.setSensitiveDetector(sens);
83 placedComponent.addPhysVolID(
"sensor", sensorNum++);
86 string sensorName = _toString((
int)sensorNum,
"sensor%d");
87 DetElement sensorElement(moduleElement, sensorName, sensorNum);
88 sensorElement.setPlacement(placedComponent);
92 sensorExtension->
addType(
"sensor",
"detector");
93 sensorExtension->
addType(
"axes",
"definitions",
"XZY");
100 return std::pair<Assembly, DetElement>(moduleAssembly, moduleElement);
107 Assembly moduleAssembly(
"module");
109 moduleAssembly.setVisAttributes(oddd, x_module.visStr());
112 DetElement moduleElement(
"ModuleElementTemplate", 0);
115 unsigned int compNum = 0;
116 unsigned int sensorNum = 0;
118 for (xml_coll_t comp(x_module, _U(module_component)); comp;
120 xml_comp_t x_comp = comp;
123 string componentName = _toString((
int)compNum,
"component%d");
124 Box boxShape(0.5 * x_comp.dx(), 0.5 * x_comp.dy(), 0.5 * x_comp.dz());
126 Volume componentVolume(componentName, boxShape,
127 oddd.material(x_comp.materialStr()));
130 if (x_comp.hasChild(_U(subtraction))) {
131 xml_comp_t x_sub = x_comp.child(_U(subtraction));
132 Tube tubeCutout(x_sub.rmin(), x_sub.rmax(), x_comp.dy());
136 Volume(componentName,
138 boxShape, tubeCutout,
140 Position(x_sub.x_offset(), x_sub.y_offset(),
142 oddd.material(x_comp.materialStr()));
145 if (x_comp.hasChild(_U(tube))) {
146 xml_comp_t x_pipe = x_comp.child(_U(tube));
147 Tube coolingPipe(x_pipe.rmin(), x_pipe.rmax(), 0.5 * x_comp.dy());
149 Volume pipeVolume(
"CoolingPipe", coolingPipe,
150 oddd.material(x_pipe.materialStr()));
151 pipeVolume.setVisAttributes(oddd, x_pipe.visStr());
153 componentVolume.placeVolume(
156 Position(x_pipe.x_offset(), x_pipe.y_offset(),
157 x_pipe.z_offset())));
160 componentVolume.setVisAttributes(oddd, x_comp.visStr());
164 2. *
abs(std::copysign(0.5 * x_comp.dy(), x_comp.y_offset()) +
166 ylength = cylength > ylength ? cylength : ylength;
169 componentVolume.setVisAttributes(oddd, x_comp.visStr());
171 double stereoAlpha = x_comp.alpha();
172 PlacedVolume placedComponent = moduleAssembly.placeVolume(
175 RotationZ(stereoAlpha),
176 Position(x_comp.x_offset(), x_comp.y_offset(), x_comp.z_offset())));
179 if (x_comp.isSensitive()) {
180 componentVolume.setSensitiveDetector(sens);
181 placedComponent.addPhysVolID(
"sensor", sensorNum++);
184 string sensorName = _toString((
int)sensorNum,
"sensor%d");
185 DetElement sensorElement(moduleElement, sensorName, sensorNum);
186 sensorElement.setPlacement(placedComponent);
190 sensorExtension->
addType(
"sensor",
"detector");
191 sensorExtension->
addType(
"axes",
"definitions",
"XYZ");
198 return std::pair<Assembly, DetElement>(moduleAssembly, moduleElement);