CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/L1TriggerConfig/L1ScalesProducers/src/L1MuTriggerScaleKeysOnlineProd.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   \class L1MuGMTParametersOnlineProd
00004 //
00005 //   Description:      A key producer to deduce the GMT LUT keys from the master 
00006 //                     GMT configuration  key, closely following the example of 
00007 //
00008 //   https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideL1ConfigOnlineProd r11
00009 //
00010 //   $Date: 2009/03/18 14:13:10 $
00011 //   $Revision: 1.3 $
00012 //
00013 //   Author :
00014 //   Thomas Themel
00015 //
00016 //--------------------------------------------------
00017 
00018 #include "CondTools/L1Trigger/interface/L1ObjectKeysOnlineProdBase.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 #include "CondCore/DBCommon/interface/Exception.h"
00021 
00022 
00023 class L1MuTriggerScaleKeysOnlineProd : public L1ObjectKeysOnlineProdBase {
00024    public:
00025       L1MuTriggerScaleKeysOnlineProd(const edm::ParameterSet& iConfig)
00026           : L1ObjectKeysOnlineProdBase( iConfig ),
00027             m_objectTypes(iConfig.getParameter<std::vector<std::string> >("objectTypes")),
00028             m_recordTypes(iConfig.getParameter<std::vector<std::string> >("recordTypes"))
00029       {
00030         if(m_objectTypes.size() != m_recordTypes.size()) { 
00031             throw cond::Exception("mismatch: need equal number objectType and recordType entries!");
00032         }        
00033       }
00034 
00035       ~L1MuTriggerScaleKeysOnlineProd() {}
00036 
00037       virtual void fillObjectKeys( ReturnType pL1TriggerKey ) ;
00038 
00039    private:    
00040     std::vector<std::string> m_objectTypes;
00041     std::vector<std::string> m_recordTypes;
00042 
00043 };
00044 
00045 void
00046 L1MuTriggerScaleKeysOnlineProd::fillObjectKeys( ReturnType pL1TriggerKey )
00047 {
00048     
00049       std::string subsystemKey = pL1TriggerKey->subsystemKey( L1TriggerKey::kGMT ) ;
00050 
00051       if( !subsystemKey.empty() )
00052         {
00053       // Lookup GT scales key from GMT main config key
00054       l1t::OMDSReader::QueryResults scalesKeyResults =
00055       m_omdsReader.basicQuery(
00056           // SELECTed column
00057           "SCALES_KEY",
00058           // schema name
00059           "CMS_GMT",
00060           // table name
00061           "GMT_CONFIG",
00062           // WHERE lhs
00063           "GMT_CONFIG.KEY",
00064           // WHERE rhs
00065           m_omdsReader.singleAttribute( subsystemKey  ) );
00066 
00067       if( scalesKeyResults.numberRows() != 1 ) // check if query was successful
00068       {
00069          edm::LogError( "L1-O2O" ) << "Problem extracting GMT scales key from GMT config key." ;
00070          return ;
00071       }
00072 
00073       std::string objectKey ;
00074       scalesKeyResults.fillVariable(objectKey) ;
00075 
00076       edm::LogError( "L1-O2O" ) << "Registering " << m_recordTypes.size() << " keys ";
00077       // register the scales key for all the scales types we need to produce
00078       for(unsigned i = 0; i < m_recordTypes.size() ; ++i) { 
00079         edm::LogError( "L1-O2O" ) << "Registering scales key " << objectKey << " for " << m_recordTypes[i];
00080           pL1TriggerKey->add(m_recordTypes[i], m_objectTypes[i], objectKey ) ;
00081       }
00082         }
00083 }
00084 
00085 DEFINE_FWK_EVENTSETUP_MODULE(L1MuTriggerScaleKeysOnlineProd);