Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:50:22

0001 /**
0002  * \class GlobalObjectMap
0003  * 
0004  * 
0005  * Description: see header file.  
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *   
0010  * \author: Vasile Mihai Ghete - HEPHY Vienna
0011  * 
0012  *
0013  */
0014 
0015 // this class header
0016 #include "DataFormats/L1TGlobal/interface/GlobalObjectMap.h"
0017 
0018 // system include files
0019 #include <iostream>
0020 #include <iomanip>
0021 #include <iterator>
0022 
0023 #include <algorithm>
0024 
0025 // user include files
0026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0027 
0028 // forward declarations
0029 
0030 // methods
0031 
0032 // return all the combinations passing the requirements imposed in condition condNameVal
0033 const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const {
0034   for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
0035     if ((m_operandTokenVector[i]).tokenName == condNameVal) {
0036       return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
0037     }
0038   }
0039 
0040   // return a null address - should not arrive here
0041   edm::LogError("GlobalObjectMap") << "\n\n  ERROR: The requested condition with tokenName = " << condNameVal
0042                                    << "\n  does not exists in the operand token vector."
0043                                    << "\n  Returning zero pointer for getCombinationsInCond\n\n"
0044                                    << std::endl;
0045 
0046   return nullptr;
0047 }
0048 
0049 /// return all the combinations passing the requirements imposed in condition condNumberVal
0050 const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const {
0051   for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
0052     if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) {
0053       return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
0054     }
0055   }
0056 
0057   // return a null address - should not arrive here
0058   edm::LogError("GlobalObjectMap") << "\n\n  ERROR: The requested condition with tokenNumber = " << condNumberVal
0059                                    << "\n  does not exists in the operand token vector."
0060                                    << "\n  Returning zero pointer for getCombinationsInCond\n\n"
0061                                    << std::endl;
0062 
0063   return nullptr;
0064 }
0065 // return the result for the condition condNameVal
0066 const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) const {
0067   for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
0068     if ((m_operandTokenVector[i]).tokenName == condNameVal) {
0069       return (m_operandTokenVector[i]).tokenResult;
0070     }
0071   }
0072 
0073   // return false - should not arrive here
0074   edm::LogError("GlobalObjectMap") << "\n\n  ERROR: The requested condition with name = " << condNameVal
0075                                    << "\n  does not exists in the operand token vector."
0076                                    << "\n  Returning false for getConditionResult\n\n"
0077                                    << std::endl;
0078   return false;
0079 }
0080 
0081 void GlobalObjectMap::reset() {
0082   // name of the algorithm
0083   m_algoName.clear();
0084 
0085   // bit number for algorithm
0086   m_algoBitNumber = -1;
0087 
0088   // GTL result of the algorithm
0089   m_algoGtlResult = false;
0090 
0091   // vector of operand tokens for an algorithm
0092   m_operandTokenVector.clear();
0093 
0094   // vector of combinations for all conditions in an algorithm
0095   m_combinationVector.clear();
0096 }
0097 
0098 void GlobalObjectMap::print(std::ostream& myCout) const {
0099   myCout << "GlobalObjectMap: print " << std::endl;
0100 
0101   myCout << "  Algorithm name: " << m_algoName << std::endl;
0102   myCout << "    Bit number: " << m_algoBitNumber << std::endl;
0103   myCout << "    GTL result: " << m_algoGtlResult << std::endl;
0104 
0105   int operandTokenVectorSize = m_operandTokenVector.size();
0106 
0107   myCout << "    Operand token vector size: " << operandTokenVectorSize;
0108 
0109   if (operandTokenVectorSize == 0) {
0110     myCout << "   - not properly initialized! " << std::endl;
0111   } else {
0112     myCout << std::endl;
0113 
0114     for (int i = 0; i < operandTokenVectorSize; ++i) {
0115       myCout << "      " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t" << std::setw(25)
0116              << (m_operandTokenVector[i]).tokenName << "\t" << (m_operandTokenVector[i]).tokenResult << std::endl;
0117     }
0118   }
0119 
0120   myCout << "    CombinationVector size: " << m_combinationVector.size() << std::endl;
0121 
0122   myCout << "  conditions: " << std::endl;
0123 
0124   std::vector<CombinationsInCond>::const_iterator itVVV;
0125   int iCond = 0;
0126   for (itVVV = m_combinationVector.begin(); itVVV != m_combinationVector.end(); itVVV++) {
0127     std::string condName = (m_operandTokenVector[iCond]).tokenName;
0128     bool condResult = (m_operandTokenVector[iCond]).tokenResult;
0129 
0130     myCout << "    Condition " << condName << " evaluated to " << condResult << std::endl;
0131 
0132     myCout << "    List of combinations passing all requirements for this condition:" << std::endl;
0133 
0134     myCout << "    ";
0135 
0136     if ((*itVVV).empty()) {
0137       myCout << "(none)";
0138     } else {
0139       CombinationsInCond::const_iterator itVV;
0140       for (itVV = (*itVVV).begin(); itVV != (*itVVV).end(); itVV++) {
0141         myCout << "( ";
0142 
0143         std::copy((*itVV).begin(), (*itVV).end(), std::ostream_iterator<int>(myCout, " "));
0144 
0145         myCout << "); ";
0146       }
0147     }
0148     iCond++;
0149     myCout << "\n\n";
0150   }
0151 }