1 #include "DD4hep/DetFactoryHelper.h"
2 #include "DD4hep/Printout.h"
3 #include <XML/Helper.h>
5 #include "DDRec/Surface.h"
6 #include "DDRec/DetectorData.h"
10 using namespace dd4hep::rec;
29 xml::DetElement detElem = handle;
31 std::string detName = detElem.nameStr();
32 int detID = detElem.id();
34 xml::Component dims = detElem.dimensions();
35 double rInner = dims.rmin();
36 double rOuter1 = dims.rmax1();
37 double rOuter2 = dims.rmax2();
38 double zMin = dims.zmin();
39 double zMax = dims.zmax();
41 Material air = desc.air();
42 Material PyrexGlass = desc.material(
"PyrexGlass");
44 Assembly assembly( detName+
"_assembly" );
48 double l_side = 6.25 * cm;
49 double r_nearest = l_side * std::sqrt(3.0) / 2.0;
50 double thickness = 2.0 * cm;
51 double l_side_spacing = 6.25 * cm + 1.0 * mm;
52 double r_nearest_spacing = l_side_spacing * std::sqrt(3.0) / 2.0;
53 double y_spacing = 1.5*l_side_spacing;
55 std::vector<double> ptx = { r_nearest, 0.0, -r_nearest, -r_nearest, 0.0, r_nearest };
56 std::vector<double> pty = { l_side/2.0, l_side, l_side/2.0, -l_side/2.0, -l_side, -l_side/2.0 };
57 std::vector<double> sec_x = { 0.0, 0.0 };
58 std::vector<double> sec_y = { 0.0, 0.0 };
59 std::vector<double> sec_z = { -thickness/2.0, thickness/2.0 };
60 std::vector<double> z_scale = { 1.0, 1.0 };
61 std::vector<double> sec_r = {r_nearest, r_nearest};
66 double width_x = (2.0*r_nearest_spacing)*nx + r_nearest_spacing;
67 double width_y = (y_spacing)*ny + 0.5*l_side_spacing;
69 double offset_x = -(width_x / 2.0) + r_nearest_spacing;
70 double offset_y = -(width_y / 2.0) + l_side_spacing;
72 Box Pb_wall_shape(width_x/2.0, width_y/2.0,1.2*cm/2.0);
73 Volume Pb_wall_Vol(
"Pb_preshower_wall", Pb_wall_shape, desc.material(
"Lead"));
74 PlacedVolume Pb_wall_PV = assembly.placeVolume(Pb_wall_Vol, Position(0.0,0.0, -5.0*cm));
77 Polyhedra hexScintShape(
"hex_lead", 6, 0.0, 2.0*M_PI, sec_z, sec_r);
78 Volume scintVol(
"hex_scint_volume", hexScintShape, PyrexGlass);
79 scintVol.setSensitiveDetector(sens);
80 sens.setType(
"calorimeter");
82 for(
int ix =0; ix<nx; ix++){
83 for(
int iy =0; iy<ny; iy++){
84 double extra_x = -(iy%2)*r_nearest_spacing + r_nearest_spacing;
85 PlacedVolume mirrorPV = assembly.placeVolume(
86 scintVol, Translation3D(offset_x + ix * (2.0 * r_nearest_spacing) + extra_x,
87 offset_y + iy * (y_spacing),
88 0.0)*RotationZ(M_PI*30.0/180.0));
92 scintVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
93 assembly.setVisAttributes(desc.visAttributes(detElem.visStr()));
95 DetElement det(detName, detID);
96 Volume motherVol = desc.pickMotherVolume(det);
97 PlacedVolume envPV = motherVol.placeVolume(assembly, Position(0, 0, 0.5 * (zMin + zMax)));
98 envPV.addPhysVolID(
"system", detID);
99 det.setPlacement(envPV);