5#include "Identifier/Identifier.h"
6#include <GeoModelKernel/throwExcept.h>
10#include <Acts/Surfaces/PlaneSurface.hpp>
11#include <Acts/Geometry/TrapezoidVolumeBounds.hpp>
12#include <Acts/Geometry/Volume.hpp>
25 std::vector<unsigned int>
range (
unsigned min,
unsigned max) {
27 std::vector<unsigned int>
v(
max -
min);
28 std::iota(
v.begin(),
v.end(),
min);
36using BoundEnums = Acts::TrapezoidVolumeBounds::BoundValues;
40 for (
auto & chamber :
m_args.chambers) {
41 chamber->setParent(this);
46 return m_args.id < other.m_args.id;
49 return m_args.chambers.front()->stationEta() > 0 ? 1 : -1;
58 return std::format(
"id: {:3d}, {:} {:}-side sector: {:2},",
m_args.id,
85 toReturn.insert(toReturn.end(), ch->readoutEles().begin(), ch->readoutEles().end());
90 return m_args.detectorLocs;
97 ostr<<
"halfY: "<<
halfY(*args.bounds)<<
" [mm], ";
98 ostr<<
"halfZ: "<<
halfZ(*args.bounds)<<
" [mm], ";
99 ostr<<
"************************************************************************"<<std::endl;
101 ostr<<
" --- "<<(*ch)<<std::endl;
106 ostr<<
"MS sector "<<chamber.identString()<<
" "<<chamber.parameters();
114std::unordered_map<const MuonReadoutElement*, std::vector<unsigned int>>
117 std::unordered_map<const MuonReadoutElement*, std::vector<unsigned int>> cache{};
128 auto nextLayer = [
this, &cache, &reEleSorted](
const Identifier& lastId) ->
129 std::pair<const MuonReadoutElement*, const Identifier> {
137 if (cache.count(reEle))
continue;
144 if (logicalId == lastId){
145 return std::make_pair(reEle, logicalId);
155 return std::make_pair(nextReEle, nextId);
158 unsigned int layCounter {0}, nIter {0};
160 unsigned int deltaN {0};
161 while(++nIter <= reEleSorted.size()){
163 auto [nextReEle, nextId] = nextLayer(lastId);
165 THROW_EXCEPTION(
"Failed to retrieve next reEle in fillDetLayIdCache()");
170 if (nextId != lastId) {
171 layCounter += deltaN;
176 deltaN = std::max(deltaN, nLayers);
179 cache[nextReEle] = range(layCounter, layCounter + nLayers);
182 " Add logicLay: " <<
idHelperSvc()->toStringGasGap(nextId) <<
" nInserted, layCounter " << cache.at(nextReEle).size() <<
" ," << layCounter);
193 mdtRele->stationPhi(),
194 mdtRele->multilayer(),
200 rpcRele->stationPhi(),
201 rpcRele->doubletR(), 1, 1,
207 tgcRele->stationPhi(),
213 stgcRele->stationPhi(),
214 stgcRele->multilayer(),
220 mmRele->stationPhi(),
221 mmRele->multilayer(),
225 THROW_EXCEPTION(
"Unexpected Readout Element Type in computeDetLayerId()");
253 THROW_EXCEPTION(
"Unexpected Readout Element Type in nLayerPerReadout()");
Acts::GeometryContext context() const
virtual DetectorType detectorType() const =0
Returns the detector element type.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
std::vector< const MuonReadoutElement * > ReadoutSet
Define the list of read out elements of the chamber.
unsigned int numLayers() const
Returns the number of tube layer.
unsigned int nGasGaps() const
Returns the number of gas gaps.
The MuonReadoutElement is an abstract class representing the geometry representing the muon detector.
Amg::Vector3D center(const ActsTrk::GeometryContext &ctx) const
Returns the detector center (Which is the same as the detector center of the first measurement layer)
Identifier identify() const override final
Return the athena identifier.
unsigned nGasGaps() const
Returns the number of gasgaps described by this ReadOutElement (usally 2 or 3)
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
bool operator<(const SpectrometerSector &other) const
int8_t side() const
Returns the side of the MS-sector 1 -> A side ; -1 -> C side.
const std::vector< unsigned int > & logicalLayerIdx(const MuonReadoutElement *reEle) const
Returns the logic layer numbering of a given Readout Element.
double halfZ() const
Thickness of the chamber in the z-direction.
unsigned int nLayerPerReadout(const MuonReadoutElement *rele) const
Helper function giving the number of measurement layers in a given readout ele.
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Returns the IdHelpeSvc.
bool barrel() const
Returns whether the sector is placed in the barrel.
Amg::Transform3D globalToLocalTrans(const ActsTrk::GeometryContext &gctx) const
Returns the global -> local transformation from the ATLAS global.
const Amg::Transform3D & localToGlobalTrans(const ActsTrk::GeometryContext &gctx) const
Returns the local -> global tarnsformation from the sector.
Chamber::ReadoutSet readoutEles() const
Returns the list of all associated readout elements.
std::unordered_map< const MuonReadoutElement *, std::vector< unsigned int > > fillDetLayIdCache() const
Function filling the map mapping the readout elements to layer numbers.
SpectrometerSector(defineArgs &&args)
Standard constructor taking the defining parameters.
Identifier computeDetLayerId(const MuonReadoutElement *rele) const
Helper function calculating the logic layer Id and the physical layer id.
std::string identString() const
Returns a string encoding the chamber index & the sector of the MS sector.
double halfY() const
Extend of the chamber in the y-direction.
const Acts::PlaneSurface & surface() const
Returns the associated surface.
const ChamberSet & chambers() const
Returns the associated chambers with this sector.
GeoModel::TransientConstSharedPtr< Chamber > ChamberPtr
double halfXLong() const
Long-extend of the chamber in the x-direction at positive Y.
int sector() const
Returns the sector of the MS-sector.
std::shared_ptr< Acts::VolumeBounds > bounds() const
Returns the volume bounds.
std::shared_ptr< Acts::Volume > boundingVolume(const ActsTrk::GeometryContext &gctx) const
Returns the Acts::Volume representation of the sector.
const std::unordered_map< const MuonReadoutElement *, std::vector< unsigned int > > m_detLayIdCache
Map mapping each Readout Element to the layer numbering in the sector frame.
const std::vector< chamberLocation > & chamberLocations() const
returns the list of all MDT chambers in the sector for fast navigation
double halfXShort() const
Short extend of the chamber in the x-direction at negative Y.
int stationPhi() const
: Returns the station phi of the sector
const defineArgs & parameters() const
Returns the reference to the defining parameters of the sector.
Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index scheme.
std::vector< ChamberPtr > ChamberSet
unsigned nGasGaps() const
Returns the number of gasgaps described by this ReadOutElement (usally 2 or 3)
unsigned int numLayers() const
Returns the number of gas gap layers.
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
virtual const MmIdHelper & mmIdHelper() const =0
access to CscIdHelper
virtual const RpcIdHelper & rpcIdHelper() const =0
access to RpcIdHelper
virtual const sTgcIdHelper & stgcIdHelper() const =0
access to TgcIdHelper
virtual const TgcIdHelper & tgcIdHelper() const =0
access to TgcIdHelper
virtual const MdtIdHelper & mdtIdHelper() const =0
access to MdtIdHelper
Identifier channelID(int stationName, int stationEta, int stationPhi, int doubletR, int doubletZ, int doubletPhi, int gasGap, int measuresPhi, int strip) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int gasGap, int isStrip, int channel) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
@ Mm
Maybe not needed in the migration.
@ Tgc
Resitive Plate Chambers.
@ Rpc
Monitored Drift Tubes.
Eigen::Affine3d Transform3D
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Acts::TrapezoidVolumeBounds::BoundValues BoundEnums
double halfY(const Acts::VolumeBounds &bounds)
Returns the half-Y length for the parsed volume bounds (Trapezoid/ Cuboid)
std::ostream & operator<<(std::ostream &ostr, const Chamber::defineArgs &args)
SpectrometerSector::ChamberSet ChamberSet
double halfZ(const Acts::VolumeBounds &bounds)
Returns the half-Z length for the parsed volume bounds (Trapezoid/ Cuboid)
double halfXhighY(const Acts::VolumeBounds &bounds)
Returns the half-Y length @ posiive Y for the parsed volume bounds (Trapezoid/ Cuboid)
double halfXlowY(const Acts::VolumeBounds &bounds)
Returns the half-X length @ negative Y for the parsed volume bounds (Trapezoid/ Cuboid)
const std::string & chName(ChIndex index)
convert ChIndex into a string
ChIndex
enum to classify the different chamber layers in the muon spectrometer
#define THROW_EXCEPTION(MESSAGE)