ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCalib::IndexSet Class Reference

#include <IndexSet.h>

Collaboration diagram for MuonCalib::IndexSet:

Public Member Functions

 IndexSet ()
 default constructor: the number of indices is set to 0
 IndexSet (const unsigned int &r_nb_indices)
 constructor: the number of indices is set to r_nb_indices
 IndexSet (const unsigned int &r_nb_indices, const std::vector< int > &r_index)
 constructor: the number of indices is set to r_nb_indices, the vector r_index contains the indices
unsigned int size () const
 get the number of indices
void resize (const unsigned int &r_size)
 resize the index set to r_size; the index store is preserved as far as possible
int operator[] (const unsigned int &r_k)
 :::::::::::::::::::::::
int operator[] (const unsigned int &r_k) const
 access to the indices stored in the class, 0 <= r_k < size(); WARNING: no test on the index is performed
void sort ()
 sort the indices in ascending order
bool operator== (const IndexSet &r_index_set) const
bool operator!= (const IndexSet &r_index_set) const
 comparison of two index sets; two index sets are considered equal if they are of the same size and their indices are the same at the same position [.

Private Member Functions

void init ()
void init (const unsigned int &r_nb_indices)
void init (const unsigned int &r_nb_indices, const std::vector< int > &r_index)

Private Attributes

unsigned int m_nb_indices
std::vector< int > m_index

Detailed Description

Definition at line 40 of file IndexSet.h.

Constructor & Destructor Documentation

◆ IndexSet() [1/3]

MuonCalib::IndexSet::IndexSet ( )
inline

default constructor: the number of indices is set to 0

Definition at line 57 of file IndexSet.h.

◆ IndexSet() [2/3]

MuonCalib::IndexSet::IndexSet ( const unsigned int & r_nb_indices)
inline

constructor: the number of indices is set to r_nb_indices

Definition at line 60 of file IndexSet.h.

◆ IndexSet() [3/3]

MuonCalib::IndexSet::IndexSet ( const unsigned int & r_nb_indices,
const std::vector< int > & r_index )
inline

constructor: the number of indices is set to r_nb_indices, the vector r_index contains the indices

Definition at line 63 of file IndexSet.h.

Member Function Documentation

◆ init() [1/3]

void IndexSet::init ( )
private

Definition at line 27 of file IndexSet.cxx.

27 {
28 m_nb_indices = 0;
29 return;
30}
unsigned int m_nb_indices
Definition IndexSet.h:43

◆ init() [2/3]

void IndexSet::init ( const unsigned int & r_nb_indices)
private

Definition at line 38 of file IndexSet.cxx.

38 {
39 m_nb_indices = r_nb_indices;
40 m_index = std::vector<int>(m_nb_indices);
41 return;
42}
std::vector< int > m_index
Definition IndexSet.h:44

◆ init() [3/3]

void IndexSet::init ( const unsigned int & r_nb_indices,
const std::vector< int > & r_index )
private

Definition at line 50 of file IndexSet.cxx.

50 {
52 // CHECK VECTOR SIZE //
54
55 if (r_index.size() < r_nb_indices) {
56 throw std::runtime_error(Form("File: %s, Line: %d\nIndexSet::init() - Index vector too short!", __FILE__, __LINE__));
57 }
58
60 // INITIALIZATION //
62
63 m_nb_indices = r_nb_indices;
64 m_index = std::vector<int>(m_nb_indices);
65 for (unsigned int k = 0; k < m_nb_indices; k++) {
66 if (k < r_index.size()) {
67 m_index[k] = r_index[k];
68 } else {
69 m_index[k] = 0;
70 }
71 }
72
73 return;
74}

◆ operator!=()

bool IndexSet::operator!= ( const IndexSet & r_index_set) const

comparison of two index sets; two index sets are considered equal if they are of the same size and their indices are the same at the same position [.

]

Definition at line 164 of file IndexSet.cxx.

164{ return !(*this == r_index_set); }

◆ operator==()

bool IndexSet::operator== ( const IndexSet & r_index_set) const

Definition at line 148 of file IndexSet.cxx.

148 {
149 if (r_index_set.size() != m_nb_indices) { return false; }
150
151 for (unsigned int k = 0; k < m_nb_indices; k++) {
152 if (m_index[k] != r_index_set[k]) { return false; }
153 }
154
155 return true;
156}
unsigned int size() const
get the number of indices
Definition IndexSet.cxx:82

◆ operator[]() [1/2]

int IndexSet::operator[] ( const unsigned int & r_k)

:::::::::::::::::::::::

Definition at line 121 of file IndexSet.cxx.

121{ return m_index[r_k]; }

◆ operator[]() [2/2]

int IndexSet::operator[] ( const unsigned int & r_k) const

access to the indices stored in the class, 0 <= r_k < size(); WARNING: no test on the index is performed

Definition at line 129 of file IndexSet.cxx.

129{ return m_index[r_k]; }

◆ resize()

void IndexSet::resize ( const unsigned int & r_size)

resize the index set to r_size; the index store is preserved as far as possible

Definition at line 90 of file IndexSet.cxx.

90 {
91 //:::::::::::::::
92 //:: VARIABLES ::
93 //:::::::::::::::
94
95 std::vector<int> aux_index = m_index; // vector for temporary storage of
96 // the indices
97
98 //:::::::::::::::::::::::::::::::::::::
99 //:: RESIZE AND COPY THE OLD INDICES ::
100 //:::::::::::::::::::::::::::::::::::::
101
102 m_index = std::vector<int>(r_size);
103 for (unsigned int k = 0; k < r_size; k++) {
104 if (k < m_nb_indices) {
105 m_index[k] = aux_index[k];
106 } else {
107 m_index[k] = 0;
108 }
109 }
110 m_nb_indices = r_size;
111
112 return;
113}

◆ size()

unsigned int IndexSet::size ( ) const

get the number of indices

Definition at line 82 of file IndexSet.cxx.

82{ return m_nb_indices; }

◆ sort()

void IndexSet::sort ( )

sort the indices in ascending order

Definition at line 137 of file IndexSet.cxx.

137 {
138 std::stable_sort(m_index.begin(), m_index.end());
139 return;
140}
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.

Member Data Documentation

◆ m_index

std::vector<int> MuonCalib::IndexSet::m_index
private

Definition at line 44 of file IndexSet.h.

◆ m_nb_indices

unsigned int MuonCalib::IndexSet::m_nb_indices
private

Definition at line 43 of file IndexSet.h.


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