CMS 3D CMS Logo

GlobalAlgorithm.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 GlobalAlgorithm::GlobalAlgorithm(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 GlobalAlgorithm::GlobalAlgorithm(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 GlobalAlgorithm::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 GlobalAlgorithm::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 GlobalAlgorithm::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 GlobalAlgorithm& result) {
148  result.print(os);
149  return os;
150 }
mps_fire.i
i
Definition: mps_fire.py:355
GlobalAlgorithm::m_algoBitNumber
int m_algoBitNumber
Definition: GlobalAlgorithm.h:114
GlobalAlgorithm::m_algoAlias
std::string m_algoAlias
algorithm alias
Definition: GlobalAlgorithm.h:103
GlobalAlgorithm::~GlobalAlgorithm
virtual ~GlobalAlgorithm()
destructor
Definition: GlobalAlgorithm.cc:73
GlobalAlgorithm::m_algoChipNumber
int m_algoChipNumber
chip number (redundant with bit number)
Definition: GlobalAlgorithm.h:117
GlobalAlgorithm.h
GlobalAlgorithm
Definition: GlobalAlgorithm.h:32
GlobalAlgorithm::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: GlobalAlgorithm.cc:95
GlobalLogicParser
Definition: GlobalLogicParser.h:17
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
operator<<
std::ostream & operator<<(std::ostream &os, const GlobalAlgorithm &result)
Definition: GlobalAlgorithm.cc:147
GlobalLogicParser::rpnVector
RpnVector rpnVector() const
return the RPN vector
Definition: GlobalLogicParser.h:93
GlobalAlgorithm::m_algoLogicalExpression
std::string m_algoLogicalExpression
algorithm logical expression
Definition: GlobalAlgorithm.h:106
GlobalAlgorithm::GlobalAlgorithm
GlobalAlgorithm()
Definition: GlobalAlgorithm.cc:30
GlobalAlgorithm::m_algoRpnVector
std::vector< GlobalLogicParser::TokenRPN > m_algoRpnVector
algorithm RPN vector
Definition: GlobalAlgorithm.h:109
GlobalAlgorithm::print
virtual void print(std::ostream &myCout) const
print condition
Definition: GlobalAlgorithm.cc:106
GlobalAlgorithm::m_algoName
std::string m_algoName
algorithm name
Definition: GlobalAlgorithm.h:100
mps_fire.result
result
Definition: mps_fire.py:303
GlobalAlgorithm::algoChipNumber
const int algoChipNumber() const
get / set algorithm bit number
Definition: GlobalAlgorithm.h:77