11 #include "DD4hep/DetFactoryHelper.h"
12 #include "XML/Layering.h"
17 using namespace dd4hep::detail;
39 xml_dim_t dim = x_det.dimensions();
40 int det_id = x_det.id();
41 string det_name = x_det.nameStr();
42 Material PbWO4 = description.material(
"PbWO4");
43 double rmin = dim.rmin();
44 double rmax = dim.rmax();
45 double zmin = dim.zmin();
46 double zmax = dim.zmax();
47 double thickness = zmax - zmin;
48 double z_pos = zmin + thickness / 2.0;
50 Assembly assembly(det_name);
51 DetElement endcap_DE(det_name,det_id);
54 Tube tube(rmin, rmax, thickness / 2.0);
55 Volume Vol(
"tube_volume", tube, PbWO4);
62 Assembly box_assembly(
"box_assembly");
66 double box_x_width = 2*cm;
67 double box_y_width = 2*cm;
68 double box_z_length = 20*cm;
70 double offset_x = 1*mm;
71 double offset_y = 1*mm;
72 double offset_diagonal = box_x_width*sqrt(2)/2.0 + 0.1*cm;
74 double limit_inner = rmin + offset_diagonal;
75 double limit_outer = rmax - offset_diagonal;
77 int nx = floor(rmax/box_x_width);
78 int ny = floor(rmax/box_y_width);
80 double x_spacing = box_x_width + offset_x;
81 double y_spacing = box_y_width + offset_y;
87 Box box(box_x_width/2.0, box_y_width/2.0, box_z_length/2.0);
88 Volume vol(
"box_volume", box, PbWO4);
96 for(
int iy=0; iy<ny-1; iy++){
97 for(
int ix=0; ix<nx; ix++){
98 double x_start = box_x_width/2.0 + offset_x/2.0;
103 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
104 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
115 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner)
117 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
124 pv_box.addPhysVolID(
"sector",1).addPhysVolID(
"module",i_module);
125 sens.setType(
"calorimeter");
126 vol.setSensitiveDetector(sens);
138 for(
int iy=0; iy<ny-1; iy++){
139 for(
int ix=0; ix<nx; ix++){
140 double x_start = box_x_width/2.0 + offset_x/2.0;
145 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
146 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
157 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
158 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
165 pv_box.addPhysVolID(
"sector",2).addPhysVolID(
"module",i_module);
166 sens.setType(
"calorimeter");
167 vol.setSensitiveDetector(sens);
180 for(
int iy=0; iy<ny-2; iy++){
181 for(
int ix=0; ix<nx; ix++){
182 double x_start = box_x_width/2.0 + offset_x/2.0;
187 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
188 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
199 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
200 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
207 pv_box.addPhysVolID(
"sector",3).addPhysVolID(
"module",i_module);
208 sens.setType(
"calorimeter");
209 vol.setSensitiveDetector(sens);
222 for(
int iy=0; iy<ny-2; iy++){
223 for(
int ix=0; ix<nx; ix++)
225 double x_start = box_x_width/2.0 + offset_x/2.0;
230 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
231 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
242 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
243 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
250 pv_box.addPhysVolID(
"sector",4).addPhysVolID(
"module",i_module);
251 sens.setType(
"calorimeter");
252 vol.setSensitiveDetector(sens);
260 Volume motherVol = description.pickMotherVolume(endcap_DE);
261 auto pv = motherVol.placeVolume(assembly, Position(0.0, 0.0, z_pos));
262 pv.addPhysVolID(
"system", det_id);
263 endcap_DE.setPlacement(pv);