265 bool navtype)
const {
269 const bool bevelled = std::find_if(vols.begin(),vols.end(),
271 return dynamic_cast<const BevelledCylinderVolumeBounds*>(&(ptr->volumeBounds()));
277 std::vector<TrackingVolumeOrderPosition> volOrder;
281 <<
" Volumes (with CylinderVolumeBounds) with PhiH-binning. ");
282 std::vector<float> phiSteps;
283 std::vector<std::pair<std::pair<double, int>, std::pair<double, double>>>
285 std::vector<VolumePtr> fullPhiVols;
297 rmin = cyl->innerRadius();
298 rmax = cyl->outerRadius();
299 dphi = cyl->halfPhiSector();
300 mRad = cyl->mediumRadius();
302 rmin = bcyl->innerRadius();
303 rmax = bcyl->outerRadius();
304 dphi = bcyl->halfPhiSector();
305 mRad = bcyl->mediumRadius();
314 Amg::Vector3D ngp((vol->transform()) * (mRad * Amg::Vector3D::UnitX()));
315 volOrder.emplace_back(vol, ngp);
318 volPos.emplace_back(std::pair<double, int>(ngp.phi(),
type),
319 std::pair<double, double>(rmin, rmax));
321 double phi1 = ngp.phi() - dphi;
322 double phi2 = ngp.phi() + dphi;
323 if (phi1 < -2 *
M_PI) {
325 }
if (phi2 < -2 *
M_PI) {
327 }
if (phi1 > 2 *
M_PI) {
329 }
if (phi2 > 2 *
M_PI) {
333 if (!phiSteps.empty()) {
334 std::vector<float>::iterator iter = phiSteps.begin();
336 while (iter != phiSteps.end()) {
337 if (std::abs(phi1 - (*iter)) < tol) {
341 if (phi1 < (*iter)) {
342 phiSteps.insert(iter, phi1);
349 phiSteps.push_back(phi1);
350 iter = phiSteps.begin();
352 while (iter != phiSteps.end()) {
353 if (std::abs(phi2 - (*iter)) < tol) {
357 if (phi2 < (*iter)) {
358 phiSteps.insert(iter, phi2);
365 phiSteps.push_back(phi2);
367 phiSteps.push_back(fmin(phi1, phi2));
368 phiSteps.push_back(fmax(phi1, phi2));
371 fullPhiVols.push_back(vol);
375 if (phiSteps.empty()) {
376 phiSteps.push_back(-
M_PI);
377 phiSteps.push_back(+
M_PI);
379 for (
auto & fullPhiVol : fullPhiVols) {
382 ATH_MSG_WARNING(
"dynamic_cast<const CylinderVolumeBounds*> failed ... trying to continue loop");
386 double rmax = cyl->outerRadius();
388 for (
unsigned int iphi = 0; iphi < phiSteps.size(); ++iphi) {
390 double phiRef = 0.5 * phiSteps[iphi];
391 if (iphi < phiSteps.size() - 1)
392 phiRef += 0.5 * phiSteps[iphi + 1];
394 phiRef += 0.5 * phiSteps[0] +
M_PI;
396 const Amg::Vector3D ngp{cyl->mediumRadius() * std::cos(phiRef),cyl->mediumRadius() * std::sin(phiRef),0.};
398 volOrder.emplace_back(fullPhiVol, ngp);
401 volPos.emplace_back(std::pair<double, int>(ngp.phi(), 0),
402 std::pair<double, double>(rmin, rmax));
408 if (phiSteps.size() > 1) {
409 if (phiSteps.back() >
M_PI)
410 phiSteps.erase(phiSteps.end() - 1);
412 phiSteps.erase(phiSteps.begin());
416 std::vector<std::vector<std::pair<int, float>>> hSteps(phiSteps.size());
417 std::vector<float> phiRef(phiSteps.size());
418 for (
unsigned int ip = 0; ip < phiSteps.size() - 1; ++ip)
419 phiRef[ip] = 0.5 * (phiSteps[ip] + phiSteps[ip + 1]);
420 phiRef.back() = 0.5 * (phiSteps.back() + phiSteps.front());
421 phiRef.back() += (phiRef.back() > 0) ? -
M_PI :
M_PI;
427 for (
unsigned int i = 0; i < volPos.size(); ++i) {
430 int type = volPos[i].first.second;
431 double rmin = volPos[i].second.first;
432 double rmax = volPos[i].second.second;
433 int tmin = (
type != 1 &&
type != 3) ? 0 : 1;
434 int tmax = (
type < 2) ? 0 : 1;
436 int phibin = phiBinUtil.bin(volOrder[i].second);
438 if (!hSteps[phibin].
empty()) {
439 std::vector<std::pair<int, float>>
::iterator iter =
440 hSteps[phibin].begin();
442 while (iter != hSteps[phibin].end()) {
443 if (std::abs(rmin - (*iter).second) < tol) {
447 if (rmin < (*iter).second) {
448 hSteps[phibin].insert(iter, std::pair<int, float>(tmin, rmin));
455 hSteps[phibin].emplace_back(tmin, rmin);
456 iter = hSteps[phibin].begin();
458 while (iter != hSteps[phibin].end()) {
459 if (std::abs(rmax - (*iter).second) < tol) {
463 if (rmax < (*iter).second) {
464 hSteps[phibin].insert(iter, std::pair<int, float>(tmax, rmax));
471 hSteps[phibin].emplace_back(tmax, rmax);
473 hSteps[phibin].emplace_back(tmin, rmin);
474 hSteps[phibin].emplace_back(tmax, rmax);
480 auto hUtil = std::vector<BinUtility>(phiSteps.size());
482 for (
unsigned int ih = 0; ih < phiSteps.size(); ++ih) {
483 (hUtil)[ih] =
BinUtility(phiRef[ih], hSteps[ih]);
486 return std::make_unique<BinnedArray1D1D<TrackingVolume>>(volOrder, phiBinUtil, hUtil);
490 <<
" Volumes (with CylinderVolumeBounds) with PhiR-binning. ");
492 std::vector<float> rSteps;
493 double phiSector =
M_PI;
494 std::vector<std::pair<double, std::pair<double, double>>> volPos;
496 for (
const auto& vol : vols) {
499 ATH_MSG_WARNING(
"dynamic_cast<const CylinderVolumeBounds*> failed ... trying to continue loop");
503 double rmax = cyl->outerRadius();
504 double dphi = cyl->halfPhiSector();
505 if (phiSector > 0. && std::abs(dphi - phiSector) > 0.001)
506 phiSector = phiSector <
M_PI ? -1. : dphi;
509 const Amg::Vector3D ngp{vol->transform() * (cyl->mediumRadius()* Amg::Vector3D::UnitX())};
510 volOrder.emplace_back(vol, ngp);
513 volPos.emplace_back(cyl->mediumRadius(), std::make_pair(ngp.phi(), dphi));
515 if (!rSteps.empty()) {
516 std::vector<float>::iterator iter = rSteps.begin();
518 while (iter != rSteps.end()) {
519 if (std::abs(rmin - (*iter)) < tol) {
523 if (rmin < (*iter)) {
524 rSteps.insert(iter, rmin);
531 rSteps.push_back(rmin);
532 iter = rSteps.begin();
534 while (iter != rSteps.end()) {
535 if (std::abs(rmax - (*iter)) < tol) {
539 if (rmax < (*iter)) {
540 rSteps.insert(iter, rmax);
547 rSteps.push_back(rmax);
549 rSteps.push_back(rmin);
550 rSteps.push_back(rmax);
554 if (phiSector > 0.) {
556 const int rStepsSizem1 = rSteps.size() - 1;
557 std::vector<double>
phi(rStepsSizem1,
M_PI);
558 std::vector<int> phiSect(rStepsSizem1,
int(
M_PI / phiSector));
561 if (rSteps.size() == 1) {
564 if (phiSector ==
M_PI) {
569 auto phiUtil = std::vector<BinUtility>(rSteps.size() - 1);
570 for (
unsigned int ip = 0; ip < phiUtil.size(); ++ip) {
573 return std::make_unique<BinnedArray1D1D<TrackingVolume>>(volOrder, rBinUtil, phiUtil);
580 std::vector<std::vector<float>> phiSteps(rSteps.size() - 1);
582 for (
unsigned int i = 0; i < volPos.size(); ++i) {
584 double phi = volPos[i].second.first;
585 double dphi = volPos[i].second.second;
587 int binr = binGenR.bin(volOrder[i].second);
589 float phi1 =
phi - dphi;
590 float phi2 =
phi + dphi;
596 if (!phiSteps[binr].
empty()) {
597 std::vector<float>::iterator iter = phiSteps[binr].begin();
599 while (iter != phiSteps[binr].end()) {
600 if (std::abs(phi1 - (*iter)) < tol) {
604 if (phi1 < (*iter)) {
605 phiSteps[binr].insert(iter, phi1);
612 phiSteps[binr].push_back(phi1);
613 iter = phiSteps[binr].begin();
615 while (iter != phiSteps[binr].end()) {
616 if (std::abs(phi2 - (*iter)) < tol) {
620 if (phi2 < (*iter)) {
621 phiSteps[binr].insert(iter, phi2);
628 phiSteps[binr].push_back(phi2);
630 phiSteps[binr].push_back(std::fmin(phi1, phi2));
631 phiSteps[binr].push_back(std::fmax(phi1, phi2));
636 auto phiUtil = std::vector<BinUtility>(phiSteps.size());
638 for (
unsigned int ip = 0; ip < phiSteps.size(); ++ip) {
642 return std::make_unique<BinnedArray1D1D<TrackingVolume>>(volOrder, binGenR, phiUtil);
647 bool navtype)
const {
650 <<
" Volumes (with CylinderVolumeBounds) with PhiZ-binning. ");
654 std::vector<TrackingVolumeOrderPosition> volOrder;
656 std::vector<float> zSteps;
658 double phiSector =
M_PI;
659 std::vector<std::pair<float, std::pair<float, float>>> volPos;
669 zmin = vol->center().z() - cyl->halflengthZ();
670 zmax = vol->center().z() + cyl->halflengthZ();
671 dphi = cyl->halfPhiSector();
672 mRad = cyl->mediumRadius();
674 zmin = vol->center().z() - bcyl->halflengthZ();
675 zmax = vol->center().z() + bcyl->halflengthZ();
676 dphi = bcyl->halfPhiSector();
677 mRad = bcyl->mediumRadius();
683 if (phiSector > 0. && std::abs(dphi - phiSector) > 0.001)
684 phiSector = phiSector <
M_PI ? -1. : dphi;
687 const Amg::Vector3D ngp{vol->transform() * (mRad * Amg::Vector3D::UnitX())};
689 volOrder.emplace_back(vol, ngp);
691 volPos.emplace_back(vol->center().z(), std::make_pair(ngp.phi(), dphi));
693 if (!zSteps.empty()) {
694 std::vector<float>::iterator iter = zSteps.begin();
696 while (iter != zSteps.end()) {
697 if (std::abs(zmin - (*iter)) < tol) {
701 if (zmin < (*iter)) {
702 zSteps.insert(iter, zmin);
709 zSteps.push_back(zmin);
710 iter = zSteps.begin();
712 while (iter != zSteps.end()) {
713 if (std::abs(zmax - (*iter)) < tol) {
717 if (zmax < (*iter)) {
718 zSteps.insert(iter, zmax);
725 zSteps.push_back(zmax);
727 zSteps.push_back(zmin);
728 zSteps.push_back(zmax);
732 if (phiSector > 0.) {
734 const int zStepsSizem1 = zSteps.size() - 1;
735 std::vector<double>
phi(zStepsSizem1,
M_PI);
736 std::vector<int> phiSect(zStepsSizem1,
int(
M_PI / phiSector));
739 if (phiSector ==
M_PI) {
742 if (zSteps.size() == 2) {
748 return std::make_unique<BinnedArray2D<TrackingVolume>>(volOrder, binGenZPhi);
755 std::vector<std::vector<float>> phiSteps(zSteps.size() - 1);
757 for (
unsigned int i = 0; i < volPos.size(); ++i) {
759 float phi = volPos[i].second.first;
760 float dphi = volPos[i].second.second;
762 int binZ = binGenZ.bin(volOrder[i].second);
764 float phi1 =
phi - dphi;
765 float phi2 =
phi + dphi;
772 std::vector<float>::iterator iter = phiSteps[
binZ].begin();
774 while (iter != phiSteps[
binZ].end()) {
775 if (std::abs(phi1 - (*iter)) < tol) {
779 if (phi1 < (*iter)) {
780 phiSteps[
binZ].insert(iter, phi1);
787 phiSteps[
binZ].push_back(phi1);
788 iter = phiSteps[
binZ].begin();
790 while (iter != phiSteps[
binZ].end()) {
791 if (std::abs(phi2 - (*iter)) < tol) {
795 if (phi2 < (*iter)) {
796 phiSteps[
binZ].insert(iter, phi2);
803 phiSteps[
binZ].push_back(phi2);
805 phiSteps[
binZ].push_back(std::fmin(phi1, phi2));
806 phiSteps[
binZ].push_back(std::fmax(phi1, phi2));
812 auto phiUtil = std::vector<BinUtility>(phiSteps.size());
814 for (
unsigned int ip = 0; ip < phiSteps.size(); ++ip) {
818 return std::make_unique<BinnedArray1D1D<TrackingVolume>>(volOrder, binGenZ, phiUtil);