ATLAS Offline Software
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
InDetDD::TRT_DetElementContainer Class Reference

Class to hold different TRT detector elements structures. More...

#include <TRT_DetElementContainer.h>

Inheritance diagram for InDetDD::TRT_DetElementContainer:
Collaboration diagram for InDetDD::TRT_DetElementContainer:

Public Member Functions

 TRT_DetElementContainer ()
 
 ~TRT_DetElementContainer ()
 
 TRT_DetElementContainer (const TRT_DetElementContainer &other)=delete
 
void operator= (const TRT_DetElementContainer &other)=delete
 
void setNumerology (const TRT_Numerology *mynum)
 
void addBarrelElement (TRT_BarrelElement *element)
 
void addEndcapElement (TRT_EndcapElement *element)
 
void manageBarrelElement (TRT_BarrelElement *barrel, const TRT_ID *idHelper)
 
void manageEndcapElement (TRT_EndcapElement *endcap, const TRT_ID *idHelper)
 
const TRT_DetElementCollectiongetElements () const
 
const TRT_NumerologygetTRTNumerology () const
 
const TRT_BarrelElementgetBarrelDetElement (unsigned int positive, unsigned int moduleIndex, unsigned int phiIndex, unsigned int strawLayerIndex) const
 
TRT_BarrelElementgetBarrelDetElement (unsigned int positive, unsigned int moduleIndex, unsigned int phiIndex, unsigned int strawLayerIndex)
 
const TRT_EndcapElementgetEndcapDetElement (unsigned int positive, unsigned int wheelIndex, unsigned int strawLayerIndex, unsigned int phiIndex) const
 
TRT_EndcapElementgetEndcapDetElement (unsigned int positive, unsigned int wheelIndex, unsigned int strawLayerIndex, unsigned int phiIndex)
 
void clear ()
 
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

enum  { NMODMAX =3 }
 
enum  { NWHEELMAX =18 }
 
enum  { NPHIMAX =32 }
 
enum  { NSTRAWLAYMAXBR =30 }
 
enum  { NSTRAWLAYMAXEC =16 }
 

Private Member Functions

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

Private Attributes

TRT_DetElementCollection m_trtcoll
 
const TRT_Numerologym_trtnum
 
TRT_BarrelElementm_baArray [2][NMODMAX][NPHIMAX][NSTRAWLAYMAXBR] {}
 
TRT_EndcapElementm_ecArray [2][NWHEELMAX][NSTRAWLAYMAXEC][NPHIMAX] {}
 
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

Class to hold different TRT detector elements structures.

Definition at line 24 of file TRT_DetElementContainer.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
NMODMAX 

Definition at line 77 of file TRT_DetElementContainer.h.

77 {NMODMAX=3};

◆ anonymous enum

anonymous enum
private
Enumerator
NWHEELMAX 

Definition at line 78 of file TRT_DetElementContainer.h.

78 {NWHEELMAX=18};

◆ anonymous enum

anonymous enum
private
Enumerator
NPHIMAX 

Definition at line 79 of file TRT_DetElementContainer.h.

79 {NPHIMAX=32};

◆ anonymous enum

anonymous enum
private
Enumerator
NSTRAWLAYMAXBR 

Definition at line 80 of file TRT_DetElementContainer.h.

80 {NSTRAWLAYMAXBR=30};

◆ anonymous enum

anonymous enum
private
Enumerator
NSTRAWLAYMAXEC 

Definition at line 81 of file TRT_DetElementContainer.h.

81 {NSTRAWLAYMAXEC=16};

Constructor & Destructor Documentation

◆ TRT_DetElementContainer() [1/2]

InDetDD::TRT_DetElementContainer::TRT_DetElementContainer ( )

Definition at line 11 of file TRT_DetElementContainer.cxx.

12  : AthMessaging("TRT_DetElementContainer")
13  , m_trtcoll()
14  , m_trtnum(nullptr)
15  {
16  clear();
17  }

◆ ~TRT_DetElementContainer()

InDetDD::TRT_DetElementContainer::~TRT_DetElementContainer ( )

Definition at line 19 of file TRT_DetElementContainer.cxx.

20  {
21  clear();
22  }

◆ TRT_DetElementContainer() [2/2]

InDetDD::TRT_DetElementContainer::TRT_DetElementContainer ( const TRT_DetElementContainer other)
delete

Member Function Documentation

◆ addBarrelElement()

void InDetDD::TRT_DetElementContainer::addBarrelElement ( TRT_BarrelElement element)

Definition at line 84 of file TRT_DetElementContainer.cxx.

85  {
86  // check if the element has already been added
87  if (std::find(m_trtcoll.begin(), m_trtcoll.end(), barrel) != m_trtcoll.end()) return;
88  // check if something was stored at the given indices
89  TRT_BarrelElement* arrayElement = m_baArray
90  [barrel->getCode().isPosZ()]
91  [barrel->getCode().getModuleIndex()]
92  [barrel->getCode().getPhiIndex()]
93  [barrel->getCode().getStrawLayerIndex()];
94  if (arrayElement != nullptr) {
95  m_trtcoll.erase(std::remove(m_trtcoll.begin(), m_trtcoll.end(), arrayElement));
96  delete arrayElement;
97  }
98  m_baArray[barrel->getCode().isPosZ()]
99  [barrel->getCode().getModuleIndex()]
100  [barrel->getCode().getPhiIndex()]
101  [barrel->getCode().getStrawLayerIndex()] = barrel;
102  m_trtcoll.push_back(barrel);
103  }

◆ addEndcapElement()

void InDetDD::TRT_DetElementContainer::addEndcapElement ( TRT_EndcapElement element)

Definition at line 105 of file TRT_DetElementContainer.cxx.

106  {
107  // check if the element has already been added
108  if (std::find(m_trtcoll.begin(), m_trtcoll.end(), endcap) != m_trtcoll.end()) return;
109  // check if something was stored at the given indices
110  TRT_EndcapElement* arrayElement = m_ecArray
111  [endcap->getCode().isPosZ()]
112  [endcap->getCode().getWheelIndex()]
113  [endcap->getCode().getStrawLayerIndex()]
114  [endcap->getCode().getPhiIndex()];
115  if (arrayElement != nullptr) {
116  m_trtcoll.erase(std::remove(m_trtcoll.begin(), m_trtcoll.end(), arrayElement));
117  delete arrayElement;
118  }
119  m_ecArray[endcap->getCode().isPosZ()]
120  [endcap->getCode().getWheelIndex()]
121  [endcap->getCode().getStrawLayerIndex()]
122  [endcap->getCode().getPhiIndex()] = endcap;
123  m_trtcoll.push_back(endcap);
124  }

◆ clear()

void InDetDD::TRT_DetElementContainer::clear ( )

Definition at line 208 of file TRT_DetElementContainer.cxx.

209  {
210  for (auto *p : m_trtcoll) {
211  delete p;
212  }
213  m_trtcoll.clear();
214  for (auto & ec : m_baArray) {
215  for (auto & mod : ec) {
216  for (auto & phi : mod) {
217  for (auto & sLay : phi) {
218  sLay = nullptr;
219  }
220  }
221  }
222  }
223  for (auto & ec : m_ecArray) {
224  for (auto & whe : ec) {
225  for (auto & sLay : whe) {
226  for(auto & phi : sLay) {
227  phi = nullptr;
228  }
229  }
230  }
231  }
232  }

◆ getBarrelDetElement() [1/2]

TRT_BarrelElement * InDetDD::TRT_DetElementContainer::getBarrelDetElement ( unsigned int  positive,
unsigned int  moduleIndex,
unsigned int  phiIndex,
unsigned int  strawLayerIndex 
)

Definition at line 50 of file TRT_DetElementContainer.cxx.

54  {
55  if ( positive >= 2 || moduleIndex >= NMODMAX
56  || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXBR) return nullptr;
57 
58  return m_baArray[positive][moduleIndex][phiIndex][strawLayerIndex];
59  }

◆ getBarrelDetElement() [2/2]

const TRT_BarrelElement * InDetDD::TRT_DetElementContainer::getBarrelDetElement ( unsigned int  positive,
unsigned int  moduleIndex,
unsigned int  phiIndex,
unsigned int  strawLayerIndex 
) const

Definition at line 39 of file TRT_DetElementContainer.cxx.

43  {
44  if ( positive >= 2 || moduleIndex >= NMODMAX
45  || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXBR) return nullptr;
46 
47  return m_baArray[positive][moduleIndex][phiIndex][strawLayerIndex];
48  }

◆ getElements()

const TRT_DetElementCollection * InDetDD::TRT_DetElementContainer::getElements ( ) const

Definition at line 29 of file TRT_DetElementContainer.cxx.

30  {
31  return &m_trtcoll;
32  }

◆ getEndcapDetElement() [1/2]

TRT_EndcapElement * InDetDD::TRT_DetElementContainer::getEndcapDetElement ( unsigned int  positive,
unsigned int  wheelIndex,
unsigned int  strawLayerIndex,
unsigned int  phiIndex 
)

Definition at line 73 of file TRT_DetElementContainer.cxx.

77  {
78  if ( positive >= 2 || wheelIndex >= NWHEELMAX
79  || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXEC) return nullptr;
80 
81  return m_ecArray[positive][wheelIndex][strawLayerIndex][phiIndex];
82  }

◆ getEndcapDetElement() [2/2]

const TRT_EndcapElement * InDetDD::TRT_DetElementContainer::getEndcapDetElement ( unsigned int  positive,
unsigned int  wheelIndex,
unsigned int  strawLayerIndex,
unsigned int  phiIndex 
) const

Definition at line 62 of file TRT_DetElementContainer.cxx.

66  {
67  if ( positive >= 2 || wheelIndex >= NWHEELMAX
68  || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXEC) return nullptr;
69 
70  return m_ecArray[positive][wheelIndex][strawLayerIndex][phiIndex];
71  }

◆ getTRTNumerology()

const TRT_Numerology * InDetDD::TRT_DetElementContainer::getTRTNumerology ( ) const

Definition at line 34 of file TRT_DetElementContainer.cxx.

35  {
36  return m_trtnum;
37  }

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

◆ manageBarrelElement()

void InDetDD::TRT_DetElementContainer::manageBarrelElement ( TRT_BarrelElement barrel,
const TRT_ID idHelper 
)

Definition at line 126 of file TRT_DetElementContainer.cxx.

127  {
128  if (m_baArray
129  [barrel->getCode().isPosZ()]
130  [barrel->getCode().getModuleIndex()]
131  [barrel->getCode().getPhiIndex()]
132  [barrel->getCode().getStrawLayerIndex()] ) {
133 
134  //Element already added - complain!
135  ATH_MSG_DEBUG("manageBarrelElement: Overriding existing element");
136  }
137 
138  m_baArray
139  [barrel->getCode().isPosZ()]
140  [barrel->getCode().getModuleIndex()]
141  [barrel->getCode().getPhiIndex()]
142  [barrel->getCode().getStrawLayerIndex()]
143  =barrel;
144 
145  // Add the barrel element to the hash vector:
146  if (idHelper) {
147  Identifier id = idHelper->layer_id(barrel->getCode().isPosZ() ? +1 : -1,
148  barrel->getCode().getPhiIndex(),
149  barrel->getCode().getModuleIndex(),
150  barrel->getCode().getStrawLayerIndex());
151  IdentifierHash hashId = idHelper->straw_layer_hash(id);
152  if (hashId.is_valid()) {
153  if (m_trtcoll.size() <= hashId) {
154  m_trtcoll.resize(static_cast<unsigned int>(hashId) + 1);
155  }
156  if (m_trtcoll[hashId]) {
157  //Element already added - complain!
158  ATH_MSG_DEBUG("manageBarrelElement: Overriding existing element for hashID");
159  }
160  m_trtcoll[hashId]=barrel;
161  }
162  else {
163  ATH_MSG_WARNING("manageBarrelElement: Invalid identifier");
164  }
165  }
166  }

◆ manageEndcapElement()

void InDetDD::TRT_DetElementContainer::manageEndcapElement ( TRT_EndcapElement endcap,
const TRT_ID idHelper 
)

Definition at line 168 of file TRT_DetElementContainer.cxx.

169  {
170  if (m_ecArray
171  [endcap->getCode().isPosZ()]
172  [endcap->getCode().getWheelIndex()]
173  [endcap->getCode().getStrawLayerIndex()]
174  [endcap->getCode().getPhiIndex()] ) {
175  //Element already added - complain!
176  ATH_MSG_WARNING("manageEndcapElement: Overriding existing element");
177  }
178 
179  m_ecArray
180  [endcap->getCode().isPosZ()]
181  [endcap->getCode().getWheelIndex()]
182  [endcap->getCode().getStrawLayerIndex()]
183  [endcap->getCode().getPhiIndex()]
184  =endcap;
185 
186  if (idHelper) {
187  Identifier id = idHelper->layer_id(endcap->getCode().isPosZ() ? +2 : -2,
188  endcap->getCode().getPhiIndex(),
189  endcap->getCode().getWheelIndex(),
190  endcap->getCode().getStrawLayerIndex());
191 
192  IdentifierHash hashId = idHelper->straw_layer_hash(id);
193  if (hashId.is_valid()) {
194  if (m_trtcoll.size() <= hashId) {
195  m_trtcoll.resize(static_cast<unsigned int>(hashId) + 1);
196  }
197  if (m_trtcoll[hashId]) {
198  //Element already added - complain!
199  ATH_MSG_DEBUG("manageEndcapElement: Overriding existing element for hashID");
200  }
201  m_trtcoll[hashId]=endcap;
202  } else {
203  ATH_MSG_WARNING("manageEndcapElement: Invalid identifier");
204  }
205  }
206  }

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

◆ operator=()

void InDetDD::TRT_DetElementContainer::operator= ( const TRT_DetElementContainer other)
delete

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

◆ setNumerology()

void InDetDD::TRT_DetElementContainer::setNumerology ( const TRT_Numerology mynum)

Definition at line 24 of file TRT_DetElementContainer.cxx.

25  {
26  m_trtnum=mynum;
27  }

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_baArray

TRT_BarrelElement* InDetDD::TRT_DetElementContainer::m_baArray[2][NMODMAX][NPHIMAX][NSTRAWLAYMAXBR] {}
private

Definition at line 83 of file TRT_DetElementContainer.h.

◆ m_ecArray

TRT_EndcapElement* InDetDD::TRT_DetElementContainer::m_ecArray[2][NWHEELMAX][NSTRAWLAYMAXEC][NPHIMAX] {}
private

Definition at line 84 of file TRT_DetElementContainer.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_trtcoll

TRT_DetElementCollection InDetDD::TRT_DetElementContainer::m_trtcoll
private

Definition at line 74 of file TRT_DetElementContainer.h.

◆ m_trtnum

const TRT_Numerology* InDetDD::TRT_DetElementContainer::m_trtnum
private

Definition at line 75 of file TRT_DetElementContainer.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
InDetDD::TRT_DetElementContainer::NSTRAWLAYMAXEC
@ NSTRAWLAYMAXEC
Definition: TRT_DetElementContainer.h:81
InDetDD::TRT_DetElementContainer::NPHIMAX
@ NPHIMAX
Definition: TRT_DetElementContainer.h:79
TRT_ID::layer_id
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
Definition: TRT_ID.h:500
InDetDD::TRT_DetElementContainer::m_ecArray
TRT_EndcapElement * m_ecArray[2][NWHEELMAX][NSTRAWLAYMAXEC][NPHIMAX]
Definition: TRT_DetElementContainer.h:84
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
InDetDD::TRT_DetElementContainer::NSTRAWLAYMAXBR
@ NSTRAWLAYMAXBR
Definition: TRT_DetElementContainer.h:80
ReadBchFromCool.barrel
barrel
Definition: ReadBchFromCool.py:405
InDetDD::TRT_DetElementContainer::NMODMAX
@ NMODMAX
Definition: TRT_DetElementContainer.h:77
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
InDetDD::TRT_DetElementContainer::clear
void clear()
Definition: TRT_DetElementContainer.cxx:208
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
IdentifierHash::is_valid
bool is_valid() const
Check if id is in a valid state.
InDetDD::TRT_DetElementContainer::m_trtcoll
TRT_DetElementCollection m_trtcoll
Definition: TRT_DetElementContainer.h:74
InDetDD::TRT_DetElementContainer::NWHEELMAX
@ NWHEELMAX
Definition: TRT_DetElementContainer.h:78
InDetDD::TRT_DetElementContainer::m_baArray
TRT_BarrelElement * m_baArray[2][NMODMAX][NPHIMAX][NSTRAWLAYMAXBR]
Definition: TRT_DetElementContainer.h:83
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
InDetDD::TRT_DetElementContainer::m_trtnum
const TRT_Numerology * m_trtnum
Definition: TRT_DetElementContainer.h:75
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
TRT_ID::straw_layer_hash
IdentifierHash straw_layer_hash(Identifier straw_layer_id) const
straw_layer hash from id - optimized
Definition: TRT_ID.h:750
Identifier
Definition: IdentifierFieldParser.cxx:14