CMS 3D CMS Logo

L1GlobalTriggerObjectMap.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
00019 
00020 // system include files
00021 #include <iostream>
00022 #include <iomanip>
00023 #include <iterator>
00024 
00025 
00026 #include <algorithm>
00027 
00028 // user include files
00029 #include "DataFormats/L1GlobalTrigger/interface/L1GtLogicParser.h"
00030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00031 
00032 // forward declarations
00033 
00034 
00035 // constructor(s)
00036 L1GlobalTriggerObjectMap::L1GlobalTriggerObjectMap() {
00037 
00038     //empty
00039 
00040 }
00041 
00042 // destructor
00043 L1GlobalTriggerObjectMap::~L1GlobalTriggerObjectMap() {
00044 
00045     //empty
00046 
00047 }
00048 
00049 // methods
00050 
00051 // return all the combinations passing the requirements imposed in condition condNameVal
00052 const CombinationsInCond* L1GlobalTriggerObjectMap::getCombinationsInCond(
00053     const std::string& condNameVal) const {
00054 
00055     for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
00056 
00057         if ((m_operandTokenVector[i]).tokenName == condNameVal) {
00058             return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
00059         }
00060 
00061     }
00062 
00063     // return a null address - should not arrive here
00064     edm::LogError("L1GlobalTriggerObjectMap")
00065         << "\n\n  ERROR: The requested condition with tokenName = " << condNameVal
00066         << "\n  does not exists in the operand token vector."
00067         << "\n  Returning zero pointer for getCombinationsInCond\n\n" << std::endl;
00068 
00069     return 0;
00070 
00071 }
00072 
00074 const CombinationsInCond* L1GlobalTriggerObjectMap::getCombinationsInCond(const int condNumberVal) const {
00075 
00076     for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
00077 
00078         if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) {
00079             return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
00080         }
00081 
00082     }
00083 
00084     // return a null address - should not arrive here
00085     edm::LogError("L1GlobalTriggerObjectMap")
00086         << "\n\n  ERROR: The requested condition with tokenNumber = " << condNumberVal
00087         << "\n  does not exists in the operand token vector."
00088         << "\n  Returning zero pointer for getCombinationsInCond\n\n" << std::endl;
00089 
00090     return 0;
00091 
00092 }
00093 // return the result for the condition condNameVal
00094 const bool L1GlobalTriggerObjectMap::getConditionResult(const std::string& condNameVal) const {
00095 
00096     for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
00097 
00098         if ((m_operandTokenVector[i]).tokenName == condNameVal) {
00099             return (m_operandTokenVector[i]).tokenResult;
00100         }
00101     }
00102 
00103     // return false - should not arrive here
00104     edm::LogError("L1GlobalTriggerObjectMap")
00105         << "\n\n  ERROR: The requested condition with name = " << condNameVal
00106         << "\n  does not exists in the operand token vector."
00107         << "\n  Returning false for getConditionResult\n\n" << std::endl;
00108     return false;
00109 
00110 }
00111 
00112 
00113 void L1GlobalTriggerObjectMap::reset()
00114 {
00115 
00116     // name of the algorithm
00117     m_algoName.clear();
00118 
00119     // bit number for algorithm
00120     m_algoBitNumber = -1;
00121 
00122     // GTL result of the algorithm
00123     m_algoGtlResult = false;
00124 
00125     // vector of operand tokens for an algorithm 
00126     m_operandTokenVector.clear();
00127     
00128     // vector of combinations for all conditions in an algorithm
00129     m_combinationVector.clear();
00130 
00131 }
00132 
00133 void L1GlobalTriggerObjectMap::print(std::ostream& myCout) const
00134 {
00135 
00136     myCout << "L1GlobalTriggerObjectMap: print " << std::endl;
00137 
00138     myCout << "  Algorithm name: " << m_algoName << std::endl;
00139     myCout << "    Bit number: " << m_algoBitNumber << std::endl;
00140     myCout << "    GTL result: " << m_algoGtlResult << std::endl;
00141 
00142     int operandTokenVectorSize = m_operandTokenVector.size();
00143 
00144     myCout << "    Operand token vector size: " << operandTokenVectorSize;
00145 
00146     if (operandTokenVectorSize == 0) {
00147         myCout << "   - not properly initialized! " << std::endl;
00148     }
00149     else {
00150         myCout << std::endl;
00151 
00152         for (int i = 0; i < operandTokenVectorSize; ++i) {
00153 
00154             myCout << "      " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t"
00155             << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t" 
00156             << (m_operandTokenVector[i]).tokenResult 
00157             << std::endl;
00158         }
00159 
00160     }
00161 
00162     myCout << "    CombinationVector size: " << m_combinationVector.size() << std::endl;
00163 
00164     myCout << "  conditions: "  << std::endl;
00165 
00166     std::vector<CombinationsInCond>::const_iterator itVVV;
00167     int iCond = 0;
00168     for(itVVV  = m_combinationVector.begin();
00169             itVVV != m_combinationVector.end(); itVVV++) {
00170 
00171         std::string condName = (m_operandTokenVector[iCond]).tokenName;
00172         bool condResult = (m_operandTokenVector[iCond]).tokenResult;
00173 
00174         myCout << "    Condition " << condName << " evaluated to " << condResult
00175         << std::endl;
00176 
00177         myCout << "    List of combinations passing all requirements for this condition:"
00178         << std::endl;
00179 
00180         myCout << "    ";
00181 
00182         if ((*itVVV).size() == 0) {
00183             myCout << "(none)";
00184         } else {
00185 
00186             CombinationsInCond::const_iterator itVV;
00187             for(itVV  = (*itVVV).begin(); itVV != (*itVVV).end(); itVV++) {
00188 
00189                 myCout << "( ";
00190 
00191                 std::copy((*itVV).begin(), (*itVV).end(),
00192                           std::ostream_iterator<int> (myCout, " "));
00193 
00194                 myCout << "); ";
00195 
00196             }
00197 
00198         }
00199         iCond++;
00200         myCout << "\n\n";
00201     }
00202 }
00203 

Generated on Tue Jun 9 17:31:13 2009 for CMSSW by  doxygen 1.5.4