95 const G4double realTemperture = (273.15 + 23.) * CLHEP::kelvin;
105 G4double h2odensity = 1.000 * CLHEP::g / CLHEP::cm3;
106 G4double a = 1.01 * CLHEP::g / CLHEP::mole;
107 G4Element* elH =
new G4Element(
"Hydrogen",
"H", 1., a);
108 a = 16.00 * CLHEP::g / CLHEP::mole;
109 G4Element* elO =
new G4Element(
"Oxygen",
"O", 8., a);
110 G4Material* medH2O =
new G4Material(
"Water", h2odensity, 2);
111 medH2O->AddElement(elH, 2);
112 medH2O->AddElement(elO, 1);
124 const double num_senseWire =
static_cast<double>(geo.
getNSenseWires());
125 const double num_fieldWire =
static_cast<double>(geo.
getNFieldWires());
126 double totalCS = M_PI * (rmin_outerWall * rmin_outerWall - rmax_innerWall * rmax_innerWall);
129 double senseCS = M_PI * (diameter_senseWire / 2) * (diameter_senseWire / 2) * num_senseWire;
132 double fieldCS = M_PI * (diameter_fieldWire / 2) * (diameter_fieldWire / 2) * num_fieldWire;
135 const double denHelium = medHelium->GetDensity() / 2.0;
136 const double denEthane = medEthane->GetDensity() / 2.0;
137 const double denAluminum = medAluminum->GetDensity() * (fieldCS / totalCS);
138 const double denTungsten = medTungsten->GetDensity() * (senseCS / totalCS);
139 const double density = denHelium + denEthane + denAluminum + denTungsten;
140 G4Material* cdcMed =
new G4Material(
"CDCGasWire", density, 4, kStateGas, realTemperture);
141 cdcMed->AddMaterial(medHelium, denHelium / density);
142 cdcMed->AddMaterial(medEthane, denEthane / density);
143 cdcMed->AddMaterial(medTungsten, denTungsten / density);
144 cdcMed->AddMaterial(medAluminum, denAluminum / density);
146 G4Material* cdcMedGas = cdcMed;
154 const double density2 = denHelium + denEthane;
155 cdcMedGas =
new G4Material(
"CDCRealGas", density2, 2, kStateGas, realTemperture);
156 cdcMedGas->AddMaterial(medHelium, denHelium / density2);
157 cdcMedGas->AddMaterial(medEthane, denEthane / density2);
161 G4cout << *(G4Material::GetMaterialTable());
165 const auto& motherRmin = mother.
getRmin();
166 const auto& motherRmax = mother.getRmax();
167 const auto& motherZ = mother.getZ();
168 G4Polycone* solid_cdc =
169 new G4Polycone(
"solidCDC", 0 * CLHEP::deg, 360.* CLHEP::deg,
170 mother.getNNodes(), motherZ.data(),
171 motherRmin.data(), motherRmax.data());
172 m_logicalCDC =
new G4LogicalVolume(solid_cdc, medAir,
"logicalCDC", 0, 0, 0);
176 "physicalCDC", &topVolume,
false, 0);
179 G4Region* aRegion =
new G4Region(
"CDCEnvelope");
183 m_VisAttributes.push_back(
new G4VisAttributes(
true, G4Colour(0., 1., 0.)));
185 const int iOuterWall = wall.getId();
186 const string wallName = wall.getName();
187 const double wallRmin = wall.getRmin();
188 const double wallRmax = wall.getRmax();
189 const double wallZfwd = wall.getZfwd();
190 const double wallZbwd = wall.getZbwd();
191 const double length = (wallZfwd - wallZbwd) / 2.0;
195 if (strstr((wallName).c_str(),
"MiddleWall") !=
nullptr) {
198 medWall = medAluminum;
200 G4Tubs* outerWallTubeShape =
new G4Tubs(
"solid" + wallName, wallRmin * CLHEP::cm,
201 wallRmax * CLHEP::cm, length * CLHEP::cm, 0 * CLHEP::deg, 360.*CLHEP::deg);
203 G4LogicalVolume* outerWallTube =
new G4LogicalVolume(outerWallTubeShape, medWall,
"solid" + wallName, 0, 0, 0);
205 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (length + wallZbwd)*CLHEP::cm), outerWallTube,
"logical" + wallName,
210 m_VisAttributes.push_back(
new G4VisAttributes(
true, G4Colour(0., 1., 0.)));
212 const string wallName = wall.getName();
213 const double wallRmin = wall.getRmin();
214 const double wallRmax = wall.getRmax();
215 const double wallZfwd = wall.getZfwd();
216 const double wallZbwd = wall.getZbwd();
217 const double length = (wallZfwd - wallZbwd) / 2.0;
218 const int iInnerWall = wall.getId();
221 if (strstr(wallName.c_str(),
"MiddleWall") !=
nullptr) {
223 }
else if (strstr(wallName.c_str(),
"MiddleGlue") !=
nullptr) {
226 medWall = medAluminum;
229 G4Tubs* innerWallTubeShape =
new G4Tubs(
"solid" + wallName, wallRmin * CLHEP::cm,
230 wallRmax * CLHEP::cm, length * CLHEP::cm, 0 * CLHEP::deg, 360.*CLHEP::deg);
231 G4LogicalVolume* innerWallTube =
new G4LogicalVolume(innerWallTubeShape, medWall,
"logical" + wallName, 0, 0, 0);
233 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (length + wallZbwd)*CLHEP::cm), innerWallTube,
"physical" + wallName,
246 for (
int iSLayer = 0; iSLayer < nSLayer; ++iSLayer) {
250 double rmin_sensitive_left, rmax_sensitive_left;
251 double rmin_sensitive_middle, rmax_sensitive_middle;
252 double rmin_sensitive_right, rmax_sensitive_right;
253 double zback_sensitive_left, zfor_sensitive_left;
254 double zback_sensitive_middle, zfor_sensitive_middle;
255 double zback_sensitive_right, zfor_sensitive_right;
258 const auto& epLayerBwd = endplate.getEndPlateLayer(0);
259 const auto& epLayerFwd = endplate.getEndPlateLayer(nEPLayer / 2);
263 rmin_sensitive_left = epLayerBwd.getRmax();
264 rmax_sensitive_left = fieldLayer.
getR();
265 zback_sensitive_left = senseLayer.getZbwd();
266 zfor_sensitive_left = epLayerBwd.getZfwd();
268 rmin_sensitive_middle = (geo.
getInnerWall(0)).getRmax();
269 rmax_sensitive_middle = fieldLayer.getR();
270 zback_sensitive_middle = epLayerBwd.getZfwd();
271 zfor_sensitive_middle = epLayerFwd.getZbwd();
273 rmin_sensitive_right = epLayerFwd.getRmax();
274 rmax_sensitive_right = fieldLayer.getR();
275 zback_sensitive_right = epLayerFwd.getZbwd();
276 zfor_sensitive_right = senseLayer.getZfwd();
277 }
else if (iSLayer >= 1 && iSLayer <= 14) {
278 const auto& epLayerBwd = endplate.getEndPlateLayer(1);
279 const auto& epLayerFwd = endplate.getEndPlateLayer((nEPLayer / 2) + 1);
284 rmin_sensitive_left = epLayerBwd.getRmax();
285 rmax_sensitive_left = fieldLayerOut.
getR();
286 zback_sensitive_left = senseLayer.getZbwd();
287 zfor_sensitive_left = epLayerBwd.getZfwd();
289 rmin_sensitive_middle = fieldLayerIn.getR();
290 rmax_sensitive_middle = fieldLayerOut.getR();
291 zback_sensitive_middle = epLayerBwd.getZfwd();
292 zfor_sensitive_middle = epLayerFwd.getZbwd();
294 rmin_sensitive_right = epLayerFwd.getRmax();
295 rmax_sensitive_right = fieldLayerOut.getR();
296 zback_sensitive_right = epLayerFwd.getZbwd();
297 zfor_sensitive_right = senseLayer.getZfwd();
298 }
else if (iSLayer >= 15 && iSLayer <= 18) {
299 const auto& epLayerBwd = endplate.getEndPlateLayer(1);
300 const auto& epLayerFwd = endplate.getEndPlateLayer(nEPLayer / 2);
305 rmin_sensitive_left = epLayerBwd.getRmax();
306 rmax_sensitive_left = fieldLayerOut.
getR();
307 zback_sensitive_left = senseLayer.getZbwd();
308 zfor_sensitive_left = epLayerBwd.getZfwd();
310 rmin_sensitive_middle = fieldLayerIn.getR();
311 rmax_sensitive_middle = fieldLayerOut.getR();
312 zback_sensitive_middle = epLayerBwd.getZfwd();
313 zfor_sensitive_middle = epLayerFwd.getZbwd();
315 rmin_sensitive_right = epLayerFwd.getRmax();
316 rmax_sensitive_right = fieldLayerOut.getR();
317 zback_sensitive_right = epLayerFwd.getZbwd();
318 zfor_sensitive_right = senseLayer.getZfwd();
319 }
else if (iSLayer >= 19 && iSLayer < 55) {
320 const auto& epLayerBwd = endplate.getEndPlateLayer(0);
321 const auto& epLayerFwd = endplate.getEndPlateLayer(nEPLayer / 2);
326 rmin_sensitive_left = epLayerBwd.getRmax();
327 rmax_sensitive_left = fieldLayerOut.
getR();
328 zback_sensitive_left = senseLayer.getZbwd();
329 zfor_sensitive_left = epLayerBwd.getZfwd();
331 rmin_sensitive_middle = fieldLayerIn.getR();
332 rmax_sensitive_middle = fieldLayerOut.getR();
333 zback_sensitive_middle = epLayerBwd.getZfwd();
334 zfor_sensitive_middle = epLayerFwd.getZbwd();
336 rmin_sensitive_right = epLayerFwd.getRmax();
337 rmax_sensitive_right = fieldLayerOut.getR();
338 zback_sensitive_right = epLayerFwd.getZbwd();
339 zfor_sensitive_right = senseLayer.getZfwd();
341 }
else if (iSLayer == 55) {
343 const auto& epLayerBwdIn = endplate.getEndPlateLayer(0);
344 const auto& epLayerBwdOut = endplate.getEndPlateLayer((nEPLayer / 2) - 1);
345 const auto& epLayerFwdIn = endplate.getEndPlateLayer(nEPLayer / 2);
346 const auto& epLayerFwdOut = endplate.getEndPlateLayer(nEPLayer - 1);
349 int iSLayerMinus1 = iSLayer - 1;
351 rmin_sensitive_left = epLayerBwdIn.getRmax();
352 rmax_sensitive_left = epLayerBwdOut.getRmax();
353 zback_sensitive_left = senseLayer.
getZbwd();
354 zfor_sensitive_left = epLayerBwdIn.getZfwd();
356 rmin_sensitive_middle = fieldLayerIn.getR();
357 rmax_sensitive_middle = (geo.
getOuterWall(0)).getRmin();
358 zback_sensitive_middle = epLayerBwdIn.getZfwd();
359 zfor_sensitive_middle = epLayerFwdIn.getZbwd();
361 rmin_sensitive_right = epLayerFwdIn.getRmax();
362 rmax_sensitive_right = epLayerFwdOut.getRmax();
363 zback_sensitive_right = epLayerFwdIn.getZbwd();
364 zfor_sensitive_right = senseLayer.getZfwd();
367 B2ERROR(
"Undefined sensitive layer : " << iSLayer);
373 if ((zfor_sensitive_left - zback_sensitive_left) > length_feedthrough) {
390 G4Tubs* leftTubeShape =
new G4Tubs((boost::format(
"solidCDCLayer_%1%_leftTube") % iSLayer).str().c_str(),
391 rmin_sensitive_left * CLHEP::cm,
392 rmax_sensitive_left * CLHEP::cm, length_feedthrough * CLHEP::cm / 2.0, 0 * CLHEP::deg, 360.*CLHEP::deg);
393 G4LogicalVolume* leftTube =
new G4LogicalVolume(leftTubeShape, cdcMed,
394 (boost::format(
"logicalCDCLayer_%1%_leftTube") % iSLayer).str().c_str(), 0, 0, 0);
395 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zback_sensitive_left + length_feedthrough / 2.0)*CLHEP::cm), leftTube,
396 (boost::format(
"physicalCDCLayer_%1%_leftTube") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
398 G4Tubs* leftSensitiveTubeShape =
new G4Tubs((boost::format(
"solidSD_CDCLayer_%1%_left") % iSLayer).str().c_str(),
399 rmin_sensitive_left * CLHEP::cm, rmax_sensitive_left * CLHEP::cm,
400 (zfor_sensitive_left - zback_sensitive_left - length_feedthrough)*CLHEP::cm / 2.0, 0 * CLHEP::deg, 360.*CLHEP::deg);
401 G4LogicalVolume* leftSensitiveTube =
new G4LogicalVolume(leftSensitiveTubeShape, cdcMed,
402 (boost::format(
"logicalSD_CDCLayer_%1%_left") % iSLayer).str().c_str(), 0, 0, 0);
403 leftSensitiveTube->SetSensitiveDetector(
m_sensitive);
404 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zfor_sensitive_left + zback_sensitive_left + length_feedthrough)*CLHEP::cm / 2.0),
405 leftSensitiveTube, (boost::format(
"physicalSD_CDCLayer_%1%_left") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
423 G4Tubs* leftTubeShape =
new G4Tubs((boost::format(
"solidCDCLayer_%1%_leftTube") % iSLayer).str().c_str(),
424 rmin_sensitive_left * CLHEP::cm,
425 rmax_sensitive_left * CLHEP::cm, (zfor_sensitive_left - zback_sensitive_left)*CLHEP::cm / 2.0, 0 * CLHEP::deg, 360.*CLHEP::deg);
426 G4LogicalVolume* leftTube =
new G4LogicalVolume(leftTubeShape, cdcMed,
427 (boost::format(
"logicalCDCLayer_%1%_leftTube") % iSLayer).str().c_str(), 0, 0, 0);
428 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zfor_sensitive_left + zback_sensitive_left)*CLHEP::cm / 2.0), leftTube,
429 (boost::format(
"physicalCDCLayer_%1%_leftTube") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
433 G4Tubs* leftMidTubeShape =
new G4Tubs((boost::format(
"solidCDCLayer_%1%_leftMidTube") % iSLayer).str().c_str(),
434 rmin_sensitive_middle * CLHEP::cm, rmax_sensitive_middle * CLHEP::cm,
435 (length_feedthrough - zfor_sensitive_left + zback_sensitive_left)*CLHEP::cm / 2.0, 0 * CLHEP::deg, 360.*CLHEP::deg);
436 G4LogicalVolume* leftMidTube =
new G4LogicalVolume(leftMidTubeShape, cdcMed,
437 (boost::format(
"logicalCDCLayer_%1%_leftMidTube") % iSLayer).str().c_str(), 0, 0, 0);
439 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (length_feedthrough + zfor_sensitive_left + zback_sensitive_left)*CLHEP::cm / 2.0),
440 leftMidTube, (boost::format(
"physicalCDCLayer_%1%_leftMidTube") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
443 zback_sensitive_middle = length_feedthrough + zback_sensitive_left;
447 if ((zfor_sensitive_right - zback_sensitive_right) > length_feedthrough) {
464 G4Tubs* rightTubeShape =
new G4Tubs((boost::format(
"solidCDCLayer_%1%_rightTube") % iSLayer).str().c_str(),
465 rmin_sensitive_right * CLHEP::cm, rmax_sensitive_right * CLHEP::cm, length_feedthrough * CLHEP::cm / 2.0, 0 * CLHEP::deg,
467 G4LogicalVolume* rightTube =
new G4LogicalVolume(rightTubeShape, cdcMed,
468 (boost::format(
"logicalCDCLayer_%1%_rightTube") % iSLayer).str().c_str(), 0, 0, 0);
470 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zfor_sensitive_right - length_feedthrough / 2.0)*CLHEP::cm), rightTube,
471 (boost::format(
"physicalCDCLayer_%1%_rightTube") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
475 G4Tubs* rightSensitiveTubeShape =
new G4Tubs((boost::format(
"solidSD_CDCLayer_%1%_right") % iSLayer).str().c_str(),
476 rmin_sensitive_right * CLHEP::cm, rmax_sensitive_right * CLHEP::cm,
477 (zfor_sensitive_right - zback_sensitive_right - length_feedthrough)*CLHEP::cm / 2.0, 0 * CLHEP::deg, 360.*CLHEP::deg);
478 G4LogicalVolume* rightSensitiveTube =
new G4LogicalVolume(rightSensitiveTubeShape, cdcMed,
479 (boost::format(
"logicalSD_CDCLayer_%1%_right") % iSLayer).str().c_str(), 0, 0, 0);
480 rightSensitiveTube->SetSensitiveDetector(
m_sensitive);
482 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zfor_sensitive_right + zback_sensitive_right - length_feedthrough)*CLHEP::cm / 2.0),
483 rightSensitiveTube, (boost::format(
"physicalSD_CDCLayer_%1%_right") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
502 G4Tubs* rightTubeShape =
new G4Tubs((boost::format(
"solidCDCLayer_%1%_rightTube") % iSLayer).str().c_str(),
503 rmin_sensitive_right * CLHEP::cm, rmax_sensitive_right * CLHEP::cm, (zfor_sensitive_right - zback_sensitive_right)*CLHEP::cm / 2.0,
504 0 * CLHEP::deg, 360.*CLHEP::deg);
505 G4LogicalVolume* rightTube =
new G4LogicalVolume(rightTubeShape, cdcMed,
506 (boost::format(
"logicalCDCLayer_%1%_rightTube") % iSLayer).str().c_str(), 0, 0, 0);
508 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zfor_sensitive_right + zback_sensitive_right)*CLHEP::cm / 2.0), rightTube,
509 (boost::format(
"physicalCDCLayer_%1%_rightTube") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
513 G4Tubs* rightMidTubeShape =
new G4Tubs((boost::format(
"solidCDCLayer_%1%_rightMidTube") % iSLayer).str().c_str(),
514 rmin_sensitive_middle * CLHEP::cm, rmax_sensitive_middle * CLHEP::cm,
515 (length_feedthrough - zfor_sensitive_right + zback_sensitive_right)*CLHEP::cm / 2.0, 0 * CLHEP::deg, 360.*CLHEP::deg);
516 G4LogicalVolume* rightMidTube =
new G4LogicalVolume(rightMidTubeShape, cdcMed,
517 (boost::format(
"logicalCDCLayer_%1%_rightMidTube") % iSLayer).str().c_str(), 0, 0, 0);
518 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zback_sensitive_right - length_feedthrough + zfor_sensitive_right)*CLHEP::cm / 2.0),
519 rightMidTube, (boost::format(
"physicalCDCLayer_%1%_rightMidTube") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
522 zfor_sensitive_middle = zfor_sensitive_right - length_feedthrough;
527 G4Tubs* middleSensitiveTubeShape =
new G4Tubs((boost::format(
"solidSD_CDCLayer_%1%_middle") % iSLayer).str().c_str(),
528 rmin_sensitive_middle * CLHEP::cm, rmax_sensitive_middle * CLHEP::cm,
529 (zfor_sensitive_middle - zback_sensitive_middle)*CLHEP::cm / 2.0, 0 * CLHEP::deg, 360.*CLHEP::deg);
530 G4LogicalVolume* middleSensitiveTube =
new G4LogicalVolume(middleSensitiveTubeShape, cdcMedGas,
531 (boost::format(
"logicalSD_CDCLayer_%1%_middle") % iSLayer).str().c_str(), 0, 0, 0);
534 G4UserLimits* uLimits =
new G4UserLimits(8.5 * CLHEP::cm);
536 middleSensitiveTube->SetUserLimits(uLimits);
537 middleSensitiveTube->SetSensitiveDetector(
m_sensitive);
539 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zfor_sensitive_middle + zback_sensitive_middle)*CLHEP::cm / 2.0), middleSensitiveTube,
540 (boost::format(
"physicalSD_CDCLayer_%1%_middle") % iSLayer).str().c_str(),
m_logicalCDC,
false, iSLayer);
544 G4String sName =
"sWire";
549 G4double tAtZ0 = -wb0.
Z() / (wf0.
Z() - wb0.
Z());
552 const G4double epsl = 25.e-4;
553 G4double reductionBwd = (zback_sensitive_middle + epsl) / wb0.
Z();
555 wb0 = reductionBwd * (wb0 - wAtZ0) + wAtZ0;
557 G4double reductionFwd = (zfor_sensitive_middle - epsl) / wf0.
Z();
558 wf0 = reductionFwd * (wf0 - wAtZ0) + wAtZ0;
560 const G4double wireHalfLength = 0.5 * (wf0 - wb0).Mag() * CLHEP::cm;
563 G4Tubs* middleSensitiveSwireShape =
new G4Tubs(sName, 0., sWireRadius, wireHalfLength, 0., 360. * CLHEP::deg);
564 G4LogicalVolume* middleSensitiveSwire =
new G4LogicalVolume(middleSensitiveSwireShape, medTungsten, sName);
568 G4String fName =
"fWire";
570 G4Tubs* middleSensitiveFwireShape =
new G4Tubs(fName, 0., fWireRadius, wireHalfLength, 0., 360. * CLHEP::deg);
571 G4LogicalVolume* middleSensitiveFwire =
new G4LogicalVolume(middleSensitiveFwireShape, medAluminum, fName);
578 const G4double dphi = M_PI / nCells;
581 for (
int ic = 0; ic < nCells; ++ic) {
585 G4double tAtZ02 = -wb.
Z() / (wf.
Z() - wb.
Z());
587 G4double reductionBwd2 = (zback_sensitive_middle + epsl) / wb.
Z();
588 wb = reductionBwd2 * (wb - wAtZ02) + wAtZ02;
589 G4double reductionFwd2 = (zfor_sensitive_middle - epsl) / wf.
Z();
590 wf = reductionFwd2 * (wf - wAtZ02) + wAtZ02;
592 G4double thetaYZ = -asin((wf - wb).Y() / (wf - wb).Mag());
594 B2Vector3D fMinusBInZX((wf - wb).X(), 0., (wf - wb).Z());
595 G4double thetaZX = asin((unitZ.
Cross(fMinusBInZX)).Y() / fMinusBInZX.
Mag());
596 G4RotationMatrix rotM;
598 rotM.rotateX(thetaYZ * CLHEP::rad);
599 rotM.rotateY(thetaZX * CLHEP::rad);
601 G4ThreeVector xyz(0.5 * (wb.
X() + wf.
X()) * CLHEP::cm,
602 0.5 * (wb.
Y() + wf.
Y()) * CLHEP::cm, 0.);
606 new G4PVPlacement(G4Transform3D(rotM, xyz), middleSensitiveSwire, sName, middleSensitiveTube,
false, ic);
610 G4double rF = rmax_sensitive_middle - 0.5 * diameter;
612 G4double phi = atan2(wbF.
Y(), wbF.
X());
613 wbF.
SetX(rF * cos(phi));
614 wbF.
SetY(rF * sin(phi));
617 rF = rmax_sensitive_middle - 0.5 * diameter;
618 phi = atan2(wfF.
Y(), wfF.
X());
619 wfF.
SetX(rF * cos(phi));
620 wfF.
SetY(rF * sin(phi));
622 thetaYZ = -asin((wfF - wbF).Y() / (wfF - wbF).Mag());
624 fMinusBInZX = wfF - wbF;
625 fMinusBInZX.
SetY(0.);
626 thetaZX = asin((unitZ.
Cross(fMinusBInZX)).Y() / fMinusBInZX.
Mag());
628 G4RotationMatrix rotM1;
629 rotM1.rotateX(thetaYZ * CLHEP::rad);
630 rotM1.rotateY(thetaZX * CLHEP::rad);
632 xyz.setX(0.5 * (wbF.
X() + wfF.
X()) * CLHEP::cm);
633 xyz.setY(0.5 * (wbF.
Y() + wfF.
Y()) * CLHEP::cm);
635 if (iSLayer != nSLayer - 1) {
637 new G4PVPlacement(G4Transform3D(rotM1, xyz), middleSensitiveFwire, fName, middleSensitiveTube,
false, ic);
643 phi = atan2(wbF.
Y(), wbF.
X());
644 wbF.
SetX(rF * cos(phi + dphi));
645 wbF.
SetY(rF * sin(phi + dphi));
649 phi = atan2(wfF.
Y(), wfF.
X());
650 wfF.
SetX(rF * cos(phi + dphi));
651 wfF.
SetY(rF * sin(phi + dphi));
653 thetaYZ = -asin((wfF - wbF).Y() / (wfF - wbF).Mag());
655 fMinusBInZX = wfF - wbF;
656 fMinusBInZX.
SetY(0.);
657 thetaZX = asin((unitZ.
Cross(fMinusBInZX)).Y() / fMinusBInZX.
Mag());
659 G4RotationMatrix rotM2;
660 rotM2.rotateX(thetaYZ * CLHEP::rad);
661 rotM2.rotateY(thetaZX * CLHEP::rad);
663 xyz.setX(0.5 * (wbF.
X() + wfF.
X()) * CLHEP::cm);
664 xyz.setY(0.5 * (wbF.
Y() + wfF.
Y()) * CLHEP::cm);
667 new G4PVPlacement(G4Transform3D(rotM2, xyz), middleSensitiveFwire, fName, middleSensitiveTube,
false, ic + nCells);
671 rF = rmax_sensitive_middle - 0.5 * diameter;
672 phi = atan2(wbF.
Y(), wbF.
X());
673 wbF.
SetX(rF * cos(phi + dphi));
674 wbF.
SetY(rF * sin(phi + dphi));
677 rF = rmax_sensitive_middle - 0.5 * diameter;
678 phi = atan2(wfF.
Y(), wfF.
X());
679 wfF.
SetX(rF * cos(phi + dphi));
680 wfF.
SetY(rF * sin(phi + dphi));
682 thetaYZ = -asin((wfF - wbF).Y() / (wfF - wbF).Mag());
684 fMinusBInZX = wfF - wbF;
685 fMinusBInZX.
SetY(0.);
686 thetaZX = asin((unitZ.
Cross(fMinusBInZX)).Y() / fMinusBInZX.
Mag());
688 G4RotationMatrix rotM3;
689 rotM3.rotateX(thetaYZ * CLHEP::rad);
690 rotM3.rotateY(thetaZX * CLHEP::rad);
692 xyz.setX(0.5 * (wbF.
X() + wfF.
X()) * CLHEP::cm);
693 xyz.setY(0.5 * (wbF.
Y() + wfF.
Y()) * CLHEP::cm);
695 if (iSLayer != nSLayer - 1) {
696 new G4PVPlacement(G4Transform3D(rotM3, xyz), middleSensitiveFwire, fName, middleSensitiveTube,
false, ic + 2 * nCells);
706 m_VisAttributes.push_back(
new G4VisAttributes(
true, G4Colour(1., 1., 0.)));
708 for (
const auto& epLayer : endplate.getEndPlateLayers()) {
709 const int iEPLayer = epLayer.getILayer();
710 const string name = epLayer.getName();
711 const double rmin = epLayer.getRmin();
712 const double rmax = epLayer.getRmax();
713 const double zbwd = epLayer.getZbwd();
714 const double zfwd = epLayer.getZfwd();
715 const double length = (zfwd - zbwd) / 2.0;
717 G4Tubs* tube =
new G4Tubs(
"solidCDCEndplate" + name, rmin * CLHEP::cm,
718 rmax * CLHEP::cm, length * CLHEP::cm, 0 * CLHEP::deg, 360.*CLHEP::deg);
719 G4LogicalVolume* logical =
new G4LogicalVolume(tube,
Materials::get(
"G4_Al"),
720 "logicalCDCEndplate" + name, 0, 0);
722 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (zfwd + zbwd)*CLHEP::cm / 2.0), logical,
723 "physicalCDCEndplate" + name,
m_logicalCDC,
false, iEPLayer);
732 const int iEB = frontend.getId();
733 const double ebInnerR = frontend.getRmin();
734 const double ebOuterR = frontend.getRmax();
735 const double ebBZ = frontend.getZbwd();
736 const double ebFZ = frontend.getZfwd();
738 G4Tubs* ebTubeShape =
new G4Tubs((boost::format(
"solidSD_ElectronicsBoard_Layer%1%") % iEB).str().c_str(), ebInnerR * CLHEP::cm,
739 ebOuterR * CLHEP::cm, (ebFZ - ebBZ)*CLHEP::cm / 2.0, 0 * CLHEP::deg, 360.*CLHEP::deg);
741 G4LogicalVolume* ebTube =
new G4LogicalVolume(ebTubeShape, medNEMA_G10_Plate,
742 (boost::format(
"logicalSD_ElectronicsBoard_Layer%1%") % iEB).str().c_str(), 0, 0, 0);
746 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, (ebFZ + ebBZ)*CLHEP::cm / 2.0), ebTube,
747 (boost::format(
"physicalSD_ElectronicsBoard_Layer%1%") % iEB).str().c_str(),
m_logicalCDC,
false, iEB);
768 for (
const auto& rib : geo.
getRibs()) {
770 const int id = rib.getId();
771 const double length = rib.getLength();
772 const double width = rib.getWidth();
773 const double thick = rib.getThick();
774 const double rotx = rib.getRotX();
775 const double roty = rib.getRotY();
776 const double rotz = rib.getRotZ();
777 const double x = rib.getX();
778 const double y = rib.getY();
779 const double z = rib.getZ();
780 const int offset = rib.getOffset();
781 const int ndiv = rib.getNDiv();
783 const string solidName =
"solidRib" + to_string(
id);
784 const string logicalName =
"logicalRib" + to_string(
id);
785 G4Box* boxShape =
new G4Box(solidName, 0.5 * length * CLHEP::cm,
786 0.5 * width * CLHEP::cm,
787 0.5 * thick * CLHEP::cm);
789 const double rmax = 0.5 * length;
790 const double rmin = max((rmax - thick), 0.);
791 G4Tubs* tubeShape =
new G4Tubs(solidName,
794 0.5 * width * CLHEP::cm,
801 G4LogicalVolume* logicalV =
new G4LogicalVolume(boxShape, medAluminum, logicalName, 0, 0, 0);
802 if (
id > 39 &&
id < 78)
803 logicalV =
new G4LogicalVolume(boxShape, medCopper, logicalName, 0, 0, 0);
804 if ((
id > 77 &&
id < 94) || (
id > 131 &&
id < 146))
805 logicalV =
new G4LogicalVolume(boxShape, medNEMA_G10_Plate, logicalName, 0, 0, 0);
806 if (
id > 93 &&
id < 110)
807 logicalV =
new G4LogicalVolume(tubeShape, medCopper, logicalName, 0, 0, 0);
808 if (
id > 109 &&
id < 126)
809 logicalV =
new G4LogicalVolume(tubeShape, medH2O, logicalName, 0, 0, 0);
810 if (
id > 127 &&
id < 132)
811 logicalV =
new G4LogicalVolume(boxShape, medHV, logicalName, 0, 0, 0);
821 const double phi = 360.0 / ndiv;
823 G4RotationMatrix rot = G4RotationMatrix();
825 if (
id > 93 &&
id < 126) dz = 0;
827 G4ThreeVector arm(x * CLHEP::cm, y * CLHEP::cm, z * CLHEP::cm - dz * CLHEP::cm / 2.0);
832 rot.rotateZ(0.5 * phi * CLHEP::deg);
833 arm.rotateZ(0.5 * phi * CLHEP::deg);
835 for (
int i = 0; i < ndiv; ++i) {
836 const string physicalName =
"physicalRib_" + to_string(
id) +
" " + to_string(i);
837 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
839 rot.rotateZ(phi * CLHEP::deg);
840 arm.rotateZ(phi * CLHEP::deg);
848 for (
const auto& rib2 : geo.
getRib2s()) {
850 const int id = rib2.getId();
851 const double length = rib2.getLength();
852 const double width = rib2.getWidth();
853 const double thick = rib2.getThick();
854 const double width2 = rib2.getWidth2();
855 const double thick2 = rib2.getThick2();
856 const double rotx = rib2.getRotX();
857 const double roty = rib2.getRotY();
858 const double rotz = rib2.getRotZ();
859 const double x = rib2.getX();
860 const double y = rib2.getY();
861 const double z = rib2.getZ();
862 const int ndiv = rib2.getNDiv();
864 const string solidName =
"solidRib2" + to_string(
id);
865 const string logicalName =
"logicalRib2" + to_string(
id);
866 G4Trd* trdShape =
new G4Trd(solidName,
867 0.5 * thick * CLHEP::cm,
868 0.5 * thick2 * CLHEP::cm,
869 0.5 * width * CLHEP::cm,
870 0.5 * width2 * CLHEP::cm,
871 0.5 * length * CLHEP::cm);
873 G4LogicalVolume* logicalV =
new G4LogicalVolume(trdShape, medAluminum, logicalName, 0, 0, 0);
876 logicalV =
new G4LogicalVolume(trdShape, medCopper, logicalName, 0, 0, 0);
880 const double phi = 360.0 / ndiv;
882 G4RotationMatrix rot = G4RotationMatrix();
883 G4ThreeVector arm(x * CLHEP::cm, y * CLHEP::cm, z * CLHEP::cm - thick * CLHEP::cm / 2.0);
888 for (
int i = 0; i < ndiv; ++i) {
889 const string physicalName =
"physicalRib2_" + to_string(
id) +
" " + to_string(i);
890 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
892 rot.rotateZ(phi * CLHEP::deg);
893 arm.rotateZ(phi * CLHEP::deg);
901 for (
const auto& rib3 : geo.
getRib3s()) {
903 const int id = rib3.getId();
904 const double length = rib3.getLength();
905 const double width = rib3.getWidth();
906 const double thick = rib3.getThick();
907 const double r = rib3.getR();
908 const double x = rib3.getX();
909 const double y = rib3.getY();
910 const double z = rib3.getZ();
911 const double rx = rib3.getRx();
912 const double ry = rib3.getRy();
913 const double rz = rib3.getRz();
914 const int offset = rib3.getOffset();
915 const int ndiv = rib3.getNDiv();
917 const string logicalName =
"logicalRib3" + to_string(
id);
918 G4VSolid* boxShape =
new G4Box(
"Block",
919 0.5 * length * CLHEP::cm,
920 0.5 * width * CLHEP::cm,
921 0.5 * thick * CLHEP::cm);
922 G4VSolid* tubeShape =
new G4Tubs(
"Hole",
929 G4RotationMatrix rotsub = G4RotationMatrix();
930 rotsub.rotateX(90. * CLHEP::deg);
931 G4ThreeVector trnsub(rx * CLHEP::cm - x * CLHEP::cm, ry * CLHEP::cm - y * CLHEP::cm,
932 rz * CLHEP::cm - z * CLHEP::cm + 0.5 * thick * CLHEP::cm);
933 G4VSolid* coolingBlock =
new G4SubtractionSolid(
"Block-Hole",
936 G4Transform3D(rotsub,
939 G4LogicalVolume* logicalV =
new G4LogicalVolume(coolingBlock, medCopper, logicalName, 0, 0, 0);
943 const double phi = 360.0 / ndiv;
945 G4RotationMatrix rot = G4RotationMatrix();
946 G4ThreeVector arm(x * CLHEP::cm, y * CLHEP::cm, z * CLHEP::cm - thick * CLHEP::cm / 2.0);
949 rot.rotateZ(0.5 * phi * CLHEP::deg);
950 arm.rotateZ(0.5 * phi * CLHEP::deg);
952 for (
int i = 0; i < ndiv; ++i) {
953 const string physicalName =
"physicalRib3_" + to_string(
id) +
" " + to_string(i);
954 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
956 rot.rotateZ(phi * CLHEP::deg);
957 arm.rotateZ(phi * CLHEP::deg);
965 for (
const auto& rib4 : geo.
getRib4s()) {
967 const int id = rib4.getId();
968 const double length = rib4.getLength();
969 const double width = rib4.getWidth();
970 const double thick = rib4.getThick();
971 const double length2 = rib4.getLength2();
972 const double width2 = rib4.getWidth2();
973 const double thick2 = rib4.getThick2();
974 const double x = rib4.getX();
975 const double y = rib4.getY();
976 const double z = rib4.getZ();
977 const double x2 = rib4.getX2();
978 const double y2 = rib4.getY2();
979 const double z2 = rib4.getZ2();
980 const int offset = rib4.getOffset();
981 const int ndiv = rib4.getNDiv();
983 const string logicalName =
"logicalRib4" + to_string(
id);
984 G4VSolid* baseShape =
new G4Box(
"Base",
985 0.5 * length * CLHEP::cm,
986 0.5 * width * CLHEP::cm,
987 0.5 * thick * CLHEP::cm);
988 G4VSolid* sqShape =
new G4Box(
"Sq",
989 0.5 * length2 * CLHEP::cm,
990 0.5 * width2 * CLHEP::cm,
991 0.5 * thick2 * CLHEP::cm);
993 G4RotationMatrix rotsub = G4RotationMatrix();
994 double dzc = (z2 - thick2 / 2.) - (z - thick / 2.);
995 G4ThreeVector trnsub(x2 * CLHEP::cm - x * CLHEP::cm,
996 y2 * CLHEP::cm - y * CLHEP::cm,
998 G4VSolid* sqHoleBase =
new G4SubtractionSolid(
"Box-Sq",
1001 G4Transform3D(rotsub,
1005 G4LogicalVolume* logicalV =
new G4LogicalVolume(sqHoleBase, medCopper, logicalName, 0, 0, 0);
1007 logicalV =
new G4LogicalVolume(sqHoleBase, medNEMA_G10_Plate, logicalName, 0, 0, 0);
1010 logicalV->SetSensitiveDetector(sensitiveDetector);
1016 const double phi = 360.0 / ndiv;
1018 G4RotationMatrix rot = G4RotationMatrix();
1019 G4ThreeVector arm(x * CLHEP::cm, y * CLHEP::cm, z * CLHEP::cm - thick * CLHEP::cm / 2.0);
1022 rot.rotateZ(0.5 * phi * CLHEP::deg);
1023 arm.rotateZ(0.5 * phi * CLHEP::deg);
1025 for (
int i = 0; i < ndiv; ++i) {
1026 const string physicalName =
"physicalRib4_" + to_string(
id) +
" " + to_string(i);
1027 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
1029 rot.rotateZ(phi * CLHEP::deg);
1030 arm.rotateZ(phi * CLHEP::deg);
1037 for (
const auto& rib5 : geo.
getRib5s()) {
1039 const int id = rib5.getId();
1040 const double dr = rib5.getDr();
1041 const double dz = rib5.getDz();
1042 const double width = rib5.getWidth();
1043 const double thick = rib5.getThick();
1044 const double rin = rib5.getRin();
1045 const double x = rib5.getX();
1046 const double y = rib5.getY();
1047 const double z = rib5.getZ();
1048 const double rotx = rib5.getRotx();
1049 const double roty = rib5.getRoty();
1050 const double rotz = rib5.getRotz();
1051 const int offset = rib5.getOffset();
1052 const int ndiv = rib5.getNDiv();
1054 const string solidName =
"solidRib5" + to_string(
id);
1055 const string logicalName =
"logicalRib5" + to_string(
id);
1057 const double rmax = rin + thick;
1058 const double rmin = rin;
1059 const double dphi = 2. * atan2(dz, dr);
1060 const double ddphi = thick *
tan(dphi) / rin;
1061 const double ddphi2 = width / 2. * width / 2. / (x + dr) / rin;
1062 const double cphi = dphi - ddphi - ddphi2;
1063 G4Tubs* tubeShape =
new G4Tubs(solidName,
1066 0.5 * width * CLHEP::cm,
1070 G4LogicalVolume* logicalV =
new G4LogicalVolume(tubeShape, medAluminum, logicalName, 0, 0, 0);
1074 const double phi = 360.0 / ndiv;
1076 G4RotationMatrix rot = G4RotationMatrix();
1079 G4ThreeVector arm(x * CLHEP::cm, y * CLHEP::cm, z * CLHEP::cm - rin * CLHEP::cm - thick * CLHEP::cm);
1084 rot.rotateZ(0.5 * phi * CLHEP::deg);
1085 arm.rotateZ(0.5 * phi * CLHEP::deg);
1087 for (
int i = 0; i < ndiv; ++i) {
1088 const string physicalName =
"physicalRib5_" + to_string(
id) +
" " + to_string(i);
1089 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
1091 rot.rotateZ(phi * CLHEP::deg);
1092 arm.rotateZ(phi * CLHEP::deg);
1186 string Aluminum = content.getString(
"Aluminum");
1189 G4double density = 1.000 * CLHEP::g / CLHEP::cm3;
1190 G4double a = 1.01 * CLHEP::g / CLHEP::mole;
1191 G4Element* elH =
new G4Element(
"Hydrogen",
"H", 1., a);
1192 a = 16.00 * CLHEP::g / CLHEP::mole;
1193 G4Element* elO =
new G4Element(
"Oxygen",
"O", 8., a);
1194 G4Material* medH2O =
new G4Material(
"Water", density, 2);
1195 medH2O->AddElement(elH, 2);
1196 medH2O->AddElement(elO, 1);
1204 m_VisAttributes.push_back(
new G4VisAttributes(
true, G4Colour(0., 1., 0.)));
1205 const int nCover = content.getNumberNodes(
"Covers/Cover");
1206 for (
int iCover = 0; iCover < nCover; ++iCover) {
1207 GearDir coverContent(content);
1208 coverContent.
append((boost::format(
"/Covers/Cover[%1%]/") % (iCover + 1)).str());
1209 const string scoverID = coverContent.
getString(
"@id");
1210 const int coverID = atoi(scoverID.c_str());
1211 const string coverName = coverContent.
getString(
"Name");
1212 const double coverInnerR1 = coverContent.
getLength(
"InnerR1");
1213 const double coverInnerR2 = coverContent.
getLength(
"InnerR2");
1214 const double coverOuterR1 = coverContent.
getLength(
"OuterR1");
1215 const double coverOuterR2 = coverContent.
getLength(
"OuterR2");
1216 const double coverThick = coverContent.
getLength(
"Thickness");
1217 const double coverPosZ = coverContent.
getLength(
"PosZ");
1219 const double rmin1 = coverInnerR1;
1220 const double rmax1 = coverOuterR1;
1221 const double rmin2 = coverInnerR2;
1222 const double rmax2 = coverOuterR2;
1233 if (coverID == 7 || coverID == 10) {
1234 createCone(rmin1, rmax1, rmin2, rmax2, coverThick, coverPosZ, coverID, medAluminum, coverName);
1236 createTube(rmin1, rmax1, coverThick, coverPosZ, coverID, medAluminum, coverName);
1239 if (coverID > 22 && coverID < 29)
1240 createTube(rmin1, rmax1, coverThick, coverPosZ, coverID, medCopper, coverName);
1241 if (coverID > 28 && coverID < 35)
1242 createTorus(rmin1, rmax1, coverThick, coverPosZ, coverID, medCopper, coverName);
1243 if (coverID > 34 && coverID < 41)
1244 createTorus(rmin1, rmax1, coverThick, coverPosZ, coverID, medH2O, coverName);
1245 if (coverID == 45 || coverID == 46)
1246 createTube(rmin1, rmax1, coverThick, coverPosZ, coverID, medLV, coverName);
1247 if (coverID == 47 || coverID == 48)
1248 createTube(rmin1, rmax1, coverThick, coverPosZ, coverID, medFiber, coverName);
1249 if (coverID == 49 || coverID == 50)
1250 createTube(rmin1, rmax1, coverThick, coverPosZ, coverID, medCAT7, coverName);
1251 if (coverID == 51 || coverID == 52)
1252 createTube(rmin1, rmax1, coverThick, coverPosZ, coverID, medTRG, coverName);
1254 createTube(rmin1, rmax1, coverThick, coverPosZ, coverID, medHV, coverName);
1257 const int nCover2 = content.getNumberNodes(
"Covers/Cover2");
1258 for (
int iCover2 = 0; iCover2 < nCover2; ++iCover2) {
1259 GearDir cover2Content(content);
1260 cover2Content.
append((boost::format(
"/Cover2s/Cover2[%1%]/") % (iCover2 + 1)).str());
1261 const string scover2ID = cover2Content.
getString(
"@id");
1262 const int cover2ID = atoi(scover2ID.c_str());
1263 const string cover2Name = cover2Content.
getString(
"Name");
1264 const double cover2InnerR = cover2Content.
getLength(
"InnerR");
1265 const double cover2OuterR = cover2Content.
getLength(
"OuterR");
1266 const double cover2StartPhi = cover2Content.
getLength(
"StartPhi");
1267 const double cover2DeltaPhi = cover2Content.
getLength(
"DeltaPhi");
1268 const double cover2Thick = cover2Content.
getLength(
"Thickness");
1269 const double cover2PosZ = cover2Content.
getLength(
"PosZ");
1272 createTube2(cover2InnerR, cover2OuterR, cover2StartPhi, cover2DeltaPhi, cover2Thick, cover2PosZ, cover2ID, medHV, cover2Name);
1273 if (cover2ID > 10 && cover2ID < 14)
1274 createTube2(cover2InnerR, cover2OuterR, cover2StartPhi, cover2DeltaPhi, cover2Thick, cover2PosZ, cover2ID, medFiber, cover2Name);
1275 if (cover2ID > 13 && cover2ID < 23)
1276 createTube2(cover2InnerR, cover2OuterR, cover2StartPhi, cover2DeltaPhi, cover2Thick, cover2PosZ, cover2ID, medCAT7, cover2Name);
1277 if (cover2ID > 22 && cover2ID < 29)
1278 createTube2(cover2InnerR, cover2OuterR, cover2StartPhi, cover2DeltaPhi, cover2Thick, cover2PosZ, cover2ID, medTRG, cover2Name);
1281 const int nRibs = content.getNumberNodes(
"Covers/Rib");
1282 for (
int iRib = 0; iRib < nRibs; ++iRib) {
1284 ribContent.
append((boost::format(
"/Covers/Rib[%1%]/") % (iRib + 1)).str());
1285 const string sribID = ribContent.
getString(
"@id");
1286 const int ribID = atoi(sribID.c_str());
1288 const double length = ribContent.
getLength(
"Length");
1289 const double width = ribContent.
getLength(
"Width");
1290 const double thick = ribContent.
getLength(
"Thickness");
1291 const double rotX = ribContent.
getLength(
"RotX");
1292 const double rotY = ribContent.
getLength(
"RotY");
1293 const double rotZ = ribContent.
getLength(
"RotZ");
1294 const double cX = ribContent.
getLength(
"PosX");
1295 const double cY = ribContent.
getLength(
"PosY");
1296 const double cZ = ribContent.
getLength(
"PosZ");
1297 const int offset = atoi((ribContent.
getString(
"Offset")).c_str());
1298 const int number = atoi((ribContent.
getString(
"NDiv")).c_str());
1300 const string solidName =
"solidRib" + to_string(ribID);
1301 const string logicalName =
"logicalRib" + to_string(ribID);
1302 G4Box* boxShape =
new G4Box(solidName, 0.5 * length * CLHEP::cm,
1303 0.5 * width * CLHEP::cm,
1304 0.5 * thick * CLHEP::cm);
1305 const double rmax = 0.5 * length;
1306 const double rmin = max((rmax - thick), 0.);
1307 G4Tubs* tubeShape =
new G4Tubs(solidName,
1310 0.5 * width * CLHEP::cm,
1317 G4LogicalVolume* logicalV =
new G4LogicalVolume(boxShape, medAluminum, logicalName, 0, 0, 0);
1318 if (ribID > 39 && ribID < 78)
1319 logicalV =
new G4LogicalVolume(boxShape, medCopper, logicalName, 0, 0, 0);
1320 if ((ribID > 77 && ribID < 94) || (ribID > 131 && ribID < 146))
1321 logicalV =
new G4LogicalVolume(boxShape, medNEMA_G10_Plate, logicalName, 0, 0, 0);
1322 if (ribID > 93 && ribID < 110)
1323 logicalV =
new G4LogicalVolume(tubeShape, medCopper, logicalName, 0, 0, 0);
1324 if (ribID > 109 && ribID < 126)
1325 logicalV =
new G4LogicalVolume(tubeShape, medH2O, logicalName, 0, 0, 0);
1326 if (ribID > 127 && ribID < 132)
1327 logicalV =
new G4LogicalVolume(boxShape, medHV, logicalName, 0, 0, 0);
1337 const double phi = 360.0 / number;
1339 G4RotationMatrix rot = G4RotationMatrix();
1342 if (ribID > 93 && ribID < 126) dz = 0;
1343 G4ThreeVector arm(cX * CLHEP::cm, cY * CLHEP::cm, cZ * CLHEP::cm - dz * CLHEP::cm / 2.0);
1349 rot.rotateZ(0.5 * phi * CLHEP::deg);
1350 arm.rotateZ(0.5 * phi * CLHEP::deg);
1352 for (
int i = 0; i < number; ++i) {
1353 const string physicalName =
"physicalRib_" + to_string(ribID) +
" " + to_string(i);
1354 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
1356 rot.rotateZ(phi * CLHEP::deg);
1357 arm.rotateZ(phi * CLHEP::deg);
1362 const int nRib2s = content.getNumberNodes(
"Covers/Rib2");
1363 for (
int iRib2 = 0; iRib2 < nRib2s; ++iRib2) {
1365 rib2Content.
append((boost::format(
"/Covers/Rib2[%1%]/") % (iRib2 + 1)).str());
1366 const string srib2ID = rib2Content.
getString(
"@id");
1367 const int rib2ID = atoi(srib2ID.c_str());
1369 const double length = rib2Content.
getLength(
"Length");
1370 const double width = rib2Content.
getLength(
"Width");
1371 const double thick = rib2Content.
getLength(
"Thickness");
1372 const double width2 = rib2Content.
getLength(
"Width2");
1373 const double thick2 = rib2Content.
getLength(
"Thickness2");
1374 const double rotX = rib2Content.
getLength(
"RotX");
1375 const double rotY = rib2Content.
getLength(
"RotY");
1376 const double rotZ = rib2Content.
getLength(
"RotZ");
1377 const double cX = rib2Content.
getLength(
"PosX");
1378 const double cY = rib2Content.
getLength(
"PosY");
1379 const double cZ = rib2Content.
getLength(
"PosZ");
1380 const int number = atoi((rib2Content.
getString(
"NDiv")).c_str());
1382 const string solidName =
"solidRib2" + to_string(rib2ID);
1383 const string logicalName =
"logicalRib2" + to_string(rib2ID);
1384 G4Trd* trdShape =
new G4Trd(solidName,
1385 0.5 * thick * CLHEP::cm,
1386 0.5 * thick2 * CLHEP::cm,
1387 0.5 * width * CLHEP::cm,
1388 0.5 * width2 * CLHEP::cm,
1389 0.5 * length * CLHEP::cm);
1391 G4LogicalVolume* logicalV =
new G4LogicalVolume(trdShape, medAluminum, logicalName, 0, 0, 0);
1393 logicalV =
new G4LogicalVolume(trdShape, medCopper, logicalName, 0, 0, 0);
1397 const double phi = 360.0 / number;
1399 G4RotationMatrix rot = G4RotationMatrix();
1400 G4ThreeVector arm(cX * CLHEP::cm, cY * CLHEP::cm, cZ * CLHEP::cm - thick * CLHEP::cm / 2.0);
1405 for (
int i = 0; i < number; ++i) {
1406 const string physicalName =
"physicalRib2_" + to_string(rib2ID) +
" " + to_string(i);
1407 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
1409 rot.rotateZ(phi * CLHEP::deg);
1410 arm.rotateZ(phi * CLHEP::deg);
1415 const int nRib3s = content.getNumberNodes(
"Covers/Rib3");
1416 for (
int iRib3 = 0; iRib3 < nRib3s; ++iRib3) {
1418 rib3Content.
append((boost::format(
"/Covers/Rib3[%1%]/") % (iRib3 + 1)).str());
1419 const string srib3ID = rib3Content.
getString(
"@id");
1420 const int rib3ID = atoi(srib3ID.c_str());
1422 const double length = rib3Content.
getLength(
"Length");
1423 const double width = rib3Content.
getLength(
"Width");
1424 const double thick = rib3Content.
getLength(
"Thickness");
1425 const double r = rib3Content.
getLength(
"HoleR");
1426 const double cX = rib3Content.
getLength(
"PosX");
1427 const double cY = rib3Content.
getLength(
"PosY");
1428 const double cZ = rib3Content.
getLength(
"PosZ");
1429 const double hX = rib3Content.
getLength(
"HoleX");
1430 const double hY = rib3Content.
getLength(
"HoleY");
1431 const double hZ = rib3Content.
getLength(
"HoleZ");
1432 const int offset = atoi((rib3Content.
getString(
"Offset")).c_str());
1433 const int number = atoi((rib3Content.
getString(
"NDiv")).c_str());
1435 const string logicalName =
"logicalRib3" + to_string(rib3ID);
1436 G4VSolid* boxShape =
new G4Box(
"Block",
1437 0.5 * length * CLHEP::cm,
1438 0.5 * width * CLHEP::cm,
1439 0.5 * thick * CLHEP::cm);
1440 G4VSolid* tubeShape =
new G4Tubs(
"Hole",
1446 G4RotationMatrix rotsub = G4RotationMatrix();
1447 G4ThreeVector trnsub(cX * CLHEP::cm - hX * CLHEP::cm, cY * CLHEP::cm - hY * CLHEP::cm,
1448 cZ * CLHEP::cm - hZ * CLHEP::cm + 0.5 * thick * CLHEP::cm);
1449 G4VSolid* coolingBlock =
new G4SubtractionSolid(
"Block-Hole",
1452 G4Transform3D(rotsub,
1455 G4LogicalVolume* logicalV =
new G4LogicalVolume(coolingBlock, medCopper, logicalName, 0, 0, 0);
1459 const double phi = 360.0 / number;
1461 G4RotationMatrix rot = G4RotationMatrix();
1462 G4ThreeVector arm(cX * CLHEP::cm, cY * CLHEP::cm, cZ * CLHEP::cm - thick * CLHEP::cm / 2.0);
1465 rot.rotateZ(0.5 * phi * CLHEP::deg);
1466 arm.rotateZ(0.5 * phi * CLHEP::deg);
1468 for (
int i = 0; i < number; ++i) {
1469 const string physicalName =
"physicalRib3_" + to_string(rib3ID) +
" " + to_string(i);
1470 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
1472 rot.rotateZ(phi * CLHEP::deg);
1473 arm.rotateZ(phi * CLHEP::deg);
1478 const int nRib4s = content.getNumberNodes(
"Covers/Rib4");
1479 for (
int iRib4 = 0; iRib4 < nRib4s; ++iRib4) {
1481 rib4Content.
append((boost::format(
"/Covers/Rib4[%1%]/") % (iRib4 + 1)).str());
1482 const string srib4ID = rib4Content.
getString(
"@id");
1483 const int rib4ID = atoi(srib4ID.c_str());
1485 const double length = rib4Content.
getLength(
"Length");
1486 const double width = rib4Content.
getLength(
"Width");
1487 const double thick = rib4Content.
getLength(
"Thickness");
1488 const double length2 = rib4Content.
getLength(
"Length2");
1489 const double width2 = rib4Content.
getLength(
"Width2");
1490 const double thick2 = rib4Content.
getLength(
"Thickness2");
1491 const double cX = rib4Content.
getLength(
"PosX");
1492 const double cY = rib4Content.
getLength(
"PosY");
1493 const double cZ = rib4Content.
getLength(
"PosZ");
1494 const double hX = rib4Content.
getLength(
"HoleX");
1495 const double hY = rib4Content.
getLength(
"HoleY");
1496 const double hZ = rib4Content.
getLength(
"HoleZ");
1497 const int offset = atoi((rib4Content.
getString(
"Offset")).c_str());
1498 const int number = atoi((rib4Content.
getString(
"NDiv")).c_str());
1500 const string logicalName =
"logicalRib4" + to_string(rib4ID);
1501 G4VSolid* baseShape =
new G4Box(
"Base",
1502 0.5 * length * CLHEP::cm,
1503 0.5 * width * CLHEP::cm,
1504 0.5 * thick * CLHEP::cm);
1505 G4VSolid* sqShape =
new G4Box(
"Sq",
1506 0.5 * length2 * CLHEP::cm,
1507 0.5 * width2 * CLHEP::cm,
1508 0.5 * thick2 * CLHEP::cm);
1509 G4RotationMatrix rotsub = G4RotationMatrix();
1510 double dzc = (hZ - thick2 / 2.) - (cZ - thick / 2.);
1511 G4ThreeVector trnsub(hX * CLHEP::cm - cX * CLHEP::cm,
1512 hY * CLHEP::cm - cY * CLHEP::cm,
1514 G4VSolid* sqHoleBase =
new G4SubtractionSolid(
"Base-Sq",
1517 G4Transform3D(rotsub,
1521 G4LogicalVolume* logicalV =
new G4LogicalVolume(sqHoleBase, medCopper, logicalName, 0, 0, 0);
1523 logicalV =
new G4LogicalVolume(sqHoleBase, medNEMA_G10_Plate, logicalName, 0, 0, 0);
1527 const double phi = 360.0 / number;
1529 G4RotationMatrix rot = G4RotationMatrix();
1530 G4ThreeVector arm(cX * CLHEP::cm, cY * CLHEP::cm, cZ * CLHEP::cm - thick * CLHEP::cm / 2.0);
1533 rot.rotateZ(0.5 * phi * CLHEP::deg);
1534 arm.rotateZ(0.5 * phi * CLHEP::deg);
1536 for (
int i = 0; i < number; ++i) {
1537 const string physicalName =
"physicalRib4_" + to_string(rib4ID) +
" " + to_string(i);
1538 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
1540 rot.rotateZ(phi * CLHEP::deg);
1541 arm.rotateZ(phi * CLHEP::deg);
1546 const int nRib5s = content.getNumberNodes(
"Covers/Rib5");
1547 for (
int iRib5 = 0; iRib5 < nRib5s; ++iRib5) {
1549 rib5Content.
append((boost::format(
"/Covers/Rib5[%1%]/") % (iRib5 + 1)).str());
1550 const string srib5ID = rib5Content.
getString(
"@id");
1551 const int rib5ID = atoi(srib5ID.c_str());
1553 const double dr = rib5Content.
getLength(
"DeltaR");
1554 const double dz = rib5Content.
getLength(
"DeltaZ");
1555 const double width = rib5Content.
getLength(
"Width");
1556 const double thick = rib5Content.
getLength(
"Thickness");
1557 const double rin = rib5Content.
getLength(
"Rin");
1558 const double rotX = rib5Content.
getLength(
"RotX");
1559 const double rotY = rib5Content.
getLength(
"RotY");
1560 const double rotZ = rib5Content.
getLength(
"RotZ");
1561 const double cX = rib5Content.
getLength(
"PosX");
1562 const double cY = rib5Content.
getLength(
"PosY");
1563 const double cZ = rib5Content.
getLength(
"PosZ");
1564 const int offset = atoi((rib5Content.
getString(
"Offset")).c_str());
1565 const int number = atoi((rib5Content.
getString(
"NDiv")).c_str());
1567 const string solidName =
"solidRib5" + to_string(rib5ID);
1568 const string logicalName =
"logicalRib5" + to_string(rib5ID);
1569 const double rmax = rin + thick;
1570 const double rmin = rin;
1571 const double dphi = 2. * atan2(dz, dr);
1572 const double ddphi = thick *
tan(dphi) / rin;
1573 const double ddphi2 = width / 2. * width / 2. / (cX + dr) / rin;
1574 const double cphi = dphi - ddphi - ddphi2;
1575 G4Tubs* tubeShape =
new G4Tubs(solidName,
1578 0.5 * width * CLHEP::cm,
1582 G4LogicalVolume* logicalV =
new G4LogicalVolume(tubeShape, medAluminum, logicalName, 0, 0, 0);
1586 const double phi = 360.0 / number;
1588 G4RotationMatrix rot = G4RotationMatrix();
1591 G4ThreeVector arm(cX * CLHEP::cm, cY * CLHEP::cm, cZ * CLHEP::cm - rin * CLHEP::cm - thick * CLHEP::cm);
1597 rot.rotateZ(0.5 * phi * CLHEP::deg);
1598 arm.rotateZ(0.5 * phi * CLHEP::deg);
1600 for (
int i = 0; i < number; ++i) {
1601 const string physicalName =
"physicalRib5_" + to_string(rib5ID) +
" " + to_string(i);
1602 new G4PVPlacement(G4Transform3D(rot, arm), logicalV,
1604 rot.rotateZ(phi * CLHEP::deg);
1605 arm.rotateZ(phi * CLHEP::deg);