Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:17

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1SubsystemKeysOnlineProd
0004 // Class:      L1SubsystemKeysOnlineProd
0005 //
0006 /**\class L1SubsystemKeysOnlineProd L1SubsystemKeysOnlineProd.h CondTools/L1SubsystemKeysOnlineProd/src/L1SubsystemKeysOnlineProd.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Werner Man-Li Sun
0015 //         Created:  Thu Aug 21 20:00:59 CEST 2008
0016 // $Id: L1SubsystemKeysOnlineProd.cc,v 1.5 2010/02/01 22:00:03 wsun Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 
0022 // user include files
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 
0025 #include "CondTools/L1Trigger/plugins/L1SubsystemKeysOnlineProd.h"
0026 
0027 #include "CondTools/L1Trigger/interface/Exception.h"
0028 #include "CondTools/L1Trigger/interface/DataWriter.h"
0029 
0030 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
0031 #include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
0032 
0033 #include "FWCore/Framework/interface/EventSetup.h"
0034 
0035 //
0036 // class declaration
0037 //
0038 
0039 //
0040 // constants, enums and typedefs
0041 //
0042 
0043 //
0044 // static data member definitions
0045 //
0046 
0047 //
0048 // constructors and destructor
0049 //
0050 L1SubsystemKeysOnlineProd::L1SubsystemKeysOnlineProd(const edm::ParameterSet& iConfig)
0051     : m_tscKey(iConfig.getParameter<std::string>("tscKey")),
0052       m_omdsReader(iConfig.getParameter<std::string>("onlineDB"),
0053                    iConfig.getParameter<std::string>("onlineAuthentication")),
0054       m_forceGeneration(iConfig.getParameter<bool>("forceGeneration")) {
0055   //the following line is needed to tell the framework what
0056   // data is being produced
0057   setWhatProduced(this, "SubsystemKeysOnly");
0058 
0059   //now do what ever other initialization is needed
0060 }
0061 
0062 L1SubsystemKeysOnlineProd::~L1SubsystemKeysOnlineProd() {
0063   // do anything here that needs to be done at desctruction time
0064   // (e.g. close files, deallocate resources etc.)
0065 }
0066 
0067 //
0068 // member functions
0069 //
0070 
0071 // ------------ method called to produce the data  ------------
0072 L1SubsystemKeysOnlineProd::ReturnType L1SubsystemKeysOnlineProd::produce(const L1TriggerKeyRcd& iRecord) {
0073   std::unique_ptr<L1TriggerKey> pL1TriggerKey;
0074 
0075   // Get L1TriggerKeyList
0076   L1TriggerKeyList keyList;
0077   l1t::DataWriter dataWriter;
0078   if (!dataWriter.fillLastTriggerKeyList(keyList)) {
0079     edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyList";
0080   }
0081 
0082   // If L1TriggerKeyList does not contain TSC key, token is empty
0083   if (keyList.token(m_tscKey).empty() || m_forceGeneration) {
0084     // Instantiate new L1TriggerKey
0085     pL1TriggerKey = std::make_unique<L1TriggerKey>();
0086     pL1TriggerKey->setTSCKey(m_tscKey);
0087 
0088     edm::LogVerbatim("L1-O2O") << "TSC KEY " << m_tscKey;
0089 
0090     // Get subsystem keys from OMDS
0091 
0092     // SELECT CSCTF_KEY, DTTF_KEY, RPC_KEY, GMT_KEY, RCT_KEY, GCT_KEY, GT_KEY FROM TRIGGERSUP_CONF WHERE TRIGGERSUP_CONF.TS_KEY = m_tscKey
0093     std::vector<std::string> queryStrings;
0094     queryStrings.push_back("CSCTF_KEY");
0095     queryStrings.push_back("DTTF_KEY");
0096     queryStrings.push_back("RPC_KEY");
0097     queryStrings.push_back("GMT_KEY");
0098     queryStrings.push_back("RCT_KEY");
0099     queryStrings.push_back("GCT_KEY");
0100     queryStrings.push_back("GT_KEY");
0101     //    queryStrings.push_back( "TSP0_KEY" ) ;
0102 
0103     l1t::OMDSReader::QueryResults subkeyResults = m_omdsReader.basicQuery(queryStrings,
0104                                                                           "CMS_TRG_L1_CONF",
0105                                                                           "TRIGGERSUP_CONF",
0106                                                                           "TRIGGERSUP_CONF.TS_KEY",
0107                                                                           m_omdsReader.singleAttribute(m_tscKey));
0108 
0109     if (subkeyResults.queryFailed() || subkeyResults.numberRows() != 1)  // check query successful
0110     {
0111       edm::LogError("L1-O2O") << "Problem with subsystem keys.";
0112       return pL1TriggerKey;
0113     }
0114 
0115     std::string csctfKey, dttfKey, rpcKey, gmtKey, rctKey, gctKey, gtKey;
0116 
0117     subkeyResults.fillVariable("CSCTF_KEY", csctfKey);
0118     pL1TriggerKey->setSubsystemKey(L1TriggerKey::kCSCTF, csctfKey);
0119     edm::LogVerbatim("L1-O2O") << "CSCTF_KEY " << csctfKey;
0120 
0121     subkeyResults.fillVariable("DTTF_KEY", dttfKey);
0122     pL1TriggerKey->setSubsystemKey(L1TriggerKey::kDTTF, dttfKey);
0123     edm::LogVerbatim("L1-O2O") << "DTTF_KEY " << dttfKey;
0124 
0125     subkeyResults.fillVariable("RPC_KEY", rpcKey);
0126     pL1TriggerKey->setSubsystemKey(L1TriggerKey::kRPC, rpcKey);
0127     edm::LogVerbatim("L1-O2O") << "RPC_KEY " << rpcKey;
0128 
0129     subkeyResults.fillVariable("GMT_KEY", gmtKey);
0130     pL1TriggerKey->setSubsystemKey(L1TriggerKey::kGMT, gmtKey);
0131     edm::LogVerbatim("L1-O2O") << "GMT_KEY " << gmtKey;
0132 
0133     subkeyResults.fillVariable("RCT_KEY", rctKey);
0134     pL1TriggerKey->setSubsystemKey(L1TriggerKey::kRCT, rctKey);
0135     edm::LogVerbatim("L1-O2O") << "RCT_KEY " << rctKey;
0136 
0137     subkeyResults.fillVariable("GCT_KEY", gctKey);
0138     pL1TriggerKey->setSubsystemKey(L1TriggerKey::kGCT, gctKey);
0139     edm::LogVerbatim("L1-O2O") << "GCT_KEY " << gctKey;
0140 
0141     subkeyResults.fillVariable("GT_KEY", gtKey);
0142     pL1TriggerKey->setSubsystemKey(L1TriggerKey::kGT, gtKey);
0143     edm::LogVerbatim("L1-O2O") << "GT_KEY " << gtKey;
0144 
0145     //       std::string tsp0Key = row[ "TSP0_KEY" ].data< std::string >() ;
0146     std::string tsp0Key;
0147     pL1TriggerKey->setSubsystemKey(L1TriggerKey::kTSP0, tsp0Key);
0148     edm::LogVerbatim("L1-O2O") << "TSP0_KEY " << tsp0Key;
0149   } else {
0150     throw l1t::DataAlreadyPresentException("L1TriggerKey for TSC key " + m_tscKey + " already in CondDB.");
0151   }
0152 
0153   return pL1TriggerKey;
0154 }
0155 
0156 //define this as a plug-in
0157 //DEFINE_FWK_EVENTSETUP_MODULE(L1SubsystemKeysOnlineProd);