ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
Trk::ElementTable Class Reference

#include <ElementTable.h>

Collaboration diagram for Trk::ElementTable:

Public Member Functions

 ElementTable ()
 Empty constructor. More...
 
 ElementTable (const ElementTable &et)
 Empty constructor. More...
 
 ~ElementTable ()
 Destructor. More...
 
ElementTableoperator= (const ElementTable &et)
 Assignment operator. More...
 
ElementTableoperator+= (const ElementTable &et)
 Adding two tables : add table entries from another table. More...
 
const Materialelement (unsigned int Z) const
 Get the material. More...
 
const std::string & elementName (unsigned int Z) const
 Get the element name. More...
 
void addElement (const Material &mat, const std::string &mname="")
 Add material to the Table - if the elment is already filled ignore. More...
 
void addElement (std::unique_ptr< Material > mat, const std::string &mname)
 Version that takes ownership of a pointer. More...
 
bool contains (unsigned int Z) const
 quick check More...
 
size_t size () const
 Print the table size. More...
 

Private Attributes

std::vector< Material * > m_table
 
std::vector< std::string > m_names
 

Detailed Description

Definition at line 24 of file ElementTable.h.

Constructor & Destructor Documentation

◆ ElementTable() [1/2]

Trk::ElementTable::ElementTable ( )
inline

Empty constructor.

Definition at line 27 of file ElementTable.h.

28  : m_table(static_cast<size_t>(UCHAR_MAX), (Material*)nullptr),
29  m_names(static_cast<size_t>(UCHAR_MAX), std::string("None")) {}

◆ ElementTable() [2/2]

Trk::ElementTable::ElementTable ( const ElementTable et)
inline

Empty constructor.

Definition at line 32 of file ElementTable.h.

33  : m_table(static_cast<size_t>(UCHAR_MAX), (Material*)nullptr),
34  m_names(et.m_names) {
35  for (size_t im = 0; im < et.m_table.size(); ++im) {
36  if (et.m_table[im]) m_table[im] = new Trk::Material(*et.m_table[im]);
37  }
38  }

◆ ~ElementTable()

Trk::ElementTable::~ElementTable ( )

Destructor.

Definition at line 15 of file ElementTable.cxx.

15  {
16  auto elIter = m_table.begin();
17  for (; elIter != m_table.end(); delete (*elIter), ++elIter)
18  ;
19 }

Member Function Documentation

◆ addElement() [1/2]

void Trk::ElementTable::addElement ( const Material mat,
const std::string &  mname = "" 
)
inline

Add material to the Table - if the elment is already filled ignore.

Definition at line 75 of file ElementTable.h.

75  {
76  unsigned int Zint = (unsigned int)mat.Z;
77  if (!m_table[Zint]) {
78  m_table[Zint] = new Material(mat);
79  m_names[Zint] = mname;
80  }
81  }

◆ addElement() [2/2]

void Trk::ElementTable::addElement ( std::unique_ptr< Material mat,
const std::string &  mname 
)
inline

Version that takes ownership of a pointer.

Definition at line 84 of file ElementTable.h.

84  {
85  unsigned int Zint = (unsigned int)mat->Z;
86  if (!m_table[Zint]) {
87  m_table[Zint] = mat.release();
88  m_names[Zint] = mname;
89  }
90  }

◆ contains()

bool Trk::ElementTable::contains ( unsigned int  Z) const
inline

quick check

Definition at line 93 of file ElementTable.h.

93 { return bool(element(Z)); }

◆ element()

const Material* Trk::ElementTable::element ( unsigned int  Z) const
inline

Get the material.

  • it can be 0 - if the entry in the table is not filled

Definition at line 71 of file ElementTable.h.

71 { return m_table[Z]; }

◆ elementName()

const std::string& Trk::ElementTable::elementName ( unsigned int  Z) const
inline

Get the element name.

Definition at line 73 of file ElementTable.h.

73 { return m_names[Z]; }

◆ operator+=()

ElementTable& Trk::ElementTable::operator+= ( const ElementTable et)
inline

Adding two tables : add table entries from another table.

Definition at line 60 of file ElementTable.h.

60  {
61  for (size_t ie = 0; ie < size_t(UCHAR_MAX); ++ie) {
62  if (et.element(ie)) {
63  addElement(*et.element(ie), et.elementName(ie));
64  }
65  }
66  return (*this);
67  }

◆ operator=()

ElementTable& Trk::ElementTable::operator= ( const ElementTable et)
inline

Assignment operator.

Definition at line 44 of file ElementTable.h.

44  {
45  if (this != &et) {
46  // clear first, then copy
47  auto elIter = m_table.begin();
48  for (; elIter != m_table.end(); delete (*elIter), ++elIter)
49  ;
50  m_names = et.m_names;
51  for (size_t im = 0; im < et.m_table.size(); ++im) {
52  m_table[im] = nullptr;
53  if (et.m_table[im]) m_table[im] = new Trk::Material(*et.m_table[im]);
54  }
55  }
56  return (*this);
57  }

◆ size()

size_t Trk::ElementTable::size ( ) const
inline

Print the table size.

Definition at line 96 of file ElementTable.h.

96 { return m_table.size(); }

Member Data Documentation

◆ m_names

std::vector<std::string> Trk::ElementTable::m_names
private

Definition at line 100 of file ElementTable.h.

◆ m_table

std::vector<Material*> Trk::ElementTable::m_table
private

Definition at line 99 of file ElementTable.h.


The documentation for this class was generated from the following files:
et
Extra patterns decribing particle interation process.
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Trk::ElementTable::m_table
std::vector< Material * > m_table
Definition: ElementTable.h:99
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:55
Trk::ElementTable::m_names
std::vector< std::string > m_names
Definition: ElementTable.h:100
python.atlas_oh.im
im
Definition: atlas_oh.py:167
Trk::ElementTable::element
const Material * element(unsigned int Z) const
Get the material.
Definition: ElementTable.h:71
PlotCalibFromCool.ie
ie
Definition: PlotCalibFromCool.py:420
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
Material
@ Material
Definition: MaterialTypes.h:8
Trk::ElementTable::addElement
void addElement(const Material &mat, const std::string &mname="")
Add material to the Table - if the elment is already filled ignore.
Definition: ElementTable.h:75