CbmRoot
L1Portion.h
Go to the documentation of this file.
1 #ifndef L1Portion_H
2 #define L1Portion_H
3 
4 #include <vector>
5 using std::vector;
6 // class for portions organization
7 
8 template<typename T>
9 class L1Portion;
10 
11 template<>
13 public:
14  typedef L1TrackPar T;
15  // typedef vector<T> vType;
17 
18  L1Portion() : a(), dataSize(0) {};
19  L1Portion(int size) : a(), dataSize(0) { reserve(size); };
20  L1Portion(int size, int size2) : a(), dataSize(size2) {
21  reserve(size);
22  // reserve2(size2);
23  };
24  vType& operator[](int i) { return a[i]; }
25  void resize(int size) { a.resize(size); };
26  void reserve(int size) { a.reserve(size); };
27  void reserve2(int size) {
28  for (unsigned int i = 0; i < a.size(); i++)
29  a[i].reserve(size);
30  };
31  void push_back(vType& v) { a.push_back(v); };
32  void add_void() {
33  vType v;
34  // v.resize(dataSize);
35  a.push_back(v);
36  a[a.size() - 1].reserve(dataSize);
37  };
38  void add_void(int i) {
39  T t;
40  a[i].push_back(t);
41  };
42 
43  int CalcSize() {
44  int size = 0;
45  for (unsigned int i = 0; i < a.size(); i++)
46  size += a[i].size();
47  return size * sizeof(T);
48  };
49 
50 private:
51  vector<vType> a;
52  // int mainSize; // size of a
53  int dataSize; // size of vType
54 };
55 
56 template<>
58 public:
59  typedef L1FieldRegion T;
61  // typedef std::vector<T, nsL1::SimdAlloc<T> > vType;
62 
63  L1Portion() : a(), dataSize(0) {};
64  L1Portion(int size) : a(), dataSize(0) { reserve(size); };
65  L1Portion(int size, int size2) : a(), dataSize(size2) {
66  reserve(size);
67  // reserve2(size2);
68  };
69 
70  vType& operator[](int i) { return a[i]; }
71  void resize(int size) { a.resize(size); };
72  void reserve(int size) { a.reserve(size); };
73  void reserve2(int size) {
74  for (unsigned int i = 0; i < a.size(); i++)
75  a[i].reserve(size);
76  };
77  void push_back(vType& v) { a.push_back(v); };
78  void add_void() {
79  vType v;
80  // v.resize(dataSize);
81  a.push_back(v);
82  a[a.size() - 1].reserve(dataSize);
83  };
84  void add_void(int i) {
85  T t;
86  a[i].push_back(t);
87  };
88 
89  int CalcSize() {
90  int size = 0;
91  for (unsigned int i = 0; i < a.size(); i++)
92  size += a[i].size();
93  return size * sizeof(T);
94  };
95 
96 private:
97  vector<vType> a;
98  // int mainSize; // size of a
99  int dataSize; // size of vType
100 };
101 
102 
103 template<typename T>
104 class L1Portion {
105 public:
106  typedef vector<T> vType;
107 
108  L1Portion() : a(), dataSize(0) {};
109  L1Portion(int size) : a(), dataSize(0) { reserve(size); };
110  L1Portion(int size, int size2) : a(), dataSize(size2) {
111  reserve(size);
112  // reserve2(size2);
113  };
114  vType& operator[](int i) { return a[i]; }
115  void resize(int size) { a.resize(size); };
116  void reserve(int size) { a.reserve(size); };
117  void reserve2(int size) {
118  for (int i = 0; i < a.size(); i++)
119  a[i].reserve(size);
120  };
121  void push_back(vType& v) { a.push_back(v); };
122  void add_void() {
123  vType v;
124  // v.resize(dataSize);
125  a.push_back(v);
126  a[a.size() - 1].reserve(dataSize);
127  };
128  void add_void(int i) {
129  T t;
130  a[i].push_back(t);
131  };
132 
133  int CalcSize() {
134  int size = 0;
135  for (int i = 0; i < a.size(); i++)
136  size += a[i].size();
137  return size * sizeof(T);
138  };
139 
140 private:
141  vector<vType> a;
142  // int mainSize; // size of a
143  int dataSize; // size of vType
144 };
145 
146 #endif // L1Portion_H
L1Portion< L1FieldRegion >::L1Portion
L1Portion()
Definition: L1Portion.h:63
L1Portion< L1FieldRegion >::dataSize
int dataSize
Definition: L1Portion.h:99
L1Portion< L1FieldRegion >::a
vector< vType > a
Definition: L1Portion.h:94
L1Portion::add_void
void add_void()
Definition: L1Portion.h:122
L1Portion< L1FieldRegion >::operator[]
vType & operator[](int i)
Definition: L1Portion.h:70
L1Portion::push_back
void push_back(vType &v)
Definition: L1Portion.h:121
L1Portion::L1Portion
L1Portion(int size, int size2)
Definition: L1Portion.h:110
L1Portion::operator[]
vType & operator[](int i)
Definition: L1Portion.h:114
L1Portion::resize
void resize(int size)
Definition: L1Portion.h:115
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
L1Portion::a
vector< vType > a
Definition: L1Portion.h:138
L1Portion< L1FieldRegion >::CalcSize
int CalcSize()
Definition: L1Portion.h:89
L1Portion< L1FieldRegion >::reserve
void reserve(int size)
Definition: L1Portion.h:72
L1Portion::dataSize
int dataSize
Definition: L1Portion.h:143
L1Portion< L1TrackPar >::CalcSize
int CalcSize()
Definition: L1Portion.h:43
L1Portion::L1Portion
L1Portion()
Definition: L1Portion.h:108
L1Portion< L1FieldRegion >::vType
nsL1::vector< T >::TSimd vType
Definition: L1Portion.h:60
L1Portion< L1TrackPar >::vType
nsL1::vector< T >::TSimd vType
Definition: L1Portion.h:16
L1Portion< L1FieldRegion >::L1Portion
L1Portion(int size)
Definition: L1Portion.h:64
L1Portion::reserve
void reserve(int size)
Definition: L1Portion.h:116
L1Portion< L1TrackPar >::add_void
void add_void(int i)
Definition: L1Portion.h:38
L1Portion< L1FieldRegion >::L1Portion
L1Portion(int size, int size2)
Definition: L1Portion.h:65
L1FieldRegion
Definition: L1Field.h:85
L1Portion< L1TrackPar >::a
vector< vType > a
Definition: L1Portion.h:48
L1Portion< L1FieldRegion >::add_void
void add_void(int i)
Definition: L1Portion.h:84
L1Portion< L1FieldRegion >::reserve2
void reserve2(int size)
Definition: L1Portion.h:73
L1Portion< L1TrackPar >::T
L1TrackPar T
Definition: L1Portion.h:14
L1Portion< L1TrackPar >::dataSize
int dataSize
Definition: L1Portion.h:53
L1Portion< L1FieldRegion >::T
L1FieldRegion T
Definition: L1Portion.h:59
L1Portion< L1TrackPar >::L1Portion
L1Portion()
Definition: L1Portion.h:18
L1Portion< L1TrackPar >::add_void
void add_void()
Definition: L1Portion.h:32
L1Portion< L1TrackPar >::L1Portion
L1Portion(int size)
Definition: L1Portion.h:19
L1Portion< L1FieldRegion >::add_void
void add_void()
Definition: L1Portion.h:78
L1Portion::add_void
void add_void(int i)
Definition: L1Portion.h:128
L1Portion::reserve2
void reserve2(int size)
Definition: L1Portion.h:117
L1Portion::CalcSize
int CalcSize()
Definition: L1Portion.h:133
L1Portion< L1TrackPar >::L1Portion
L1Portion(int size, int size2)
Definition: L1Portion.h:20
v
__m128 v
Definition: L1/vectors/P4_F32vec4.h:1
L1Portion< L1TrackPar >::reserve
void reserve(int size)
Definition: L1Portion.h:26
L1Portion::L1Portion
L1Portion(int size)
Definition: L1Portion.h:109
L1Portion< L1TrackPar >::push_back
void push_back(vType &v)
Definition: L1Portion.h:31
L1TrackPar
Definition: L1TrackPar.h:6
nsL1::vector::TSimd
std::vector< T > TSimd
Definition: L1/vectors/PSEUDO_F32vec1.h:148
L1Portion< L1FieldRegion >::push_back
void push_back(vType &v)
Definition: L1Portion.h:77
L1Portion< L1TrackPar >::resize
void resize(int size)
Definition: L1Portion.h:25
L1Portion< L1FieldRegion >::resize
void resize(int size)
Definition: L1Portion.h:71
L1Portion::vType
vector< T > vType
Definition: L1Portion.h:106
L1Portion< L1TrackPar >::reserve2
void reserve2(int size)
Definition: L1Portion.h:27
L1Portion< L1TrackPar >::operator[]
vType & operator[](int i)
Definition: L1Portion.h:24
L1Portion
Definition: L1Portion.h:9