Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:14

0001 #include <iostream>
0002 #include <fstream>
0003 #include <stdexcept>
0004 
0005 #include "tmEventSetup/tmEventSetup.hh"
0006 
0007 #include "tmEventSetup/esTriggerMenu.hh"
0008 #include "tmEventSetup/esAlgorithm.hh"
0009 #include "tmEventSetup/esCondition.hh"
0010 #include "tmEventSetup/esObject.hh"
0011 #include "tmEventSetup/esCut.hh"
0012 #include "tmEventSetup/esScale.hh"
0013 #include "tmGrammar/Algorithm.hh"
0014 
0015 #include "CondTools/L1TriggerExt/interface/L1ConfigOnlineProdBaseExt.h"
0016 #include "CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h"
0017 #include "CondFormats/DataRecord/interface/L1TUtmTriggerMenuRcd.h"
0018 #include "CondFormats/DataRecord/interface/L1TUtmTriggerMenuO2ORcd.h"
0019 
0020 class L1TUtmTriggerMenuOnlineProd : public L1ConfigOnlineProdBaseExt<L1TUtmTriggerMenuO2ORcd, L1TUtmTriggerMenu> {
0021 private:
0022 public:
0023   std::unique_ptr<const L1TUtmTriggerMenu> newObject(const std::string& objectKey,
0024                                                      const L1TUtmTriggerMenuO2ORcd& record) override;
0025 
0026   L1TUtmTriggerMenuOnlineProd(const edm::ParameterSet&);
0027   ~L1TUtmTriggerMenuOnlineProd(void) override {}
0028 };
0029 
0030 L1TUtmTriggerMenuOnlineProd::L1TUtmTriggerMenuOnlineProd(const edm::ParameterSet& iConfig)
0031     : L1ConfigOnlineProdBaseExt<L1TUtmTriggerMenuO2ORcd, L1TUtmTriggerMenu>(iConfig) {
0032   wrappedSetWhatProduced(iConfig);
0033 }
0034 
0035 std::unique_ptr<const L1TUtmTriggerMenu> L1TUtmTriggerMenuOnlineProd::newObject(const std::string& objectKey,
0036                                                                                 const L1TUtmTriggerMenuO2ORcd& record) {
0037   std::string stage2Schema = "CMS_TRG_L1_CONF";
0038   edm::LogInfo("L1-O2O: L1TUtmTriggerMenuOnlineProd") << "Producing L1TUtmTriggerMenu with key =" << objectKey;
0039 
0040   if (objectKey.empty()) {
0041     edm::LogError("L1-O2O: L1TUtmTriggerMenuOnlineProd") << "Key is empty, returning empty L1TUtmTriggerMenu object";
0042     throw std::runtime_error("Empty objectKey");
0043   }
0044 
0045   std::vector<std::string> queryColumns;
0046   queryColumns.push_back("CONF");
0047 
0048   l1t::OMDSReader::QueryResults queryResult = m_omdsReader.basicQuery(
0049       queryColumns, stage2Schema, "UGT_L1_MENU", "UGT_L1_MENU.ID", m_omdsReader.singleAttribute(objectKey));
0050 
0051   if (queryResult.queryFailed() || queryResult.numberRows() != 1) {
0052     edm::LogError("L1-O2O: L1TUtmTriggerMenuOnlineProd") << "Cannot get UGT_L1_MENU.CONF for ID = " << objectKey;
0053     throw std::runtime_error("Broken key");
0054   }
0055 
0056   std::string l1Menu;
0057   queryResult.fillVariable("CONF", l1Menu);
0058 
0059   std::istringstream iss(l1Menu);
0060 
0061   const L1TUtmTriggerMenu* cmenu = reinterpret_cast<const L1TUtmTriggerMenu*>(tmeventsetup::getTriggerMenu(iss));
0062   return std::unique_ptr<const L1TUtmTriggerMenu>(cmenu);
0063 }
0064 
0065 //define this as a plug-in
0066 DEFINE_FWK_EVENTSETUP_MODULE(L1TUtmTriggerMenuOnlineProd);