CMS 3D CMS Logo

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

#include <OrbitCollection.h>

Public Types

typedef std::vector< T >::const_iterator const_iterator
 
typedef std::vector< T >::iterator iterator
 
typedef std::vector< T >::size_type size_type
 
typedef T value_type
 

Public Member Functions

const_iterator begin () const
 
edm::Span< const_iteratorbxIterator (unsigned bx) const
 
const_iterator end () const
 
void fillAndClear (std::vector< std::vector< T >> &orbitBuffer, unsigned nObjects=0)
 
const TgetBxObject (unsigned bx, unsigned i) const
 
int getBxSize (unsigned bx) const
 
std::vector< unsigned > getFilledBxs () const
 
OrbitCollectionoperator= (const OrbitCollection &other)=default
 
OrbitCollectionoperator= (OrbitCollection &&other)=default
 
Toperator[] (std::size_t i)
 
const Toperator[] (std::size_t i) const
 
 OrbitCollection ()
 
 OrbitCollection (std::vector< std::vector< T >> &orbitBuffer, unsigned nObjects=0)
 
 OrbitCollection (const OrbitCollection &other)=default
 
 OrbitCollection (OrbitCollection &&other)=default
 
int size () const
 

Static Public Member Functions

static short Class_Version ()
 

Private Attributes

std::vector< unsigned > bxOffsets_
 
std::vector< Tdata_
 

Static Private Attributes

static constexpr int orbitBufferSize_ = 3565
 

Detailed Description

template<class T>
class OrbitCollection< T >

Definition at line 12 of file OrbitCollection.h.

Member Typedef Documentation

◆ const_iterator

template<class T >
typedef std::vector<T>::const_iterator OrbitCollection< T >::const_iterator

Definition at line 15 of file OrbitCollection.h.

◆ iterator

template<class T >
typedef std::vector<T>::iterator OrbitCollection< T >::iterator

Definition at line 14 of file OrbitCollection.h.

◆ size_type

template<class T >
typedef std::vector<T>::size_type OrbitCollection< T >::size_type

Definition at line 17 of file OrbitCollection.h.

◆ value_type

template<class T >
typedef T OrbitCollection< T >::value_type

Definition at line 16 of file OrbitCollection.h.

Constructor & Destructor Documentation

◆ OrbitCollection() [1/4]

template<class T >
OrbitCollection< T >::OrbitCollection ( )
inline

Definition at line 21 of file OrbitCollection.h.

21 : bxOffsets_(orbitBufferSize_ + 1, 0), data_(0) {}
std::vector< unsigned > bxOffsets_
std::vector< T > data_
static constexpr int orbitBufferSize_

◆ OrbitCollection() [2/4]

template<class T >
OrbitCollection< T >::OrbitCollection ( std::vector< std::vector< T >> &  orbitBuffer,
unsigned  nObjects = 0 
)
inline

Definition at line 25 of file OrbitCollection.h.

References OrbitCollection< T >::fillAndClear().

26  : bxOffsets_(orbitBufferSize_ + 1, 0), data_(nObjects) {
27  fillAndClear(orbitBuffer, nObjects);
28  }
void fillAndClear(std::vector< std::vector< T >> &orbitBuffer, unsigned nObjects=0)
std::vector< unsigned > bxOffsets_
std::vector< T > data_
static constexpr int orbitBufferSize_

◆ OrbitCollection() [3/4]

template<class T >
OrbitCollection< T >::OrbitCollection ( const OrbitCollection< T > &  other)
default

◆ OrbitCollection() [4/4]

template<class T >
OrbitCollection< T >::OrbitCollection ( OrbitCollection< T > &&  other)
default

Member Function Documentation

◆ begin()

template<class T >
const_iterator OrbitCollection< T >::begin ( void  ) const
inline

Definition at line 65 of file OrbitCollection.h.

References OrbitCollection< T >::data_.

65 { return data_.begin(); }
std::vector< T > data_

◆ bxIterator()

template<class T >
edm::Span<const_iterator> OrbitCollection< T >::bxIterator ( unsigned  bx) const
inline

Definition at line 69 of file OrbitCollection.h.

References nano_mu_digi_cff::bx, OrbitCollection< T >::bxOffsets_, OrbitCollection< T >::data_, OrbitCollection< T >::end(), Exception, OrbitCollection< T >::getBxSize(), and OrbitCollection< T >::orbitBufferSize_.

Referenced by DumpScObjects::printBx().

69  {
70  if (bx >= orbitBufferSize_)
71  throw cms::Exception("OrbitCollection::bxIterator") << "Trying to access and object outside the orbit range. "
72  << " BX = " << bx;
73  if (getBxSize(bx) > 0) {
74  return edm::Span(data_.begin() + bxOffsets_[bx], data_.begin() + bxOffsets_[bx + 1]);
75  } else {
76  return edm::Span(end(), end());
77  }
78  }
int getBxSize(unsigned bx) const
const_iterator end() const
std::vector< unsigned > bxOffsets_
std::vector< T > data_
static constexpr int orbitBufferSize_
Definition: Span.h:16

◆ Class_Version()

template<class T >
static short OrbitCollection< T >::Class_Version ( )
inlinestatic

Definition at line 121 of file OrbitCollection.h.

123 :
124  // store data vector and BX offsets as flat vectors.

◆ end()

template<class T >
const_iterator OrbitCollection< T >::end ( void  ) const
inline

◆ fillAndClear()

template<class T >
void OrbitCollection< T >::fillAndClear ( std::vector< std::vector< T >> &  orbitBuffer,
unsigned  nObjects = 0 
)
inline

Definition at line 40 of file OrbitCollection.h.

References OrbitCollection< T >::bxOffsets_, OrbitCollection< T >::data_, and OrbitCollection< T >::orbitBufferSize_.

Referenced by OrbitCollection< T >::OrbitCollection().

40  {
41  if (orbitBuffer.size() != orbitBufferSize_)
42  throw cms::Exception("OrbitCollection::fillAndClear")
43  << "Trying to fill the collection by passing an orbit buffer with incorrect size. "
44  << "Passed " << orbitBuffer.size() << ", expected 3565";
45  data_.reserve(nObjects);
46  bxOffsets_[0] = 0;
47  unsigned bxIdx = 1;
48  for (auto& bxVec : orbitBuffer) {
49  // increase offset by the currect vec size
50  bxOffsets_[bxIdx] = bxOffsets_[bxIdx - 1] + bxVec.size();
51 
52  // if bxVec contains something, copy it into the data_ vector
53  // and clear original bxVec objects
54  if (bxVec.size() > 0) {
55  data_.insert(data_.end(), bxVec.begin(), bxVec.end());
56  bxVec.clear();
57  }
58 
59  // increment bx index
60  bxIdx++;
61  }
62  }
std::vector< unsigned > bxOffsets_
std::vector< T > data_
static constexpr int orbitBufferSize_

◆ getBxObject()

template<class T >
const T& OrbitCollection< T >::getBxObject ( unsigned  bx,
unsigned  i 
) const
inline

Definition at line 91 of file OrbitCollection.h.

References nano_mu_digi_cff::bx, OrbitCollection< T >::bxOffsets_, OrbitCollection< T >::data_, Exception, OrbitCollection< T >::getBxSize(), mps_fire::i, and OrbitCollection< T >::orbitBufferSize_.

91  {
92  if (bx >= orbitBufferSize_)
93  throw cms::Exception("OrbitCollection::getBxObject") << "Trying to access and object outside the orbit range. "
94  << " BX = " << bx;
95  if (i >= getBxSize(bx))
96  throw cms::Exception("OrbitCollection::getBxObject")
97  << "Trying to get element " << i << " but for"
98  << " BX = " << bx << " there are " << getBxSize(bx) << " elements.";
99 
100  return data_[bxOffsets_[bx] + i];
101  }
int getBxSize(unsigned bx) const
std::vector< unsigned > bxOffsets_
std::vector< T > data_
static constexpr int orbitBufferSize_

◆ getBxSize()

template<class T >
int OrbitCollection< T >::getBxSize ( unsigned  bx) const
inline

Definition at line 81 of file OrbitCollection.h.

References nano_mu_digi_cff::bx, OrbitCollection< T >::bxOffsets_, Exception, and OrbitCollection< T >::orbitBufferSize_.

Referenced by OrbitCollection< T >::bxIterator(), and OrbitCollection< T >::getBxObject().

81  {
82  if (bx >= orbitBufferSize_) {
83  cms::Exception("OrbitCollection") << "Called getBxSize() of a bx out of the orbit range."
84  << " BX = " << bx;
85  return 0;
86  }
87  return bxOffsets_[bx + 1] - bxOffsets_[bx];
88  }
std::vector< unsigned > bxOffsets_
static constexpr int orbitBufferSize_

◆ getFilledBxs()

template<class T >
std::vector<unsigned> OrbitCollection< T >::getFilledBxs ( ) const
inline

Definition at line 104 of file OrbitCollection.h.

References nano_mu_digi_cff::bx, OrbitCollection< T >::bxOffsets_, OrbitCollection< T >::data_, and OrbitCollection< T >::orbitBufferSize_.

Referenced by DumpScObjects::analyze().

104  {
105  std::vector<unsigned> filledBxVec;
106  if (!data_.empty()) {
107  for (unsigned bx = 0; bx < orbitBufferSize_; bx++) {
108  if ((bxOffsets_[bx + 1] - bxOffsets_[bx]) > 0)
109  filledBxVec.push_back(bx);
110  }
111  }
112  return filledBxVec;
113  }
std::vector< unsigned > bxOffsets_
std::vector< T > data_
static constexpr int orbitBufferSize_

◆ operator=() [1/2]

template<class T >
OrbitCollection& OrbitCollection< T >::operator= ( const OrbitCollection< T > &  other)
default

◆ operator=() [2/2]

template<class T >
OrbitCollection& OrbitCollection< T >::operator= ( OrbitCollection< T > &&  other)
default

◆ operator[]() [1/2]

template<class T >
T& OrbitCollection< T >::operator[] ( std::size_t  i)
inline

Definition at line 117 of file OrbitCollection.h.

References OrbitCollection< T >::data_, and mps_fire::i.

117 { return data_[i]; }
std::vector< T > data_

◆ operator[]() [2/2]

template<class T >
const T& OrbitCollection< T >::operator[] ( std::size_t  i) const
inline

Definition at line 118 of file OrbitCollection.h.

References OrbitCollection< T >::data_, and mps_fire::i.

118 { return data_[i]; }
std::vector< T > data_

◆ size()

template<class T >
int OrbitCollection< T >::size ( void  ) const
inline

Definition at line 115 of file OrbitCollection.h.

References OrbitCollection< T >::data_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

115 { return data_.size(); }
std::vector< T > data_

Member Data Documentation

◆ bxOffsets_

template<class T >
std::vector<unsigned> OrbitCollection< T >::bxOffsets_
private

◆ data_

template<class T >
std::vector<T> OrbitCollection< T >::data_
private

◆ orbitBufferSize_

template<class T >
constexpr int OrbitCollection< T >::orbitBufferSize_ = 3565
staticprivate