Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-14 23:16:43

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 #include "DataFormats/L1TGlobal/interface/GlobalObjectMap.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 
0018 #include <iostream>
0019 #include <iomanip>
0020 #include <iterator>
0021 #include <algorithm>
0022 
0023 /// return all the combinations passing the requirements imposed in condition condNameVal
0024 const CombinationsWithBxInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const {
0025   for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
0026     if ((m_operandTokenVector[i]).tokenName == condNameVal) {
0027       return &(m_combinationWithBxVector.at((m_operandTokenVector[i]).tokenNumber));
0028     }
0029   }
0030 
0031   // return a null address - should not arrive here
0032   edm::LogError("GlobalObjectMap") << "\n\n  ERROR: The requested condition with tokenName = " << condNameVal
0033                                    << "\n  does not exists in the operand token vector."
0034                                    << "\n  Returning zero pointer for getCombinationsInCond\n\n";
0035 
0036   return nullptr;
0037 }
0038 
0039 /// return all the combinations passing the requirements imposed in condition condNumberVal
0040 const CombinationsWithBxInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const {
0041   for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
0042     if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) {
0043       return &(m_combinationWithBxVector.at((m_operandTokenVector[i]).tokenNumber));
0044     }
0045   }
0046 
0047   // return a null address - should not arrive here
0048   edm::LogError("GlobalObjectMap") << "\n\n  ERROR: The requested condition with tokenNumber = " << condNumberVal
0049                                    << "\n  does not exists in the operand token vector."
0050                                    << "\n  Returning zero pointer for getCombinationsInCond\n\n";
0051 
0052   return nullptr;
0053 }
0054 
0055 /// return the result for the condition condNameVal
0056 const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) const {
0057   for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
0058     if ((m_operandTokenVector[i]).tokenName == condNameVal) {
0059       return (m_operandTokenVector[i]).tokenResult;
0060     }
0061   }
0062 
0063   // return false - should not arrive here
0064   edm::LogError("GlobalObjectMap") << "\n\n  ERROR: The requested condition with name = " << condNameVal
0065                                    << "\n  does not exists in the operand token vector."
0066                                    << "\n  Returning false for getConditionResult\n\n";
0067 
0068   return false;
0069 }
0070 
0071 void GlobalObjectMap::reset() {
0072   // name of the algorithm
0073   m_algoName.clear();
0074 
0075   // bit number for algorithm
0076   m_algoBitNumber = -1;
0077 
0078   // GTL result of the algorithm
0079   m_algoGtlResult = false;
0080 
0081   // vector of operand tokens for an algorithm
0082   m_operandTokenVector.clear();
0083 
0084   // vector of combinations for all conditions in an algorithm
0085   m_combinationWithBxVector.clear();
0086 }
0087 
0088 void GlobalObjectMap::print(std::ostream& myCout) const {
0089   myCout << "GlobalObjectMap: print " << std::endl;
0090 
0091   myCout << "  Algorithm name: " << m_algoName << std::endl;
0092   myCout << "    Bit number: " << m_algoBitNumber << std::endl;
0093   myCout << "    GTL result: " << m_algoGtlResult << std::endl;
0094 
0095   int operandTokenVectorSize = m_operandTokenVector.size();
0096 
0097   myCout << "    Operand token vector size: " << operandTokenVectorSize;
0098 
0099   if (operandTokenVectorSize == 0) {
0100     myCout << "   - not properly initialized! " << std::endl;
0101   } else {
0102     myCout << std::endl;
0103 
0104     for (int i = 0; i < operandTokenVectorSize; ++i) {
0105       myCout << "      " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t" << std::setw(25)
0106              << (m_operandTokenVector[i]).tokenName << "\t" << (m_operandTokenVector[i]).tokenResult << std::endl;
0107     }
0108   }
0109 
0110   myCout << "    CombinationWithBxVector size: " << m_combinationWithBxVector.size() << std::endl;
0111 
0112   myCout << "  conditions: " << std::endl;
0113 
0114   for (size_t i1 = 0; i1 < m_combinationWithBxVector.size(); ++i1) {
0115     auto const& condName = m_operandTokenVector[i1].tokenName;
0116     auto const condResult = m_operandTokenVector[i1].tokenResult;
0117     myCout << "    Condition " << condName << " evaluated to " << condResult << std::endl;
0118     myCout << "    List of combinations passing all requirements for this condition:" << std::endl;
0119     myCout << "    ";
0120 
0121     if (m_combinationWithBxVector[i1].empty()) {
0122       myCout << "(none)";
0123     } else {
0124       for (size_t i2 = 0; i2 < m_combinationWithBxVector[i1].size(); ++i2) {
0125         myCout << "( ";
0126         for (size_t i3 = 0; i3 < m_combinationWithBxVector[i1][i2].size(); ++i3) {
0127           myCout << m_combinationWithBxVector[i1][i2][i3].first << ":";
0128           myCout << m_combinationWithBxVector[i1][i2][i3].second << " ";
0129         }
0130         myCout << "); ";
0131       }
0132     }
0133     myCout << "\n\n";
0134   }
0135 }