CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1MuGMTMatrix< T > Class Template Reference

#include <L1MuGMTMatrix.h>

Public Member Functions

int colAny (int c) const
 is any element in column c > 0 ? return index or -1 More...
 
bool isMax (int r, int c) const
 is the element (r,c) the max. entry in its row and column? More...
 
bool isMin (int r, int c) const
 is the element (r,c) the min. entry in its row and column? More...
 
 L1MuGMTMatrix (int r, int c, T v)
 constructor More...
 
 L1MuGMTMatrix (const L1MuGMTMatrix< T > &)
 copy constructor More...
 
 L1MuGMTMatrix (L1MuGMTMatrix< T > &&)=default
 
Toperator() (int r, int c)
 
const Toperator() (int r, int c) const
 
L1MuGMTMatrixoperator*= (const T &s)
 scalar multiplication More...
 
L1MuGMTMatrixoperator+= (const L1MuGMTMatrix &m)
 matrix addition More...
 
L1MuGMTMatrixoperator+= (const T &s)
 scalar addition More...
 
L1MuGMTMatrixoperator= (const L1MuGMTMatrix &m)
 assignment operator More...
 
void print () const
 print matrix More...
 
void reset (T v)
 reset all elements More...
 
int rowAny (int r) const
 is any element in row r > 0 ? return index or -1 More...
 
void set (int r, int c, T v)
 set matrix element More...
 
virtual ~L1MuGMTMatrix ()=default
 destructor More...
 

Private Member Functions

Tget (int r, int c)
 
T const & get (int r, int c) const
 

Private Attributes

int c_size
 
std::unique_ptr< T[]> p_
 
int r_size
 

Detailed Description

template<class T>
class L1MuGMTMatrix< T >

Matrix.

general matrix

Definition at line 45 of file L1MuGMTMatrix.h.

Constructor & Destructor Documentation

template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( int  r,
int  c,
T  v 
)

constructor

Definition at line 108 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, mps_fire::i, L1MuGMTMatrix< T >::p_, L1MuGMTMatrix< T >::r_size, and findQualityFiles::v.

108  : r_size(r), c_size(c), p_(new T[r * c]) {
109  for (int i = 0; i < r_size * c_size; ++i) {
110  p_[i] = v;
111  }
112 }
std::unique_ptr< T[]> p_
long double T
template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( const L1MuGMTMatrix< T > &  mat)

copy constructor

Definition at line 117 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, mps_fire::i, L1MuGMTMatrix< T >::p_, and L1MuGMTMatrix< T >::r_size.

118  : r_size(mat.r_size), c_size(mat.c_size), p_(new T[r_size * c_size]) {
119  for (int i = 0; i < r_size * c_size; ++i) {
120  p_[i] = mat.p_[i];
121  }
122 }
std::unique_ptr< T[]> p_
long double T
template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( L1MuGMTMatrix< T > &&  )
default
template<class T>
virtual L1MuGMTMatrix< T >::~L1MuGMTMatrix ( )
virtualdefault

destructor

Member Function Documentation

template<class T >
int L1MuGMTMatrix< T >::colAny ( int  c) const

is any element in column c > 0 ? return index or -1

Definition at line 262 of file L1MuGMTMatrix.h.

References mps_fire::i, L1MuGMTMatrix< T >::r_size, and hgcalPlots::stat.

Referenced by L1MuGMTCancelOutUnit::decide(), and L1MuGMTMerger::merge().

262  {
263  int stat = -1;
264  for (int i = 0; i < r_size; i++) {
265  if (this->get(i, c) > 0)
266  stat = i;
267  }
268 
269  return stat;
270 }
template<class T>
T& L1MuGMTMatrix< T >::get ( int  r,
int  c 
)
inlineprivate
template<class T>
T const& L1MuGMTMatrix< T >::get ( int  r,
int  c 
) const
inlineprivate
template<class T >
bool L1MuGMTMatrix< T >::isMax ( int  r,
int  c 
) const

is the element (r,c) the max. entry in its row and column?

Definition at line 222 of file L1MuGMTMatrix.h.

References HltBtagPostValidation_cff::c, L1MuGMTMatrix< T >::c_size, mps_fire::i, dqmiolumiharvest::j, SiStripPI::max, alignCSCRings::r, and L1MuGMTMatrix< T >::r_size.

Referenced by L1MuGMTMatcher::match().

222  {
223  bool max = true;
224 
225  for (int i = 0; i < c; i++) {
226  max = max && (this->get(r, c) > this->get(r, i));
227  }
228  for (int i = c + 1; i < c_size; i++) {
229  max = max && (this->get(r, c) >= this->get(r, i));
230  }
231 
232  for (int j = 0; j < r; j++) {
233  max = max && (this->get(r, c) > this->get(j, c));
234  }
235  for (int j = r + 1; j < r_size; j++) {
236  max = max && (this->get(r, c) >= this->get(j, c));
237  }
238 
239  return max;
240 }
template<class T >
bool L1MuGMTMatrix< T >::isMin ( int  r,
int  c 
) const

is the element (r,c) the min. entry in its row and column?

Definition at line 246 of file L1MuGMTMatrix.h.

References HltBtagPostValidation_cff::c, L1MuGMTMatrix< T >::c_size, mps_fire::i, dqmiolumiharvest::j, min(), alignCSCRings::r, and L1MuGMTMatrix< T >::r_size.

246  {
247  bool min = true;
248  for (int i = 0; i < c_size; i++) {
249  min = min && (this->get(r, c) <= this->get(r, i));
250  }
251  for (int j = 0; j < r_size; j++) {
252  min = min && (this->get(r, c) <= this->get(j, c));
253  }
254 
255  return min;
256 }
T min(T a, T b)
Definition: MathUtil.h:58
template<class T >
T & L1MuGMTMatrix< T >::operator() ( int  r,
int  c 
)

Definition at line 128 of file L1MuGMTMatrix.h.

References HltBtagPostValidation_cff::c, L1MuGMTMatrix< T >::c_size, and alignCSCRings::r.

128  {
129  assert(r >= 0 && r < r_size && c >= 0 && c < c_size);
130 
131  return get(r, c);
132 }
template<class T >
const T & L1MuGMTMatrix< T >::operator() ( int  r,
int  c 
) const

Definition at line 138 of file L1MuGMTMatrix.h.

References HltBtagPostValidation_cff::c, L1MuGMTMatrix< T >::c_size, and alignCSCRings::r.

138  {
139  assert(r >= 0 && r < r_size && c >= 0 && c < c_size);
140 
141  return get(r, c);
142 }
template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator*= ( const T s)

scalar multiplication

Definition at line 210 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, mps_fire::i, L1MuGMTMatrix< T >::p_, L1MuGMTMatrix< T >::r_size, and alignCSCRings::s.

210  {
211  for (int i = 0; i < r_size * c_size; ++i) {
212  p_[i] *= s;
213  }
214 
215  return *this;
216 }
std::unique_ptr< T[]> p_
template<class T >
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator+= ( const L1MuGMTMatrix< T > &  m)

matrix addition

Definition at line 184 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, mps_fire::i, L1MuGMTMatrix< T >::p_, and L1MuGMTMatrix< T >::r_size.

184  {
185  assert(m.c_size == c_size && m.r_size == r_size);
186 
187  for (int i = 0; i < r_size * c_size; ++i) {
188  p_[i] += m.p_[i];
189  }
190 
191  return *this;
192 }
std::unique_ptr< T[]> p_
template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator+= ( const T s)

scalar addition

Definition at line 198 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, mps_fire::i, L1MuGMTMatrix< T >::p_, L1MuGMTMatrix< T >::r_size, and alignCSCRings::s.

198  {
199  for (int i = 0; i < r_size * c_size; ++i) {
200  p_[i] += s;
201  }
202 
203  return *this;
204 }
std::unique_ptr< T[]> p_
template<class T >
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator= ( const L1MuGMTMatrix< T > &  m)

assignment operator

Definition at line 168 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, mps_fire::i, L1MuGMTMatrix< T >::p_, and L1MuGMTMatrix< T >::r_size.

168  {
169  if (this != &m) {
170  assert(m.c_size == c_size && m.r_size == r_size);
171 
172  for (int i = 0; i < r_size * c_size; ++i) {
173  p_[i] = m.p_[i];
174  }
175  }
176 
177  return (*this);
178 }
std::unique_ptr< T[]> p_
template<class T >
void L1MuGMTMatrix< T >::print ( void  ) const

print matrix

Definition at line 290 of file L1MuGMTMatrix.h.

References HltBtagPostValidation_cff::c, L1MuGMTMatrix< T >::c_size, convertSQLitetoXML_cfg::output, alignCSCRings::r, and L1MuGMTMatrix< T >::r_size.

Referenced by L1MuGMTMatcher::print().

290  {
291  for (int r = 0; r < r_size; r++) {
292  std::stringstream output;
293  for (int c = 0; c < c_size; c++)
294  output << get(r, c) << "\t";
295  edm::LogVerbatim("GMTMatrix_print") << output.str();
296  }
297  edm::LogVerbatim("GMTMatrix_print");
298 }
template<class T>
void L1MuGMTMatrix< T >::reset ( T  v)

reset all elements

Definition at line 148 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, mps_fire::i, L1MuGMTMatrix< T >::p_, L1MuGMTMatrix< T >::r_size, and findQualityFiles::v.

Referenced by L1MuGMTInputEvent::reset(), L1MuGMTMatcher::reset(), and L1MuGMTPSB::reset().

148  {
149  for (int i = 0; i < r_size * c_size; ++i) {
150  p_[i] = v;
151  }
152 }
std::unique_ptr< T[]> p_
template<class T >
int L1MuGMTMatrix< T >::rowAny ( int  r) const

is any element in row r > 0 ? return index or -1

Definition at line 276 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, mps_fire::i, and hgcalPlots::stat.

Referenced by L1MuGMTCancelOutUnit::decide(), and L1MuGMTMerger::merge().

276  {
277  int stat = -1;
278  for (int i = 0; i < c_size; i++) {
279  if (this->get(r, i) > 0)
280  stat = i;
281  }
282 
283  return stat;
284 }
template<class T>
void L1MuGMTMatrix< T >::set ( int  r,
int  c,
T  v 
)

set matrix element

Definition at line 158 of file L1MuGMTMatrix.h.

References HltBtagPostValidation_cff::c, L1MuGMTMatrix< T >::c_size, and alignCSCRings::r.

Referenced by L1MuGMTPSB::getCalo().

158  {
159  assert(r >= 0 && r < r_size && c >= 0 && c < c_size);
160 
161  get(r, c) = v;
162 }

Member Data Documentation

template<class T>
int L1MuGMTMatrix< T >::c_size
private
template<class T>
std::unique_ptr<T[]> L1MuGMTMatrix< T >::p_
private
template<class T>
int L1MuGMTMatrix< T >::r_size
private