356 using namespace Acts::VectorHelpers;
361 double rmax = std::numeric_limits<double>::lowest();
363 double zmax = std::numeric_limits<double>::lowest();
370 for (
const auto& box : boxStore) {
371 Acts::Vector3
vmin = box->min().cast<
double>();
372 Acts::Vector3
vmax = box->max().cast<
double>();
383 if (std::abs(
vmin.z()) < 100) {
384 rmin_at_center =
std::min(vrmin, rmin_at_center);
386 if (std::abs(
vmax.z()) < 100) {
387 rmin_at_center =
std::min(vrmax, rmin_at_center);
391 for (
const auto& box : boxStore) {
392 Acts::Vector3
vmin = box->min().cast<
double>();
393 Acts::Vector3
vmax = box->max().cast<
double>();
397 if (vrmin < rmin_at_center * 0.9) {
398 cutout_zmin_abs =
std::min(cutout_zmin_abs, std::abs(
vmin.z()));
400 if (vrmax < rmin_at_center * 0.9) {
401 cutout_zmin_abs =
std::min(cutout_zmin_abs, std::abs(
vmax.z()));
406 double dz2 = cutout_zmin_abs;
414 if(rmin_at_choke > envR) rmin_at_choke -= envR;
415 rmin_at_center -= envR;
419 <<
" rmin at choke: " << rmin_at_choke
420 <<
" rmax: " << rmax <<
" zmin: " <<
zmin <<
" zmax: " <<
zmax
421 <<
" coutout_zmin_abs: " << cutout_zmin_abs);
429 =
dynamic_cast<const Acts::CylinderVolumeBounds*
>(&insideVolume->volumeBounds());
430 if (idCylBds ==
nullptr) {
431 ATH_MSG_ERROR(
"Unable to dynamic cast volume bounds to Acts::CylinderVolumeBounds");
432 throw std::runtime_error(
"Error casting to CylinderVolumeBounds");
435 double idRMax = idCylBds->get(CVBBV::eMaxR);
436 double idRMin = idCylBds->get(CVBBV::eMinR);
437 double idHlZ = idCylBds->get(CVBBV::eHalfLengthZ);
441 ATH_MSG_VERBOSE(
"Inside volume transform: \n" << insideVolume->transform().matrix());
443 if (!insideVolume->transform().isApprox(Acts::Transform3::Identity())) {
449 const auto&
trf = insideVolume->transform();
451 Acts::RotationMatrix3 rot =
trf.rotation();
452 bool unityRot = rot.isApprox(Acts::RotationMatrix3::Identity());
457 const Acts::Vector3 trl =
trf.translation();
458 bool transZOnly = std::abs(1 - std::abs(Acts::Vector3::UnitZ().
dot(trl.normalized()))) < 1
e-6;
461 ATH_MSG_VERBOSE(
"TRL "<< trl.normalized().dot(Acts::Vector3::UnitZ()));
463 if(!unityRot || !transZOnly) {
464 ATH_MSG_ERROR(
"The ID appears to be shifted from the origin. I cannot handle this.");
466 throw std::runtime_error(
"Error building calo");
469 ATH_MSG_VERBOSE(
"Checked: non unitarity is ONLY due to shift along z axis: that's ok");
470 double prevIdHlZ = idHlZ;
471 idHlZ += std::abs(trl.z());
472 ATH_MSG_VERBOSE(
"Modifying effective half length of ID cylinder: " << prevIdHlZ <<
" => " << idHlZ);
477 if (idRMax > rmin_at_center || idHlZ > dz2 || (idRMin > rmin_at_choke && idRMin != 0.)) {
479 ATH_MSG_ERROR(
"This can be because the ID overlaps into the calo volume");
480 ATH_MSG_ERROR(
"Or because the Calo choke radius is SMALLER than the ID inner radius");
481 ATH_MSG_ERROR(
"Currently, I can only make the choke radius smaller, I can not make it larger");
482 ATH_MSG_ERROR(
"nor can I manipulate the ID volume bounds at this point.");
483 ATH_MSG_ERROR(
"ID rMax: " << idRMax <<
" Calo rMin@center: " << rmin_at_center);
484 ATH_MSG_ERROR(
"ID hlZ: " << idHlZ <<
" Calo inner Z hl: " << dz2);
485 ATH_MSG_ERROR(
"ID rMin: " << idRMin <<
" Calo rMin@choke: " << rmin_at_choke);
487 throw std::runtime_error(
"Error building calo");
493 rmin_at_choke = idRMin;
495 std::shared_ptr<Acts::CutoutCylinderVolumeBounds> volBds =
nullptr;
496 volBds = std::make_shared<Acts::CutoutCylinderVolumeBounds>(
497 rmin_at_choke, rmin_at_center, rmax, dz1, dz2);