CMS 3D CMS Logo

PhysicsToBitConverter.cc
Go to the documentation of this file.
2 
3 namespace l1t {
5  for (int m = 0; m < 2; m++) {
6  for (int n = 0; n < 6; n++) {
7  words32bitLink[m][n] = 0;
8  }
9  }
10  for (int m = 0; m < 2; m++) {
11  for (int n = 0; n < 192; n++) {
12  bitsLink[m][n] = 0;
13  }
14  }
15  }
16 
18  for (int iword = 0; iword < 6; iword++) {
19  for (int ibit = 0; ibit < 32; ibit++) {
20  //bitsLink[0].push_back(ReadBitInInt(ibit,words32bitLink[0][iword]));
21  //bitsLink[1].push_back(ReadBitInInt(ibit,words32bitLink[1][iword]));
22  bitsLink[0][ibit + iword * 32] = ReadBitInInt(ibit, words32bitLink[0][iword]);
23  bitsLink[1][ibit + iword * 32] = ReadBitInInt(ibit, words32bitLink[1][iword]);
24  }
25  }
26  }
27 
29  //link,words
30 
31  for (int ilink = 0; ilink < 2; ilink++) {
32  for (int iword = 0; iword < 6; iword++) {
33  words32bitLink[ilink][iword] = BuildDecimalValue(iword * 32, 32, ilink);
34  }
35  }
36  }
37 
39  int mystart = databaseobject.GetIndices(t, firstindex, secondindex);
40  int mylength = databaseobject.GetLength(t);
41  int mylink = databaseobject.GetLink(t);
42 
43  return BuildDecimalValue(mystart, mylength, mylink);
44  }
45 
47  int mystart = databaseobject.GetIndices(t, firstindex, secondindex);
48  int mylength = databaseobject.GetLength(t);
49  int mylink = databaseobject.GetLink(t);
50 
51  if (value > (pow(2, mylength) - 1))
52  std::cout << "The value you are trying to set has more bins than expected " << std::endl;
53  for (int i = 0; i < mylength; i++)
54  bitsLink[mylink][i + mystart] = (value >> i) & 0x1;
55  }
56 
58  std::bitset<32> foo(value);
59  return foo[bit];
60  }
61 
62  int PhysicsToBitConverter::BuildDecimalValue(int firstbit, int bitlength, int linkid) {
63  int myvalue = 0;
64  int counter = 0;
65 
66  for (int m = firstbit; m < firstbit + bitlength; m++) {
67  myvalue |= (bitsLink[linkid][m] & (0x1)) << counter;
68  counter++;
69  }
70  return myvalue;
71  }
72 } // namespace l1t
int GetLength(rctObjectType t)
Definition: rctDataBase.h:38
delete x;
Definition: CaloConfig.h:22
int GetLink(rctObjectType t)
Definition: rctDataBase.h:40
int BuildDecimalValue(int firstbit, int bitlength, int linkid)
Definition: value.py:1
int ReadBitInInt(int bit, int value)
int GetIndices(rctObjectType t, int firstindex, int secondindex=-1)
Definition: rctDataBase.h:54
static std::atomic< unsigned int > counter
int GetObject(rctDataBase::rctObjectType t, int firstindex, int secondindex=-1)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
void SetObject(rctDataBase::rctObjectType t, int value, int firstindex, int secondindex=-1)