Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:19

0001 /**
0002  * \class L1GtAlgorithm
0003  *
0004  *
0005  * Description: L1 GT algorithm.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: Vasile Mihai Ghete - HEPHY Vienna
0011  *
0012  * $Date$
0013  * $Revision$
0014  *
0015  */
0016 
0017 // this class header
0018 #include "CondFormats/L1TObjects/interface/L1GtAlgorithm.h"
0019 
0020 // system include files
0021 #include <iostream>
0022 #include <iomanip>
0023 
0024 // user include files
0025 
0026 // forward declarations
0027 
0028 // constructor(s)
0029 //   default
0030 L1GtAlgorithm::L1GtAlgorithm() {
0031   // default values for private members not set
0032   // the other private members are C++ initialized
0033   m_algoBitNumber = -1;
0034   m_algoChipNumber = -1;
0035 }
0036 
0037 //   name only
0038 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue) : m_algoName(algoNameValue) {
0039   // default values for private members not set
0040   // the other private members are C++ initialized
0041   m_algoBitNumber = -1;
0042   m_algoChipNumber = -1;
0043 }
0044 
0045 //   name and logical expression
0046 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue, const std::string& algoLogicalExpressionValue)
0047     : m_algoName(algoNameValue), m_algoLogicalExpression(algoLogicalExpressionValue) {
0048   L1GtLogicParser logicParser(m_algoLogicalExpression);
0049   m_algoRpnVector = logicParser.rpnVector();
0050 
0051   // default values for private members not set
0052   m_algoBitNumber = -1;
0053   m_algoChipNumber = -1;
0054 }
0055 
0056 //   name, logical expression and bit number
0057 L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue,
0058                              const std::string& algoLogicalExpressionValue,
0059                              const int algoBitNumberValue)
0060     : m_algoName(algoNameValue),
0061       m_algoLogicalExpression(algoLogicalExpressionValue),
0062       m_algoBitNumber(algoBitNumberValue)
0063 
0064 {
0065   L1GtLogicParser logicParser(m_algoLogicalExpression);
0066   m_algoRpnVector = logicParser.rpnVector();
0067 
0068   // default values for private members not set
0069   m_algoChipNumber = -1;
0070 }
0071 
0072 // destructor
0073 L1GtAlgorithm::~L1GtAlgorithm() {
0074   // empty
0075 }
0076 
0077 // public methods
0078 
0079 // get the condition chip number the algorithm is located on
0080 const int L1GtAlgorithm::algoChipNumber(const int numberConditionChips,
0081                                         const int pinsOnConditionChip,
0082                                         const std::vector<int>& orderConditionChip) const {
0083   int posChip = (m_algoBitNumber / pinsOnConditionChip) + 1;
0084   for (int iChip = 0; iChip < numberConditionChips; ++iChip) {
0085     if (posChip == orderConditionChip[iChip]) {
0086       return iChip;
0087     }
0088   }
0089 
0090   // chip number not found
0091   return -1;
0092 }
0093 
0094 // get the output pin on the condition chip for the algorithm
0095 const int L1GtAlgorithm::algoOutputPin(const int numberConditionChips,
0096                                        const int pinsOnConditionChip,
0097                                        const std::vector<int>& orderConditionChip) const {
0098   int iChip = algoChipNumber(numberConditionChips, pinsOnConditionChip, orderConditionChip);
0099 
0100   int outputPin = m_algoBitNumber - (orderConditionChip[iChip] - 1) * pinsOnConditionChip + 1;
0101 
0102   return outputPin;
0103 }
0104 
0105 // print algorithm
0106 void L1GtAlgorithm::print(std::ostream& myCout) const {
0107   myCout << std::endl;
0108 
0109   myCout << "    Algorithm name:         " << m_algoName << std::endl;
0110   myCout << "    Algorithm alias:        " << m_algoAlias << std::endl;
0111 
0112   myCout << "    Bit number:             " << m_algoBitNumber;
0113   if (m_algoBitNumber < 0) {
0114     myCout << "   - not properly initialized! " << std::endl;
0115   } else {
0116     myCout << std::endl;
0117   }
0118 
0119   myCout << "    Located on chip number: " << m_algoChipNumber;
0120   if (m_algoChipNumber < 0) {
0121     myCout << "   - not properly initialized! " << std::endl;
0122   } else {
0123     myCout << std::endl;
0124   }
0125 
0126   myCout << "    Logical expresssion:    " << m_algoLogicalExpression << std::endl;
0127 
0128   int rpnVectorSize = m_algoRpnVector.size();
0129 
0130   myCout << "    RPN vector size:        " << rpnVectorSize;
0131 
0132   if (rpnVectorSize == 0) {
0133     myCout << "   - not properly initialized! " << std::endl;
0134   } else {
0135     myCout << std::endl;
0136 
0137     for (int i = 0; i < rpnVectorSize; ++i) {
0138       myCout << "      ( " << (m_algoRpnVector[i]).operation << ", " << (m_algoRpnVector[i]).operand << " )"
0139              << std::endl;
0140     }
0141   }
0142 
0143   myCout << std::endl;
0144 }
0145 
0146 // output stream operator
0147 std::ostream& operator<<(std::ostream& os, const L1GtAlgorithm& result) {
0148   result.print(os);
0149   return os;
0150 }