ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Muon::TwinTubeMap Class Reference

#include <TwinTubeMap.h>

Inheritance diagram for Muon::TwinTubeMap:
Collaboration diagram for Muon::TwinTubeMap:

Classes

struct  HedgehogTray
 

Public Types

using HedgehogBoardPtr = HedgehogBoard::HedgehogBoardPtr
 

Public Member Functions

 TwinTubeMap (const IMuonIdHelperSvc *idHelperSvc)
 
bool isTwinTubeLayer (const Identifier &channelId) const
 Returns whether the multilayer is equipped with twin-tubes or not. More...
 
Identifier twinId (const Identifier &channelId) const
 Returns the Identifier of the mapped twin tube. More...
 
double hvDelayTime (const Identifier &channelId) const
 Returns the HV time delay for a given twin tube pair. More...
 
void setDefaultHVDelay (const double hvDelay)
 Sets the default HV delay. More...
 
StatusCode addHedgeHogBoard (const Identifier &detElId, const HedgehogBoardPtr &board, const uint16_t slot)
 Add a new hedgehog board with twin tube mapping. More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Types

using Storage = std::unordered_map< IdentifierHash, HedgehogTray >
 

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

const IMuonIdHelperSvcm_idHelperSvc {nullptr}
 
Storage m_twinTubesPerRE {}
 
double m_defaultHVDelay {0.}
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

Parameters
TheATLAS R3 MuonSpectrometer has 2 layers with twin tube readout. In Phase II, other multilayers may be upgraded to be twin-tube layers as well. The TwinTubeMap returns for a given Mdt Identifier the associated twin-tube Identifier, if there's any at all.

Definition at line 16 of file TwinTubeMap.h.

Member Typedef Documentation

◆ HedgehogBoardPtr

Definition at line 18 of file TwinTubeMap.h.

◆ Storage

using Muon::TwinTubeMap::Storage = std::unordered_map<IdentifierHash, HedgehogTray>
private

Definition at line 45 of file TwinTubeMap.h.

Constructor & Destructor Documentation

◆ TwinTubeMap()

Muon::TwinTubeMap::TwinTubeMap ( const IMuonIdHelperSvc idHelperSvc)

Definition at line 8 of file TwinTubeMap.cxx.

8  :
9  AthMessaging{"TwinTubeMap"},
10  m_idHelperSvc{idHelperSvc} {
11  }

Member Function Documentation

◆ addHedgeHogBoard()

StatusCode Muon::TwinTubeMap::addHedgeHogBoard ( const Identifier detElId,
const HedgehogBoardPtr board,
const uint16_t  slot 
)

Add a new hedgehog board with twin tube mapping.

Parameters
detElIdIdentifier of the multilayer
boardPointer to the HedgehogBoard instance encoding the mapping
slotInteger indicating which tube range is covered by the board

Check for compability

Check the board for consistency

Definition at line 44 of file TwinTubeMap.cxx.

44  {
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  }

◆ hvDelayTime()

double Muon::TwinTubeMap::hvDelayTime ( const Identifier channelId) const

Returns the HV time delay for a given twin tube pair.

If there's no dedicated delay safed for the pair, the default value is returned

Definition at line 88 of file TwinTubeMap.cxx.

88  {
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  }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ isTwinTubeLayer()

bool Muon::TwinTubeMap::isTwinTubeLayer ( const Identifier channelId) const

Returns whether the multilayer is equipped with twin-tubes or not.

Parameters
channelIdIdentifier of a tube in the multilayer

Definition at line 12 of file TwinTubeMap.cxx.

12  {
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  }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ setDefaultHVDelay()

void Muon::TwinTubeMap::setDefaultHVDelay ( const double  hvDelay)

Sets the default HV delay.

Definition at line 104 of file TwinTubeMap.cxx.

104  {
105  ATH_MSG_DEBUG("Set the default HV delay to "<<hvDelay<<" ns.");
106  m_defaultHVDelay = hvDelay;
107  }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

◆ twinId()

Identifier Muon::TwinTubeMap::twinId ( const Identifier channelId) const

Returns the Identifier of the mapped twin tube.

If the Identifier has no twin, then the Identifier is returned.

Parameters
channelIdIdentifier of the tube of interest

Definition at line 19 of file TwinTubeMap.cxx.

19  {
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  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_defaultHVDelay

double Muon::TwinTubeMap::m_defaultHVDelay {0.}
private

Definition at line 48 of file TwinTubeMap.h.

◆ m_idHelperSvc

const IMuonIdHelperSvc* Muon::TwinTubeMap::m_idHelperSvc {nullptr}
private

Definition at line 39 of file TwinTubeMap.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_twinTubesPerRE

Storage Muon::TwinTubeMap::m_twinTubesPerRE {}
private

Definition at line 46 of file TwinTubeMap.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
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
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
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
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
Muon::TwinTubeMap::twinId
Identifier twinId(const Identifier &channelId) const
Returns the Identifier of the mapped twin tube.
Definition: TwinTubeMap.cxx:19
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
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
Muon::IMuonIdHelperSvc::mdtIdHelper
virtual const MdtIdHelper & mdtIdHelper() const =0
access to MdtIdHelper
Muon::TwinTubeMap::m_twinTubesPerRE
Storage m_twinTubesPerRE
Definition: TwinTubeMap.h:46
Muon::IMuonIdHelperSvc::toString
virtual std::string toString(const Identifier &id) const =0
print all fields to string
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
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
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
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.
Identifier
Definition: IdentifierFieldParser.cxx:14
Muon::TwinTubeMap::m_idHelperSvc
const IMuonIdHelperSvc * m_idHelperSvc
Definition: TwinTubeMap.h:39