ATLAS Offline Software
Loading...
Searching...
No Matches
ExpandedSector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
7
8
9#include "GeoModelKernel/throwExcept.h"
10
11#include "Acts/Utilities/Helpers.hpp"
12#include "Acts/Utilities/UnitVectors.hpp"
13#include "Acts/Definitions/Units.hpp"
14
15#include <cassert>
16using namespace Acts::UnitLiterals;
17using namespace Muon::MuonStationIndex;
18
19namespace{
20 static const Muon::MuonSectorMapping sectorMap{};
21 using SectorProjector = MuonR4::ExpandedSector::SectorProjector;
22 constexpr std::int8_t nExpanded = 2*numberOfSectors();
23
24 inline std::tuple<unsigned, SectorProjector> msSectorAndProj(const std::int8_t expandSector) {
25 assert (expandSector >= 0 && expandSector <= nExpanded);
26 if (expandSector == 0) {
27 return std::make_tuple(numberOfSectors(), SectorProjector::center);
28 } else if (expandSector == 1) {
29 return std::make_tuple(numberOfSectors(), SectorProjector::rightOverlap);
30 }
31 const int regSector = expandSector / 2;
32 const int backConv = expandSector - 2*regSector;
33 switch (backConv) {
34 case 1: return std::make_tuple(regSector, SectorProjector::rightOverlap);
35 case 0: return std::make_tuple(regSector, SectorProjector::center);
36 case -1: return std::make_tuple(regSector, SectorProjector::leftOverlap);
37 default:
38 THROW_EXCEPTION("Cannot deduce the sector overlap "<<expandSector);
39 }
40 //all cases have been addressed
41 }
42
43}
44namespace MuonR4 {
45
46 ExpandedSector::ExpandedSector(const std::int8_t expSector):
47 m_sector{expSector}{}
49 const SectorProjector proj) {
50 m_sector = (2*msSector + Acts::toUnderlying(proj)) % nExpanded;
51 }
52
54 std::vector<int> sectors{};
55 sectorMap.getSectors(phi, sectors);
56 assert(!sectors.empty());
57 if (sectors.size() == 1) {
58 (*this) = ExpandedSector{static_cast<unsigned>(sectors[0]), SectorProjector::center};
59 } else {
60 const int dS = (sectors[1] - sectors[0]) % numberOfSectors();
61 assert(std::abs(dS) == 1);
62 (*this) = ExpandedSector{static_cast<unsigned>(sectors[0]),
63 static_cast<SectorProjector>(dS)};
64 }
65 }
66
68 return std::get<1>(msSectorAndProj(sector()));
69 }
70 unsigned ExpandedSector::msSector() const {
71 return std::get<0>(msSectorAndProj(sector()));
72 }
73 std::int8_t ExpandedSector::sector() const {
74 return m_sector;
75 }
77 const auto [msSec, proj] = msSectorAndProj(sector());
78 if (msSec == 1 && proj == SectorProjector::leftOverlap){
79 return numberOfSectors();
80 } else if (msSec == numberOfSectors() && proj == SectorProjector::rightOverlap) {
81 return 1;
82 }
83 return msSec + Acts::toUnderlying(proj);
84
85 }
86 bool ExpandedSector::operator<(const ExpandedSector& other) const {
87 return sector() < other.sector();
88 }
89 bool ExpandedSector::operator==(const ExpandedSector& other) const {
90 return sector() == other.sector();
91 }
92 bool ExpandedSector::operator!=(const ExpandedSector& other) const {
93 return sector() != other.sector();
94 }
95 double ExpandedSector::phi() const {
96 return sectorMap.sectorOverlapPhi(msSector(), adjacentMsSector());
97 }
99 return Acts::makeDirectionFromPhiTheta(phi(), 90._degree);
100 }
102 return Acts::makeDirectionFromPhiTheta(phi() + 90._degree, 90._degree);
103 }
105 const int dS = (other.sector() - sector()) % nExpanded;
106 return std::abs(dS) <= 1;
107 }
108
110 switch (proj){
111 using enum SectorProjector;
112 case leftOverlap: return "leftOverlap";
113 case center: return "center";
114 case rightOverlap: return "rightOverlap";
115 }
116 return "";
117 }
118 std::ostream& ExpandedSector::toString(std::ostream& ostr)const {
119 ostr<<"Expanded sector: "<<static_cast<int>(sector()) <<" -> "
120 <<projector()<<" of sector "<<msSector();
121 return ostr;
122 }
123}
double phi() const
Returns the phi angle of the expanded sector.
Amg::Vector3D normalDir() const
Returns the vector that is normal to the plane spanned by the expanded sector.
std::int8_t m_sector
the sector number stored
bool operator==(const ExpandedSector &other) const
Define the equal operator.
SectorProjector
Enumeration to select the sector projection of the regular MS sector.
@ rightOverlap
Project the segment onto the sector centre.
@ center
Project the segment onto the overlap with the previous sector.
ExpandedSector(const unsigned msSector, const SectorProjector proj)
Constructor of the expanded sector taking the regular MS sector number and the projector.
unsigned msSector() const
Returns the ms sector corresponding to the expanded sector.
std::int8_t sector() const
Returns the expanded sector number.
SectorProjector projector() const
Returns the projector in the corresponding MS sector.
bool isNeighbour(const ExpandedSector &other) const
bool operator!=(const ExpandedSector &other) const
Define the unequal operator.
unsigned adjacentMsSector() const
Returns the neighbouring msSector number constructed from the primary sector and the sector overlap p...
Amg::Vector3D radialDir() const
Returns the vector pointing radially along the sector plane.
static std::string toString(const SectorProjector proj)
Return the projector as a string.
bool operator<(const ExpandedSector &other) const
Define the ordering operator.
double sectorOverlapPhi(int sector1, int sector2) const
returns the phi position of the overlap between the two sectors (which have to be neighboring) in rad...
void getSectors(double phi, std::vector< int > &sectors) const
returns the main sector plus neighboring if the phi position is in an overlap region
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
constexpr unsigned numberOfSectors()
return total number of sectors
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10