00001
00017
00018 #include "CondFormats/L1TObjects/interface/L1GtAlgorithm.h"
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 L1GtAlgorithm::L1GtAlgorithm()
00029 {
00030
00031
00032 m_algoBitNumber = -1;
00033 m_algoChipNumber = -1;
00034
00035 }
00036
00037
00038 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue)
00039 {
00040 m_algoName = algoNameValue;
00041
00042
00043
00044 m_algoBitNumber = -1;
00045 m_algoChipNumber = -1;
00046
00047 }
00048
00049
00050 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue,
00051 const std::string& algoLogicalExpressionValue)
00052 {
00053 m_algoName = algoNameValue;
00054
00055 m_algoLogicalExpression = algoLogicalExpressionValue;
00056
00057 L1GtLogicParser logicParser(m_algoLogicalExpression);
00058 m_algoRpnVector = logicParser.rpnVector();
00059
00060
00061 m_algoBitNumber = -1;
00062 m_algoChipNumber = -1;
00063 }
00064
00065
00066 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue,
00067 const std::string& algoLogicalExpressionValue,
00068 const int algoBitNumberValue)
00069 {
00070 m_algoName = algoNameValue;
00071
00072 m_algoLogicalExpression = algoLogicalExpressionValue;
00073
00074 m_algoBitNumber = algoBitNumberValue;
00075
00076 L1GtLogicParser logicParser(m_algoLogicalExpression);
00077 m_algoRpnVector = logicParser.rpnVector();
00078
00079
00080 m_algoChipNumber = -1;
00081
00082 }
00083
00084
00085 L1GtAlgorithm::~L1GtAlgorithm()
00086 {
00087
00088 }
00089
00090
00091
00092
00093 const int L1GtAlgorithm::algoChipNumber(const int numberConditionChips,
00094 const int pinsOnConditionChip,
00095 const std::vector<int>& orderConditionChip) const
00096 {
00097 int posChip = (m_algoBitNumber/pinsOnConditionChip) + 1;
00098 for (int iChip = 0; iChip < numberConditionChips; ++iChip) {
00099 if (posChip == orderConditionChip[iChip]) {
00100 return iChip;
00101 }
00102 }
00103
00104
00105 return -1;
00106 }
00107
00108
00109 const int L1GtAlgorithm::algoOutputPin(const int numberConditionChips,
00110 const int pinsOnConditionChip,
00111 const std::vector<int>& orderConditionChip) const
00112 {
00113
00114 int iChip = algoChipNumber(numberConditionChips, pinsOnConditionChip, orderConditionChip);
00115
00116 int outputPin = m_algoBitNumber - (orderConditionChip[iChip] -1)*pinsOnConditionChip + 1;
00117
00118 return outputPin;
00119 }
00120
00121
00122
00123
00124 void L1GtAlgorithm::print(std::ostream& myCout) const {
00125
00126 myCout << std::endl;
00127
00128 myCout << " Algorithm name: " << m_algoName << std::endl;
00129
00130 myCout << " Bit number: " << m_algoBitNumber;
00131 if (m_algoBitNumber < 0) {
00132 myCout << " - not properly initialized! " << std::endl;
00133 }
00134 else {
00135 myCout << std::endl;
00136 }
00137
00138 myCout << " Located on chip number: " << m_algoChipNumber;
00139 if (m_algoChipNumber < 0) {
00140 myCout << " - not properly initialized! " << std::endl;
00141 }
00142 else {
00143 myCout << std::endl;
00144 }
00145
00146 myCout << " Logical expresssion: " << m_algoLogicalExpression << std::endl;
00147
00148 int rpnVectorSize = m_algoRpnVector.size();
00149
00150 myCout << " RPN vector size: " << rpnVectorSize;
00151
00152 if (rpnVectorSize == 0) {
00153 myCout << " - not properly initialized! " << std::endl;
00154 }
00155 else {
00156 myCout << std::endl;
00157
00158 for (int i = 0; i < rpnVectorSize; ++i) {
00159
00160 myCout << " ( " << (m_algoRpnVector[i]).operation << ", "
00161 << (m_algoRpnVector[i]).operand << " )" << std::endl;
00162 }
00163
00164 }
00165
00166 myCout << std::endl;
00167 }