CMS 3D CMS Logo

L1GtAlgorithm.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <iostream>
22 #include <iomanip>
23 
24 // user include files
25 
26 // forward declarations
27 
28 // constructor(s)
29 // default
31 {
32  // default values for private members not set
33  // the other private members are C++ initialized
34  m_algoBitNumber = -1;
35  m_algoChipNumber = -1;
36 
37 }
38 
39 // name only
41  m_algoName(algoNameValue) {
42 
43  // default values for private members not set
44  // the other private members are C++ initialized
45  m_algoBitNumber = -1;
46  m_algoChipNumber = -1;
47 
48 }
49 
50 // name and logical expression
52  const std::string& algoNameValue, const std::string& algoLogicalExpressionValue) :
53  m_algoName(algoNameValue), m_algoLogicalExpression(algoLogicalExpressionValue) {
54 
56  m_algoRpnVector = logicParser.rpnVector();
57 
58  // default values for private members not set
59  m_algoBitNumber = -1;
60  m_algoChipNumber = -1;
61 }
62 
63 // name, logical expression and bit number
65  const std::string& algoNameValue, const std::string& algoLogicalExpressionValue,
66  const int algoBitNumberValue) :
67  m_algoName(algoNameValue), m_algoLogicalExpression(algoLogicalExpressionValue),
68  m_algoBitNumber(algoBitNumberValue)
69 
70 {
72  m_algoRpnVector = logicParser.rpnVector();
73 
74  // default values for private members not set
75  m_algoChipNumber = -1;
76 
77 }
78 
79 // destructor
81 {
82  // empty
83 }
84 
85 // public methods
86 
87 // get the condition chip number the algorithm is located on
88 const int L1GtAlgorithm::algoChipNumber(const int numberConditionChips,
89  const int pinsOnConditionChip,
90  const std::vector<int>& orderConditionChip) const
91 {
92  int posChip = (m_algoBitNumber/pinsOnConditionChip) + 1;
93  for (int iChip = 0; iChip < numberConditionChips; ++iChip) {
94  if (posChip == orderConditionChip[iChip]) {
95  return iChip;
96  }
97  }
98 
99  // chip number not found
100  return -1;
101 }
102 
103 // get the output pin on the condition chip for the algorithm
104 const int L1GtAlgorithm::algoOutputPin(const int numberConditionChips,
105  const int pinsOnConditionChip,
106  const std::vector<int>& orderConditionChip) const
107 {
108 
109  int iChip = algoChipNumber(numberConditionChips, pinsOnConditionChip, orderConditionChip);
110 
111  int outputPin = m_algoBitNumber - (orderConditionChip[iChip] -1)*pinsOnConditionChip + 1;
112 
113  return outputPin;
114 }
115 
116 
117 
118 // print algorithm
119 void L1GtAlgorithm::print(std::ostream& myCout) const {
120 
121  myCout << std::endl;
122 
123  myCout << " Algorithm name: " << m_algoName << std::endl;
124  myCout << " Algorithm alias: " << m_algoAlias << std::endl;
125 
126  myCout << " Bit number: " << m_algoBitNumber;
127  if (m_algoBitNumber < 0) {
128  myCout << " - not properly initialized! " << std::endl;
129  }
130  else {
131  myCout << std::endl;
132  }
133 
134  myCout << " Located on chip number: " << m_algoChipNumber;
135  if (m_algoChipNumber < 0) {
136  myCout << " - not properly initialized! " << std::endl;
137  }
138  else {
139  myCout << std::endl;
140  }
141 
142  myCout << " Logical expresssion: " << m_algoLogicalExpression << std::endl;
143 
144  int rpnVectorSize = m_algoRpnVector.size();
145 
146  myCout << " RPN vector size: " << rpnVectorSize;
147 
148  if (rpnVectorSize == 0) {
149  myCout << " - not properly initialized! " << std::endl;
150  }
151  else {
152  myCout << std::endl;
153 
154  for (int i = 0; i < rpnVectorSize; ++i) {
155 
156  myCout << " ( " << (m_algoRpnVector[i]).operation << ", "
157  << (m_algoRpnVector[i]).operand << " )" << std::endl;
158  }
159 
160  }
161 
162  myCout << std::endl;
163 }
164 
165 // output stream operator
166 std::ostream& operator<<(std::ostream& os, const L1GtAlgorithm& result)
167 {
168  result.print(os);
169  return os;
170 
171 }
std::string m_algoLogicalExpression
algorithm logical expression
int i
Definition: DBlmapReader.cc:9
virtual void print(std::ostream &myCout) const
print condition
RpnVector rpnVector() const
return the RPN vector
virtual ~L1GtAlgorithm()
destructor
std::string m_algoAlias
algorithm alias
const int algoOutputPin(const int numberConditionChips, const int pinsOnConditionChip, const std::vector< int > &orderConditionChip) const
get the output pin on the condition chip for the algorithm
std::vector< L1GtLogicParser::TokenRPN > m_algoRpnVector
algorithm RPN vector
std::string m_algoName
algorithm name
const int algoChipNumber() const
get / set algorithm bit number
friend std::ostream & operator<<(std::ostream &, const L1GtAlgorithm &)
output stream operator
int m_algoChipNumber
chip number (redundant with bit number)