File indexing completed on 2024-04-06 12:04:37
0001 #ifndef DataFormats_L1Trigger_BXVector_h
0002 #define DataFormats_L1Trigger_BXVector_h
0003
0004
0005
0006
0007
0008 #include "DataFormats/Common/interface/FillView.h"
0009 #include "DataFormats/Common/interface/fillPtrVector.h"
0010 #include "DataFormats/Common/interface/setPtr.h"
0011 #include "DataFormats/Common/interface/traits.h"
0012 #include <vector>
0013
0014 template <class T>
0015 class BXVector {
0016 public:
0017 typedef typename std::vector<T>::iterator iterator;
0018 typedef typename std::vector<T>::const_iterator const_iterator;
0019 typedef T value_type;
0020 typedef typename std::vector<T>::size_type size_type;
0021
0022 public:
0023
0024 BXVector(unsigned size = 0,
0025 int bxFirst = 0,
0026 int bxLast = 0);
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 void setBXRange(int bxFirst, int bxLast);
0042
0043
0044 void resize(int bx, unsigned size);
0045
0046
0047 void resizeAll(unsigned size);
0048
0049
0050 void addBX();
0051
0052
0053 void deleteBX(int bx);
0054
0055
0056 int getFirstBX() const;
0057
0058
0059 int getLastBX() const;
0060
0061
0062 const_iterator begin(int bx) const;
0063
0064
0065 const_iterator end(int bx) const;
0066
0067
0068 unsigned size(int bx) const;
0069
0070
0071 unsigned size() const { return data_.size(); }
0072
0073
0074 void push_back(int bx, T object);
0075
0076
0077 void erase(int bx, unsigned i);
0078
0079
0080 void insert(int bx, unsigned i, T object);
0081
0082
0083 void clear();
0084
0085
0086 void clearBX(int bx);
0087
0088
0089 const T& at(int bx, unsigned i) const;
0090
0091
0092 void set(int bx, unsigned i, const T& object);
0093
0094
0095 bool isEmpty(int bx) const;
0096
0097
0098 const_iterator begin() const { return data_.begin(); }
0099 const_iterator end() const { return data_.end(); }
0100
0101 unsigned int key(const_iterator& iter) const { return iter - begin(); }
0102
0103
0104 T& operator[](std::size_t i) { return data_[i]; }
0105 const T& operator[](std::size_t i) const { return data_[i]; }
0106
0107
0108 void fillView(edm::ProductID const& id, std::vector<void const*>& pointers, edm::FillViewHelperVector& helpers) const;
0109
0110 void setPtr(std::type_info const& toType, unsigned long index, void const*& ptr) const;
0111 void fillPtrVector(std::type_info const& toType,
0112 std::vector<unsigned long> const& indices,
0113 std::vector<void const*>& ptrs) const;
0114
0115 private:
0116
0117
0118 unsigned indexFromBX(int bx) const;
0119 unsigned numBX() const { return 1 + static_cast<const unsigned>(bxLast_ - bxFirst_); }
0120
0121 private:
0122
0123
0124 int bxFirst_;
0125 int bxLast_;
0126
0127
0128
0129
0130
0131 std::vector<T> data_;
0132 std::vector<unsigned> itrs_;
0133 };
0134
0135 #include "BXVector.icc"
0136
0137 #endif