Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:49

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