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