6 #include "DD4hep/DetFactoryHelper.h"
7 #include "XML/Layering.h"
12 using namespace dd4hep::detail;
34 xml_dim_t dim = x_det.dimensions();
35 int det_id = x_det.id();
36 string det_name = x_det.nameStr();
37 Material PbWO4 = description.material(
"PbWO4");
38 double rmin = dim.rmin();
39 double rmax = dim.rmax();
40 double pixel_x = dim.x();
41 double pixel_y = dim.y();
42 double pixel_z = dim.z();
43 xml_dim_t pos = x_det.position();
44 double x_pos = dd4hep::getAttrOrDefault(pos, _Unicode(x),0.0);
45 double y_pos = dd4hep::getAttrOrDefault(pos, _Unicode(y),0.0);
46 double z_pos = dd4hep::getAttrOrDefault(pos, _Unicode(z),0.0);
47 double totWidth = pixel_z;
49 Assembly assembly(det_name);
50 DetElement endcap_DE(det_name,det_id);
53 Assembly box_assembly(
"box_assembly");
57 double offset_x = 0.1*mm;
58 double offset_y = 0.1*mm;
59 double offset_diagonal = pixel_x*sqrt(2)/2.0 + offset_x;
61 double limit_inner = rmin + offset_diagonal;
62 double limit_outer = rmax - offset_diagonal;
64 int nx = floor(rmax/pixel_x);
65 int ny = floor(rmax/pixel_y);
67 double x_spacing = pixel_x + offset_x;
68 double y_spacing = pixel_y + offset_y;
70 double pos_x = 0.0*mm;
71 double pos_y = 0.0*mm;
74 Box box(pixel_x/2.0, pixel_y/2.0, pixel_z/2.0);
75 Volume vol(
"box_volume", box, PbWO4);
83 pos_y = pixel_y/2.0 + offset_y/2.0;
84 for(
int iy=0; iy<ny-1; iy++){
85 for(
int ix=0; ix<nx; ix++){
86 double x_start = pixel_x/2.0 + offset_x/2.0;
91 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
92 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
103 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner)
105 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
112 pv_box.addPhysVolID(
"sector",1).addPhysVolID(
"module",i_module);
113 sens.setType(
"calorimeter");
114 vol.setSensitiveDetector(sens);
124 pos_y = pixel_y/2.0 + offset_y/2.0;
126 for(
int iy=0; iy<ny-1; iy++){
127 for(
int ix=0; ix<nx; ix++){
128 double x_start = pixel_x/2.0 + offset_x/2.0;
133 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
134 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
145 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
146 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
153 pv_box.addPhysVolID(
"sector",2).addPhysVolID(
"module",i_module);
154 sens.setType(
"calorimeter");
155 vol.setSensitiveDetector(sens);
166 pos_y = -y_spacing/2.0 - offset_y/2.0;
168 for(
int iy=0; iy<ny-1; iy++){
169 for(
int ix=0; ix<nx; ix++){
170 double x_start = pixel_x/2.0 + offset_x/2.0;
175 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
176 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
187 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
188 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
195 pv_box.addPhysVolID(
"sector",3).addPhysVolID(
"module",i_module);
196 sens.setType(
"calorimeter");
197 vol.setSensitiveDetector(sens);
208 pos_y = -y_spacing/2.0 - offset_y/2.0;
210 for(
int iy=0; iy<ny-1; iy++){
211 for(
int ix=0; ix<nx; ix++)
213 double x_start = pixel_x/2.0 + offset_x/2.0;
218 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
219 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
230 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner){
231 pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
238 pv_box.addPhysVolID(
"sector",4).addPhysVolID(
"module",i_module);
239 sens.setType(
"calorimeter");
240 vol.setSensitiveDetector(sens);
248 Volume motherVol = description.pickMotherVolume(endcap_DE);
249 auto pv = motherVol.placeVolume(assembly, Position(x_pos,y_pos,z_pos-totWidth/2.0));
250 pv.addPhysVolID(
"system", det_id);
251 endcap_DE.setPlacement(pv);