CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/L1TriggerConfig/RCTConfigProducers/src/RCTObjectKeysOnlineProd.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1TriggerConfig
00004 // Class:      RCTObjectKeysOnlineProd
00005 // 
00013 //
00014 // Original Author:  Werner Man-Li Sun
00015 //         Created:  Fri Aug 22 19:51:36 CEST 2008
00016 // $Id: RCTObjectKeysOnlineProd.cc,v 1.8 2010/05/21 13:36:40 efron Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 
00023 // user include files
00024 #include "CondTools/L1Trigger/interface/L1ObjectKeysOnlineProdBase.h"
00025 
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027 
00028 //
00029 // class declaration
00030 //
00031 
00032 class RCTObjectKeysOnlineProd : public L1ObjectKeysOnlineProdBase {
00033    public:
00034       RCTObjectKeysOnlineProd(const edm::ParameterSet&);
00035       ~RCTObjectKeysOnlineProd();
00036 
00037       virtual void fillObjectKeys( ReturnType pL1TriggerKey ) ;
00038    private:
00039       // ----------member data ---------------------------
00040 };
00041 
00042 //
00043 // constants, enums and typedefs
00044 //
00045 
00046 //
00047 // static data member definitions
00048 //
00049 
00050 //
00051 // constructors and destructor
00052 //
00053 RCTObjectKeysOnlineProd::RCTObjectKeysOnlineProd(const edm::ParameterSet& iConfig)
00054   : L1ObjectKeysOnlineProdBase( iConfig )
00055 {}
00056 
00057 
00058 RCTObjectKeysOnlineProd::~RCTObjectKeysOnlineProd()
00059 {
00060  
00061    // do anything here that needs to be done at desctruction time
00062    // (e.g. close files, deallocate resources etc.)
00063 
00064 }
00065 
00066 
00067 //
00068 // member functions
00069 //
00070 
00071 // ------------ method called to produce the data  ------------
00072 void
00073 RCTObjectKeysOnlineProd::fillObjectKeys( ReturnType pL1TriggerKey )
00074 {
00075   std::string rctKey = pL1TriggerKey->subsystemKey( L1TriggerKey::kRCT ) ;
00076 
00077   if( !rctKey.empty() )
00078     {
00079       std::string paremKey, scaleKey, ecalScaleKey , hcalScaleKey;
00080       // SELECT RCT_PARAMETER FROM RCT_CONF WHERE RCT_CONF.RCT_KEY = rctKey
00081       l1t::OMDSReader::QueryResults paremKeyResults =
00082         m_omdsReader.basicQuery( "RCT_PARAMETER",
00083                                  "CMS_RCT",
00084                                  "RCT_CONF",
00085                                  "RCT_CONF.RCT_KEY",
00086                                  m_omdsReader.singleAttribute( rctKey  ) );
00087 
00088 
00089       if( paremKeyResults.queryFailed() ||
00090           paremKeyResults.numberRows() != 1 ) // check query successful
00091         {
00092           edm::LogError( "L1-O2O" ) << "Problem with RCT Parameter key." ;
00093           return ;
00094         }
00095 
00096 
00097       l1t::OMDSReader::QueryResults scaleKeyResults =
00098         m_omdsReader.basicQuery( "L1T_SCALE_CALO_ET_THRESHOLD_ID",
00099                                  "CMS_RCT",
00100                                  "PAREM_CONF",
00101                                  "PAREM_CONF.PAREM_KEY",
00102                                  paremKeyResults );  // not null no need to check
00103 
00104       l1t::OMDSReader::QueryResults ecalKeyResults =
00105         m_omdsReader.basicQuery("ECAL_CONF",
00106                                 "CMS_RCT",
00107                                 "RCT_CONF",
00108                                 "RCT_CONF.RCT_KEY",
00109                                 m_omdsReader.singleAttribute(rctKey));
00110 
00111       if( ecalKeyResults.queryFailed() ||
00112           ecalKeyResults.numberRows() > 1 ) // check query successful)  
00113         {
00114           edm::LogError( "L1-O2O" ) << "Problem with rct_conf.ecal_conf." ;
00115           return ;
00116         }
00117       std::string ecalKey;
00118       if(!ecalKeyResults.fillVariable(ecalKey))
00119          ecalScaleKey = "NULL";
00120       else { // fill variable not null
00121 
00122         if( ecalKey == "NULL")
00123           ecalScaleKey = "NULL";
00124         else if(ecalKey == "IDENTITY")
00125           ecalScaleKey = "IDENTITY";
00126         else { // not identity or null
00127       
00128 
00129         l1t::OMDSReader::QueryResults ecalScaleKeyResults =
00130           m_omdsReader.basicQuery( "ECAL_LUT_CONFIG_ID",
00131                                      "CMS_RCT",
00132                                      "ECAL_SCALE_KEY",
00133                                    "ECAL_SCALE_KEY.ECAL_TAG",
00134                                      ecalKeyResults);
00135         
00136           if( ecalScaleKeyResults.queryFailed() ||
00137               ecalScaleKeyResults.numberRows() > 1 ) // check query successful)
00138             {
00139               std::cout << " nrows " << ecalScaleKeyResults.numberRows() <<std::endl;
00140               edm::LogError( "L1-O2O" ) << "bad results from lut_config_id." ;
00141               return ;
00142             }
00143           int ecalScaleTemp;
00144          
00145           ecalScaleKeyResults.fillVariable( ecalScaleTemp );
00146 
00147         
00148 
00149 
00150          std::stringstream ss;
00151          ss << ecalScaleTemp;
00152          ecalScaleKey = ss.str();
00153         }
00154       }    
00155 
00156       l1t::OMDSReader::QueryResults hcalKeyResults =
00157         m_omdsReader.basicQuery("HCAL_CONF",
00158                                 "CMS_RCT",
00159                                 "RCT_CONF",
00160                                 "RCT_CONF.RCT_KEY",
00161                                 m_omdsReader.singleAttribute(rctKey));
00162 
00163       if( hcalKeyResults.queryFailed() ||
00164           hcalKeyResults.numberRows() > 1 ) // check query successful)  
00165         {
00166           edm::LogError( "L1-O2O" ) << "Problem with rct_conf.hcal_conf." ;
00167           return ;
00168         }
00169       std::string hcalKey;
00170       if(!hcalKeyResults.fillVariable(hcalScaleKey))
00171         hcalScaleKey = "NULL";
00172   
00173     
00174 
00175       paremKeyResults.fillVariable( paremKey ) ;
00176       scaleKeyResults.fillVariable( scaleKey ) ;
00177   
00178       
00179       pL1TriggerKey->add( "L1RCTParametersRcd",
00180                           "L1RCTParameters",
00181                           paremKey ) ;
00182       pL1TriggerKey->add( "L1EmEtScaleRcd",
00183                           "L1CaloEtScale",
00184                           scaleKey ) ;
00185       pL1TriggerKey->add( "L1CaloEcalScaleRcd",
00186                           "L1CaloEcalScale",
00187                           ecalScaleKey ) ;
00188       pL1TriggerKey->add( "L1CaloHcalScaleRcd",
00189                           "L1CaloHcalScale",
00190                           hcalScaleKey ) ;
00191     }
00192 }
00193 
00194 
00195 //define this as a plug-in
00196 DEFINE_FWK_EVENTSETUP_MODULE(RCTObjectKeysOnlineProd);