25 typedef vector<PlacedVolume> Placements;
28 int det_id = x_det.id();
29 string det_name = x_det.nameStr();
32 map<string, Volume> volumes;
33 map<string, Placements> sensitives;
40 string m_nam = x_mod.nameStr();
41 Volume m_vol(m_nam,
Box(m_env.width()/2,m_env.length()/2,m_env.thickness()/2),air);
42 int ncomponents = 0, sensor_number = 1;
44 if ( volumes.find(m_nam) != volumes.end() ) {
45 printout(ERROR,
"SiTrackerBarrel",
"Logics error in building modules.");
46 throw runtime_error(
"Logics error in building modules.");
48 volumes[m_nam] = m_vol;
49 m_vol.setVisAttributes(description.
visAttributes(x_mod.visStr()));
50 for(
xml_coll_t ci(x_mod,
_U(module_component)); ci; ++ci, ++ncomponents) {
54 string c_nam =
_toString(ncomponents,
"component%d");
55 Box c_box(x_comp.width()/2,x_comp.length()/2,x_comp.thickness()/2);
56 Volume c_vol(c_nam,c_box,description.
material(x_comp.materialStr()));
58 if ( x_pos && x_rot ) {
59 Position c_pos(x_pos.x(0),x_pos.y(0),x_pos.z(0));
60 RotationZYX c_rot(x_rot.z(0),x_rot.y(0),x_rot.x(0));
61 pv = m_vol.placeVolume(c_vol,
Transform3D(c_rot,c_pos));
64 pv = m_vol.placeVolume(c_vol,
RotationZYX(x_rot.z(0),x_rot.y(0),x_rot.x(0)));
67 pv = m_vol.placeVolume(c_vol,
Position(x_pos.x(0),x_pos.y(0),x_pos.z(0)));
70 pv = m_vol.placeVolume(c_vol);
72 c_vol.setRegion(description, x_comp.regionStr());
73 c_vol.setLimitSet(description, x_comp.limitsStr());
74 c_vol.setVisAttributes(description, x_comp.visStr());
75 if ( x_comp.isSensitive() ) {
77 c_vol.setSensitiveDetector(sens);
78 sensitives[m_nam].push_back(pv);
84 xml_comp_t x_barrel = x_layer.child(
_U(barrel_envelope));
87 int lay_id = x_layer.id();
88 string m_nam = x_layer.moduleStr();
89 string lay_nam =
_toString(x_layer.id(),
"layer%d");
90 Tube lay_tub (x_barrel.inner_r(),x_barrel.outer_r(),x_barrel.z_length()/2);
91 Volume lay_vol (lay_nam,lay_tub,air);
92 double phi0 = x_layout.phi0();
93 double phi_tilt = x_layout.phi_tilt();
94 double rc = x_layout.rc();
95 int nphi = x_layout.nphi();
96 double rphi_dr = x_layout.dr();
97 double phi_incr = (
M_PI * 2) / nphi;
99 double z0 = z_layout.z0();
100 double nz = z_layout.nz();
101 double z_dr = z_layout.dr();
102 Volume m_env = volumes[m_nam];
104 Placements& sensVols = sensitives[m_nam];
109 double z_incr = nz > 1 ? (2.0 * z0) / (nz - 1) : 0.0;
111 double module_z = -z0;
115 for (
int ii = 0; ii < nphi; ii++) {
116 double dx = z_dr * std::cos(phic + phi_tilt);
117 double dy = z_dr * std::sin(phic + phi_tilt);
118 double x = rc * std::cos(phic);
119 double y = rc * std::sin(phic);
122 for (
int j = 0; j < nz; j++) {
123 string module_name =
_toString(module,
"module%d");
124 DetElement mod_elt(lay_elt,module_name,module);
130 pv = lay_vol.placeVolume(m_env,tr);
132 mod_elt.setPlacement(pv);
133 for(
size_t ic=0; ic<sensVols.size(); ++ic) {
136 comp_elt.setPlacement(sens_pv);
156 pv = assembly.placeVolume(lay_vol);
158 lay_elt.setAttributes(description,lay_vol,x_layer.regionStr(),x_layer.limitsStr(),x_layer.visStr());
159 lay_elt.setPlacement(pv);
161 sdet.setAttributes(description,assembly,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
162 assembly.setVisAttributes(description.
invisible());
166 sdet.setPlacement(pv);