 |
ATLAS Offline Software
|
Go to the documentation of this file.
21 template <
class ReadOutEleStoreType,
22 class ReadoutEleReturnType>
void insert(
const ElementStorage_t<ReadOutEleStoreType>& eleStore,
23 std::vector<ReadoutEleReturnType>& returnVec) {
24 returnVec.reserve(returnVec.capacity() + eleStore.size());
25 for (
const auto& ele : eleStore) {
26 if (ele) returnVec.push_back(ele.get());
29 template <
class ReadOutEleType,
30 class ReadOutEleReturnType>
void insert(std::vector<ReadOutEleType*>&& eleStore,
31 std::vector<ReadOutEleReturnType*>& returnVec) {
32 returnVec.insert(returnVec.end(),
33 std::make_move_iterator(eleStore.begin()),
34 std::make_move_iterator(eleStore.end()));
36 #ifndef SIMULATIONBASE
37 inline unsigned msSectorIdHash(
const ChIndex chIndex,
const int sector,
const int side) {
38 constexpr
unsigned chIdxMax =
static_cast<unsigned>(ChIndex::ChIndexMax);
40 const unsigned stationPhi = (sector + sector%2) / 2 - 1;
46 #define WRITE_SETTER(ELE_TYPE, SETTER, STORAGE_VEC) \
47 StatusCode MuonDetectorManager::SETTER(ElementPtr_t<ELE_TYPE> element) { \
49 ATH_MSG_FATAL(__func__ << " -- nullptr is given."); \
50 return StatusCode::FAILURE; \
52 ATH_CHECK(element->initElement()); \
53 element->releaseUnAlignedTrfs(); \
54 size_t idx = static_cast<size_t>(element->identHash()); \
55 if (idx >= STORAGE_VEC.size()) { \
56 STORAGE_VEC.resize(idx + 1); \
58 std::unique_ptr<ELE_TYPE>& new_element = STORAGE_VEC[idx]; \
60 ATH_MSG_FATAL("The detector element " \
61 << m_idHelperSvc->toStringDetEl(element->identify()) \
62 << " has already been added before " \
63 <<m_idHelperSvc->toStringDetEl(new_element->identify())); \
64 return StatusCode::FAILURE; \
66 linkElements(STORAGE_VEC, element.get()); \
67 new_element = std::move(element); \
68 return StatusCode::SUCCESS; \
70 #define ADD_DETECTOR(ELE_TYPE, STORAGE_VEC) \
71 WRITE_SETTER(ELE_TYPE, add##ELE_TYPE, STORAGE_VEC) \
73 std::vector<const ELE_TYPE*> MuonDetectorManager::getAll##ELE_TYPE##s() const { \
74 std::vector<const ELE_TYPE*> allElements{}; \
75 insert(STORAGE_VEC, allElements); \
79 std::vector<ELE_TYPE*> MuonDetectorManager::getAll##ELE_TYPE##s() { \
80 std::vector<ELE_TYPE*> allElements{}; \
81 insert(STORAGE_VEC, allElements); \
84 #define WRITE_ALLGETTER(TYPE) \
85 std::vector<TYPE MuonReadoutElement*> MuonDetectorManager::getAllReadoutElements() TYPE { \
86 std::vector<TYPE MuonReadoutElement*> allEles{}; \
87 insert(getAllMdtReadoutElements(), allEles); \
88 insert(getAllRpcReadoutElements(), allEles); \
89 insert(getAllTgcReadoutElements(), allEles); \
90 insert(getAllMmReadoutElements(), allEles); \
91 insert(getAllsTgcReadoutElements(), allEles); \
94 TYPE MuonReadoutElement* MuonDetectorManager::getReadoutElement(const Identifier& id) TYPE { \
95 switch(m_idHelperSvc->technologyIndex(id)) { \
96 using enum Muon::MuonStationIndex::TechnologyIndex; \
98 return getMdtReadoutElement(id); \
100 return getRpcReadoutElement(id); \
102 return getTgcReadoutElement(id); \
104 return getsTgcReadoutElement(id); \
106 return getMmReadoutElement(id); \
108 ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<" Not a muon detector element " \
109 <<m_idHelperSvc->toString(id)); \
117 #ifndef SIMULATIONBASE
129 #ifndef SIMULATIONBASE
135 if (!m_idHelperSvc.retrieve().isSuccess()) {
136 THROW_EXCEPTION(__func__<<
"() -- Failed to retrieve the Identifier service");
150 return m_treeTopVector.size();
163 std::vector<ActsTrk::DetectorType> types{};
172 #ifndef SIMULATIONBASE
174 const unsigned hash = msSectorIdHash(chSector->chamberIndex(), chSector->sector(), chSector->side());
176 const auto [element, isNew] =
m_envelopesById.insert(std::make_pair(
hash, chSector.get()));
178 ATH_MSG_DEBUG(
"Conflicting hash: "<<
hash<<
", inserted: "<<element->second->chambers().size()
179 <<
", "<<chSector->chambers().size());
180 if (element->second->chambers().size() < chSector->chambers().size()) {
181 element->second = chSector.get();
187 const unsigned sector,
188 const int side)
const {
189 const unsigned hash = msSectorIdHash(chIdx, sector,
side);
195 <<
", sector: "<<sector<<
", side: "<<
side);
211 sectors.insert(
ms.get());
219 std::ranges::for_each(
ms->chambers(),
221 chambers.insert(ch.get());
229 MuonDetectorType* reEle) {
235 const int complMl = refEle->
multilayer() == 2 ? 1 : idHelper.multilayerMax(refEle->
identify());
237 const unsigned mlHash =
static_cast<unsigned>(
m_idHelperSvc->detElementHash(complMlId));
242 detStore[mlHash]->setComplementaryReadoutEle(refEle);
251 #undef WRITE_ALLGETTER
static const std::string & chName(ChIndex index)
convert ChIndex into a string
constexpr uint8_t stationPhi
station Phi 1 to 8
The TransientConstSharedPtr allows non-const access if the pointer itself is non-const but in the con...
std::vector< ActsTrk::DetectorType > getDetectorTypes() const
Returns a list of all detector types.
MuonDetectorManager::MuonSectorSet MuonSectorSet
const Chamber * chamber() const
Returns the pointer to the chamber enclosing this readout element.
ElementStorage_t< sTgcReadoutElement > m_sTgcEles
const SpectrometerSector * msSector() const
Returns the pointer to the envelope volume enclosing all chambers in the sector.
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
std::set< const SpectrometerSector *, MSEnvelopeSorter > MuonSectorSet
void linkElements(ElementStorage_t< MuonDetectorType > &allStore, MuonDetectorType *readOutEle)
Method that connects the same elements from the station with the parsed readout Element and vice vers...
@ Tgc
Resitive Plate Chambers.
std::unique_ptr< MuonDetectorType > ElementPtr_t
: Abrivation of the smart pointer holding the readout element
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
EnvelopeMap_t m_envelopesById
#define ATH_MSG_VERBOSE(x)
static unsigned int numberOfSectors()
return total number of sectors
unsigned int multilayer() const
Returns the multi layer of the MdtReadoutElement.
const Chamber * getChamber(const Identifier &channelId) const
Retrieves the chamber enclosing the channel's readout element.
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
@ Mm
Maybe not needed in the migration.
std::vector< ElementPtr_t< MuonDetectorType > > ElementStorage_t
: Abbrivation of the container holding all readout elements of a technology.
#define WRITE_ALLGETTER(TYPE)
std::set< const Chamber *, MSEnvelopeSorter > MuonChamberSet
Class to provide easy MsgStream access and capabilities.
ADD_DETECTOR(MdtReadoutElement, m_mdtEles)
MuonDetectorManager::MuonChamberSet MuonChamberSet
PVConstLink getTreeTop(unsigned int i) const override final
Returns the i-the tree top GeoModel volume.
std::vector< PVConstLink > m_treeTopVector
ElementStorage_t< SpectrometerSector > m_secEnvelopes
std::string to_string(const DetectorType &type)
void addTreeTop(PVConstLink pv)
Adds a new GeoModelVolume with its children as a new top node of the muon system.
Identifier identify() const override final
Return the athena identifier.
#define THROW_EXCEPTION(MESSAGE)
MuonSectorSet getAllSectors() const
: Returns all MuonChambers associated with the readout geometry
ElementStorage_t< MmReadoutElement > m_mmEles
#define ATH_MSG_WARNING(x)
void setComplementaryReadoutEle(const MdtReadoutElement *other)
Set the link to the second readout element inside the muon station.
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Returns a pointer to the central MuonIdHelperSvc.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
@ Rpc
Monitored Drift Tubes.
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
ElementStorage_t< MdtReadoutElement > m_mdtEles
ChIndex
enum to classify the different chamber layers in the muon spectrometer
void addSpectrometerSector(ElementPtr_t< SpectrometerSector > &&chSector)
Add a spectrometer enevelope object to the manager.
bool operator()(const SpectrometerSector *a, const SpectrometerSector *b) const
MuonChamberSet getAllChambers() const
ElementStorage_t< RpcReadoutElement > m_rpcEles
ElementStorage_t< TgcReadoutElement > m_tgcEles
const SpectrometerSector * getSectorEnvelope(const Identifier &channelId) const
Retrieves the spectrometer envelope enclosing the channel's readout element.
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Returns a generic Muon readout element.