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  // default values for private members not set
32  // the other private members are C++ initialized
33  m_algoBitNumber = -1;
34  m_algoChipNumber = -1;
35 }
36 
37 // name only
38 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue) : m_algoName(algoNameValue) {
39  // default values for private members not set
40  // the other private members are C++ initialized
41  m_algoBitNumber = -1;
42  m_algoChipNumber = -1;
43 }
44 
45 // name and logical expression
46 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue, const std::string& algoLogicalExpressionValue)
47  : m_algoName(algoNameValue), m_algoLogicalExpression(algoLogicalExpressionValue) {
49  m_algoRpnVector = logicParser.rpnVector();
50 
51  // default values for private members not set
52  m_algoBitNumber = -1;
53  m_algoChipNumber = -1;
54 }
55 
56 // name, logical expression and bit number
58  const std::string& algoLogicalExpressionValue,
59  const int algoBitNumberValue)
60  : m_algoName(algoNameValue),
61  m_algoLogicalExpression(algoLogicalExpressionValue),
62  m_algoBitNumber(algoBitNumberValue)
63 
64 {
66  m_algoRpnVector = logicParser.rpnVector();
67 
68  // default values for private members not set
69  m_algoChipNumber = -1;
70 }
71 
72 // destructor
74  // empty
75 }
76 
77 // public methods
78 
79 // get the condition chip number the algorithm is located on
80 const int L1GtAlgorithm::algoChipNumber(const int numberConditionChips,
81  const int pinsOnConditionChip,
82  const std::vector<int>& orderConditionChip) const {
83  int posChip = (m_algoBitNumber / pinsOnConditionChip) + 1;
84  for (int iChip = 0; iChip < numberConditionChips; ++iChip) {
85  if (posChip == orderConditionChip[iChip]) {
86  return iChip;
87  }
88  }
89 
90  // chip number not found
91  return -1;
92 }
93 
94 // get the output pin on the condition chip for the algorithm
95 const int L1GtAlgorithm::algoOutputPin(const int numberConditionChips,
96  const int pinsOnConditionChip,
97  const std::vector<int>& orderConditionChip) const {
98  int iChip = algoChipNumber(numberConditionChips, pinsOnConditionChip, orderConditionChip);
99 
100  int outputPin = m_algoBitNumber - (orderConditionChip[iChip] - 1) * pinsOnConditionChip + 1;
101 
102  return outputPin;
103 }
104 
105 // print algorithm
106 void L1GtAlgorithm::print(std::ostream& myCout) const {
107  myCout << std::endl;
108 
109  myCout << " Algorithm name: " << m_algoName << std::endl;
110  myCout << " Algorithm alias: " << m_algoAlias << std::endl;
111 
112  myCout << " Bit number: " << m_algoBitNumber;
113  if (m_algoBitNumber < 0) {
114  myCout << " - not properly initialized! " << std::endl;
115  } else {
116  myCout << std::endl;
117  }
118 
119  myCout << " Located on chip number: " << m_algoChipNumber;
120  if (m_algoChipNumber < 0) {
121  myCout << " - not properly initialized! " << std::endl;
122  } else {
123  myCout << std::endl;
124  }
125 
126  myCout << " Logical expresssion: " << m_algoLogicalExpression << std::endl;
127 
128  int rpnVectorSize = m_algoRpnVector.size();
129 
130  myCout << " RPN vector size: " << rpnVectorSize;
131 
132  if (rpnVectorSize == 0) {
133  myCout << " - not properly initialized! " << std::endl;
134  } else {
135  myCout << std::endl;
136 
137  for (int i = 0; i < rpnVectorSize; ++i) {
138  myCout << " ( " << (m_algoRpnVector[i]).operation << ", " << (m_algoRpnVector[i]).operand << " )"
139  << std::endl;
140  }
141  }
142 
143  myCout << std::endl;
144 }
145 
146 // output stream operator
147 std::ostream& operator<<(std::ostream& os, const L1GtAlgorithm& result) {
148  result.print(os);
149  return os;
150 }
mps_fire.i
i
Definition: mps_fire.py:355
L1GtAlgorithm.h
L1GtAlgorithm::m_algoBitNumber
int m_algoBitNumber
Definition: L1GtAlgorithm.h:114
L1GtAlgorithm::m_algoRpnVector
std::vector< L1GtLogicParser::TokenRPN > m_algoRpnVector
algorithm RPN vector
Definition: L1GtAlgorithm.h:109
operator<<
std::ostream & operator<<(std::ostream &os, const L1GtAlgorithm &result)
Definition: L1GtAlgorithm.cc:147
L1GtAlgorithm::~L1GtAlgorithm
virtual ~L1GtAlgorithm()
destructor
Definition: L1GtAlgorithm.cc:73
L1GtAlgorithm::m_algoChipNumber
int m_algoChipNumber
chip number (redundant with bit number)
Definition: L1GtAlgorithm.h:117
L1GtAlgorithm::m_algoAlias
std::string m_algoAlias
algorithm alias
Definition: L1GtAlgorithm.h:103
L1GtAlgorithm::algoChipNumber
const int algoChipNumber() const
get / set algorithm bit number
Definition: L1GtAlgorithm.h:77
L1GtAlgorithm::algoOutputPin
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
Definition: L1GtAlgorithm.cc:95
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1GtAlgorithm::L1GtAlgorithm
L1GtAlgorithm()
Definition: L1GtAlgorithm.cc:30
L1GtAlgorithm
Definition: L1GtAlgorithm.h:32
L1GtAlgorithm::m_algoLogicalExpression
std::string m_algoLogicalExpression
algorithm logical expression
Definition: L1GtAlgorithm.h:106
L1GtAlgorithm::print
virtual void print(std::ostream &myCout) const
print condition
Definition: L1GtAlgorithm.cc:106
L1GtLogicParser
Definition: L1GtLogicParser.h:31
mps_fire.result
result
Definition: mps_fire.py:303
L1GtAlgorithm::m_algoName
std::string m_algoName
algorithm name
Definition: L1GtAlgorithm.h:100
L1GtLogicParser::rpnVector
RpnVector rpnVector() const
return the RPN vector
Definition: L1GtLogicParser.h:104