CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CondTools/L1Trigger/plugins/L1SubsystemKeysOnlineProd.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1SubsystemKeysOnlineProd
00004 // Class:      L1SubsystemKeysOnlineProd
00005 // 
00013 //
00014 // Original Author:  Werner Man-Li Sun
00015 //         Created:  Thu Aug 21 20:00:59 CEST 2008
00016 // $Id: L1SubsystemKeysOnlineProd.cc,v 1.6 2010/02/16 21:59:24 wsun Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 
00023 // user include files
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 
00026 #include "CondTools/L1Trigger/plugins/L1SubsystemKeysOnlineProd.h"
00027 
00028 #include "CondTools/L1Trigger/interface/Exception.h"
00029 #include "CondTools/L1Trigger/interface/DataWriter.h"
00030 
00031 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
00032 #include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
00033 
00034 #include "FWCore/Framework/interface/EventSetup.h"
00035 
00036 //
00037 // class declaration
00038 //
00039 
00040 //
00041 // constants, enums and typedefs
00042 //
00043 
00044 //
00045 // static data member definitions
00046 //
00047 
00048 //
00049 // constructors and destructor
00050 //
00051 L1SubsystemKeysOnlineProd::L1SubsystemKeysOnlineProd(const edm::ParameterSet& iConfig)
00052    : m_tscKey( iConfig.getParameter< std::string >( "tscKey" ) ),
00053      m_omdsReader(
00054         iConfig.getParameter< std::string >( "onlineDB" ),
00055         iConfig.getParameter< std::string >( "onlineAuthentication" ) ),
00056      m_forceGeneration( iConfig.getParameter< bool >( "forceGeneration" ) )
00057 {
00058    //the following line is needed to tell the framework what
00059    // data is being produced
00060   setWhatProduced(this, "SubsystemKeysOnly");
00061 
00062    //now do what ever other initialization is needed
00063 }
00064 
00065 
00066 L1SubsystemKeysOnlineProd::~L1SubsystemKeysOnlineProd()
00067 {
00068  
00069    // do anything here that needs to be done at desctruction time
00070    // (e.g. close files, deallocate resources etc.)
00071 
00072 }
00073 
00074 
00075 //
00076 // member functions
00077 //
00078 
00079 // ------------ method called to produce the data  ------------
00080 L1SubsystemKeysOnlineProd::ReturnType
00081 L1SubsystemKeysOnlineProd::produce(const L1TriggerKeyRcd& iRecord)
00082 {
00083    using namespace edm::es;
00084    boost::shared_ptr<L1TriggerKey> pL1TriggerKey ;
00085 
00086    // Get L1TriggerKeyList
00087    L1TriggerKeyList keyList ;
00088    l1t::DataWriter dataWriter ;
00089    if( !dataWriter.fillLastTriggerKeyList( keyList ) )
00090      {
00091        edm::LogError( "L1-O2O" )
00092          << "Problem getting last L1TriggerKeyList" ;
00093      }
00094 
00095    // If L1TriggerKeyList does not contain TSC key, token is empty
00096    if( keyList.token( m_tscKey ) == std::string() ||
00097        m_forceGeneration )
00098      {
00099        // Instantiate new L1TriggerKey
00100        pL1TriggerKey = boost::shared_ptr< L1TriggerKey >(
00101          new L1TriggerKey() ) ;
00102        pL1TriggerKey->setTSCKey( m_tscKey ) ;
00103 
00104        edm::LogVerbatim( "L1-O2O" ) << "TSC KEY " << m_tscKey ;
00105 
00106        // Get subsystem keys from OMDS
00107 
00108        // 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
00109        std::vector< std::string > queryStrings ;
00110        queryStrings.push_back( "CSCTF_KEY" ) ;
00111        queryStrings.push_back( "DTTF_KEY" ) ;
00112        queryStrings.push_back( "RPC_KEY" ) ;
00113        queryStrings.push_back( "GMT_KEY" ) ;
00114        queryStrings.push_back( "RCT_KEY" ) ;
00115        queryStrings.push_back( "GCT_KEY" ) ;
00116        queryStrings.push_back( "GT_KEY" ) ;
00117        //         queryStrings.push_back( "TSP0_KEY" ) ;
00118 
00119        l1t::OMDSReader::QueryResults subkeyResults =
00120          m_omdsReader.basicQuery( queryStrings,
00121                                   "CMS_TRG_L1_CONF",
00122                                   "TRIGGERSUP_CONF",
00123                                   "TRIGGERSUP_CONF.TS_KEY",
00124                                   m_omdsReader.singleAttribute( m_tscKey ) ) ;
00125 
00126        if( subkeyResults.queryFailed() ||
00127            subkeyResults.numberRows() != 1 ) // check query successful
00128          {
00129            edm::LogError( "L1-O2O" ) << "Problem with subsystem keys." ;
00130            return pL1TriggerKey ;
00131          }
00132 
00133        std::string csctfKey, dttfKey, rpcKey, gmtKey, rctKey, gctKey, gtKey ;
00134 
00135        subkeyResults.fillVariable( "CSCTF_KEY", csctfKey ) ;
00136        pL1TriggerKey->setSubsystemKey( L1TriggerKey::kCSCTF, csctfKey ) ;
00137        edm::LogVerbatim( "L1-O2O" ) << "CSCTF_KEY " << csctfKey ;
00138 
00139        subkeyResults.fillVariable( "DTTF_KEY", dttfKey ) ;
00140        pL1TriggerKey->setSubsystemKey( L1TriggerKey::kDTTF, dttfKey ) ;
00141        edm::LogVerbatim( "L1-O2O" ) << "DTTF_KEY " << dttfKey ;
00142 
00143        subkeyResults.fillVariable( "RPC_KEY", rpcKey ) ;
00144        pL1TriggerKey->setSubsystemKey( L1TriggerKey::kRPC, rpcKey ) ;
00145        edm::LogVerbatim( "L1-O2O" ) << "RPC_KEY " << rpcKey ;
00146 
00147        subkeyResults.fillVariable( "GMT_KEY", gmtKey ) ;
00148        pL1TriggerKey->setSubsystemKey( L1TriggerKey::kGMT, gmtKey ) ;
00149        edm::LogVerbatim( "L1-O2O" ) << "GMT_KEY " << gmtKey ;
00150 
00151        subkeyResults.fillVariable( "RCT_KEY", rctKey ) ;
00152        pL1TriggerKey->setSubsystemKey( L1TriggerKey::kRCT, rctKey ) ;
00153        edm::LogVerbatim( "L1-O2O" ) << "RCT_KEY " << rctKey ;
00154 
00155        subkeyResults.fillVariable( "GCT_KEY", gctKey ) ;
00156        pL1TriggerKey->setSubsystemKey( L1TriggerKey::kGCT, gctKey ) ;
00157        edm::LogVerbatim( "L1-O2O" ) << "GCT_KEY " << gctKey ;
00158 
00159        subkeyResults.fillVariable( "GT_KEY", gtKey ) ;
00160        pL1TriggerKey->setSubsystemKey( L1TriggerKey::kGT, gtKey ) ;
00161        edm::LogVerbatim( "L1-O2O" ) << "GT_KEY " << gtKey ;
00162 
00163        //       std::string tsp0Key = row[ "TSP0_KEY" ].data< std::string >() ;
00164        std::string tsp0Key ;
00165        pL1TriggerKey->setSubsystemKey( L1TriggerKey::kTSP0, tsp0Key ) ;
00166        edm::LogVerbatim( "L1-O2O" ) << "TSP0_KEY " << tsp0Key ;
00167    }
00168    else
00169    {
00170      throw l1t::DataAlreadyPresentException(
00171         "L1TriggerKey for TSC key " + m_tscKey + " already in CondDB." ) ;
00172    }
00173 
00174    return pL1TriggerKey ;
00175 }
00176 
00177 //define this as a plug-in
00178 //DEFINE_FWK_EVENTSETUP_MODULE(L1SubsystemKeysOnlineProd);