CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CondFormats/L1TObjects/src/L1GtAlgorithm.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "CondFormats/L1TObjects/interface/L1GtAlgorithm.h"
00019 
00020 // system include files
00021 #include <iostream>
00022 #include <iomanip>
00023 
00024 // user include files
00025 
00026 // forward declarations
00027 
00028 // constructor(s)
00029 //   default
00030 L1GtAlgorithm::L1GtAlgorithm()
00031 {
00032     // default values for private members not set
00033     // the other private members are C++ initialized
00034     m_algoBitNumber = -1;
00035     m_algoChipNumber = -1;
00036 
00037 }
00038 
00039 //   name only
00040 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue) :
00041     m_algoName(algoNameValue) {
00042 
00043     // default values for private members not set
00044     // the other private members are C++ initialized
00045     m_algoBitNumber = -1;
00046     m_algoChipNumber = -1;
00047 
00048 }
00049 
00050 //   name and logical expression
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     // default values for private members not set
00059     m_algoBitNumber = -1;
00060     m_algoChipNumber = -1;
00061 }
00062 
00063 //   name, logical expression and bit number
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     // default values for private members not set
00075     m_algoChipNumber = -1;
00076 
00077 }
00078 
00079 // destructor
00080 L1GtAlgorithm::~L1GtAlgorithm()
00081 {
00082     // empty
00083 }
00084 
00085 // public methods
00086 
00087 // get the condition chip number the algorithm is located on
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     // chip number not found
00100     return -1;
00101 }
00102 
00103 // get the output pin on the condition chip for the algorithm
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 // print algorithm
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 // output stream operator
00166 std::ostream& operator<<(std::ostream& os, const L1GtAlgorithm& result)
00167 {
00168     result.print(os);
00169     return os;
00170 
00171 }