ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 More...
 
 IndexSet (const unsigned int &r_nb_indices)
 constructor: the number of indices is set to r_nb_indices More...
 
 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 More...
 
unsigned int size () const
 get the number of indices More...
 
void resize (const unsigned int &r_size)
 resize the index set to r_size; the index store is preserved as far as possible More...
 
int operator[] (const unsigned int &r_k)
 ::::::::::::::::::::::: More...
 
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 More...
 
void sort ()
 sort the indices in ascending order More...
 
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 [. More...
 

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 }

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

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

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

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:
MuonCalib::IndexSet::size
unsigned int size() const
get the number of indices
Definition: IndexSet.cxx:82
std::stable_sort
void stable_sort(std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, std::reverse_iterator< DataModel_detail::iterator< DVL > > end, Compare comp)
Specialization of stable_sort for DataVector/List.
Definition: DVL_algorithms.h:711
MuonCalib::IndexSet::m_nb_indices
unsigned int m_nb_indices
Definition: IndexSet.h:43
MuonCalib::IndexSet::m_index
std::vector< int > m_index
Definition: IndexSet.h:44
fitman.k
k
Definition: fitman.py:528