ATLAS Offline Software
Loading...
Searching...
No Matches
BunchLumisUtil.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6//#Include "CoolKernel/IObject.h"
7#include "CoralBase/Blob.h"
8#include "CoralBase/Attribute.h"
9#include <sstream>
10#include <iostream>
11#include <cmath>
12#include <vector>
13
15 // Clear vectors
16 this->clear();
17 error.clear();
18}
19
20// The number 3564 is the number of BCID's
21void
25
26// Access functions
27unsigned int
29 return m_bunchLumis.size();
30}
31
32int
33BunchLumisUtil::nxStorage(const cool::Record& rec) {
34 return nxStorage(rec.attributeList());
35}
36
37int
38BunchLumisUtil::nyStorage(const cool::Record& rec) {
39 return nyStorage(rec.attributeList());
40}
41
42int
43BunchLumisUtil::nxStorage(const coral::AttributeList& attrList1) const {
44 return m_blobUtil.xvalue(attrList1);
45}
46
47int
48BunchLumisUtil::nyStorage (const coral::AttributeList& attrList1) const {
49 return m_blobUtil.yvalue(attrList1);
50}
51
52const std::vector<double> &
56
57// Fill value from cool::Record (ie. python)
58bool
59BunchLumisUtil::setValue(const cool::Record& rec) {
60 return setValue(rec.attributeList());
61}
62
63bool
64BunchLumisUtil::setCollidingBCIDs(std::vector<unsigned int> & p) {
66 return true;
67}
68
69// Fill value from AttributeList
70// Returns false on error
71bool
72BunchLumisUtil::setValue(const coral::AttributeList& attrList1) {
73 // First, clear old values
74 this->clear();
75 error.clear();
76 // Check if there is any data
77 if (attrList1["BunchRawInstLum"].isNull()) {
78 error = "BunchCode is NULL!";
79 return false;
80 }
81
82 // Defines the blob and integer from COOL
83 cool::Float ARI = attrList1["AverageRawInstLum"].data<cool::Float>();
84 const coral::Blob &blobBC = attrList1["BunchRawInstLum"].data<coral::Blob>();
85
86 // m_blobUtil.setValue(attrList1);
87
88 m_blobUtil.unpack(ARI,blobBC,m_collidingBCIDs);
89
90 return true;
91}
92 // const uint8_t *k=static_cast<const uint8_t*>(blobBC.startingAddress());
93 /*
94 if (blobBC.size() == 0) {
95 std::cout << "No Blob" << std::endl;
96 return false;
97 }
98
99 else {
100
101 unsigned int fact = 0;
102 unsigned int x = 1;
103 unsigned int y = 1;
104 unsigned int BCID = 0;
105 unsigned int BCIDold = 0;
106 float BV = 0;
107 double element = 0;
108 unsigned int tmk = *k;
109
110 x=tmk/10;
111 y=tmk-10*x;
112 fact=int(pow(100,x));
113
114 std::cout << "value of x: " << x << std::endl;
115 std::cout << "value of y: " << y << std::endl;
116 std::cout << "BlobBC.size() " << blobBC.size() << std::endl;
117 std::cout << "m_collidingBCIDs.size() " << m_collidingBCIDs.size() << std::endl;
118 k++;
119 if (x==1) {
120 if (y==0) {
121 for (unsigned int i =0; i<m_collidingBCIDs.size(); i++) {
122 BCID = m_collidingBCIDs[i];
123
124 const uint8_t* y10 = (const uint8_t*) k;
125 for (unsigned int j = BCIDold; j <= BCID; j++, y10++) {
126 if (j==BCID) {
127 tmk = *y10;
128 BV = ARI*tmk/fact;
129 m_bunchLumis.push_back(BV);
130 }
131 else {
132 m_bunchLumis.push_back(element);
133 }
134 }
135 BCIDold=BCID+1;
136 }
137 for (unsigned int i=BCIDold; i<3564; i++) {
138 m_bunchLumis.push_back(element);
139 }
140 } //This ends y=0
141
142 if (y==1) {
143 const uint8_t* y11 = (const uint8_t*) k;
144 for (unsigned int i = 0; i < ((blobBC.size()-1)/x); i++, y11++) {
145 tmk = *y11;
146 BV = ARI*tmk/fact;
147 m_bunchLumis.push_back(BV);
148 }
149 }
150 //This ends y=1
151 if (y==2) {
152 const uint16_t* k1 = (const uint16_t*) k;
153 unsigned int len = *k1;
154 k1++;
155 const uint8_t* y12 = (const uint8_t*) (k+2*(len+1));
156
157 for (unsigned int i = 0; i<len; i++, k1++) {
158 BCID = *k1;
159 for (unsigned int j=BCIDold; j<=(BCID); j++, y12++) {
160 if (j==BCID) {
161 tmk=*y12;
162 BV = ARI*tmk/fact;
163 m_bunchLumis.push_back(BV);
164 }
165 else {
166 m_bunchLumis.push_back(element);
167 }
168 }
169 BCIDold=BCID+1;
170 }
171 for (unsigned int i=(BCIDold); i<3564; i++) {
172 m_bunchLumis.push_back(element);
173 }
174 BCIDold=0;
175 } //This ends y=2
176 } //This ends x=1
177
178 if (x==2) {
179 if (y==0) {
180 for (unsigned int i =0; i<m_collidingBCIDs.size(); i++) {
181 BCID = m_collidingBCIDs[i];
182
183 const uint16_t* y20 = (const uint16_t*) k;
184 for (unsigned int j = BCIDold; j <= BCID; j++, y20++) {
185 if (j==BCID) {
186 tmk = *y20;
187 BV = ARI*tmk/fact;
188 m_bunchLumis.push_back(BV);
189 }
190 else {
191 m_bunchLumis.push_back(element);
192 }
193 }
194 BCIDold=BCID+1;
195 }
196 for (unsigned int i=BCIDold; i<3564; i++) {
197 m_bunchLumis.push_back(element);
198 }
199 } //This ends y=0
200 if (y==1) {
201 const uint16_t* y21 = (const uint16_t*) k;
202 for (unsigned int i = 0; i < ((blobBC.size()-1)/x); i++, y21++) {
203 tmk=*y21;
204 BV = ARI*tmk/fact;
205 m_bunchLumis.push_back(BV);
206 }
207 } //This ends y=1
208
209 if (y==2) {
210 const uint16_t* k2 = (const uint16_t*) k;
211 unsigned int len = *k2;
212 k2++;
213
214 const uint16_t* y22 = (const uint16_t*) (k+2*(len+1));
215
216 for (unsigned int i = 0; i<len; i++, k2++) {
217 BCID = *k2;
218 for (unsigned int j=BCIDold; j<=(BCID); j++, y22++) {
219 if (j==BCID) {
220 tmk=*y22;
221 BV = ARI*tmk/fact;
222 m_bunchLumis.push_back(BV);
223 }
224 else {
225 m_bunchLumis.push_back(element);
226 }
227 }
228 BCIDold=BCID+1;
229 }
230 for (unsigned int i=(BCIDold); i<3564; i++) {
231 m_bunchLumis.push_back(element);
232 }
233 }
234 //This ends y=2
235 }
236 //This ends x=2
237 if (x==4) {
238 if (y==0) {
239 for (unsigned int i =0; i<m_collidingBCIDs.size(); i++) {
240 BCID = m_collidingBCIDs[i];
241
242 const float * y40 = (const float*) k;
243 for (unsigned int j = BCIDold; j <= BCID; j++, y40++) {
244 if (j==BCID) {
245 tmk = *y40;
246 BV = ARI*tmk/fact;
247 m_bunchLumis.push_back(BV);
248 }
249 else {
250 m_bunchLumis.push_back(element);
251 }
252 }
253 BCIDold=BCID+1;
254 }
255 for (unsigned int i=BCIDold; i<3564; i++) {
256 m_bunchLumis.push_back(element);
257 }
258 } //This ends y=0
259 if (y==1) {
260 const float* y41 = (const float*) k;
261 for (unsigned int i = 0; i < ((blobBC.size()-1)/x); i++, y41++) {
262 BV = *y41;
263 m_bunchLumis.push_back(BV);
264 }
265 } //This ends y=1
266 if (y==2) {
267 const uint16_t* k4 = (const uint16_t*) k;
268 unsigned int len = *k4;
269 k4++;
270 const float* y42 = (const float*) (k+2*(1+len));
271
272 for (unsigned int i = 0; i<len; i++, k4++) {
273 BCID = *k4;
274 for (unsigned int j=BCIDold; j<=(BCID); j++, y42++) {
275 if (j==BCID) {
276 BV = *y42;
277 m_bunchLumis.push_back(BV);
278 }
279 else {
280 m_bunchLumis.push_back(element);
281 }
282 }
283 BCIDold=BCID+1;
284 }
285 for (unsigned int i=(BCIDold); i<3564; i++) {
286 m_bunchLumis.push_back(element);
287 }
288 } //This ends y=2
289 } //This ends x=4
290
291
292 return true;
293}
294
295 */
std::vector< unsigned int > m_collidingBCIDs
int nxStorage(const cool::Record &rec)
const std::vector< double > & bunchLumis() const
class LumiBlobUtil m_blobUtil
bool setCollidingBCIDs(std::vector< unsigned int > &)
bool setValue(const coral::AttributeList &attrList1)
unsigned int nBunchLumis() const
int nyStorage(const cool::Record &rec)
std::vector< double > m_bunchLumis