CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DataFormats/L1GlobalTrigger/src/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 
00036 
00037 // methods
00038 
00039 // return all the combinations passing the requirements imposed in condition condNameVal
00040 const CombinationsInCond* L1GlobalTriggerObjectMap::getCombinationsInCond(
00041     const std::string& condNameVal) const {
00042 
00043     for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
00044 
00045         if ((m_operandTokenVector[i]).tokenName == condNameVal) {
00046             return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
00047         }
00048 
00049     }
00050 
00051     // return a null address - should not arrive here
00052     edm::LogError("L1GlobalTriggerObjectMap")
00053         << "\n\n  ERROR: The requested condition with tokenName = " << condNameVal
00054         << "\n  does not exists in the operand token vector."
00055         << "\n  Returning zero pointer for getCombinationsInCond\n\n" << std::endl;
00056 
00057     return 0;
00058 
00059 }
00060 
00062 const CombinationsInCond* L1GlobalTriggerObjectMap::getCombinationsInCond(const int condNumberVal) const {
00063 
00064     for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
00065 
00066         if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) {
00067             return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
00068         }
00069 
00070     }
00071 
00072     // return a null address - should not arrive here
00073     edm::LogError("L1GlobalTriggerObjectMap")
00074         << "\n\n  ERROR: The requested condition with tokenNumber = " << condNumberVal
00075         << "\n  does not exists in the operand token vector."
00076         << "\n  Returning zero pointer for getCombinationsInCond\n\n" << std::endl;
00077 
00078     return 0;
00079 
00080 }
00081 // return the result for the condition condNameVal
00082 const bool L1GlobalTriggerObjectMap::getConditionResult(const std::string& condNameVal) const {
00083 
00084     for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
00085 
00086         if ((m_operandTokenVector[i]).tokenName == condNameVal) {
00087             return (m_operandTokenVector[i]).tokenResult;
00088         }
00089     }
00090 
00091     // return false - should not arrive here
00092     edm::LogError("L1GlobalTriggerObjectMap")
00093         << "\n\n  ERROR: The requested condition with name = " << condNameVal
00094         << "\n  does not exists in the operand token vector."
00095         << "\n  Returning false for getConditionResult\n\n" << std::endl;
00096     return false;
00097 
00098 }
00099 
00100 
00101 void L1GlobalTriggerObjectMap::reset()
00102 {
00103 
00104     // name of the algorithm
00105     m_algoName.clear();
00106 
00107     // bit number for algorithm
00108     m_algoBitNumber = -1;
00109 
00110     // GTL result of the algorithm
00111     m_algoGtlResult = false;
00112 
00113     // vector of operand tokens for an algorithm 
00114     m_operandTokenVector.clear();
00115     
00116     // vector of combinations for all conditions in an algorithm
00117     m_combinationVector.clear();
00118 
00119 }
00120 
00121 void L1GlobalTriggerObjectMap::print(std::ostream& myCout) const
00122 {
00123 
00124     myCout << "L1GlobalTriggerObjectMap: print " << std::endl;
00125 
00126     myCout << "  Algorithm name: " << m_algoName << std::endl;
00127     myCout << "    Bit number: " << m_algoBitNumber << std::endl;
00128     myCout << "    GTL result: " << m_algoGtlResult << std::endl;
00129 
00130     int operandTokenVectorSize = m_operandTokenVector.size();
00131 
00132     myCout << "    Operand token vector size: " << operandTokenVectorSize;
00133 
00134     if (operandTokenVectorSize == 0) {
00135         myCout << "   - not properly initialized! " << std::endl;
00136     }
00137     else {
00138         myCout << std::endl;
00139 
00140         for (int i = 0; i < operandTokenVectorSize; ++i) {
00141 
00142             myCout << "      " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t"
00143             << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t" 
00144             << (m_operandTokenVector[i]).tokenResult 
00145             << std::endl;
00146         }
00147 
00148     }
00149 
00150     myCout << "    CombinationVector size: " << m_combinationVector.size() << std::endl;
00151 
00152     myCout << "  conditions: "  << std::endl;
00153 
00154     std::vector<CombinationsInCond>::const_iterator itVVV;
00155     int iCond = 0;
00156     for(itVVV  = m_combinationVector.begin();
00157             itVVV != m_combinationVector.end(); itVVV++) {
00158 
00159         std::string condName = (m_operandTokenVector[iCond]).tokenName;
00160         bool condResult = (m_operandTokenVector[iCond]).tokenResult;
00161 
00162         myCout << "    Condition " << condName << " evaluated to " << condResult
00163         << std::endl;
00164 
00165         myCout << "    List of combinations passing all requirements for this condition:"
00166         << std::endl;
00167 
00168         myCout << "    ";
00169 
00170         if ((*itVVV).size() == 0) {
00171             myCout << "(none)";
00172         } else {
00173 
00174             CombinationsInCond::const_iterator itVV;
00175             for(itVV  = (*itVVV).begin(); itVV != (*itVVV).end(); itVV++) {
00176 
00177                 myCout << "( ";
00178 
00179                 std::copy((*itVV).begin(), (*itVV).end(),
00180                           std::ostream_iterator<int> (myCout, " "));
00181 
00182                 myCout << "); ";
00183 
00184             }
00185 
00186         }
00187         iCond++;
00188         myCout << "\n\n";
00189     }
00190 }
00191