CMS 3D CMS Logo

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