HexagonalScintPreShower_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 #include "DDRec/DetectorData.h"
7 
8 using namespace std;
9 using namespace dd4hep;
10 using namespace dd4hep::rec;
11 
12 using namespace dd4hep;
13 
28 static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetector sens) {
29  xml::DetElement detElem = handle;
30 
31  std::string detName = detElem.nameStr();
32  int detID = detElem.id();
33 
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();
40 
41  Material air = desc.air();
42  Material PyrexGlass = desc.material("PyrexGlass");
43 
44  Assembly assembly( detName+"_assembly" );
45  //Cone envShape(0.5 * (zMax - zMin), rInner, rOuter1, rInner, rOuter2);
46  //Volume envVol(detName + "_envelope", envShape, air);
47 
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;
54 
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};
62 
63  int nx = 10;
64  int ny = 10;
65 
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;
68 
69  double offset_x = -(width_x / 2.0) + r_nearest_spacing;
70  double offset_y = -(width_y / 2.0) + l_side_spacing;
71 
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));
75 
76  //ExtrudedPolygon mirrorShape("hex_scint",ptx, pty, sec_z, sec_x, sec_y, z_scale);
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");
81 
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));
89  }
90  }
91 
92  scintVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
93  assembly.setVisAttributes(desc.visAttributes(detElem.visStr()));
94 
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);
100  return det;
101 }
103 // clang-format off
104 DECLARE_DETELEMENT(HexagonalScintPreShower, createDetector)
static Ref_t createDetector(Detector &desc, xml::Handle_t handle, SensitiveDetector sens)
Detector
Definition: DDG4.py:69
Namespace for the AIDA detector description toolkit.