Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-13 01:32:15

0001 /**
0002  * \class L1GtTriggerMenuTester
0003  *
0004  *
0005  * Description: test analyzer for L1 GT trigger menu.
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 "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMenuTester.h"
0017 
0018 // system include files
0019 #include <iomanip>
0020 #include <boost/algorithm/string/erase.hpp>
0021 
0022 // user include files
0023 //   base class
0024 #include "FWCore/Framework/interface/EDAnalyzer.h"
0025 
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0028 
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/Framework/interface/ESHandle.h"
0031 
0032 #include "CondFormats/L1TObjects/interface/L1GtStableParameters.h"
0033 #include "CondFormats/DataRecord/interface/L1GtStableParametersRcd.h"
0034 
0035 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
0036 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
0037 
0038 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
0039 
0040 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
0041 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
0042 
0043 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
0044 
0045 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
0046 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
0047 
0048 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoAlgoTrigRcd.h"
0049 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoTechTrigRcd.h"
0050 
0051 #include "DataFormats/L1GlobalTrigger/interface/L1GtLogicParser.h"
0052 
0053 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0054 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0055 
0056 // forward declarations
0057 
0058 // constructor(s)
0059 L1GtTriggerMenuTester::L1GtTriggerMenuTester(const edm::ParameterSet& parSet)
0060     : m_overwriteHtmlFile(parSet.getParameter<bool>("OverwriteHtmlFile")),
0061       m_htmlFile(parSet.getParameter<std::string>("HtmlFile")),
0062       m_useHltMenu(parSet.getParameter<bool>("UseHltMenu")),
0063       m_hltProcessName(parSet.getParameter<std::string>("HltProcessName")),
0064       m_noThrowIncompatibleMenu(parSet.getParameter<bool>("NoThrowIncompatibleMenu")),
0065       m_printPfsRates(parSet.getParameter<bool>("PrintPfsRates")),
0066       m_indexPfSet(parSet.getParameter<int>("IndexPfSet")),
0067       m_l1GtStableParToken(esConsumes<edm::Transition::BeginRun>()),
0068       m_l1GtPfAlgoToken(esConsumes<edm::Transition::BeginRun>()),
0069       m_l1GtPfTechToken(esConsumes<edm::Transition::BeginRun>()),
0070       m_l1GtTmTechToken(esConsumes<edm::Transition::BeginRun>()),
0071       m_l1GtTmVetoAlgoToken(esConsumes<edm::Transition::BeginRun>()),
0072       m_l1GtTmVetoTechToken(esConsumes<edm::Transition::BeginRun>()),
0073       m_l1GtMenuToken(esConsumes<edm::Transition::BeginRun>()),
0074       m_numberAlgorithmTriggers(0),
0075       m_numberTechnicalTriggers(0) {
0076   // empty
0077 }
0078 
0079 // begin run
0080 void L1GtTriggerMenuTester::beginRun(const edm::Run& iRun, const edm::EventSetup& evSetup) {
0081   // retrieve L1 trigger configuration
0082   retrieveL1EventSetup(evSetup);
0083 
0084   // print with various level of verbosity
0085 
0086   // define an output stream to print into
0087   // it can then be directed to whatever log level is desired
0088   std::ostringstream myCout;
0089 
0090   int printVerbosity = 0;
0091   m_l1GtMenu->print(myCout, printVerbosity);
0092   myCout << std::flush << std::endl;
0093 
0094   printVerbosity = 1;
0095   m_l1GtMenu->print(myCout, printVerbosity);
0096   myCout << std::flush << std::endl;
0097 
0098   printVerbosity = 2;
0099   m_l1GtMenu->print(myCout, printVerbosity);
0100   myCout << std::flush << std::endl;
0101 
0102   // redirect myCout to edm::LogVerbatim TODO - parameter to choose the log
0103   edm::LogVerbatim("L1GtTriggerMenuTester") << myCout.str() << std::endl;
0104 
0105   // prepare L1 - HLT
0106   if (m_useHltMenu) {
0107     associateL1SeedsHltPath(iRun, evSetup);
0108 
0109     if (m_noThrowIncompatibleMenu) {
0110       edm::LogVerbatim("L1GtTriggerMenuTester")
0111           << "\n List of algorithm triggers used as L1 seeds but not in L1 menu" << std::endl;
0112 
0113       for (std::vector<std::string>::const_iterator strIter = m_algoTriggerSeedNotInL1Menu.begin();
0114            strIter != m_algoTriggerSeedNotInL1Menu.end();
0115            ++strIter) {
0116         edm::LogVerbatim("L1GtTriggerMenuTester") << "   " << (*strIter) << std::endl;
0117       }
0118     }
0119   }
0120 
0121   // print in wiki format
0122   printWiki();
0123 }
0124 
0125 // loop over events
0126 void L1GtTriggerMenuTester::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0127   // empty
0128 }
0129 
0130 // end run
0131 void L1GtTriggerMenuTester::endRun(const edm::Run&, const edm::EventSetup& evSetup) {}
0132 
0133 void L1GtTriggerMenuTester::retrieveL1EventSetup(const edm::EventSetup& evSetup) {
0134   // get / update the stable parameters from the EventSetup
0135 
0136   m_l1GtStablePar = &evSetup.getData(m_l1GtStableParToken);
0137 
0138   // number of algorithm triggers
0139   m_numberAlgorithmTriggers = m_l1GtStablePar->gtNumberPhysTriggers();
0140 
0141   // number of technical triggers
0142   m_numberTechnicalTriggers = m_l1GtStablePar->gtNumberTechnicalTriggers();
0143 
0144   //    int maxNumberTrigger = std::max(m_numberAlgorithmTriggers,
0145   //            m_numberTechnicalTriggers);
0146 
0147   //    m_triggerMaskSet.reserve(maxNumberTrigger);
0148   //    m_prescaleFactorSet.reserve(maxNumberTrigger);
0149 
0150   // get / update the prescale factors from the EventSetup
0151 
0152   m_l1GtPfAlgo = &evSetup.getData(m_l1GtPfAlgoToken);
0153 
0154   m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
0155 
0156   m_l1GtPfTech = &evSetup.getData(m_l1GtPfTechToken);
0157 
0158   m_prescaleFactorsTechTrig = &(m_l1GtPfTech->gtPrescaleFactors());
0159 
0160   // get / update the trigger mask from the EventSetup
0161 
0162   m_l1GtTmAlgo = &evSetup.getData(m_l1GtTmAlgoToken);
0163 
0164   m_triggerMaskAlgoTrig = &(m_l1GtTmAlgo->gtTriggerMask());
0165 
0166   m_l1GtTmTech = &evSetup.getData(m_l1GtTmTechToken);
0167 
0168   m_triggerMaskTechTrig = &(m_l1GtTmTech->gtTriggerMask());
0169 
0170   m_l1GtTmVetoAlgo = &evSetup.getData(m_l1GtTmVetoAlgoToken);
0171 
0172   m_triggerMaskVetoAlgoTrig = &(m_l1GtTmVetoAlgo->gtTriggerMask());
0173 
0174   m_l1GtTmVetoTech = &evSetup.getData(m_l1GtTmVetoTechToken);
0175 
0176   m_triggerMaskVetoTechTrig = &(m_l1GtTmVetoTech->gtTriggerMask());
0177 
0178   // get / update the trigger menu from the EventSetup
0179 
0180   m_l1GtMenu = &evSetup.getData(m_l1GtMenuToken);
0181   m_algorithmMap = &(m_l1GtMenu->gtAlgorithmMap());
0182   m_algorithmAliasMap = &(m_l1GtMenu->gtAlgorithmAliasMap());
0183   m_technicalTriggerMap = &(m_l1GtMenu->gtTechnicalTriggerMap());
0184 }
0185 
0186 void L1GtTriggerMenuTester::associateL1SeedsHltPath(const edm::Run& iRun, const edm::EventSetup& evSetup) {
0187   bool hltChanged = true;
0188 
0189   if (m_hltConfig.init(iRun, evSetup, m_hltProcessName, hltChanged)) {
0190     // if init returns TRUE, initialization has succeeded!
0191     if (hltChanged) {
0192       // HLT configuration has actually changed wrt the previous run
0193       m_hltTableName = m_hltConfig.tableName();
0194 
0195       edm::LogVerbatim("L1GtTriggerMenuTester") << "\nHLT ConfDB menu name: \n   " << m_hltTableName << std::endl;
0196 
0197       // loop over trigger paths, get the HLTLevel1GTSeed logical expression, and add the path to
0198       // each L1 trigger
0199 
0200       m_hltPathsForL1AlgorithmTrigger.resize(m_numberAlgorithmTriggers);
0201       m_hltPathsForL1TechnicalTrigger.resize(m_numberTechnicalTriggers);
0202 
0203       m_algoTriggerSeedNotInL1Menu.reserve(m_numberAlgorithmTriggers);
0204       m_techTriggerSeedNotInL1Menu.reserve(m_numberTechnicalTriggers);
0205 
0206       for (unsigned int iHlt = 0; iHlt < m_hltConfig.size(); ++iHlt) {
0207         const std::string& hltPathName = m_hltConfig.triggerName(iHlt);
0208 
0209         const std::vector<std::pair<bool, std::string> >& hltL1Seed = m_hltConfig.hltL1GTSeeds(hltPathName);
0210 
0211         unsigned int numberHltL1GTSeeds = hltL1Seed.size();
0212 
0213         edm::LogVerbatim("L1GtTriggerMenuTester") << "\nPath: " << hltPathName << " :    <== " << numberHltL1GTSeeds
0214                                                   << " HLTLevel1GTSeed module(s)" << std::endl;
0215 
0216         for (unsigned int iSeedModule = 0; iSeedModule < numberHltL1GTSeeds; ++iSeedModule) {
0217           // one needs a non-const logical expression... TODO check why
0218           std::string m_l1SeedsLogicalExpression = (hltL1Seed[iSeedModule]).second;
0219 
0220           edm::LogVerbatim("L1GtTriggerMenuTester") << "      '" << m_l1SeedsLogicalExpression << "'";
0221 
0222           // parse logical expression
0223 
0224           if (m_l1SeedsLogicalExpression != "L1GlobalDecision") {
0225             // check also the logical expression - add/remove spaces if needed
0226             L1GtLogicParser m_l1AlgoLogicParser = L1GtLogicParser(m_l1SeedsLogicalExpression);
0227 
0228             // list of required algorithms for seeding
0229             std::vector<L1GtLogicParser::OperandToken> m_l1AlgoSeeds = m_l1AlgoLogicParser.expressionSeedsOperandList();
0230             size_t l1AlgoSeedsSize = m_l1AlgoSeeds.size();
0231 
0232             edm::LogVerbatim("L1GtTriggerMenuTester") << " :    <== " << l1AlgoSeedsSize << " L1 seeds" << std::endl;
0233 
0234             // for each algorithm trigger, check if it is in the L1 menu, get the bit number
0235             // and add path to the vector of strings for that bit number
0236 
0237             for (size_t i = 0; i < l1AlgoSeedsSize; ++i) {
0238               const std::string& trigNameOrAlias = (m_l1AlgoSeeds[i]).tokenName;
0239 
0240               CItAlgo itAlgo = m_algorithmAliasMap->find(trigNameOrAlias);
0241               if (itAlgo != m_algorithmAliasMap->end()) {
0242                 int bitNr = (itAlgo->second).algoBitNumber();
0243 
0244                 (m_hltPathsForL1AlgorithmTrigger.at(bitNr)).push_back(hltPathName);
0245 
0246                 edm::LogVerbatim("L1GtTriggerMenuTester")
0247                     << "         " << trigNameOrAlias << " bit " << bitNr << std::endl;
0248 
0249               } else {
0250                 if (m_noThrowIncompatibleMenu) {
0251                   edm::LogVerbatim("L1GtTriggerMenuTester")
0252                       << "         " << trigNameOrAlias << " trigger not in L1 menu " << m_l1GtMenu->gtTriggerMenuName()
0253                       << std::endl;
0254 
0255                   m_algoTriggerSeedNotInL1Menu.push_back(trigNameOrAlias);
0256 
0257                 } else {
0258                   throw cms::Exception("FailModule")
0259                       << "\nAlgorithm  " << trigNameOrAlias
0260                       << ", requested as seed by a HLT path, not found in the L1 trigger menu\n   "
0261                       << m_l1GtMenu->gtTriggerMenuName() << "\nIncompatible L1 and HLT menus.\n"
0262                       << std::endl;
0263                 }
0264               }
0265             }
0266           }
0267         }
0268       }
0269     }
0270   } else {
0271     // if init returns FALSE, initialization has NOT succeeded, which indicates a problem
0272     // with the file and/or code and needs to be investigated!
0273     edm::LogError("MyAnalyzer") << " HLT config extraction failure with process name " << m_hltProcessName;
0274   }
0275 }
0276 
0277 // printing template for a trigger group
0278 void L1GtTriggerMenuTester::printTriggerGroup(const std::string& trigGroupName,
0279                                               const std::map<std::string, const L1GtAlgorithm*>& trigGroup,
0280                                               const bool compactPrint,
0281                                               const bool printPfsRates) {
0282   // FIXME get values - either read from a specific L1 menu file, or from
0283   std::string lumiVal1 = "5.0E33";
0284   std::string lumiVal2 = "7.0E33";
0285   std::string trigComment;
0286 
0287   int trigPfVal1 = 0;
0288   int trigPfVal2 = 0;
0289 
0290   int trigRateVal1 = 0;
0291   int trigRateVal2 = 0;
0292 
0293   // cumulative list of L1 triggers not used as seed by HLT
0294   std::vector<std::string> algoTriggerNotSeed;
0295   algoTriggerNotSeed.reserve(m_numberAlgorithmTriggers);
0296 
0297   std::vector<std::string> techTriggerNotSeed;
0298   techTriggerNotSeed.reserve(m_numberTechnicalTriggers);
0299 
0300   // force a page break before each group
0301   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "<p style=\"page-break-before: always\">&nbsp;</p>";
0302 
0303   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "\n---++++ " << trigGroupName << "\n" << std::endl;
0304 
0305   if (compactPrint) {
0306     edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0307         << "|  *Trigger Name*  |  *Trigger Alias*  |  *Bit*  |  *Comments*  |" << std::endl;
0308 
0309   } else {
0310     if (printPfsRates) {
0311       edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "|  *Trigger Name*  |  *Trigger Alias*  |  *Bit*  |  "
0312                                                        "*Luminosity*  ||||  *Seed for !HLT path(s)*  |  *Comments*  |"
0313                                                     << std::endl;
0314 
0315       edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0316           << "|^|^|^|  *" << lumiVal1 << "*  ||  *" << lumiVal2 << "*  ||  **  |  **  |" << std::endl;
0317 
0318       edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0319           << "|^|^|^|  *PF*  |  *Rate*  |  *PF*  |  *Rate*  |  ** |  **  |" << std::endl;
0320 
0321     } else {
0322       edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0323           << "|  *Trigger Name*  |  *Trigger Alias*  |  *Bit*  |  *Seed for !HLT path(s)*  |" << std::endl;
0324     }
0325   }
0326 
0327   for (CItAlgoP itAlgo = trigGroup.begin(); itAlgo != trigGroup.end(); itAlgo++) {
0328     const std::string& aName = (itAlgo->second)->algoName();
0329     const std::string& aAlias = (itAlgo->second)->algoAlias();
0330     const int& bitNumber = (itAlgo->second)->algoBitNumber();
0331 
0332     // concatenate in a string, to simplify the next print instruction
0333     std::string seedsHlt;
0334     if (m_useHltMenu) {
0335       const std::vector<std::string>& hltPaths = m_hltPathsForL1AlgorithmTrigger.at(bitNumber);
0336 
0337       if (hltPaths.empty()) {
0338         algoTriggerNotSeed.push_back(aAlias);
0339         seedsHlt = "<font color = \"red\">Not used as seed by any !HLT path</font>";
0340       } else {
0341         for (std::vector<std::string>::const_iterator strIter = hltPaths.begin(); strIter != hltPaths.end();
0342              ++strIter) {
0343           seedsHlt = seedsHlt + (*strIter) + "<BR>";
0344         }
0345       }
0346     }
0347 
0348     if (compactPrint) {
0349       edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0350           << "|" << std::left << "[[" << (m_htmlFile + "#" + aName) << "][ " << aName << "]] "
0351           << "  |" << aAlias << "  |  " << bitNumber << "| |" << std::endl;
0352 
0353     } else {
0354       if (printPfsRates) {
0355         edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0356             << "|" << std::left << "[[" << (m_htmlFile + "#" + aName) << "][ " << aName << "]] "
0357             << "  |" << aAlias << "  |  " << bitNumber << "|  " << ((trigPfVal1 != 0) ? trigPfVal1 : 0) << "  |  "
0358             << ((trigRateVal1 != 0) ? trigRateVal1 : 0) << "  |  " << ((trigPfVal2 != 0) ? trigPfVal2 : 0) << "  |  "
0359             << ((trigRateVal2 != 0) ? trigRateVal2 : 0) << "  |  " << seedsHlt << "  |  " << trigComment << "  |"
0360             << std::endl;
0361 
0362       } else {
0363         edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0364             << "|" << std::left << "[[" << (m_htmlFile + "#" + aName) << "][ " << aName << "]] "
0365             << "  |" << aAlias << "  |  " << bitNumber << "|" << seedsHlt << "  |  " << std::endl;
0366       }
0367     }
0368   }
0369 
0370   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0371       << "\n"
0372       << trigGroupName << ": " << (trigGroup.size()) << " bits defined." << std::endl;
0373 
0374   if (m_useHltMenu && (!compactPrint)) {
0375     edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0376         << "\n Algorithm triggers from " << trigGroupName << " not used as seeds by !HLT:" << std::endl;
0377 
0378     if (!algoTriggerNotSeed.empty()) {
0379       for (std::vector<std::string>::const_iterator strIter = algoTriggerNotSeed.begin();
0380            strIter != algoTriggerNotSeed.end();
0381            ++strIter) {
0382         edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "   * " << (*strIter) << std::endl;
0383       }
0384 
0385     } else {
0386       edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "   * none" << std::endl;
0387     }
0388   }
0389 }
0390 
0391 /// printing in Wiki format
0392 void L1GtTriggerMenuTester::printWiki() {
0393   //
0394   // print menu, prescale factors and trigger mask in wiki format
0395   //
0396 
0397   // L1 GT prescale factors for algorithm triggers
0398 
0399   std::vector<int> prescaleFactorsAlgoTrig = m_prescaleFactorsAlgoTrig->at(m_indexPfSet);
0400 
0401   // L1 GT prescale factors for technical triggers
0402 
0403   std::vector<int> prescaleFactorsTechTrig = m_prescaleFactorsTechTrig->at(m_indexPfSet);
0404 
0405   // use another map <int, L1GtAlgorithm> to get the menu sorted after bit number
0406   // both algorithm and bit numbers are unique
0407   typedef std::map<int, const L1GtAlgorithm*>::const_iterator CItBit;
0408 
0409   //    algorithm triggers
0410 
0411   std::map<int, const L1GtAlgorithm*> algoBitToAlgo;
0412 
0413   std::map<std::string, const L1GtAlgorithm*> jetAlgoTrig;
0414   std::map<std::string, const L1GtAlgorithm*> egammaAlgoTrig;
0415   std::map<std::string, const L1GtAlgorithm*> esumAlgoTrig;
0416   std::map<std::string, const L1GtAlgorithm*> muonAlgoTrig;
0417   std::map<std::string, const L1GtAlgorithm*> crossAlgoTrig;
0418   std::map<std::string, const L1GtAlgorithm*> bkgdAlgoTrig;
0419 
0420   int algoTrigNumber = 0;
0421   int freeAlgoTrigNumber = 0;
0422 
0423   int jetAlgoTrigNumber = 0;
0424   int egammaAlgoTrigNumber = 0;
0425   int esumAlgoTrigNumber = 0;
0426   int muonAlgoTrigNumber = 0;
0427   int crossAlgoTrigNumber = 0;
0428   int bkgdAlgoTrigNumber = 0;
0429 
0430   for (CItAlgo itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
0431     const int bitNumber = (itAlgo->second).algoBitNumber();
0432     const std::string& algName = (itAlgo->second).algoName();
0433 
0434     algoBitToAlgo[bitNumber] = &(itAlgo->second);
0435 
0436     algoTrigNumber++;
0437 
0438     // per category
0439 
0440     const ConditionMap& conditionMap = (m_l1GtMenu->gtConditionMap()).at((itAlgo->second).algoChipNumber());
0441 
0442     const std::vector<L1GtLogicParser::TokenRPN>& rpnVector = (itAlgo->second).algoRpnVector();
0443     const L1GtLogicParser::OperationType condOperand = L1GtLogicParser::OP_OPERAND;
0444 
0445     std::list<L1GtObject> listObjects;
0446 
0447     for (size_t i = 0; i < rpnVector.size(); ++i) {
0448       if ((rpnVector[i]).operation == condOperand) {
0449         const std::string& cndName = (rpnVector[i]).operand;
0450 
0451         // search the condition in the condition list
0452 
0453         bool foundCond = false;
0454 
0455         CItCond itCond = conditionMap.find(cndName);
0456         if (itCond != conditionMap.end()) {
0457           foundCond = true;
0458 
0459           // loop through object types and add them to the list
0460 
0461           const std::vector<L1GtObject>& objType = (itCond->second)->objectType();
0462 
0463           for (std::vector<L1GtObject>::const_iterator itObject = objType.begin(); itObject != objType.end();
0464                itObject++) {
0465             listObjects.push_back(*itObject);
0466 
0467             edm::LogVerbatim("L1GtTriggerMenuTester") << (*itObject) << std::endl;
0468           }
0469 
0470           // FIXME for XML parser, add GtExternal to objType correctly
0471           if ((itCond->second)->condCategory() == CondExternal) {
0472             listObjects.push_back(GtExternal);
0473           }
0474         }
0475 
0476         if (!foundCond) {
0477           // it should never be happen, all conditions are in the maps
0478           throw cms::Exception("FailModule") << "\nCondition " << cndName << " not found in the condition map"
0479                                              << " for chip number " << ((itAlgo->second).algoChipNumber()) << std::endl;
0480         }
0481       }
0482     }
0483 
0484     // eliminate duplicates
0485     listObjects.sort();
0486     listObjects.unique();
0487 
0488     // add the algorithm to the corresponding group
0489 
0490     bool jetGroup = false;
0491     bool egammaGroup = false;
0492     bool esumGroup = false;
0493     bool muonGroup = false;
0494     bool crossGroup = false;
0495     bool bkgdGroup = false;
0496 
0497     for (std::list<L1GtObject>::const_iterator itObj = listObjects.begin(); itObj != listObjects.end(); ++itObj) {
0498       switch (*itObj) {
0499         case Mu: {
0500           muonGroup = true;
0501         }
0502 
0503         break;
0504         case NoIsoEG: {
0505           egammaGroup = true;
0506         }
0507 
0508         break;
0509         case IsoEG: {
0510           egammaGroup = true;
0511         }
0512 
0513         break;
0514         case CenJet: {
0515           jetGroup = true;
0516         }
0517 
0518         break;
0519         case ForJet: {
0520           jetGroup = true;
0521         }
0522 
0523         break;
0524         case TauJet: {
0525           jetGroup = true;
0526         }
0527 
0528         break;
0529         case ETM: {
0530           esumGroup = true;
0531 
0532         }
0533 
0534         break;
0535         case ETT: {
0536           esumGroup = true;
0537 
0538         }
0539 
0540         break;
0541         case HTT: {
0542           esumGroup = true;
0543 
0544         }
0545 
0546         break;
0547         case HTM: {
0548           esumGroup = true;
0549 
0550         }
0551 
0552         break;
0553         case JetCounts: {
0554           // do nothing - not available
0555         }
0556 
0557         break;
0558         case HfBitCounts: {
0559           bkgdGroup = true;
0560         }
0561 
0562         break;
0563         case HfRingEtSums: {
0564           bkgdGroup = true;
0565         }
0566 
0567         break;
0568         case GtExternal: {
0569           bkgdGroup = true;
0570         }
0571 
0572         break;
0573         case TechTrig:
0574         case Castor:
0575         case BPTX:
0576         default: {
0577           // should not arrive here
0578 
0579           edm::LogVerbatim("L1GtTriggerMenuTester") << "\n      Unknown object of type " << *itObj << std::endl;
0580         } break;
0581       }
0582     }
0583 
0584     int sumGroup = jetGroup + egammaGroup + esumGroup + muonGroup + crossGroup + bkgdGroup;
0585 
0586     if (sumGroup > 1) {
0587       crossAlgoTrig[algName] = &(itAlgo->second);
0588     } else {
0589       if (jetGroup) {
0590         jetAlgoTrig[algName] = &(itAlgo->second);
0591 
0592       } else if (egammaGroup) {
0593         egammaAlgoTrig[algName] = &(itAlgo->second);
0594 
0595       } else if (esumGroup && (listObjects.size() > 1)) {
0596         crossAlgoTrig[algName] = &(itAlgo->second);
0597 
0598       } else if (esumGroup) {
0599         esumAlgoTrig[algName] = &(itAlgo->second);
0600 
0601       } else if (muonGroup) {
0602         muonAlgoTrig[algName] = &(itAlgo->second);
0603 
0604       } else if (bkgdGroup) {
0605         bkgdAlgoTrig[algName] = &(itAlgo->second);
0606 
0607       } else {
0608         // do nothing
0609       }
0610     }
0611 
0612     edm::LogVerbatim("L1GtTriggerMenuTester")
0613         << algName << " sum: " << sumGroup << " size: " << listObjects.size() << std::endl;
0614   }
0615 
0616   freeAlgoTrigNumber = m_numberAlgorithmTriggers - algoTrigNumber;
0617 
0618   jetAlgoTrigNumber = jetAlgoTrig.size();
0619   egammaAlgoTrigNumber = egammaAlgoTrig.size();
0620   esumAlgoTrigNumber = esumAlgoTrig.size();
0621   muonAlgoTrigNumber = muonAlgoTrig.size();
0622   crossAlgoTrigNumber = crossAlgoTrig.size();
0623   bkgdAlgoTrigNumber = bkgdAlgoTrig.size();
0624 
0625   //    technical triggers
0626   std::map<int, const L1GtAlgorithm*> techBitToAlgo;
0627 
0628   int techTrigNumber = 0;
0629   int freeTechTrigNumber = 0;
0630 
0631   for (CItAlgo itAlgo = m_technicalTriggerMap->begin(); itAlgo != m_technicalTriggerMap->end(); itAlgo++) {
0632     int bitNumber = (itAlgo->second).algoBitNumber();
0633     techBitToAlgo[bitNumber] = &(itAlgo->second);
0634 
0635     techTrigNumber++;
0636   }
0637 
0638   freeTechTrigNumber = m_numberTechnicalTriggers - techTrigNumber;
0639 
0640   // name of the attached HTML file
0641   if (!m_overwriteHtmlFile) {
0642     std::string menuName = m_l1GtMenu->gtTriggerMenuImplementation();
0643 
0644     // replace "/" with "_"
0645     std::replace(menuName.begin(), menuName.end(), '/', '_');
0646     m_htmlFile = "%ATTACHURL%/" + menuName + ".html";
0647   } else {
0648     m_htmlFile = "%ATTACHURL%/" + m_htmlFile;
0649   }
0650 
0651   // header for printing algorithms
0652 
0653   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0654       << "\n   ********** L1 Trigger Menu - printing in wiki format  ********** \n\n"
0655       << "\n---+++ L1 menu identification\n"
0656       << "\n|L1 Trigger Menu Interface: |!" << m_l1GtMenu->gtTriggerMenuInterface() << " |"
0657       << "\n|L1 Trigger Menu Name: |!" << m_l1GtMenu->gtTriggerMenuName() << " |"
0658       << "\n|L1 Trigger Menu Implementation: |!" << m_l1GtMenu->gtTriggerMenuImplementation() << " |"
0659       << "\n|Associated L1 scale DB key: |!" << m_l1GtMenu->gtScaleDbKey() << " |"
0660       << "\n\n"
0661       << std::flush << std::endl;
0662 
0663   // Overview page
0664   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "\n---+++ Summary\n" << std::endl;
0665   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0666       << "   * Number of algorithm triggers: " << algoTrigNumber << " defined, 128 possible." << std::endl;
0667   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0668       << "   * Number of technical triggers: " << techTrigNumber << " defined,  64 possible.<BR><BR>" << std::endl;
0669 
0670   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0671       << "   * Number of free bits for algorithm triggers: " << freeAlgoTrigNumber << std::endl;
0672   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0673       << "   * Number of free bits for technical triggers: " << freeTechTrigNumber << "<BR>" << std::endl;
0674 
0675   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "\nNumber of algorithm triggers per trigger group\n" << std::endl;
0676   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "    | *Trigger group* | *Number of bits used*|" << std::endl;
0677   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0678       << "    | Jet algorithm triggers: |  " << jetAlgoTrigNumber << "|" << std::endl;
0679   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0680       << "    | EGamma algorithm triggers: |  " << egammaAlgoTrigNumber << "|" << std::endl;
0681   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0682       << "    | Energy sum algorithm triggers: |  " << esumAlgoTrigNumber << "|" << std::endl;
0683   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0684       << "    | Muon algorithm triggers: |  " << muonAlgoTrigNumber << "|" << std::endl;
0685   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0686       << "    | Cross algorithm triggers: |  " << crossAlgoTrigNumber << "|" << std::endl;
0687   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0688       << "    | Background algorithm triggers: |  " << bkgdAlgoTrigNumber << "|" << std::endl;
0689 
0690   // force a page break
0691   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "<p style=\"page-break-before: always\">&nbsp;</p>";
0692 
0693   // compact print - without HLT path
0694   bool compactPrint = true;
0695 
0696   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "\n---+++ List of algorithm triggers sorted by trigger groups\n"
0697                                                 << std::endl;
0698 
0699   // Jet algorithm triggers
0700   printTriggerGroup("Jet algorithm triggers", jetAlgoTrig, compactPrint, m_printPfsRates);
0701 
0702   // EGamma algorithm triggers
0703   printTriggerGroup("EGamma algorithm triggers", egammaAlgoTrig, compactPrint, m_printPfsRates);
0704 
0705   // Energy sum algorithm triggers
0706   printTriggerGroup("Energy sum algorithm triggers", esumAlgoTrig, compactPrint, m_printPfsRates);
0707 
0708   // Muon algorithm triggers
0709   printTriggerGroup("Muon algorithm triggers", muonAlgoTrig, compactPrint, m_printPfsRates);
0710 
0711   // Cross algorithm triggers
0712   printTriggerGroup("Cross algorithm triggers", crossAlgoTrig, compactPrint, m_printPfsRates);
0713 
0714   // Background algorithm triggers
0715   printTriggerGroup("Background algorithm triggers", bkgdAlgoTrig, compactPrint, m_printPfsRates);
0716 
0717   // force a page break
0718   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "<p style=\"page-break-before: always\">&nbsp;</p>";
0719 
0720   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "\n---+++ List of algorithm triggers sorted by bits\n" << std::endl;
0721 
0722   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "| *Algorithm* | *Alias* | *Bit number* |" << std::endl;
0723 
0724   for (CItBit itBit = algoBitToAlgo.begin(); itBit != algoBitToAlgo.end(); itBit++) {
0725     int bitNumber = itBit->first;
0726     std::string aName = (itBit->second)->algoName();
0727     std::string aAlias = (itBit->second)->algoAlias();
0728 
0729     edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0730         << "|" << std::left << "[[" << (m_htmlFile + "#" + aName) << "][ " << aName << "]] "
0731         << "  |" << aAlias << "  |  " << bitNumber << "| |" << std::endl;
0732   }
0733 
0734   // force a page break
0735   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "<p style=\"page-break-before: always\">&nbsp;</p>";
0736   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "\n---+++ List of technical triggers\n" << std::endl;
0737 
0738   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "| *Technical trigger* | *Bit number* |" << std::endl;
0739 
0740   for (CItBit itBit = techBitToAlgo.begin(); itBit != techBitToAlgo.end(); itBit++) {
0741     int bitNumber = itBit->first;
0742     std::string aName = (itBit->second)->algoName();
0743     std::string aAlias = (itBit->second)->algoAlias();
0744 
0745     edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0746         << "|!" << std::left << aName << "  |  " << std::right << bitNumber << " |" << std::endl;
0747   }
0748 
0749   // force a page break
0750   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << "<p style=\"page-break-before: always\">&nbsp;</p>";
0751 
0752   // compact print false: with HLT path association, if the parameter m_useHltMenu is true
0753   // otherwise, we have no association computed
0754 
0755   if (m_useHltMenu) {
0756     compactPrint = false;
0757   } else {
0758     return;
0759   }
0760 
0761   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0762       << "\n---+++ List of algorithm triggers sorted by trigger groups, including !HLT path association \n"
0763       << std::endl;
0764 
0765   edm::LogVerbatim("L1GtTriggerMenuTesterWiki")
0766       << "\n The following !HLT menu was used to associate the !HLT path to the L1 algorithm triggers:\n    "
0767       << std::endl;
0768   edm::LogVerbatim("L1GtTriggerMenuTesterWiki") << m_hltTableName << std::endl;
0769 
0770   // Jet algorithm triggers
0771   printTriggerGroup("Jet algorithm triggers", jetAlgoTrig, compactPrint, m_printPfsRates);
0772 
0773   // EGamma algorithm triggers
0774   printTriggerGroup("EGamma algorithm triggers", egammaAlgoTrig, compactPrint, m_printPfsRates);
0775 
0776   // Energy sum algorithm triggers
0777   printTriggerGroup("Energy sum algorithm triggers", esumAlgoTrig, compactPrint, m_printPfsRates);
0778 
0779   // Muon algorithm triggers
0780   printTriggerGroup("Muon algorithm triggers", muonAlgoTrig, compactPrint, m_printPfsRates);
0781 
0782   // Cross algorithm triggers
0783   printTriggerGroup("Cross algorithm triggers", crossAlgoTrig, compactPrint, m_printPfsRates);
0784 
0785   // Background algorithm triggers
0786   printTriggerGroup("Background algorithm triggers", bkgdAlgoTrig, compactPrint, m_printPfsRates);
0787 }