CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DataFormats/L1GlobalTrigger/src/L1GtTriggerMenuLite.cc

Go to the documentation of this file.
00001 
00026 // this class header
00027 #include "DataFormats/L1GlobalTrigger/interface/L1GtTriggerMenuLite.h"
00028 
00029 // system include files
00030 #include <iostream>
00031 #include <iomanip>
00032 
00033 // user include files
00034 
00035 
00036 // forward declarations
00037 
00038 // constructor
00039 L1GtTriggerMenuLite::L1GtTriggerMenuLite() :
00040     m_triggerMenuInterface("NULL"), m_triggerMenuName("NULL"),
00041             m_triggerMenuImplementation("NULL"), m_scaleDbKey("NULL") {
00042 
00043     // empty
00044 
00045 }
00046 
00047 L1GtTriggerMenuLite::L1GtTriggerMenuLite(
00048         const std::string& triggerMenuNameVal,
00049         const L1TriggerMap& algorithmMapVal,
00050         const L1TriggerMap& algorithmAliasMapVal,
00051         const L1TriggerMap& technicalTriggerMapVal,
00052         const std::vector<unsigned int>& triggerMaskAlgoTrigVal,
00053         const std::vector<unsigned int>& triggerMaskTechTrigVal,
00054         const std::vector<std::vector<int> >& prescaleFactorsAlgoTrigVal,
00055         const std::vector<std::vector<int> >& prescaleFactorsTechTrigVal)
00056         :
00057     m_triggerMenuInterface("NULL"),
00058     m_triggerMenuName(triggerMenuNameVal),
00059     m_triggerMenuImplementation("NULL"),
00060     m_scaleDbKey("NULL"),
00061     m_algorithmMap(algorithmMapVal),
00062     m_algorithmAliasMap(algorithmAliasMapVal),
00063     m_technicalTriggerMap(technicalTriggerMapVal),
00064     m_triggerMaskAlgoTrig(triggerMaskAlgoTrigVal),
00065     m_triggerMaskTechTrig(triggerMaskTechTrigVal),
00066     m_prescaleFactorsAlgoTrig(prescaleFactorsAlgoTrigVal),
00067     m_prescaleFactorsTechTrig(prescaleFactorsTechTrigVal)
00068 
00069 
00070     {
00071 
00072     // empty
00073 
00074 }
00075 
00076 // copy constructor
00077 L1GtTriggerMenuLite::L1GtTriggerMenuLite(const L1GtTriggerMenuLite& rhs) {
00078 
00079     m_triggerMenuInterface = rhs.m_triggerMenuInterface;
00080     m_triggerMenuName = rhs.m_triggerMenuName;
00081     m_triggerMenuImplementation = rhs.m_triggerMenuImplementation;
00082     m_scaleDbKey = rhs.m_scaleDbKey;
00083 
00084     // copy algorithm map
00085     m_algorithmMap = rhs.m_algorithmMap;
00086     m_algorithmAliasMap = rhs.m_algorithmAliasMap;
00087 
00088     // copy technical triggers
00089     // (separate map for technical triggers and physics triggers)
00090     m_technicalTriggerMap = rhs.m_technicalTriggerMap;
00091 
00092     // copy masks
00093     m_triggerMaskAlgoTrig = rhs.m_triggerMaskAlgoTrig;
00094     m_triggerMaskTechTrig = rhs.m_triggerMaskTechTrig;
00095 
00096     // copy prescale factors
00097     m_prescaleFactorsAlgoTrig = rhs.m_prescaleFactorsAlgoTrig;
00098     m_prescaleFactorsTechTrig = rhs.m_prescaleFactorsTechTrig;
00099 
00100 }
00101 
00102 // destructor
00103 L1GtTriggerMenuLite::~L1GtTriggerMenuLite()
00104 {
00105 
00106     m_algorithmMap.clear();
00107     m_algorithmAliasMap.clear();
00108     m_technicalTriggerMap.clear();
00109 
00110 }
00111 
00112 // assignment operator
00113 L1GtTriggerMenuLite& L1GtTriggerMenuLite::operator=(
00114         const L1GtTriggerMenuLite& rhs) {
00115 
00116     if (this != &rhs) {
00117 
00118         m_triggerMenuInterface = rhs.m_triggerMenuInterface;
00119         m_triggerMenuName = rhs.m_triggerMenuName;
00120         m_triggerMenuImplementation = rhs.m_triggerMenuImplementation;
00121         m_scaleDbKey = rhs.m_scaleDbKey;
00122 
00123         m_algorithmMap = rhs.m_algorithmMap;
00124         m_algorithmAliasMap = rhs.m_algorithmAliasMap;
00125 
00126         m_technicalTriggerMap = rhs.m_technicalTriggerMap;
00127 
00128         m_triggerMaskAlgoTrig = rhs.m_triggerMaskAlgoTrig;
00129         m_triggerMaskTechTrig = rhs.m_triggerMaskTechTrig;
00130 
00131         m_prescaleFactorsAlgoTrig = rhs.m_prescaleFactorsAlgoTrig;
00132         m_prescaleFactorsTechTrig = rhs.m_prescaleFactorsTechTrig;
00133     }
00134 
00135     // return the object
00136     return *this;
00137 
00138 }
00139 
00140 // equal operator
00141 bool L1GtTriggerMenuLite::operator==(const L1GtTriggerMenuLite& rhs) const {
00142 
00143     if (m_triggerMenuInterface != rhs.m_triggerMenuInterface) {
00144         return false;
00145     }
00146 
00147     if (m_triggerMenuName != rhs.m_triggerMenuName) {
00148         return false;
00149     }
00150 
00151     if (m_triggerMenuImplementation != rhs.m_triggerMenuImplementation) {
00152         return false;
00153     }
00154 
00155     if (m_scaleDbKey != rhs.m_scaleDbKey) {
00156         return false;
00157     }
00158 
00159     if (m_algorithmMap != rhs.m_algorithmMap) {
00160         return false;
00161     }
00162 
00163     if (m_algorithmAliasMap != rhs.m_algorithmAliasMap) {
00164         return false;
00165     }
00166 
00167     if (m_technicalTriggerMap != rhs.m_technicalTriggerMap) {
00168         return false;
00169     }
00170 
00171     if (m_triggerMaskAlgoTrig != rhs.m_triggerMaskAlgoTrig) {
00172         return false;
00173     }
00174 
00175     if (m_triggerMaskTechTrig != rhs.m_triggerMaskTechTrig) {
00176         return false;
00177     }
00178 
00179     if (m_prescaleFactorsAlgoTrig != rhs.m_prescaleFactorsAlgoTrig) {
00180         return false;
00181     }
00182 
00183     if (m_prescaleFactorsTechTrig != rhs.m_prescaleFactorsTechTrig) {
00184         return false;
00185     }
00186 
00187     // all members identical
00188     return true;
00189 
00190 }
00191 
00192 // unequal operator
00193 bool L1GtTriggerMenuLite::operator!=(const L1GtTriggerMenuLite& otherObj) const {
00194 
00195     return !(otherObj == *this);
00196 
00197 }
00198 
00199 // merge rule: test on isProductEqual
00200 bool L1GtTriggerMenuLite::isProductEqual(const L1GtTriggerMenuLite& otherObj) const {
00201 
00202     return (otherObj == *this);
00203 }
00204 
00205 
00206 // set the trigger menu name
00207 void L1GtTriggerMenuLite::setGtTriggerMenuInterface(
00208         const std::string& menuInterface) {
00209     m_triggerMenuInterface = menuInterface;
00210 }
00211 
00212 void L1GtTriggerMenuLite::setGtTriggerMenuName(const std::string& menuName) {
00213     m_triggerMenuName = menuName;
00214 }
00215 
00216 void L1GtTriggerMenuLite::setGtTriggerMenuImplementation(
00217         const std::string& menuImplementation) {
00218     m_triggerMenuImplementation = menuImplementation;
00219 }
00220 
00221 // set menu associated scale key
00222 void L1GtTriggerMenuLite::setGtScaleDbKey(const std::string& scaleKey) {
00223     m_scaleDbKey = scaleKey;
00224 }
00225 
00226 // set the algorithm map (by algorithm names)
00227 void L1GtTriggerMenuLite::setGtAlgorithmMap(const L1TriggerMap& algoMap) {
00228     m_algorithmMap = algoMap;
00229 }
00230 
00231 // set the algorithm map (by algorithm aliases)
00232 void L1GtTriggerMenuLite::setGtAlgorithmAliasMap(const L1TriggerMap& algoMap) {
00233     m_algorithmAliasMap = algoMap;
00234 }
00235 
00236 // set the technical trigger map
00237 void L1GtTriggerMenuLite::setGtTechnicalTriggerMap(const L1TriggerMap& ttMap) {
00238     m_technicalTriggerMap = ttMap;
00239 }
00240 
00241 // set the trigger mask for physics algorithms
00242 void L1GtTriggerMenuLite::setGtTriggerMaskAlgoTrig(
00243         const std::vector<unsigned int>& maskValue) {
00244 
00245     m_triggerMaskAlgoTrig = maskValue;
00246 
00247 }
00248 
00249 // set the trigger mask for technical triggers
00250 void L1GtTriggerMenuLite::setGtTriggerMaskTechTrig(const std::vector<unsigned int>& maskValue)
00251 {
00252 
00253     m_triggerMaskTechTrig = maskValue;
00254 
00255 }
00256 
00257 
00258 // set the prescale factors
00259 void L1GtTriggerMenuLite::setGtPrescaleFactorsAlgoTrig(
00260         const std::vector<std::vector<int> >& factorValue) {
00261 
00262     m_prescaleFactorsAlgoTrig = factorValue;
00263 
00264 }
00265 
00266 void L1GtTriggerMenuLite::setGtPrescaleFactorsTechTrig(
00267         const std::vector<std::vector<int> >& factorValue) {
00268 
00269     m_prescaleFactorsTechTrig = factorValue;
00270 
00271 }
00272 
00273 // print the trigger menu
00274 void L1GtTriggerMenuLite::print(std::ostream& myCout, int& printVerbosity) const {
00275 
00276     //
00277 
00278     switch (printVerbosity) {
00279 
00280         case 0: {
00281 
00282             size_t nrDefinedAlgo = m_algorithmMap.size();
00283             size_t nrDefinedTech = m_technicalTriggerMap.size();
00284 
00285             // header for printing algorithms
00286 
00287             myCout << "\n   ********** L1 Trigger Menu - printing   ********** \n"
00288             << "\nL1 Trigger Menu Interface: " << m_triggerMenuInterface
00289             << "\nL1 Trigger Menu Name:      " << m_triggerMenuName
00290             << "\nL1 Trigger Menu Implementation: " << m_triggerMenuImplementation
00291             << "\nAssociated Scale DB Key: " << m_scaleDbKey << "\n\n"
00292             << "\nL1 Physics Algorithms: " << nrDefinedAlgo << " algorithms defined." << "\n\n"
00293             << "Bit Number "
00294             << std::right << std::setw(35) << "Algorithm Name" << "  "
00295             << std::right << std::setw(35) << "Algorithm Alias" << "  "
00296             << std::right << std::setw(12) << "Trigger Mask";
00297             for (unsigned iSet = 0; iSet < m_prescaleFactorsAlgoTrig.size(); iSet++) {
00298                 myCout << std::right << std::setw(10) << "PF Set "
00299                        << std::right << std::setw(2)  << iSet;
00300             }
00301 
00302             myCout << std::endl;
00303 
00304 
00305             for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig
00306                     != m_algorithmMap.end(); itTrig++) {
00307 
00308                 const unsigned int bitNumber = itTrig->first;
00309                 const std::string& aName = itTrig->second;
00310 
00311                 std::string aAlias;
00312                 CItL1Trig itAlias = m_algorithmAliasMap.find(bitNumber);
00313                 if (itAlias != m_algorithmAliasMap.end()) {
00314                     aAlias = itAlias->second;
00315                 }
00316 
00317                 myCout << std::setw(6) << bitNumber << "     "
00318                     << std::right << std::setw(35) << aName << "  "
00319                     << std::right << std::setw(35) << aAlias << "  "
00320                     << std::right << std::setw(12) << m_triggerMaskAlgoTrig[bitNumber];
00321                 for (unsigned iSet = 0; iSet < m_prescaleFactorsAlgoTrig.size(); iSet++) {
00322                     myCout << std::right << std::setw(12) << m_prescaleFactorsAlgoTrig[iSet][bitNumber];
00323                 }
00324 
00325                 myCout << std::endl;
00326             }
00327 
00328             myCout << "\nL1 Technical Triggers: " << nrDefinedTech
00329                     << " technical triggers defined." << "\n\n" << std::endl;
00330             if (nrDefinedTech) {
00331                 myCout
00332                     << std::right << std::setw(6) << "Bit Number "
00333                     << std::right << std::setw(45) << " Technical trigger name " << "  "
00334                     << std::right << std::setw(12) << "Trigger Mask";
00335                 for (unsigned iSet = 0; iSet < m_prescaleFactorsTechTrig.size(); iSet++) {
00336                     myCout << std::right << std::setw(10) << "PF Set "
00337                             << std::right << std::setw(2) << iSet;
00338                 }
00339 
00340                 myCout << std::endl;
00341             }
00342 
00343             for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig
00344                     != m_technicalTriggerMap.end(); itTrig++) {
00345 
00346                 unsigned int bitNumber = itTrig->first;
00347                 std::string aName = itTrig->second;
00348 
00349                 myCout << std::setw(6) << bitNumber << "       "
00350                 << std::right << std::setw(45) << aName
00351                 << std::right << std::setw(12) << m_triggerMaskTechTrig[bitNumber];
00352                 for (unsigned iSet = 0; iSet < m_prescaleFactorsTechTrig.size(); iSet++) {
00353                     myCout << std::right << std::setw(12) << m_prescaleFactorsTechTrig[iSet][bitNumber];
00354                 }
00355 
00356                 myCout << std::endl;
00357 
00358             }
00359 
00360 
00361 
00362         }
00363             break;
00364         default: {
00365             myCout << "\n   ********** L1 Trigger Menu - printing   ********** \n\n"
00366             << "Verbosity level: " << printVerbosity << " not implemented.\n\n"
00367             << std::endl;
00368         }
00369             break;
00370     }
00371 
00372 }
00373 
00374 // output stream operator
00375 std::ostream& operator<<(std::ostream& streamRec,
00376         const L1GtTriggerMenuLite& result) {
00377     int verbosityLevel = 0;
00378 
00379     result.print(streamRec, verbosityLevel);
00380     return streamRec;
00381 
00382 }
00383 
00384 // get the alias for a physics algorithm with a given bit number
00385 const std::string* L1GtTriggerMenuLite::gtAlgorithmAlias(
00386         const unsigned int bitNumber, int& errorCode) const {
00387 
00388     const std::string* gtAlgorithmAlias = 0;
00389 
00390     for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig
00391             != m_algorithmAliasMap.end(); itTrig++) {
00392 
00393         if (itTrig->first == bitNumber) {
00394 
00395             gtAlgorithmAlias = &(itTrig->second);
00396 
00397             errorCode = 0;
00398             return gtAlgorithmAlias;
00399         }
00400     }
00401 
00402     errorCode = 1;
00403     return gtAlgorithmAlias;
00404 
00405 }
00406 
00407 // get the name for a physics algorithm or a technical trigger
00408 // with a given bit number
00409 const std::string* L1GtTriggerMenuLite::gtAlgorithmName(
00410         const unsigned int bitNumber, int& errorCode) const {
00411 
00412     const std::string* gtAlgorithmName = 0;
00413 
00414     for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig
00415             != m_algorithmMap.end(); itTrig++) {
00416 
00417         if (itTrig->first == bitNumber) {
00418 
00419             gtAlgorithmName = &(itTrig->second);
00420 
00421             errorCode = 0;
00422             return gtAlgorithmName;
00423         }
00424     }
00425 
00426     errorCode = 1;
00427     return gtAlgorithmName;
00428 
00429 }
00430 
00431 const std::string* L1GtTriggerMenuLite::gtTechTrigName(
00432         const unsigned int bitNumber, int& errorCode) const {
00433 
00434     const std::string* gtTechTrigName = 0;
00435 
00436     for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig
00437             != m_technicalTriggerMap.end(); itTrig++) {
00438 
00439         if (itTrig->first == bitNumber) {
00440 
00441             gtTechTrigName = &(itTrig->second);
00442 
00443             errorCode = 0;
00444             return gtTechTrigName;
00445         }
00446     }
00447 
00448     errorCode = 1;
00449     return gtTechTrigName;
00450 
00451 }
00452 
00453 // get the bit number for a physics algorithm or a technical trigger
00454 // with a given name or alias
00455 const unsigned int L1GtTriggerMenuLite::gtBitNumber(
00456         const std::string& trigName, int& errorCode) const {
00457 
00458     unsigned int bitNr = 999;
00459 
00460     //
00461     for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig
00462             != m_algorithmAliasMap.end(); itTrig++) {
00463 
00464         if (itTrig->second == trigName) {
00465 
00466             bitNr = itTrig->first;
00467 
00468             errorCode = 0;
00469             return bitNr;
00470         }
00471     }
00472 
00473     //
00474     for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig
00475             != m_algorithmMap.end(); itTrig++) {
00476 
00477         if (itTrig->second == trigName) {
00478 
00479             bitNr = itTrig->first;
00480             errorCode = 0;
00481             return bitNr;
00482         }
00483     }
00484 
00485     //
00486     for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig
00487             != m_technicalTriggerMap.end(); itTrig++) {
00488 
00489         if (itTrig->second == trigName) {
00490 
00491             bitNr = itTrig->first;
00492             errorCode = 0;
00493             return bitNr;
00494         }
00495     }
00496 
00497     errorCode = 1;
00498     return bitNr;
00499 
00500 }
00501 
00502 // get the result for a physics algorithm or a technical trigger with name trigName
00503 // use directly the format of decisionWord (no typedef)
00504 const bool L1GtTriggerMenuLite::gtTriggerResult(const std::string& trigName,
00505         const std::vector<bool>& decWord, int& errorCode) const {
00506 
00507     bool trigResult = false;
00508 
00509     // try first physics algorithm aliases
00510 
00511     for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig
00512             != m_algorithmAliasMap.end(); itTrig++) {
00513 
00514         if (itTrig->second == trigName) {
00515             unsigned int bitNumber = itTrig->first;
00516 
00517             if ((bitNumber >= decWord.size())) {
00518                 trigResult = false;
00519                 errorCode = 10;
00520             } else {
00521                 trigResult = decWord[bitNumber];
00522                 errorCode = 0;
00523             }
00524 
00525             return trigResult;
00526         }
00527     }
00528 
00529     // ... then physics algorithm names
00530 
00531     for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig
00532             != m_algorithmMap.end(); itTrig++) {
00533 
00534         if (itTrig->second == trigName) {
00535             unsigned int bitNumber = itTrig->first;
00536 
00537             if ((bitNumber >= decWord.size())) {
00538                 trigResult = false;
00539                 errorCode = 10;
00540             } else {
00541                 trigResult = decWord[bitNumber];
00542                 errorCode = 0;
00543             }
00544 
00545             return trigResult;
00546         }
00547     }
00548 
00549     // ... then technical trigger names
00550 
00551     for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig
00552             != m_technicalTriggerMap.end(); itTrig++) {
00553 
00554         if (itTrig->second == trigName) {
00555             unsigned int bitNumber = itTrig->first;
00556 
00557             if ((bitNumber >= decWord.size())) {
00558                 trigResult = false;
00559                 errorCode = 10;
00560             } else {
00561                 trigResult = decWord[bitNumber];
00562                 errorCode = 0;
00563             }
00564 
00565             return trigResult;
00566         }
00567     }
00568 
00569     // algorithm or technical trigger not in the menu
00570 
00571     errorCode = 1;
00572     return false;
00573 
00574 }
00575