268 bool navtype)
const {
272 const bool bevelled = std::find_if(vols.begin(),vols.end(),
274 return dynamic_cast<const BevelledCylinderVolumeBounds*>(&(ptr->volumeBounds()));
280 std::vector<TrackingVolumeOrderPosition> volOrder;
284 <<
" Volumes (with CylinderVolumeBounds) with PhiH-binning. ");
285 std::vector<float> phiSteps;
286 std::vector<std::pair<std::pair<double, int>, std::pair<double, double>>>
288 std::vector<VolumePtr> fullPhiVols;
300 rmin = cyl->innerRadius();
301 rmax = cyl->outerRadius();
302 dphi = cyl->halfPhiSector();
303 mRad = cyl->mediumRadius();
305 rmin = bcyl->innerRadius();
306 rmax = bcyl->outerRadius();
307 dphi = bcyl->halfPhiSector();
308 mRad = bcyl->mediumRadius();
317 Amg::Vector3D ngp((vol->transform()) * (mRad * Amg::Vector3D::UnitX()));
318 volOrder.emplace_back(vol, ngp);
321 volPos.emplace_back(std::pair<double, int>(ngp.phi(),
type),
322 std::pair<double, double>(rmin, rmax));
324 double phi1 = ngp.phi() - dphi;
325 double phi2 = ngp.phi() + dphi;
326 if (phi1 < -2 *
M_PI) {
328 }
if (phi2 < -2 *
M_PI) {
330 }
if (phi1 > 2 *
M_PI) {
332 }
if (phi2 > 2 *
M_PI) {
336 if (!phiSteps.empty()) {
337 std::vector<float>::iterator iter = phiSteps.begin();
339 while (iter != phiSteps.end()) {
340 if (std::abs(phi1 - (*iter)) < tol) {
344 if (phi1 < (*iter)) {
345 phiSteps.insert(iter, phi1);
352 phiSteps.push_back(phi1);
353 iter = phiSteps.begin();
355 while (iter != phiSteps.end()) {
356 if (std::abs(phi2 - (*iter)) < tol) {
360 if (phi2 < (*iter)) {
361 phiSteps.insert(iter, phi2);
368 phiSteps.push_back(phi2);
370 phiSteps.push_back(fmin(phi1, phi2));
371 phiSteps.push_back(fmax(phi1, phi2));
374 fullPhiVols.push_back(vol);
378 if (phiSteps.empty()) {
379 phiSteps.push_back(-
M_PI);
380 phiSteps.push_back(+
M_PI);
382 for (
auto & fullPhiVol : fullPhiVols) {
385 ATH_MSG_WARNING(
"dynamic_cast<const CylinderVolumeBounds*> failed ... trying to continue loop");
389 double rmax = cyl->outerRadius();
391 for (
unsigned int iphi = 0; iphi < phiSteps.size(); ++iphi) {
393 double phiRef = 0.5 * phiSteps[iphi];
394 if (iphi < phiSteps.size() - 1)
395 phiRef += 0.5 * phiSteps[iphi + 1];
397 phiRef += 0.5 * phiSteps[0] +
M_PI;
399 const Amg::Vector3D ngp{cyl->mediumRadius() * std::cos(phiRef),cyl->mediumRadius() * std::sin(phiRef),0.};
401 volOrder.emplace_back(fullPhiVol, ngp);
404 volPos.emplace_back(std::pair<double, int>(ngp.phi(), 0),
405 std::pair<double, double>(rmin, rmax));
411 if (phiSteps.size() > 1) {
412 if (phiSteps.back() >
M_PI)
413 phiSteps.erase(phiSteps.end() - 1);
415 phiSteps.erase(phiSteps.begin());
419 std::vector<std::vector<std::pair<int, float>>> hSteps(phiSteps.size());
420 std::vector<float> phiRef(phiSteps.size());
421 for (
unsigned int ip = 0; ip < phiSteps.size() - 1; ++ip)
422 phiRef[ip] = 0.5 * (phiSteps[ip] + phiSteps[ip + 1]);
423 phiRef.back() = 0.5 * (phiSteps.back() + phiSteps.front());
424 phiRef.back() += (phiRef.back() > 0) ? -
M_PI :
M_PI;
430 for (
unsigned int i = 0; i < volPos.size(); ++i) {
433 int type = volPos[i].first.second;
434 double rmin = volPos[i].second.first;
435 double rmax = volPos[i].second.second;
436 int tmin = (
type != 1 &&
type != 3) ? 0 : 1;
437 int tmax = (
type < 2) ? 0 : 1;
439 int phibin = phiBinUtil.bin(volOrder[i].second);
441 if (!hSteps[phibin].
empty()) {
442 std::vector<std::pair<int, float>>
::iterator iter =
443 hSteps[phibin].begin();
445 while (iter != hSteps[phibin].end()) {
446 if (std::abs(rmin - (*iter).second) < tol) {
450 if (rmin < (*iter).second) {
451 hSteps[phibin].insert(iter, std::pair<int, float>(tmin, rmin));
458 hSteps[phibin].emplace_back(tmin, rmin);
459 iter = hSteps[phibin].begin();
461 while (iter != hSteps[phibin].end()) {
462 if (std::abs(rmax - (*iter).second) < tol) {
466 if (rmax < (*iter).second) {
467 hSteps[phibin].insert(iter, std::pair<int, float>(tmax, rmax));
474 hSteps[phibin].emplace_back(tmax, rmax);
476 hSteps[phibin].emplace_back(tmin, rmin);
477 hSteps[phibin].emplace_back(tmax, rmax);
483 auto hUtil = std::vector<BinUtility>(phiSteps.size());
485 for (
unsigned int ih = 0; ih < phiSteps.size(); ++ih) {
486 (hUtil)[ih] =
BinUtility(phiRef[ih], hSteps[ih]);
489 return std::make_unique<BinnedArray1D1D<TrackingVolume>>(volOrder, phiBinUtil, hUtil);
493 <<
" Volumes (with CylinderVolumeBounds) with PhiR-binning. ");
495 std::vector<float> rSteps;
496 double phiSector =
M_PI;
497 std::vector<std::pair<double, std::pair<double, double>>> volPos;
499 for (
const auto& vol : vols) {
502 ATH_MSG_WARNING(
"dynamic_cast<const CylinderVolumeBounds*> failed ... trying to continue loop");
506 double rmax = cyl->outerRadius();
507 double dphi = cyl->halfPhiSector();
508 if (phiSector > 0. && std::abs(dphi - phiSector) > 0.001)
509 phiSector = phiSector <
M_PI ? -1. : dphi;
512 const Amg::Vector3D ngp{vol->transform() * (cyl->mediumRadius()* Amg::Vector3D::UnitX())};
513 volOrder.emplace_back(vol, ngp);
516 volPos.emplace_back(cyl->mediumRadius(), std::make_pair(ngp.phi(), dphi));
518 if (!rSteps.empty()) {
519 std::vector<float>::iterator iter = rSteps.begin();
521 while (iter != rSteps.end()) {
522 if (std::abs(rmin - (*iter)) < tol) {
526 if (rmin < (*iter)) {
527 rSteps.insert(iter, rmin);
534 rSteps.push_back(rmin);
535 iter = rSteps.begin();
537 while (iter != rSteps.end()) {
538 if (std::abs(rmax - (*iter)) < tol) {
542 if (rmax < (*iter)) {
543 rSteps.insert(iter, rmax);
550 rSteps.push_back(rmax);
552 rSteps.push_back(rmin);
553 rSteps.push_back(rmax);
557 if (phiSector > 0.) {
559 const int rStepsSizem1 = rSteps.size() - 1;
560 std::vector<double>
phi(rStepsSizem1,
M_PI);
561 std::vector<int> phiSect(rStepsSizem1,
int(
M_PI / phiSector));
564 if (rSteps.size() == 1) {
567 if (phiSector ==
M_PI) {
572 auto phiUtil = std::vector<BinUtility>(rSteps.size() - 1);
573 for (
unsigned int ip = 0; ip < phiUtil.size(); ++ip) {
576 return std::make_unique<BinnedArray1D1D<TrackingVolume>>(volOrder, rBinUtil, phiUtil);
583 std::vector<std::vector<float>> phiSteps(rSteps.size() - 1);
585 for (
unsigned int i = 0; i < volPos.size(); ++i) {
587 double phi = volPos[i].second.first;
588 double dphi = volPos[i].second.second;
590 int binr = binGenR.bin(volOrder[i].second);
592 float phi1 =
phi - dphi;
593 float phi2 =
phi + dphi;
599 if (!phiSteps[binr].
empty()) {
600 std::vector<float>::iterator iter = phiSteps[binr].begin();
602 while (iter != phiSteps[binr].end()) {
603 if (std::abs(phi1 - (*iter)) < tol) {
607 if (phi1 < (*iter)) {
608 phiSteps[binr].insert(iter, phi1);
615 phiSteps[binr].push_back(phi1);
616 iter = phiSteps[binr].begin();
618 while (iter != phiSteps[binr].end()) {
619 if (std::abs(phi2 - (*iter)) < tol) {
623 if (phi2 < (*iter)) {
624 phiSteps[binr].insert(iter, phi2);
631 phiSteps[binr].push_back(phi2);
633 phiSteps[binr].push_back(std::fmin(phi1, phi2));
634 phiSteps[binr].push_back(std::fmax(phi1, phi2));
639 auto phiUtil = std::vector<BinUtility>(phiSteps.size());
641 for (
unsigned int ip = 0; ip < phiSteps.size(); ++ip) {
645 return std::make_unique<BinnedArray1D1D<TrackingVolume>>(volOrder, binGenR, phiUtil);
650 bool navtype)
const {
653 <<
" Volumes (with CylinderVolumeBounds) with PhiZ-binning. ");
657 std::vector<TrackingVolumeOrderPosition> volOrder;
659 std::vector<float> zSteps;
661 double phiSector =
M_PI;
662 std::vector<std::pair<float, std::pair<float, float>>> volPos;
672 zmin = vol->center().z() - cyl->halflengthZ();
673 zmax = vol->center().z() + cyl->halflengthZ();
674 dphi = cyl->halfPhiSector();
675 mRad = cyl->mediumRadius();
677 zmin = vol->center().z() - bcyl->halflengthZ();
678 zmax = vol->center().z() + bcyl->halflengthZ();
679 dphi = bcyl->halfPhiSector();
680 mRad = bcyl->mediumRadius();
686 if (phiSector > 0. && std::abs(dphi - phiSector) > 0.001)
687 phiSector = phiSector <
M_PI ? -1. : dphi;
690 const Amg::Vector3D ngp{vol->transform() * (mRad * Amg::Vector3D::UnitX())};
692 volOrder.emplace_back(vol, ngp);
694 volPos.emplace_back(vol->center().z(), std::make_pair(ngp.phi(), dphi));
696 if (!zSteps.empty()) {
697 std::vector<float>::iterator iter = zSteps.begin();
699 while (iter != zSteps.end()) {
700 if (std::abs(zmin - (*iter)) < tol) {
704 if (zmin < (*iter)) {
705 zSteps.insert(iter, zmin);
712 zSteps.push_back(zmin);
713 iter = zSteps.begin();
715 while (iter != zSteps.end()) {
716 if (std::abs(zmax - (*iter)) < tol) {
720 if (zmax < (*iter)) {
721 zSteps.insert(iter, zmax);
728 zSteps.push_back(zmax);
730 zSteps.push_back(zmin);
731 zSteps.push_back(zmax);
735 if (phiSector > 0.) {
737 const int zStepsSizem1 = zSteps.size() - 1;
738 std::vector<double>
phi(zStepsSizem1,
M_PI);
739 std::vector<int> phiSect(zStepsSizem1,
int(
M_PI / phiSector));
742 if (phiSector ==
M_PI) {
745 if (zSteps.size() == 2) {
751 return std::make_unique<BinnedArray2D<TrackingVolume>>(volOrder, binGenZPhi);
758 std::vector<std::vector<float>> phiSteps(zSteps.size() - 1);
760 for (
unsigned int i = 0; i < volPos.size(); ++i) {
762 float phi = volPos[i].second.first;
763 float dphi = volPos[i].second.second;
765 int binZ = binGenZ.bin(volOrder[i].second);
767 float phi1 =
phi - dphi;
768 float phi2 =
phi + dphi;
775 std::vector<float>::iterator iter = phiSteps[
binZ].begin();
777 while (iter != phiSteps[
binZ].end()) {
778 if (std::abs(phi1 - (*iter)) < tol) {
782 if (phi1 < (*iter)) {
783 phiSteps[
binZ].insert(iter, phi1);
790 phiSteps[
binZ].push_back(phi1);
791 iter = phiSteps[
binZ].begin();
793 while (iter != phiSteps[
binZ].end()) {
794 if (std::abs(phi2 - (*iter)) < tol) {
798 if (phi2 < (*iter)) {
799 phiSteps[
binZ].insert(iter, phi2);
806 phiSteps[
binZ].push_back(phi2);
808 phiSteps[
binZ].push_back(std::fmin(phi1, phi2));
809 phiSteps[
binZ].push_back(std::fmax(phi1, phi2));
815 auto phiUtil = std::vector<BinUtility>(phiSteps.size());
817 for (
unsigned int ip = 0; ip < phiSteps.size(); ++ip) {
821 return std::make_unique<BinnedArray1D1D<TrackingVolume>>(volOrder, binGenZ, phiUtil);