ATLAS Offline Software
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
21 void
23  m_bunchLumis.clear();
24 }
25 
26 // Access functions
27 unsigned int
29  return m_bunchLumis.size();
30 }
31 
32 int
33 BunchLumisUtil::nxStorage(const cool::Record& rec) {
34  return nxStorage(rec.attributeList());
35 }
36 
37 int
38 BunchLumisUtil::nyStorage(const cool::Record& rec) {
39  return nyStorage(rec.attributeList());
40 }
41 
42 int
44  return m_blobUtil.xvalue(attrList1);
45 }
46 
47 int
49  return m_blobUtil.yvalue(attrList1);
50 }
51 
52 const std::vector<double> &
54  return m_bunchLumis;
55 }
56 
57 // Fill value from cool::Record (ie. python)
58 bool
59 BunchLumisUtil::setValue(const cool::Record& rec) {
60  return setValue(rec.attributeList());
61 }
62 
63 bool
64 BunchLumisUtil::setCollidingBCIDs(std::vector<unsigned int> & p) {
66  return true;
67 }
68 
69 // Fill value from AttributeList
70 // Returns false on error
71 bool
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 
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  */
BunchLumisUtil::clear
void clear()
Definition: BunchLumisUtil.cxx:22
BunchLumisUtil::nyStorage
int nyStorage(const cool::Record &rec)
Definition: BunchLumisUtil.cxx:38
BunchLumisUtil::bunchLumis
const std::vector< double > & bunchLumis() const
Definition: BunchLumisUtil.cxx:53
BunchLumisUtil::setCollidingBCIDs
bool setCollidingBCIDs(std::vector< unsigned int > &)
Definition: BunchLumisUtil.cxx:64
BunchLumisUtil::m_bunchLumis
std::vector< double > m_bunchLumis
Definition: BunchLumisUtil.h:56
BunchLumisUtil::setValue
bool setValue(const coral::AttributeList &attrList1)
Definition: BunchLumisUtil.cxx:72
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
BunchLumisUtil.h
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
LumiBlobUtil::yvalue
int yvalue(const cool::Record &rec)
Definition: LumiBlobUtil.cxx:33
BunchLumisUtil::BunchLumisUtil
BunchLumisUtil()
Definition: BunchLumisUtil.cxx:14
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
LumiBlobUtil::xvalue
int xvalue(const cool::Record &rec)
Definition: LumiBlobUtil.cxx:28
BunchLumisUtil::nBunchLumis
unsigned int nBunchLumis() const
Definition: BunchLumisUtil.cxx:28
BunchLumisUtil::m_blobUtil
class LumiBlobUtil m_blobUtil
Definition: BunchLumisUtil.h:60
BunchLumisUtil::m_collidingBCIDs
std::vector< unsigned int > m_collidingBCIDs
Definition: BunchLumisUtil.h:58
LumiBlobUtil::unpack
bool unpack(const cool::Float &ARI, const coral::Blob &blobBC, const std::vector< unsigned int > &PV)
Definition: LumiBlobUtil.cxx:90
error
Definition: IImpactPoint3dEstimator.h:70
BunchLumisUtil::nxStorage
int nxStorage(const cool::Record &rec)
Definition: BunchLumisUtil.cxx:33