ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::ElementTable Class Reference

#include <ElementTable.h>

Collaboration diagram for Trk::ElementTable:

Public Member Functions

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

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")) {}
@ Material
std::vector< std::string > m_names
std::vector< Material * > m_table

◆ 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 }
float et(const xAOD::jFexSRJetRoI *j)

◆ ~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)); }
const Material * element(unsigned int Z) const
Get the material.
setBGCode setTAP setLVL2ErrorBits bool

◆ 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 }
void addElement(const Material &mat, const std::string &mname="")
Add material to the Table - if the elment is already filled ignore.

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