1 #include "DD4hep/DetFactoryHelper.h"
2 #include "DD4hep/Printout.h"
3 #include <XML/Helper.h>
5 #include "DDRec/Surface.h"
7 #include "DD4hep/OpticalSurfaces.h"
8 #include "DDRec/DetectorData.h"
12 using namespace dd4hep::rec;
29 xml::DetElement detElem = handle;
30 xml_det_t x_det = handle;
32 std::string detName = detElem.nameStr();
33 int detID = detElem.id();
35 DetElement det(detName, detID);
36 xml::Component dims = detElem.dimensions();
37 double rInner1 = dims.rmin1();
38 double rInner2 = dims.rmin2();
39 double rOuter1 = dims.rmax1();
40 double rOuter2 = dims.rmax2();
41 double zMin = dims.zmin();
42 double zMax = dims.zmax();
43 double tank_length = zMax - zMin;
45 std::map<int,Position> mirror_positions;
46 std::map<int,std::array<double,3>> mirror_rotations;
48 for(xml_coll_t i(x_det,Unicode(
"mirror")); i; ++i){
51 xml_dim_t mir_pos = x_mir.child(_U(placement));
52 xml_dim_t mir_rot = x_mir.child(_U(rotation));
53 mirror_positions[x_mir.id()] = Position(mir_pos.x(), mir_pos.y(), mir_pos.z());
54 mirror_rotations[x_mir.id()] = {mir_rot.x(), mir_rot.y(), mir_rot.z()};
57 xml_dim_t pos = x_det.child(_U(placement));
58 double pos_x = pos.x();
59 double pos_y = pos.y();
60 double pos_z = pos.z();
62 Material air = desc.air();
63 Material PyrexGlass = desc.material(
"PyrexGlass");
64 Material N2cherenkov = desc.material(
"N2cherenkov");
65 Material Copper = desc.material(
"Copper");
67 double LGC_inner_radius1 = 71.0*cm;
68 double LGC_inner_radius2 = 85.0*cm;
69 double LGC_outer_radius1 = 265.0*cm;
70 double LGC_main_length = 105.0*cm;
71 double LGC_snout_length = 107.0*cm;
72 double LGC_snout_inner_radius1 = 58.0*cm;
73 double LGC_snout_inner_radius2 = LGC_inner_radius1;
74 double LGC_snout_outer_radius1 = 127.0*cm;
75 double LGC_snout_outer_radius2 = 144.0*cm;
76 double LGC_entrance_window_thickness = 0.05*mm;
77 double LGC_exit_window_thickness = 0.1*mm;
79 double LGC_mirror1_radius = 210.0*cm;
80 double LGC_mirror2_radius = 157.99*cm;
82 double LGC_mirror1_length = 114.53*cm;
83 double LGC_mirror2_length = 59.260*cm;
84 double LGC_mirror1_width1 = 16.26*cm;
85 double LGC_mirror1_width2 = 36.03*cm;
86 double LGC_mirror2_width1 = 37.06*cm;
87 double LGC_mirror2_width2 = 45.95*cm;
88 double LGC_mirror1_thickness = 2.0*mm;
89 double LGC_mirror2_thickness = 2.0*mm;
91 double LGC_sector_angle = M_PI * 15.0 / 180.0;
94 double LGC_mirror1_tilt_angle = mirror_rotations[1][0];
95 double LGC_mirror2_tilt_angle = mirror_rotations[2][0];
96 double LGC_pmt_tilt_angle = mirror_rotations[3][0];
98 double LGC_pmt_z_pos = mirror_positions[3].z();
99 double LGC_pmt_y_pos = mirror_positions[3].y();
100 double LGC_pmt_array_size = 20.0*cm;
103 ConeSegment tank_main(0.5 * tank_length, rInner1, rOuter1,
105 Volume v_lgc_tank(
"v_lgc_tank_gas", tank_main, N2cherenkov);
107 v_lgc_tank.setVisAttributes(desc.visAttributes(detElem.visStr()));
109 Assembly v_sector(
"cherenkov_sector_1");
110 DetElement de_sector(
"de_sector"+std::to_string(1),1);
114 Sphere mirror1_shell(LGC_mirror1_radius, LGC_mirror1_radius + LGC_mirror1_thickness,
116 Trd1 mirror1_cutout(LGC_mirror1_width1 / 2.0, LGC_mirror1_width2 / 2.0,
117 LGC_mirror1_length / 2.0, LGC_mirror1_length / 2.0);
118 IntersectionSolid mirror1_shape(mirror1_cutout, mirror1_shell,
119 RotationX(M_PI/2.0)*Transform3D(Position(0, 0, -LGC_mirror1_radius)));
127 double z_mirror1 = mirror_positions[1].z();
129 double y_mirror1 = mirror_positions[1].y();
132 Volume v_mirror1_shape(
"v_mirror1_shape", mirror1_shape, PyrexGlass);
133 PlacedVolume pv_mirror1_shape = v_sector.placeVolume(
134 v_mirror1_shape, Transform3D(Position(0, y_mirror1, z_mirror1)) *
135 RotationX(-M_PI / 2.0 + LGC_mirror1_tilt_angle));
137 DetElement de_mirror1_shape(det,
"de_mirror1_shape"+std::to_string(1),1);
138 pv_mirror1_shape.addPhysVolID(
"mirror", 1);
139 de_mirror1_shape.setPlacement(pv_mirror1_shape);
140 sens.setType(
"photoncounter");
141 v_mirror1_shape.setSensitiveDetector(sens);
156 double LGC_winston_cone_thickness = 4*mm;
157 double LGC_winston_tube_inner_radius = 11.28*cm;
158 double LGC_winston_tube_length = 30.0*cm;
159 double LGC_winston_cone_length = 30.0*cm;
160 double LGC_winston_cone_inner_radius1 = 7.8*cm;
161 double LGC_winston_cone_inner_radius2 = 21.0*cm;
162 double LGC_winston_cone_inset_length = 7.90909*cm;
163 DetElement de_winston_cone(det,
"de_winston_cone1",1);
164 Tube winston_tube(LGC_winston_tube_inner_radius,
165 LGC_winston_tube_inner_radius + LGC_winston_cone_thickness,
166 LGC_winston_tube_length / 2.0);
172 Paraboloid winston_cone1(LGC_winston_cone_inner_radius1 + LGC_winston_cone_thickness,
173 LGC_winston_cone_inner_radius2 + LGC_winston_cone_thickness,
174 LGC_winston_cone_length / 2.0 );
175 Paraboloid winston_cone2(LGC_winston_cone_inner_radius1,
176 LGC_winston_cone_inner_radius2,
177 LGC_winston_cone_length / 2.0 );
179 SubtractionSolid winston_cone(winston_cone1, winston_cone2);
181 Volume v_winston_cone_solid(
"v_winston_cone_solid", winston_cone, PyrexGlass);
182 PlacedVolume pv_winston_cone_solid = v_sector.placeVolume(
183 v_winston_cone_solid, Transform3D(Position(0, LGC_pmt_y_pos, LGC_pmt_z_pos)) *
184 RotationX(LGC_pmt_tilt_angle) *
185 Transform3D(Position(0, 0, LGC_winston_tube_length / 2.0 + 5.0 * mm)));
186 de_winston_cone.setPlacement(pv_winston_cone_solid);
199 DetElement de_pmt_array(det,
"PMT_DE", 1);
200 Box pmt_array(LGC_pmt_array_size / 2.0, LGC_pmt_array_size / 2.0, 5 * mm / 2.0);
201 Volume v_pmt_array(
"v_pmt_array", pmt_array, N2cherenkov);
202 PlacedVolume pv_pmt_array =
203 v_sector.placeVolume(v_pmt_array, Transform3D(Position(0, LGC_pmt_y_pos, LGC_pmt_z_pos)) *
204 RotationX(LGC_pmt_tilt_angle));
206 pv_pmt_array.addPhysVolID(
"mirror", 3);
207 de_pmt_array.setPlacement(pv_pmt_array);
208 sens.setType(
"photoncounter");
209 v_pmt_array.setSensitiveDetector(sens);
212 Box pmt_array_backing(LGC_pmt_array_size/2.0, LGC_pmt_array_size/2.0, 1*mm/2.0);
213 Volume v_pmt_array_backing(
"v_pmt_array_backing", pmt_array_backing, Copper);
214 PlacedVolume pv_pmt_array_backing = v_pmt_array.placeVolume(v_pmt_array_backing, Position(0,0,0));
218 OpticalSurfaceManager surfMgr = desc.surfaceManager();
219 OpticalSurface mirrorSurf = surfMgr.opticalSurface(
"MirrorOpticalSurface");
220 OpticalSurface pmtSurf = surfMgr.opticalSurface(
"PMTOpticalSurface");
222 SkinSurface mirrorBorder_Surf(desc,de_mirror1_shape,
"RICHmirror", mirrorSurf, v_mirror1_shape);
223 SkinSurface winstonBorder_Surf(desc,de_winston_cone,
"WinstonCone", mirrorSurf, v_winston_cone_solid);
224 SkinSurface pmtBorder_Surf(desc,de_pmt_array,
"PMTsurface", pmtSurf, v_pmt_array);
226 mirrorBorder_Surf.isValid();
227 winstonBorder_Surf.isValid();
228 pmtBorder_Surf.isValid();
233 for (
int i_sector = 1; i_sector <= 30; i_sector++) {
236 v_lgc_tank.placeVolume(v_sector, Transform3D(RotationZ((i_sector - 1) * LGC_sector_angle)));
237 pv.addPhysVolID(
"sector", i_sector);
238 auto amod = (i_sector == 1 ? de_sector : de_sector.clone(
"de_sector" + std::to_string(i_sector), i_sector));
239 amod.setPlacement(pv);
247 Volume motherVol = desc.pickMotherVolume(det);
248 PlacedVolume envPV = motherVol.placeVolume(v_lgc_tank, Position(pos_x, pos_y, pos_z));
249 envPV.addPhysVolID(
"system", detID);
250 det.setPlacement(envPV);