CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/L1TriggerConfig/GctConfigProducers/src/L1GctJetFinderParamsOnlineProd.cc

Go to the documentation of this file.
00001 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
00002 #include "CondFormats/L1TObjects/interface/L1GctJetFinderParams.h"
00003 #include "CondFormats/DataRecord/interface/L1GctJetFinderParamsRcd.h"
00004 
00005 class L1GctJetFinderParamsOnlineProd : public L1ConfigOnlineProdBase< L1GctJetFinderParamsRcd, L1GctJetFinderParams > {
00006    public:
00007       L1GctJetFinderParamsOnlineProd(const edm::ParameterSet& iConfig)
00008          : L1ConfigOnlineProdBase< L1GctJetFinderParamsRcd, L1GctJetFinderParams >( iConfig ) {}
00009       ~L1GctJetFinderParamsOnlineProd() {}
00010 
00011       virtual boost::shared_ptr< L1GctJetFinderParams > newObject( const std::string& objectKey ) ;
00012    private:
00013 };
00014 
00015 boost::shared_ptr< L1GctJetFinderParams >
00016 L1GctJetFinderParamsOnlineProd::newObject( const std::string& objectKey )
00017 {
00018    // Execute SQL queries to get data from OMDS (using key) and make C++ object
00019    // Example: SELECT A_PARAMETER FROM CMS_XXX.XXX_CONF WHERE XXX_CONF.XXX_KEY = objectKey
00020 
00021   // get parameters
00022   std::vector< std::string > columns;
00023   columns.push_back( "GCT_RGN_ET_LSB" );
00024   columns.push_back( "GCT_HT_LSB" );
00025   columns.push_back( "GCT_CJET_SEED_ET_THRESHOLD" );
00026   columns.push_back( "GCT_TJET_SEED_ET_THRESHOLD" );
00027   columns.push_back( "GCT_FJET_SEED_ET_THRESHOLD" );
00028   columns.push_back( "GCT_HT_JET_ET_THRESHOLD" );
00029   columns.push_back( "GCT_MHT_JET_ET_THRESHOLD" );
00030   columns.push_back( "GCT_TAU_ISO_ET_THRESHOLD" );
00031   columns.push_back( "GCT_CEN_JET_ETA_MAX" );
00032   columns.push_back( "GCT_JET_CORR_KEY" );
00033   
00034   l1t::OMDSReader::QueryResults results =
00035     m_omdsReader.basicQuery(
00036                             columns,
00037                             "CMS_GCT",
00038                             "GCT_PHYS_PARAMS",
00039                             "GCT_PHYS_PARAMS.CONFIG_KEY",
00040                             m_omdsReader.singleAttribute( objectKey ) ) ;
00041 
00042    if( results.queryFailed() ) // check if query was successful
00043    {
00044       edm::LogError( "L1-O2O" ) << "Problem with L1GctJetFinderParams key." ;
00045       return boost::shared_ptr< L1GctJetFinderParams >() ;
00046    }
00047 
00048    // fill values
00049    double rgnEtLsb=0.;
00050    double htLsb=0.;
00051    double cJetSeed=0.;
00052    double tJetSeed=0.;
00053    double fJetSeed=0.;
00054    double tauIsoEtThresh=0.;
00055    double htJetEtThresh=0.;
00056    double mhtJetEtThresh=0.;
00057    short int etaBoundary=7;
00058    int corrType=0;
00059    std::vector< std::vector<double> > jetCorrCoeffs;
00060    std::vector< std::vector<double> > tauCorrCoeffs;
00061    bool convertToEnergy=false;            // Not in OMDS
00062    std::vector<double> energyConvCoeffs(11);  // Not in OMDS
00063    std::string jetCorrKey;
00064 
00065    results.fillVariable( "GCT_RGN_ET_LSB", rgnEtLsb );
00066    results.fillVariable( "GCT_HT_LSB", htLsb );
00067    results.fillVariable( "GCT_CJET_SEED_ET_THRESHOLD", cJetSeed );
00068    results.fillVariable( "GCT_TJET_SEED_ET_THRESHOLD", tJetSeed );
00069    results.fillVariable( "GCT_FJET_SEED_ET_THRESHOLD", fJetSeed );
00070    results.fillVariable( "GCT_TAU_ISO_ET_THRESHOLD", tauIsoEtThresh );
00071    results.fillVariable( "GCT_HT_JET_ET_THRESHOLD", htJetEtThresh );
00072    results.fillVariable( "GCT_MHT_JET_ET_THRESHOLD", mhtJetEtThresh );
00073    results.fillVariable( "GCT_CEN_JET_ETA_MAX", etaBoundary );
00074    results.fillVariable( "GCT_JET_CORR_KEY", jetCorrKey );
00075 
00076    edm::LogInfo("L1-O2O") << "L1 jet corrections key : " << jetCorrKey << std::endl;
00077 
00078    // get jet corr coefficients
00079    std::vector< std::string > jetCorrColumns;
00080    jetCorrColumns.push_back( "GCT_JETCORR_TYPE" );
00081    jetCorrColumns.push_back( "GCT_JETCORR_NETA_10" );
00082    jetCorrColumns.push_back( "GCT_JETCORR_NETA_9" );
00083    jetCorrColumns.push_back( "GCT_JETCORR_NETA_8" );
00084    jetCorrColumns.push_back( "GCT_JETCORR_NETA_7" );
00085    jetCorrColumns.push_back( "GCT_JETCORR_NETA_6" );
00086    jetCorrColumns.push_back( "GCT_JETCORR_NETA_5" );
00087    jetCorrColumns.push_back( "GCT_JETCORR_NETA_4" );
00088    jetCorrColumns.push_back( "GCT_JETCORR_NETA_3" );
00089    jetCorrColumns.push_back( "GCT_JETCORR_NETA_2" );
00090    jetCorrColumns.push_back( "GCT_JETCORR_NETA_1" );
00091    jetCorrColumns.push_back( "GCT_JETCORR_NETA_0" );
00092    jetCorrColumns.push_back( "GCT_JETCORR_PETA_0" );
00093    jetCorrColumns.push_back( "GCT_JETCORR_PETA_1" );
00094    jetCorrColumns.push_back( "GCT_JETCORR_PETA_2" );
00095    jetCorrColumns.push_back( "GCT_JETCORR_PETA_3" );
00096    jetCorrColumns.push_back( "GCT_JETCORR_PETA_4" );
00097    jetCorrColumns.push_back( "GCT_JETCORR_PETA_5" );
00098    jetCorrColumns.push_back( "GCT_JETCORR_PETA_6" );
00099    jetCorrColumns.push_back( "GCT_JETCORR_PETA_7" );
00100    jetCorrColumns.push_back( "GCT_JETCORR_PETA_8" );
00101    jetCorrColumns.push_back( "GCT_JETCORR_PETA_9" );
00102    jetCorrColumns.push_back( "GCT_JETCORR_PETA_10" );
00103    
00104    l1t::OMDSReader::QueryResults jetCorrResults =
00105     m_omdsReader.basicQuery(
00106                             jetCorrColumns,
00107                             "CMS_GCT",
00108                             "GCT_JET_CORRECTIONS",
00109                             "GCT_JET_CORRECTIONS.CONFIG_KEY",
00110                             m_omdsReader.singleAttribute( jetCorrKey ) ) ;
00111 
00112    if( jetCorrResults.queryFailed() ) // check if query was successful
00113    {
00114       edm::LogError( "L1-O2O" ) << "Problem getting L1 jet corrections" ;
00115       return boost::shared_ptr< L1GctJetFinderParams >() ;
00116    }
00117 
00118    // fill jet corr type
00119    jetCorrResults.fillVariable( "GCT_JETCORR_TYPE", corrType );
00120 
00121    edm::LogInfo("L1-O2O") << "L1 jet corrections type : " << corrType << std::endl;
00122 
00123    // get coefficients
00124    for (unsigned i=0; i < L1GctJetFinderParams::NUMBER_ETA_VALUES; ++i) {
00125 
00126      // get corr key for eta value
00127      std::stringstream etaCol;
00128      etaCol << "GCT_JETCORR_NETA_" << std::dec << i;
00129      std::string etaKey;
00130      jetCorrResults.fillVariable( etaCol.str(), etaKey );
00131 
00132      std::vector< std::string > coeffColumns;
00133      coeffColumns.push_back( "GCT_JETCORR_C0" );
00134      coeffColumns.push_back( "GCT_JETCORR_C1" );
00135      coeffColumns.push_back( "GCT_JETCORR_C2" );
00136      coeffColumns.push_back( "GCT_JETCORR_C3" );
00137      coeffColumns.push_back( "GCT_JETCORR_C4" );
00138      coeffColumns.push_back( "GCT_JETCORR_C5" );
00139      coeffColumns.push_back( "GCT_JETCORR_C6" );
00140      coeffColumns.push_back( "GCT_JETCORR_C7" );
00141      coeffColumns.push_back( "GCT_JETCORR_C8" );
00142      coeffColumns.push_back( "GCT_JETCORR_C9" );
00143      coeffColumns.push_back( "GCT_JETCORR_C10" );
00144      coeffColumns.push_back( "GCT_JETCORR_C11" );
00145      coeffColumns.push_back( "GCT_JETCORR_C12" );
00146      coeffColumns.push_back( "GCT_JETCORR_C13" );
00147      coeffColumns.push_back( "GCT_JETCORR_C14" );
00148      coeffColumns.push_back( "GCT_JETCORR_C15" );
00149      coeffColumns.push_back( "GCT_JETCORR_C16" );
00150      coeffColumns.push_back( "GCT_JETCORR_C17" );
00151      coeffColumns.push_back( "GCT_JETCORR_C18" );
00152      coeffColumns.push_back( "GCT_JETCORR_C19" );
00153      
00154      l1t::OMDSReader::QueryResults jetCorrResults =
00155        m_omdsReader.basicQuery(
00156                                coeffColumns,
00157                                "CMS_GCT",
00158                                "GCT_JET_COEFFS",
00159                                "GCT_JET_COEFFS.CONFIG_KEY",
00160                                m_omdsReader.singleAttribute( etaKey ) ) ;
00161      
00162      if( results.queryFailed() ) // check if query was successful
00163        {
00164          edm::LogError( "L1-O2O" ) << "Problem getting L1 jet correction coefficients" ;
00165          return boost::shared_ptr< L1GctJetFinderParams >() ;
00166        }
00167 
00168      // fill coeffs - TODO
00169      std::vector<double> coeffs;
00170 
00171      unsigned nCoeffs = 0;
00172      if (corrType == 0) nCoeffs = 0;
00173      else {
00174        edm::LogError( "L1-O2O" ) << "Unsupported jet correction type : " << corrType ;
00175        return boost::shared_ptr< L1GctJetFinderParams >() ;
00176      }
00177 
00178      for (unsigned j=0; j< nCoeffs; ++j) {
00179        std::stringstream coeffCol;
00180        coeffCol << "GCT_JETCORR_C" << std::dec << j;
00181        int coeff;
00182        jetCorrResults.fillVariable( coeffCol.str(), coeff );
00183 
00184        coeffs.push_back(coeff);
00185      }
00186 
00187      jetCorrCoeffs.push_back(coeffs);
00188     
00189      // copy to tau coeffs
00190      if (i < L1GctJetFinderParams::N_CENTRAL_ETA_VALUES) tauCorrCoeffs.push_back(coeffs);
00191      
00192    }
00193    
00194    
00195 
00196    return boost::shared_ptr< L1GctJetFinderParams >( 
00197                                                     new L1GctJetFinderParams( rgnEtLsb,
00198                                                                               htLsb,
00199                                                                               cJetSeed,
00200                                                                               fJetSeed,
00201                                                                               tJetSeed,
00202                                                                               tauIsoEtThresh,
00203                                                                               htJetEtThresh,
00204                                                                               mhtJetEtThresh,
00205                                                                               etaBoundary,
00206                                                                               corrType,
00207                                                                               jetCorrCoeffs,
00208                                                                               tauCorrCoeffs,
00209                                                                               convertToEnergy,
00210                                                                               energyConvCoeffs
00211 
00212  )
00213                                                     );
00214 
00215 }
00216 
00217 
00218 DEFINE_FWK_EVENTSETUP_MODULE(L1GctJetFinderParamsOnlineProd);