ATLAS Offline Software
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 
6 namespace Muon{
9  AthMessaging{"TwinTubeMap"},
10  m_idHelperSvc{idHelperSvc} {
11  }
13  ATH_MSG_VERBOSE("Check whether "<<m_idHelperSvc->toStringDetEl(channelId)<<" is a twin tube layer");
15  Storage::const_iterator itr = m_twinTubesPerRE.find(detHash);
16  return itr != m_twinTubesPerRE.end();
17  }
18 
20  ATH_MSG_VERBOSE("Fetch the twin tube id for "<<m_idHelperSvc->toString(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  }
89  ATH_MSG_VERBOSE("Fetch the hv delay time for "<<m_idHelperSvc->toString(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 
Muon::TwinTubeMap::setDefaultHVDelay
void setDefaultHVDelay(const double hvDelay)
Sets the default HV delay.
Definition: TwinTubeMap.cxx:104
Muon::TwinTubeMap::hvDelayTime
double hvDelayTime(const Identifier &channelId) const
Returns the HV time delay for a given twin tube pair.
Definition: TwinTubeMap.cxx:88
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Muon::TwinTubeMap::HedgehogBoardPtr
HedgehogBoard::HedgehogBoardPtr HedgehogBoardPtr
Definition: TwinTubeMap.h:18
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
Muon::IMuonIdHelperSvc::toStringDetEl
virtual std::string toStringDetEl(const Identifier &id) const =0
print all fields up to detector element to string
Muon::TwinTubeMap::addHedgeHogBoard
StatusCode addHedgeHogBoard(const Identifier &detElId, const HedgehogBoardPtr &board, const uint16_t slot)
Add a new hedgehog board with twin tube mapping.
Definition: TwinTubeMap.cxx:44
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
Muon::TubeLayer
HedgehogBoard::TubeLayer TubeLayer
Definition: HedgehogBoard.cxx:27
Muon::TwinTubeMap::m_defaultHVDelay
double m_defaultHVDelay
Definition: TwinTubeMap.h:48
Muon::HedgehogBoard::TubeLayer::layer
uint8_t layer
Layer number [1- numTubeLayers()].
Definition: HedgehogBoard.h:61
MdtIdHelper::tubeLayerMax
static int tubeLayerMax()
Definition: MdtIdHelper.cxx:766
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
Muon::TwinTubeMap::twinId
Identifier twinId(const Identifier &channelId) const
Returns the Identifier of the mapped twin tube.
Definition: TwinTubeMap.cxx:19
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MdtIdHelper
Definition: MdtIdHelper.h:61
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
Muon::IMuonIdHelperSvc::mdtIdHelper
virtual const MdtIdHelper & mdtIdHelper() const =0
access to MdtIdHelper
Muon::TwinTubeMap::m_twinTubesPerRE
Storage m_twinTubesPerRE
Definition: TwinTubeMap.h:46
Muon::TwinTubeMap::TwinTubeMap
TwinTubeMap(const IMuonIdHelperSvc *idHelperSvc)
Definition: TwinTubeMap.cxx:8
Muon::TwinTubeMap::HedgehogTray
Definition: TwinTubeMap.h:41
Muon::IMuonIdHelperSvc::toString
virtual std::string toString(const Identifier &id) const =0
print all fields to string
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
Muon::IMuonIdHelperSvc
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Definition: IMuonIdHelperSvc.h:27
Muon::HedgehogBoard::TubeLayer
Helper struct to return a tube & tube layer pair.
Definition: HedgehogBoard.h:57
TwinTubeMap.h
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
Muon::TwinTubeMap::isTwinTubeLayer
bool isTwinTubeLayer(const Identifier &channelId) const
Returns whether the multilayer is equipped with twin-tubes or not.
Definition: TwinTubeMap.cxx:12
calibdata.tube
tube
Definition: calibdata.py:31
Muon::HedgehogBoard::TubeLayer::tube
uint8_t tube
Tube number [1- 24/numTubeLayers()].
Definition: HedgehogBoard.h:59
Muon::IMuonIdHelperSvc::detElementHash
virtual IdentifierHash detElementHash(const Identifier &id) const =0
Returns the detector element hash associated to an Identifier.
Muon::TwinTubeMap::m_idHelperSvc
const IMuonIdHelperSvc * m_idHelperSvc
Definition: TwinTubeMap.h:39
Identifier
Definition: IdentifierFieldParser.cxx:14