ATLAS Offline Software
Loading...
Searching...
No Matches
TwinTubeMap.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
5
6namespace Muon{
9 AthMessaging{"TwinTubeMap"},
10 m_idHelperSvc{idHelperSvc} {
11 }
12 bool TwinTubeMap::isTwinTubeLayer(const Identifier& channelId) const {
13 ATH_MSG_VERBOSE("Check whether "<<m_idHelperSvc->toStringDetEl(channelId)<<" is a twin tube layer");
14 const IdentifierHash detHash{m_idHelperSvc->detElementHash(channelId)};
15 Storage::const_iterator itr = m_twinTubesPerRE.find(detHash);
16 return itr != m_twinTubesPerRE.end();
17 }
18
19 Identifier TwinTubeMap::twinId(const Identifier& channelId) const {
20 ATH_MSG_VERBOSE("Fetch the twin tube id for "<<m_idHelperSvc->toString(channelId));
21 const IdentifierHash detHash{m_idHelperSvc->detElementHash(channelId)};
22 Storage::const_iterator twinItr = m_twinTubesPerRE.find(detHash);
23 if (twinItr != m_twinTubesPerRE.end()) {
24 const HedgehogTray& tray{twinItr->second};
25 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
26 TubeLayer in{};
27 in.tube = idHelper.tube(channelId);
28 in.layer = idHelper.tubeLayer(channelId);
29
30 const uint8_t boardNum = ( (in.tube-1) - (in.tube-1) % tray.nTubesPerLay) / tray.nTubesPerLay;
31 if (boardNum >= tray.cards.size() || !tray.cards[boardNum]) {
32 return channelId;
33 }
34 const TubeLayer out = tray.cards[boardNum]->twinPair(in);
35 if (in != out) {
36 const Identifier twinId = idHelper.channelID(channelId,idHelper.multilayer(channelId),
37 out.layer, out.tube + tray.nTubesPerLay*boardNum);
38 ATH_MSG_VERBOSE("The matching twin tube is "<<m_idHelperSvc->toString(twinId));
39 return twinId;
40 }
41 }
42 return channelId;
43 }
44 StatusCode TwinTubeMap::addHedgeHogBoard(const Identifier& detElId, const HedgehogBoardPtr& board, const uint16_t slot) {
45 ATH_MSG_DEBUG("Add new hedgehog board for "<<m_idHelperSvc->toStringDetEl(detElId)<<" "<<(*board)
46 <<", slot: "<<static_cast<int>(slot));
47 const IdentifierHash detHash{m_idHelperSvc->detElementHash(detElId)};
48 HedgehogTray& tray{m_twinTubesPerRE[detHash]};
50 if (!tray.nTubesPerLay) {
51 const int nTubLayers = m_idHelperSvc->mdtIdHelper().tubeLayerMax(detElId);
52 tray.nTubesPerLay = board->numTubesPerLayer();
53 if (nTubLayers != board->numTubeLayers()) {
54 ATH_MSG_FATAL("The new hedgehog board "<<(*board)<<" does not match in terms of tube layers"
55 <<nTubLayers<<" "<<m_idHelperSvc->toStringDetEl(detElId));
56 return StatusCode::FAILURE;
57 }
58 } else if (tray.nTubesPerLay != board->numTubesPerLayer()){
59 ATH_MSG_FATAL("Cannot at new hedgeog board in "<<m_idHelperSvc->toStringDetEl(detElId)
60 <<"Number of tubes per layer does not match. "<<static_cast<int>(tray.nTubesPerLay)<<" vs. "
61 <<static_cast<int>(board->numTubesPerLayer()));
62 return StatusCode::FAILURE;
63 }
64
66 if (board.use_count() < 3) {
67 for (uint8_t lay = 1 ; lay<= board->numTubeLayers(); ++lay) {
68 for (uint8_t tube = 1; tube<=board->numTubesPerLayer(); ++tube) {
69 TubeLayer in{};
70 in.layer = lay;
71 in.tube = tube;
72 const TubeLayer out = board->twinPair(in);
73 const TubeLayer twinTwin = board->twinPair(out);
74 if (twinTwin != in) {
75 ATH_MSG_FATAL("Back & forth mapping of "<<std::endl<<(*board)<<std::endl
76 <<" failed. Started with "<<in<<" via "<<out<<" & ended in "<<twinTwin);
77 return StatusCode::FAILURE;
78 }
79 }
80 }
81 }
82 if (tray.cards.size() <= slot) {
83 tray.cards.resize(slot +1);
84 }
85 tray.cards[slot] = board;
86 return StatusCode::SUCCESS;
87 }
88 double TwinTubeMap::hvDelayTime(const Identifier& channelId) const {
89 ATH_MSG_VERBOSE("Fetch the hv delay time for "<<m_idHelperSvc->toString(channelId));
90 const IdentifierHash detHash{m_idHelperSvc->detElementHash(channelId)};
91 Storage::const_iterator twinItr = m_twinTubesPerRE.find(detHash);
92 if (twinItr != m_twinTubesPerRE.end()) {
93 const HedgehogTray& tray{twinItr->second};
94 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
95 const uint8_t tube = idHelper.tube(channelId);
96 const uint8_t boardNum = (tube - tube % tray.nTubesPerLay) / tray.nTubesPerLay;
97 if (boardNum < tray.cards.size() && tray.cards[boardNum] && tray.cards[boardNum]->hasHVDelayTime()) {
98 ATH_MSG_VERBOSE("Specific delay time set to "<<tray.cards[boardNum]->hvDelayTime());
99 return tray.cards[boardNum]->hvDelayTime();
100 }
101 }
102 return m_defaultHVDelay;
103 }
104 void TwinTubeMap::setDefaultHVDelay(const double hvDelay) {
105 ATH_MSG_DEBUG("Set the default HV delay to "<<hvDelay<<" ns.");
106 m_defaultHVDelay = hvDelay;
107 }
108
109}
110
111
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
This is a "hash" representation of an Identifier.
int multilayer(const Identifier &id) const
Access to components of the ID.
int tube(const Identifier &id) const
int tubeLayer(const Identifier &id) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
const IMuonIdHelperSvc * m_idHelperSvc
Definition TwinTubeMap.h:39
double hvDelayTime(const Identifier &channelId) const
Returns the HV time delay for a given twin tube pair.
bool isTwinTubeLayer(const Identifier &channelId) const
Returns whether the multilayer is equipped with twin-tubes or not.
Identifier twinId(const Identifier &channelId) const
Returns the Identifier of the mapped twin tube.
StatusCode addHedgeHogBoard(const Identifier &detElId, const HedgehogBoardPtr &board, const uint16_t slot)
Add a new hedgehog board with twin tube mapping.
HedgehogBoard::HedgehogBoardPtr HedgehogBoardPtr
Definition TwinTubeMap.h:18
double m_defaultHVDelay
Definition TwinTubeMap.h:48
Storage m_twinTubesPerRE
Definition TwinTubeMap.h:46
void setDefaultHVDelay(const double hvDelay)
Sets the default HV delay.
TwinTubeMap(const IMuonIdHelperSvc *idHelperSvc)
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
HedgehogBoard::TubeLayer TubeLayer
Helper struct to return a tube & tube layer pair.
uint8_t tube
Tube number [1- 24/numTubeLayers()].
uint8_t layer
Layer number [1- numTubeLayers()].
std::vector< HedgehogBoardPtr > cards
Definition TwinTubeMap.h:43