HeavyGasCherenkov_geo.cpp
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
2 #include "DD4hep/Printout.h"
3 #include <XML/Helper.h>
4 #include "TMath.h"
5 #include "DDRec/Surface.h"
6 
7 #include "DD4hep/OpticalSurfaces.h"
8 #include "DDRec/DetectorData.h"
9 
10 using namespace std;
11 using namespace dd4hep;
12 using namespace dd4hep::rec;
13 
14 using namespace dd4hep;
15 
28 static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetector sens) {
29  xml::DetElement detElem = handle;
30  xml_det_t x_det = handle;
31 
32  std::string detName = detElem.nameStr();
33  int detID = detElem.id();
34 
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;
44 
45  std::map<int,Position> mirror_positions;
46  std::map<int,std::array<double,3>> mirror_rotations;
47 
48  for(xml_coll_t i(x_det,Unicode("mirror")); i; ++i){
49  xml_comp_t x_mir = i;
50  //std::cout << "mirror " << x_mir.id() << "\n";
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()};
55  }
56 
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();
61 
62  Material air = desc.air();
63  Material PyrexGlass = desc.material("PyrexGlass");
64  Material N2cherenkov = desc.material("N2cherenkov");
65  Material Copper = desc.material("Copper");
66 
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; // something tells this might be 5 mil, not mm
77  double LGC_exit_window_thickness = 0.1*mm; // same here
78 
79  double LGC_mirror1_radius = 210.0*cm;
80  double LGC_mirror2_radius = 157.99*cm;
81 
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;
90 
91  double LGC_sector_angle = M_PI * 15.0 / 180.0;
92  //double LGC_scattering_angle = 11.0 * M_PI / 180.0;
93 
94  double LGC_mirror1_tilt_angle = mirror_rotations[1][0];//25.0 * M_PI / 180.0;
95  double LGC_mirror2_tilt_angle = mirror_rotations[2][0];//2.0 * M_PI / 180.0;
96  double LGC_pmt_tilt_angle = mirror_rotations[3][0];//45.0 * M_PI / 180.0;
97 
98  double LGC_pmt_z_pos = mirror_positions[3].z();//-30.0*cm;
99  double LGC_pmt_y_pos = mirror_positions[3].y();//LGC_outer_radius1 - 20.0*cm;
100  double LGC_pmt_array_size = 20.0*cm;
101 
102  // the gas tank
103  ConeSegment tank_main(0.5 * tank_length, rInner1, rOuter1,
104  rInner2, rOuter2);
105  Volume v_lgc_tank("v_lgc_tank_gas", tank_main, N2cherenkov);
106 
107  v_lgc_tank.setVisAttributes(desc.visAttributes(detElem.visStr()));
108  // Everything that goes in the tank will be copies of the sector assembly volume
109  Assembly v_sector("cherenkov_sector_1");
110  DetElement de_sector("de_sector"+std::to_string(1),1);
111 
112 
113  // mirrors
114  Sphere mirror1_shell(LGC_mirror1_radius, LGC_mirror1_radius + LGC_mirror1_thickness,
115  0.0, M_PI / 2);
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)));
120  //Sphere mirror2_shell(LGC_mirror2_radius, LGC_mirror2_radius + LGC_mirror2_thickness,
121  // 0.0, M_PI / 2);
122  //Trd1 mirror2_cutout(LGC_mirror2_width1 / 2.0, LGC_mirror2_width2 / 2.0,
123  // LGC_mirror2_length / 2.0, LGC_mirror2_length / 2.0);
124  //IntersectionSolid mirror2_shape(mirror2_cutout, mirror2_shell,
125  // RotationX(M_PI/2.0)*Transform3D(Position(0, 0, -LGC_mirror2_radius)));
126 
127  double z_mirror1 = mirror_positions[1].z();
128  //double z_mirror2 = mirror_positions[2].z();
129  double y_mirror1 = mirror_positions[1].y();
130  //double y_mirror2 = mirror_positions[2].y();
131 
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));
136 
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);
142 
143  //Volume v_mirror2_shape("v_mirror2_shape", mirror2_shape, PyrexGlass);
144  //PlacedVolume pv_mirror2_shape = v_sector.placeVolume(
145  // v_mirror2_shape, Transform3D(Position(0, y_mirror2, z_mirror2)) *
146  // RotationX(-M_PI / 2.0 + LGC_mirror2_tilt_angle));
147 
148  //DetElement de_mirror2_shape(det,"de_mirror2_shape"+std::to_string(2),2);
149  //pv_mirror2_shape.addPhysVolID("mirror", 2);
150  //de_mirror2_shape.setPlacement(pv_mirror2_shape);
151  //sens.setType("photoncounter");
152  //v_mirror2_shape.setSensitiveDetector(sens);
153 
154  // ---------------
155  // Winston Cone
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);
167  //Cone winston_cone(LGC_winston_cone_length / 2.0, LGC_winston_cone_inner_radius1,
168  // LGC_winston_cone_inner_radius1 + LGC_winston_cone_thickness,
169  // LGC_winston_cone_inner_radius2,
170  // LGC_winston_cone_inner_radius2 + LGC_winston_cone_thickness );
171  //UnionSolid winston_cone_solid(winston_tube,winston_cone,Position(0,0,LGC_winston_tube_length / 2.0 - LGC_winston_cone_inset_length));
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 );
178 
179  SubtractionSolid winston_cone(winston_cone1, winston_cone2);
180 
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);
187 
188  //std::cout << " LGC_pmt_y_pos/cm " << LGC_pmt_y_pos/cm << "\n";
189  //std::cout << " LGC_pmt_z_pos/cm " << LGC_pmt_z_pos/cm << "\n";
190  //mirrorPV.addPhysVolID("layer", 2).addPhysVolID("module", 1);
191  //mirror_DE.setPlacement(mirrorPV);
192  //sens.setType("photoncounter");
193  //mirrorVol.setSensitiveDetector(sens);
194 
196 
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));
205 
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);
210 
211  // copper layer inside to stop photons
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));
215 
216  // Optical Surfaces
217 
218  OpticalSurfaceManager surfMgr = desc.surfaceManager();
219  OpticalSurface mirrorSurf = surfMgr.opticalSurface("MirrorOpticalSurface");
220  OpticalSurface pmtSurf = surfMgr.opticalSurface("PMTOpticalSurface");
221  //BorderSurface mirrorBorder_Surf = BorderSurface(desc, det, "RICHmirror", mirrorSurf, mirrorPV, envPV);
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);
225  //BorderSurface bubbleSurf = BorderSurface(description, sdet, "TankBubble", airSurf, bubblePlace, tankPlace);
226  mirrorBorder_Surf.isValid();
227  winstonBorder_Surf.isValid();
228  pmtBorder_Surf.isValid();
229  //tankSurf.isValid();
230 
231 
232  // all sectors
233  for (int i_sector = 1; i_sector <= 30; i_sector++) {
234  //std::cout << i_sector << " sector\n";
235  PlacedVolume pv =
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);
240  det.add(amod);
241  }
242 
243 
245 
246 
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);
251 
252  return det;
253 }
255 // clang-format off
256 DECLARE_DETELEMENT(HeavyGasCherenkov, createDetector)
257 
Detector
Definition: DDG4.py:69
Namespace for the AIDA detector description toolkit.
static Ref_t createDetector(Detector &desc, xml::Handle_t handle, SensitiveDetector sens)