CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/L1TriggerConfig/L1ScalesProducers/src/L1HfRingEtScaleOnlineProd.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1HfRingEtScaleOnlineProd
00004 // Class:      L1HfRingEtScaleOnlineProd
00005 // 
00013 //
00014 // Original Author:  Werner Man-Li Sun
00015 //         Created:  Tue Sep 16 22:43:22 CEST 2008
00016 // $Id: L1HfRingEtScaleOnlineProd.cc,v 1.5 2012/06/18 10:17:56 eulisse Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 
00023 // user include files
00024 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
00025 
00026 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
00027 #include "CondFormats/DataRecord/interface/L1HfRingEtScaleRcd.h"
00028 
00029 
00030 //
00031 // class declaration
00032 //
00033 
00034 class L1HfRingEtScaleOnlineProd :
00035   public L1ConfigOnlineProdBase< L1HfRingEtScaleRcd, L1CaloEtScale > {
00036    public:
00037       L1HfRingEtScaleOnlineProd(const edm::ParameterSet&);
00038       ~L1HfRingEtScaleOnlineProd();
00039 
00040   virtual boost::shared_ptr< L1CaloEtScale > newObject(
00041     const std::string& objectKey ) ;
00042 
00043 
00044    private:
00045       // ----------member data ---------------------------
00046 };
00047 
00048 //
00049 // constants, enums and typedefs
00050 //
00051 
00052 //
00053 // static data member definitions
00054 //
00055 
00056 //
00057 // constructors and destructor
00058 //
00059 L1HfRingEtScaleOnlineProd::L1HfRingEtScaleOnlineProd(
00060   const edm::ParameterSet& iConfig)
00061   : L1ConfigOnlineProdBase< L1HfRingEtScaleRcd, L1CaloEtScale >( iConfig )
00062 {
00063    //the following line is needed to tell the framework what
00064    // data is being produced
00065 
00066    //now do what ever other initialization is needed
00067 }
00068 
00069 
00070 L1HfRingEtScaleOnlineProd::~L1HfRingEtScaleOnlineProd()
00071 {
00072  
00073    // do anything here that needs to be done at desctruction time
00074    // (e.g. close files, deallocate resources etc.)
00075 
00076 }
00077 
00078 boost::shared_ptr< L1CaloEtScale >
00079 L1HfRingEtScaleOnlineProd::newObject( const std::string& objectKey )
00080 {
00081      using namespace edm::es;
00082 
00083      // get scales keys
00084      l1t::OMDSReader::QueryResults scalesKeyResults =
00085        m_omdsReader.basicQuery(
00086                                "GCT_SCALES_KEY",
00087                                "CMS_GCT",
00088                                "GCT_PHYS_PARAMS",
00089                                "GCT_PHYS_PARAMS.CONFIG_KEY",
00090                                m_omdsReader.singleAttribute( objectKey ) );
00091      
00092      std::string scalesKey ;
00093      
00094      if( scalesKeyResults.queryFailed() ) {
00095        edm::LogError("L1-O2O")
00096          << "Problem with key for L1JetEtScaleRcd : GCT scales key query failed ";
00097      }
00098      else if( scalesKeyResults.numberRows() != 1 ) {
00099        edm::LogError("L1-O2O")
00100          << "Problem with key for L1JetEtScaleRcd : "
00101          << (scalesKeyResults.numberRows()) << " rows were returned when getting GCT scales key";
00102      }
00103      else {
00104        scalesKeyResults.fillVariable( scalesKey );
00105      }
00106      
00107 
00108      // get ring scale key
00109      l1t::OMDSReader::QueryResults hfRingScaleKeyResults =
00110        m_omdsReader.basicQuery(
00111                                "SC_HF_ET_SUM_FK",
00112                                "CMS_GT",
00113                                "L1T_SCALES",
00114                                "L1T_SCALES.ID",
00115                                scalesKeyResults );
00116 
00117      std::string hfRingScaleKey ;
00118 
00119      if( hfRingScaleKeyResults.queryFailed() ) {
00120        edm::LogError("L1-O2O")
00121          << "Problem with key for L1HfRingEtScaleRcd : HF ring Et scale key query failed ";
00122      }
00123      else if( hfRingScaleKeyResults.numberRows() != 1 ) {
00124        edm::LogError("L1-O2O")
00125          << "Problem with key for L1HfRingEtScaleRcd : "
00126          << (hfRingScaleKeyResults.numberRows()) << " rows were returned when getting HF ring Et scale key";
00127      }
00128      else {
00129        hfRingScaleKeyResults.fillVariable( hfRingScaleKey ) ;
00130      }
00131  
00132      // get thresholds
00133      std::vector< std::string > queryStrings ;
00134      queryStrings.push_back( "E_GEV_BIN_LOW_0");
00135      queryStrings.push_back( "E_GEV_BIN_LOW_1");
00136      queryStrings.push_back( "E_GEV_BIN_LOW_2");
00137      queryStrings.push_back( "E_GEV_BIN_LOW_3");
00138      queryStrings.push_back( "E_GEV_BIN_LOW_4");
00139      queryStrings.push_back( "E_GEV_BIN_LOW_5");
00140      queryStrings.push_back( "E_GEV_BIN_LOW_6");
00141      queryStrings.push_back( "E_GEV_BIN_LOW_7");
00142 
00143      l1t::OMDSReader::QueryResults scaleResults =
00144        m_omdsReader.basicQuery( queryStrings,
00145                                 "CMS_GT",
00146                                 "L1T_SCALE_HF_ET_SUM",
00147                                 "L1T_SCALE_HF_ET_SUM.ID",
00148                                 hfRingScaleKeyResults
00149                                 );
00150 
00151      std::vector<double> thresholds;
00152 
00153      if( scaleResults.queryFailed() ) {
00154          edm::LogError( "L1-O2O" ) << "Problem with L1HfRingEtScale key : scale query failed." ;
00155      }
00156      else if ( scaleResults.numberRows() != 1 ) {
00157          edm::LogError( "L1-O2O" ) << "Problem with L1HfRingEtScale key : scale query failed." ;
00158      }
00159      else {
00160        for( std::vector< std::string >::iterator thresh = queryStrings.begin();
00161             thresh != queryStrings.end(); ++thresh) {
00162          float tempScale = 0.;
00163          scaleResults.fillVariable(*thresh,tempScale);
00164          thresholds.push_back(tempScale);
00165        }
00166      }
00167 
00168      // get region LSB
00169      double rgnEtLsb=0.;
00170      
00171      l1t::OMDSReader::QueryResults lsbResults =
00172        m_omdsReader.basicQuery( "GCT_RGN_ET_LSB",
00173                                 "CMS_GCT",
00174                                 "GCT_PHYS_PARAMS",
00175                                 "GCT_PHYS_PARAMS.CONFIG_KEY",
00176                                 m_omdsReader.singleAttribute( objectKey ) ) ;
00177      
00178      if( lsbResults.queryFailed() ) {
00179          edm::LogError( "L1-O2O" ) << "Problem with L1JetEtScale key." ;
00180      }
00181      else {
00182        lsbResults.fillVariable( "GCT_RGN_ET_LSB", rgnEtLsb );
00183      }
00184 
00185      //~~~~~~~~~ Instantiate new L1HfRingEtScale object. ~~~~~~~~~
00186      return boost::shared_ptr< L1CaloEtScale >( new L1CaloEtScale(0xff, 0x7, rgnEtLsb, thresholds ) );
00187 }
00188 
00189 
00190 // ------------ method called to produce the data  ------------
00191 
00192 
00193 //define this as a plug-in
00194 DEFINE_FWK_EVENTSETUP_MODULE(L1HfRingEtScaleOnlineProd);