ATLAS Offline Software
Loading...
Searching...
No Matches
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.
Identifier twinId (const Identifier &channelId) const
 Returns the Identifier of the mapped twin tube.
double hvDelayTime (const Identifier &channelId) const
 Returns the HV time delay for a given twin tube pair.
void setDefaultHVDelay (const double hvDelay)
 Sets the default HV delay.
StatusCode addHedgeHogBoard (const Identifier &detElId, const HedgehogBoardPtr &board, const uint16_t slot)
 Add a new hedgehog board with twin tube mapping.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Types

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

Private Member Functions

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

Private Attributes

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

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

◆ 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 }
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
const IMuonIdHelperSvc * m_idHelperSvc
Definition TwinTubeMap.h:39

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 }
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
Storage m_twinTubesPerRE
Definition TwinTubeMap.h:46
HedgehogBoard::TubeLayer TubeLayer
uint8_t layer
Layer number [1- numTubeLayers()].
std::vector< HedgehogBoardPtr > cards
Definition TwinTubeMap.h:43

◆ 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));
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 }
#define ATH_MSG_VERBOSE(x)
int tube(const Identifier &id) const
double m_defaultHVDelay
Definition TwinTubeMap.h:48

◆ 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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ 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");
14 const IdentifierHash detHash{m_idHelperSvc->detElementHash(channelId)};
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 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ 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 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ 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_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ 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));
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 }
int multilayer(const Identifier &id) const
Access to components of the ID.
int tubeLayer(const Identifier &id) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Identifier twinId(const Identifier &channelId) const
Returns the Identifier of the mapped twin tube.
uint8_t tube
Tube number [1- 24/numTubeLayers()].

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.

48{0.};

◆ m_idHelperSvc

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

Definition at line 39 of file TwinTubeMap.h.

39{nullptr};

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ 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.

46{};

The documentation for this class was generated from the following files: