7 #include "DD4hep/DetFactoryHelper.h"
8 #include "DD4hep/Printout.h"
9 #include <XML/Helper.h>
11 #include "DDRec/Surface.h"
12 #include "DDRec/DetectorData.h"
16 using namespace dd4hep::rec;
17 using namespace dd4hep::detail;
38 int det_id = x_det.id();
39 string det_name = x_det.nameStr();
42 double rmax = 10.0*cm;
44 Assembly assembly( det_name+
"_assembly" );
48 double layer0_thickness = 0.5*mm;
49 double layer1_thickness = 1.5*mm;
50 double total_layer_thickness = layer0_thickness + layer1_thickness;
52 double width_x = 1*cm;
53 double width_y = 1*cm;
55 auto gray_vis = description.visAttributes(
"GrayVis");
56 auto red_vis = description.visAttributes(
"RedVis");
58 DetElement det(det_name, det_id);
60 Assembly module_assembly(
"module_assembly" );
61 PlacedVolume module_PV;
64 Box lead_layer_shape(width_x/2.0, width_y/2.0,layer0_thickness/2.0);
65 Volume lead_layer_Vol(
"lead_layer_Vol", lead_layer_shape, description.material(
"Lead"));
66 lead_layer_Vol.setVisAttributes(gray_vis);
68 Box scint_layer_shape(width_x/2.0, width_y/2.0,layer1_thickness/2.0);
69 Volume scint_layer_Vol(
"scint_layer_Vol", scint_layer_shape, description.material(
"PlasticScint"));
70 scint_layer_Vol.setVisAttributes(red_vis);
72 for(
int ilayer = 0; ilayer < nlayers; ilayer++) {
73 double z_layer = ilayer * total_layer_thickness + layer0_thickness / 2.0;
74 auto lead_PV = module_assembly.placeVolume(lead_layer_Vol, Position(0.0, 0.0, z_layer));
75 lead_PV.addPhysVolID(
"layer", ilayer).addPhysVolID(
"slice", 1);
76 sens.setType(
"calorimeter");
77 lead_layer_Vol.setSensitiveDetector(sens);
78 double dz_scint = layer0_thickness / 2.0 + layer1_thickness / 2.0;
79 auto scint_PV = module_assembly.placeVolume(scint_layer_Vol, Position(0.0, 0.0, z_layer + dz_scint));
80 scint_PV.addPhysVolID(
"layer", ilayer).addPhysVolID(
"slice", 2);
81 sens.setType(
"calorimeter");
82 scint_layer_Vol.setSensitiveDetector(sens);
89 double offset_x = 0.1*mm;
90 double offset_y = 0.1*mm;
92 double pos_x = 0.0*cm;
93 double pos_y = 0.0*cm;
95 double x_start = (width_x + offset_x)/2.0;
96 double y_start = (width_y + offset_x)/2.0;
98 double x_spacing = width_x + offset_x;
99 double y_spacing = width_y + offset_y;
100 double diagonal = width_x*sqrt(2);
102 double limit_inner = rmin + diagonal/2.0;
103 double limit_outer = rmax - diagonal/2.0;
112 for(
int ix = 0; ix<nx; ix++)
114 pos_x = x_start + (ix*x_spacing);
116 for(
int iy = 0; iy<ny; iy++)
118 pos_y = y_start + (iy*y_spacing);
119 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner && sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer)
121 module_PV = assembly.placeVolume(module_assembly, Position(pos_x,pos_y,0.0));
123 module_PV.addPhysVolID(
"module", imod);
132 for(
int ix = 0; ix<nx; ix++)
134 pos_x = -x_start - (ix*x_spacing);
136 for(
int iy = 0; iy<ny; iy++)
138 pos_y = y_start + (iy*y_spacing);
139 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner && sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer)
141 module_PV = assembly.placeVolume(module_assembly, Position(pos_x,pos_y, 0.0));
143 module_PV.addPhysVolID(
"module", imod);
152 for(
int ix = 0; ix<nx; ix++)
154 pos_x = x_start + (ix*x_spacing);
156 for(
int iy = 0; iy<ny; iy++)
158 pos_y = -y_start - (iy*y_spacing);
159 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner && sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer)
161 module_PV = assembly.placeVolume(module_assembly, Position(pos_x,pos_y, 0.0));
163 module_PV.addPhysVolID(
"module", imod);
172 for(
int ix = 0; ix<nx; ix++)
174 pos_x = -x_start - (ix*x_spacing);
176 for(
int iy = 0; iy<ny; iy++)
178 pos_y = -y_start - (iy*y_spacing);
179 if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > limit_inner && sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer)
181 module_PV = assembly.placeVolume(module_assembly, Position(pos_x,pos_y, 0.0));
183 module_PV.addPhysVolID(
"module", imod);
190 Volume motherVol = description.pickMotherVolume(det);
191 PlacedVolume envPV = motherVol.placeVolume(assembly, Position(0, 0, 0));
192 envPV.addPhysVolID(
"system", det_id);
193 det.setPlacement(envPV);