CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/L1TriggerConfig/L1ScalesProducers/src/L1JetEtScaleOnlineProd.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1JetEtScaleOnlineProd
00004 // Class:      L1JetEtScaleOnlineProd
00005 // 
00013 //
00014 // Original Author:  Werner Man-Li Sun
00015 //         Created:  Tue Sep 16 22:43:22 CEST 2008
00016 // $Id: L1JetEtScaleOnlineProd.cc,v 1.4 2009/03/27 13:22:46 jbrooke 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/L1JetEtScaleRcd.h"
00028 
00029 
00030 //
00031 // class declaration
00032 //
00033 
00034 class L1JetEtScaleOnlineProd :
00035   public L1ConfigOnlineProdBase< L1JetEtScaleRcd, L1CaloEtScale > {
00036    public:
00037       L1JetEtScaleOnlineProd(const edm::ParameterSet&);
00038       ~L1JetEtScaleOnlineProd();
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 L1JetEtScaleOnlineProd::L1JetEtScaleOnlineProd(
00060   const edm::ParameterSet& iConfig)
00061   : L1ConfigOnlineProdBase< L1JetEtScaleRcd, 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 L1JetEtScaleOnlineProd::~L1JetEtScaleOnlineProd()
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 L1JetEtScaleOnlineProd::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 jet scale key
00109      l1t::OMDSReader::QueryResults jetScaleKeyResults =
00110        m_omdsReader.basicQuery(
00111                                "SC_CENJET_ET_THRESHOLD_FK",
00112                                "CMS_GT",
00113                                "L1T_SCALES",
00114                                "L1T_SCALES.ID",
00115                                scalesKeyResults );
00116 
00117      std::string jetScaleKey ;
00118 
00119      if( jetScaleKeyResults.queryFailed() ) {
00120        edm::LogError("L1-O2O")
00121          << "Problem with key for L1GctJetEtScaleRcd : jet scale key query failed ";
00122      }
00123      else if( jetScaleKeyResults.numberRows() != 1 ) {
00124        edm::LogError("L1-O2O")
00125          << "Problem with key for L1GctJetEtScaleRcd : "
00126          << (jetScaleKeyResults.numberRows()) << " rows were returned when getting jet Et scale key";
00127      }
00128      else {
00129        jetScaleKeyResults.fillVariable( jetScaleKey ) ;
00130      }
00131      
00132      // get thresholds
00133      std::vector< std::string > queryStrings ;
00134      queryStrings.push_back( "ET_GEV_BIN_LOW_0");
00135      queryStrings.push_back( "ET_GEV_BIN_LOW_1");
00136      queryStrings.push_back( "ET_GEV_BIN_LOW_2");
00137      queryStrings.push_back( "ET_GEV_BIN_LOW_3");
00138      queryStrings.push_back( "ET_GEV_BIN_LOW_4");
00139      queryStrings.push_back( "ET_GEV_BIN_LOW_5");
00140      queryStrings.push_back( "ET_GEV_BIN_LOW_6");
00141      queryStrings.push_back( "ET_GEV_BIN_LOW_7");
00142      queryStrings.push_back( "ET_GEV_BIN_LOW_8");
00143      queryStrings.push_back( "ET_GEV_BIN_LOW_9");
00144      queryStrings.push_back( "ET_GEV_BIN_LOW_10");
00145      queryStrings.push_back( "ET_GEV_BIN_LOW_11");
00146      queryStrings.push_back( "ET_GEV_BIN_LOW_12");
00147      queryStrings.push_back( "ET_GEV_BIN_LOW_13");
00148      queryStrings.push_back( "ET_GEV_BIN_LOW_14");
00149      queryStrings.push_back( "ET_GEV_BIN_LOW_15");
00150      queryStrings.push_back( "ET_GEV_BIN_LOW_16");
00151      queryStrings.push_back( "ET_GEV_BIN_LOW_17");
00152      queryStrings.push_back( "ET_GEV_BIN_LOW_18");
00153      queryStrings.push_back( "ET_GEV_BIN_LOW_19");
00154      queryStrings.push_back( "ET_GEV_BIN_LOW_20");
00155      queryStrings.push_back( "ET_GEV_BIN_LOW_21");
00156      queryStrings.push_back( "ET_GEV_BIN_LOW_22");
00157      queryStrings.push_back( "ET_GEV_BIN_LOW_23");
00158      queryStrings.push_back( "ET_GEV_BIN_LOW_24");
00159      queryStrings.push_back( "ET_GEV_BIN_LOW_25");
00160      queryStrings.push_back( "ET_GEV_BIN_LOW_26");
00161      queryStrings.push_back( "ET_GEV_BIN_LOW_27");
00162      queryStrings.push_back( "ET_GEV_BIN_LOW_28");
00163      queryStrings.push_back( "ET_GEV_BIN_LOW_29");
00164      queryStrings.push_back( "ET_GEV_BIN_LOW_30");
00165      queryStrings.push_back( "ET_GEV_BIN_LOW_31");
00166      queryStrings.push_back( "ET_GEV_BIN_LOW_32");
00167      queryStrings.push_back( "ET_GEV_BIN_LOW_33");
00168      queryStrings.push_back( "ET_GEV_BIN_LOW_34");
00169      queryStrings.push_back( "ET_GEV_BIN_LOW_35");
00170      queryStrings.push_back( "ET_GEV_BIN_LOW_36");
00171      queryStrings.push_back( "ET_GEV_BIN_LOW_37");
00172      queryStrings.push_back( "ET_GEV_BIN_LOW_38");
00173      queryStrings.push_back( "ET_GEV_BIN_LOW_39");
00174      queryStrings.push_back( "ET_GEV_BIN_LOW_40");
00175      queryStrings.push_back( "ET_GEV_BIN_LOW_41");
00176      queryStrings.push_back( "ET_GEV_BIN_LOW_42");
00177      queryStrings.push_back( "ET_GEV_BIN_LOW_43");
00178      queryStrings.push_back( "ET_GEV_BIN_LOW_44");
00179      queryStrings.push_back( "ET_GEV_BIN_LOW_45");
00180      queryStrings.push_back( "ET_GEV_BIN_LOW_46");
00181      queryStrings.push_back( "ET_GEV_BIN_LOW_47");
00182      queryStrings.push_back( "ET_GEV_BIN_LOW_48");
00183      queryStrings.push_back( "ET_GEV_BIN_LOW_49");
00184      queryStrings.push_back( "ET_GEV_BIN_LOW_50");
00185      queryStrings.push_back( "ET_GEV_BIN_LOW_51");
00186      queryStrings.push_back( "ET_GEV_BIN_LOW_52");
00187      queryStrings.push_back( "ET_GEV_BIN_LOW_53");
00188      queryStrings.push_back( "ET_GEV_BIN_LOW_54");
00189      queryStrings.push_back( "ET_GEV_BIN_LOW_55");
00190      queryStrings.push_back( "ET_GEV_BIN_LOW_56");
00191      queryStrings.push_back( "ET_GEV_BIN_LOW_57");
00192      queryStrings.push_back( "ET_GEV_BIN_LOW_58");
00193      queryStrings.push_back( "ET_GEV_BIN_LOW_59");
00194      queryStrings.push_back( "ET_GEV_BIN_LOW_60");
00195      queryStrings.push_back( "ET_GEV_BIN_LOW_61");
00196      queryStrings.push_back( "ET_GEV_BIN_LOW_62");
00197      queryStrings.push_back( "ET_GEV_BIN_LOW_63");
00198 
00199      l1t::OMDSReader::QueryResults scaleResults =
00200        m_omdsReader.basicQuery( queryStrings,
00201                                 "CMS_GT",
00202                                 "L1T_SCALE_CALO_ET_THRESHOLD",
00203                                 "L1T_SCALE_CALO_ET_THRESHOLD.ID",
00204                                 jetScaleKeyResults
00205                                 );
00206 
00207      std::vector<double> thresholds;
00208 
00209      if( scaleResults.queryFailed() ||
00210          scaleResults.numberRows() != 1 ) // check query successful
00211        {
00212          edm::LogError( "L1-O2O" ) << "Problem with L1JetEtScale key : when reading scale." ;
00213        }
00214      else {
00215        for( std::vector< std::string >::iterator thresh = queryStrings.begin();
00216             thresh != queryStrings.end(); ++thresh) {
00217          float tempScale;
00218          scaleResults.fillVariable(*thresh,tempScale);
00219          thresholds.push_back(tempScale);
00220        }
00221      }
00222 
00223      // get region LSB
00224      double rgnEtLsb=0.;
00225 
00226      l1t::OMDSReader::QueryResults lsbResults =
00227        m_omdsReader.basicQuery( "GCT_RGN_ET_LSB",
00228                                 "CMS_GCT",
00229                                 "GCT_PHYS_PARAMS",
00230                                 "GCT_PHYS_PARAMS.CONFIG_KEY",
00231                                 m_omdsReader.singleAttribute( objectKey ) ) ;
00232      
00233      if( lsbResults.queryFailed() ) {
00234          edm::LogError( "L1-O2O" ) << "Problem with L1JetEtScale key." ;
00235      }
00236      else {
00237       lsbResults.fillVariable( "GCT_RGN_ET_LSB", rgnEtLsb );
00238      }
00239 
00240      // return object
00241      return boost::shared_ptr< L1CaloEtScale >( new L1CaloEtScale( rgnEtLsb, thresholds ) );
00242 }
00243 
00244 
00245 // ------------ method called to produce the data  ------------
00246 
00247 
00248 //define this as a plug-in
00249 DEFINE_FWK_EVENTSETUP_MODULE(L1JetEtScaleOnlineProd);