86 string name = shield.getName();
87 double minZ(0), maxZ(0);
90 double minPhi = shield.getMinPhi();
91 double dPhi = shield.getMaxPhi() - minPhi;
92 int nPlanes = shield.getPlanes().size();
94 B2ERROR(
"Polycone needs at least two planes");
97 std::vector<double> z(nPlanes, 0);
98 std::vector<double> rMin(nPlanes, 0);
99 std::vector<double> rMax(nPlanes, 0);
101 minZ = numeric_limits<double>::infinity();
102 maxZ = -numeric_limits<double>::infinity();
106 z[index] = plane.getPosZ() /
Unit::mm;
107 minZ = min(minZ, z[index]);
108 maxZ = max(maxZ, z[index]);
109 rMin[index] = plane.getInnerRadius() /
Unit::mm;
110 rMax[index] = plane.getOuterRadius() /
Unit::mm;
114 G4VSolid* geoShield =
new G4Polycone(name +
" IR Shield", minPhi, dPhi, nPlanes, z.data(), rMin.data(), rMax.data());
117 if (shield.getDoCutOut()) {
119 double sizeX1 = shield.getCutOutWidth1() /
Unit::mm / 2.;
120 double sizeX2 = shield.getCutOutWidth2() /
Unit::mm / 2.;
121 double sizeY = shield.getCutOutHeight() /
Unit::mm / 2.;
122 double depth2 = shield.getCutOutDepth() /
Unit::mm / 2.;
123 double sizeZ = (maxZ - minZ) / 2.;
124 double sign = boost::math::sign<double>(minZ);
125 double minAbsZ = min(fabs(minZ), fabs(maxZ));
127 G4ThreeVector origin1(0, 0, sign * (minAbsZ + sizeZ));
128 G4ThreeVector origin2(0, 0, sign * (minAbsZ + depth2));
131 G4Trd* box1 =
new G4Trd(
"Cutout1", sizeX1, sizeX2, sizeY, sizeY, sizeZ);
132 G4Box* box2 =
new G4Box(
"Cutout2", 100 /
Unit::mm, sizeY, depth2);
134 geoShield =
new G4SubtractionSolid(name +
" IR Shield", geoShield, box1, G4Translate3D(origin1));
135 geoShield =
new G4SubtractionSolid(name +
" IR Shield", geoShield, box2, G4Translate3D(origin2));
138 string materialName = shield.getMaterial();
140 if (!material) B2FATAL(
"Material '" << materialName <<
"', required by " << name <<
" IR Shield could not be found");
142 G4LogicalVolume* volume =
new G4LogicalVolume(geoShield, material, name +
" IR Shield");
145 new G4PVPlacement(0, G4ThreeVector(0, 0, 0), volume, name +
" IR Shield", &topVolume,
false, 0);