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;
31 xml::DetElement detElem = handle;
33 std::string detName = detElem.nameStr();
34 int detID = detElem.id();
36 DetElement det(detName, detID);
37 xml::Component dims = detElem.dimensions();
38 double rInner1 = dims.rmin1();
39 double rInner2 = dims.rmin2();
40 double rOuter1 = dims.rmax1();
41 double rOuter2 = dims.rmax2();
42 double zMin = dims.zmin();
43 double zMax = dims.zmax();
45 Material air = desc.air();
46 Material PyrexGlass = desc.material(
"PyrexGlass");
47 Material N2cherenkov = desc.material(
"N2cherenkov");
49 Cone envShape(0.5 * (zMax - zMin), rInner1, rOuter1, rInner2, rOuter2);
50 Volume envVol(detName +
"_envelope", envShape, N2cherenkov);
54 DetElement mirror_DE(det,
"Mirror_DE",0);
55 Tube mirrorShape(rInner1+1*cm, rOuter2-2*cm, 6*mm/2.0);
56 Volume mirrorVol(
"RICH_mirror_dummy", mirrorShape, PyrexGlass);
57 PlacedVolume mirrorPV = envVol.placeVolume(mirrorVol, Position(0, 0, 0.5*(zMax-zMin)-1*cm));
58 mirrorPV.addPhysVolID(
"layer", 2).addPhysVolID(
"module", 1);
59 mirror_DE.setPlacement(mirrorPV);
81 double a_side_mcp = 10.2 * cm;
82 double mcppmt_radius = (rOuter1 - a_side_mcp);
83 double theta_start = std::asin(2.0 * a_side_mcp / mcppmt_radius);
84 double first_y_disp = 2.0 * a_side_mcp / std::tan(theta_start);
85 int N_mcppmt = std::floor(mcppmt_radius / a_side_mcp);
87 Box mcppmt_shape(10.0*cm/2.0, 10.0*cm/2.0, 1.0*cm/2.0);
88 Volume mcppmt_v(
"mcppmt_v", mcppmt_shape, N2cherenkov);
89 mcppmt_v.setVisAttributes(desc.visAttributes(
"BlueVis"));
91 double x_PMTi = -N_mcppmt * a_side_mcp;
92 double y_PMTi = first_y_disp;
96 while(y_PMTi > -mcppmt_radius) {
97 while(x_PMTi < mcppmt_radius) {
98 double r_PMTi = std::sqrt(x_PMTi*x_PMTi + y_PMTi*y_PMTi);
99 if ( (r_PMTi < mcppmt_radius) && (r_PMTi > (rInner1 + a_side_mcp )) ) {
100 PlacedVolume mcppmt_pv =
101 envVol.placeVolume(mcppmt_v, Position(x_PMTi, y_PMTi, -0.5 * (zMax - zMin) + 4 * cm));
102 DetElement mcppmt_DE(det,std::string(
"MCPPMT_DE")+std::to_string(in),in);
103 mcppmt_pv.addPhysVolID(
"layer", 3)
104 .addPhysVolID(
"module", 1)
105 .addPhysVolID(
"x", ix)
106 .addPhysVolID(
"y", iy);
107 sens.setType(
"photoncounter");
108 mcppmt_DE.setPlacement(mcppmt_pv);
109 mcppmt_v.setSensitiveDetector(sens);
113 x_PMTi += a_side_mcp;
115 x_PMTi = -N_mcppmt*a_side_mcp;
116 y_PMTi -= a_side_mcp;
121 envVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
123 Volume motherVol = desc.pickMotherVolume(det);
124 PlacedVolume envPV = motherVol.placeVolume(envVol, Position(0, 0, 0.5 * (zMin + zMax)));
125 envPV.addPhysVolID(
"system", detID);
126 det.setPlacement(envPV);
128 OpticalSurfaceManager surfMgr = desc.surfaceManager();
129 OpticalSurface mirrorSurf = surfMgr.opticalSurface(
"MirrorOpticalSurface");
132 SkinSurface mirrorBorder_Surf(desc,mirror_DE,
"RICHmirror", mirrorSurf, mirrorVol);
134 mirrorBorder_Surf.isValid();