355 using namespace Acts::VectorHelpers;
360 double rmax = std::numeric_limits<double>::lowest();
362 double zmax = std::numeric_limits<double>::lowest();
369 for (
const auto& box : boxStore) {
370 Acts::Vector3
vmin = box->min().cast<
double>();
371 Acts::Vector3
vmax = box->max().cast<
double>();
382 if (std::abs(
vmin.z()) < 100) {
383 rmin_at_center =
std::min(vrmin, rmin_at_center);
385 if (std::abs(
vmax.z()) < 100) {
386 rmin_at_center =
std::min(vrmax, rmin_at_center);
390 for (
const auto& box : boxStore) {
391 Acts::Vector3
vmin = box->min().cast<
double>();
392 Acts::Vector3
vmax = box->max().cast<
double>();
396 if (vrmin < rmin_at_center * 0.9) {
397 cutout_zmin_abs =
std::min(cutout_zmin_abs, std::abs(
vmin.z()));
399 if (vrmax < rmin_at_center * 0.9) {
400 cutout_zmin_abs =
std::min(cutout_zmin_abs, std::abs(
vmax.z()));
405 double dz2 = cutout_zmin_abs;
413 if(rmin_at_choke > envR) rmin_at_choke -= envR;
414 rmin_at_center -= envR;
418 <<
" rmin at choke: " << rmin_at_choke
419 <<
" rmax: " << rmax <<
" zmin: " <<
zmin <<
" zmax: " <<
zmax
420 <<
" coutout_zmin_abs: " << cutout_zmin_abs);
428 =
dynamic_cast<const Acts::CylinderVolumeBounds*
>(&insideVolume->volumeBounds());
429 if (idCylBds ==
nullptr) {
430 ATH_MSG_ERROR(
"Unable to dynamic cast volume bounds to Acts::CylinderVolumeBounds");
431 throw std::runtime_error(
"Error casting to CylinderVolumeBounds");
434 double idRMax = idCylBds->get(CVBBV::eMaxR);
435 double idRMin = idCylBds->get(CVBBV::eMinR);
436 double idHlZ = idCylBds->get(CVBBV::eHalfLengthZ);
440 ATH_MSG_VERBOSE(
"Inside volume transform: \n" << insideVolume->transform().matrix());
442 if (!insideVolume->transform().isApprox(Acts::Transform3::Identity())) {
448 const auto&
trf = insideVolume->transform();
450 Acts::RotationMatrix3 rot =
trf.rotation();
451 bool unityRot = rot.isApprox(Acts::RotationMatrix3::Identity());
456 const Acts::Vector3 trl =
trf.translation();
457 bool transZOnly = std::abs(1 - std::abs(Acts::Vector3::UnitZ().
dot(trl.normalized()))) < 1
e-6;
460 ATH_MSG_VERBOSE(
"TRL "<< trl.normalized().dot(Acts::Vector3::UnitZ()));
462 if(!unityRot || !transZOnly) {
463 ATH_MSG_ERROR(
"The ID appears to be shifted from the origin. I cannot handle this.");
465 throw std::runtime_error(
"Error building calo");
468 ATH_MSG_VERBOSE(
"Checked: non unitarity is ONLY due to shift along z axis: that's ok");
469 double prevIdHlZ = idHlZ;
470 idHlZ += std::abs(trl.z());
471 ATH_MSG_VERBOSE(
"Modifying effective half length of ID cylinder: " << prevIdHlZ <<
" => " << idHlZ);
476 if (idRMax > rmin_at_center || idHlZ > dz2 || (idRMin > rmin_at_choke && idRMin != 0.)) {
478 ATH_MSG_ERROR(
"This can be because the ID overlaps into the calo volume");
479 ATH_MSG_ERROR(
"Or because the Calo choke radius is SMALLER than the ID inner radius");
480 ATH_MSG_ERROR(
"Currently, I can only make the choke radius smaller, I can not make it larger");
481 ATH_MSG_ERROR(
"nor can I manipulate the ID volume bounds at this point.");
482 ATH_MSG_ERROR(
"ID rMax: " << idRMax <<
" Calo rMin@center: " << rmin_at_center);
483 ATH_MSG_ERROR(
"ID hlZ: " << idHlZ <<
" Calo inner Z hl: " << dz2);
484 ATH_MSG_ERROR(
"ID rMin: " << idRMin <<
" Calo rMin@choke: " << rmin_at_choke);
486 throw std::runtime_error(
"Error building calo");
492 rmin_at_choke = idRMin;
494 std::shared_ptr<Acts::CutoutCylinderVolumeBounds> volBds =
nullptr;
495 volBds = std::make_shared<Acts::CutoutCylinderVolumeBounds>(
496 rmin_at_choke, rmin_at_center, rmax, dz1, dz2);