Warning, /L1TriggerConfig/CSCTFConfigProducers/test/CSCTFConfigProducer.cc-readFromOMDS is written in an unsupported language. File is not indexed.
0001 #include <L1TriggerConfig/CSCTFConfigProducers/interface/CSCTFConfigProducer.h>
0002 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0003
0004 #include <stdio.h>
0005 #include <errno.h>
0006 #include <iostream>
0007 #include <fstream>
0008
0009 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
0010
0011 CSCTFConfigProducer::CSCTFConfigProducer(const edm::ParameterSet& pset) {
0012
0013 alignment = pset.getParameter< std::vector<double> >("alignment");
0014 setWhatProduced(this, &CSCTFConfigProducer::produceL1MuCSCTFConfigurationRcd);
0015 setWhatProduced(this, &CSCTFConfigProducer::produceL1MuCSCTFAlignmentRcd);
0016 setWhatProduced(this, &CSCTFConfigProducer::produceL1MuCSCPtLutRcd);
0017
0018 }
0019
0020 std::unique_ptr<L1MuCSCTFConfiguration> CSCTFConfigProducer::produceL1MuCSCTFConfigurationRcd(const L1MuCSCTFConfigurationRcd& iRecord){
0021
0022 std::string objectKey("170210");
0023 l1t::OMDSReader m_omdsReader("oracle://CMS_OMDS_LB/CMS_TRG_R",".");
0024
0025 edm::LogInfo( "L1-O2O: CSCTFConfigProducer" ) << "Producing "
0026 << " L1MuCSCTFConfiguration"
0027 << "with key CSCTF_KEY="
0028 << objectKey;
0029
0030 // Execute SQL querie`s to get data from OMDS (using key) and make C++ object
0031 // Example: SELECT A_PARAMETER FROM CMS_XXX.XXX_CONF WHERE XXX_CONF.XXX_KEY = objectKey
0032 for (int iSP=1;iSP<13; iSP++) {
0033
0034 char spName[2];
0035 if (iSP<10) sprintf(spName,"0%d",iSP);
0036 else sprintf(spName, "%d",iSP);
0037
0038 std::string spkey = objectKey + "00" + spName;
0039
0040 edm::LogInfo("L1 O2O: CSCTFConfigProducer") << "spkey: " << spkey;
0041
0042 // SELECT Multiple columns FROM TABLE with correct key:
0043 std::vector< std::string > columns ;
0044 columns.push_back( "STATIC_CONFIG" ) ;
0045 columns.push_back( "ETA_CONFIG" ) ;
0046 l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
0047 columns,
0048 "CMS_CSC_TF",
0049 "CSCTF_SP_CONF",
0050 "CSCTF_SP_CONF.SP_KEY",
0051 m_omdsReader.singleAttribute( spkey )
0052 ) ;
0053
0054 if( results.queryFailed() ) // check if query was successful
0055 {
0056 edm::LogError( "L1-O2O" ) << "Problem with L1CSCTFParameters key." ;
0057 return std::unique_ptr<L1MuCSCTFConfiguration>( new L1MuCSCTFConfiguration() );
0058 }
0059
0060 // double datum ;
0061 std::string conf_stat, conf_eta;
0062 results.fillVariable( "STATIC_CONFIG", conf_stat);
0063 results.fillVariable( "ETA_CONFIG", conf_eta );
0064 // std::cout<<conf_stat<<std::endl;
0065 edm::LogInfo( "conf_stat queried" ) << conf_stat ;
0066 edm::LogInfo( "conf_eta queried" ) << conf_eta ;
0067
0068 for(size_t pos=conf_stat.find("\\n"); pos!=std::string::npos; pos=conf_stat.find("\\n",pos))
0069 {
0070 conf_stat[pos]=' ';
0071 conf_stat[pos+1]='\n';
0072 }
0073
0074 for(size_t pos=conf_eta.find("\\n"); pos!=std::string::npos; pos=conf_eta.find("\\n",pos))
0075 {
0076 conf_eta[pos]=' ';
0077 conf_eta[pos+1]='\n';
0078 }
0079
0080 std::string conf_fixed= "CSR_LQE F1 M1 0xFFFF \nCSR_LQE F1 M2 0xFFFF \nCSR_LQE F1 M3 0xFFFF \nCSR_LQE F2 M1 0xFFFF \nCSR_LQE F2 M2 0xFFFF \nCSR_LQE F2 M3 0xFFFF \nCSR_LQE F3 M1 0xFFFF \nCSR_LQE F3 M2 0xFFFF \nCSR_LQE F3 M3 0xFFFF \nCSR_LQE F4 M1 0xFFFF \nCSR_LQE F4 M2 0xFFFF \nCSR_LQE F4 M3 0xFFFF \nCSR_LQE F5 M1 0xFFFF \nCSR_LQE F5 M2 0xFFFF \nCSR_LQE F5 M3 0xFFFF \nCSR_KFL SP MA 0x0000 \nDAT_FTR SP MA 0xFF \nCSR_SFC SP MA 0x1000 \n";
0081
0082
0083 std::string conf_read=conf_fixed+conf_eta+conf_stat;
0084
0085 registers[iSP-1]=conf_read;
0086
0087 }
0088
0089 std::unique_ptr<L1MuCSCTFConfiguration> config = std::unique_ptr<L1MuCSCTFConfiguration>( new L1MuCSCTFConfiguration(registers) );
0090 return config;
0091
0092 }
0093
0094 std::unique_ptr<L1MuCSCTFAlignment> CSCTFConfigProducer::produceL1MuCSCTFAlignmentRcd(const L1MuCSCTFAlignmentRcd& iRecord){
0095 std::unique_ptr<L1MuCSCTFAlignment> al = std::unique_ptr<L1MuCSCTFAlignment>( new L1MuCSCTFAlignment(alignment) );
0096 return al;
0097 }
0098
0099 std::unique_ptr<L1MuCSCPtLut> CSCTFConfigProducer::produceL1MuCSCPtLutRcd(const L1MuCSCPtLutRcd& iRecord){
0100
0101 std::string objectKey("1");
0102 l1t::OMDSReader m_omdsReader("oracle://CMS_OMDS_LB/CMS_TRG_R",".");
0103
0104 edm::LogInfo( "L1-O2O: L1MuCSCPtLutConfigOnlineProd" ) << "Producing "
0105 << "L1MuCSCPtLut "
0106 << "with key PTLUT_VERSION="
0107 << objectKey;
0108
0109 // read the Pt_LUT: it is CLOB with 2^21 different values
0110 l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
0111 "PT_LUT",
0112 "CMS_CSC_TF",
0113 "CSCTF_PTLUTS",
0114 "CSCTF_PTLUTS.PTLUT_VERSION",
0115 m_omdsReader.singleAttribute(objectKey)
0116 ) ;
0117
0118 if( results.queryFailed() ) // check if query was successful
0119 {
0120 edm::LogError( "L1-O2O" ) << "Problem with L1MuCSCPtLutParameters key." ;
0121 return std::unique_ptr<L1MuCSCPtLut>( new L1MuCSCPtLut() );
0122 }
0123
0124 std::string ptlut;
0125 results.fillVariable( ptlut ) ;
0126
0127 // if uncommented it will generate a huge output...
0128 //edm::LogInfo( "L1-O2O: CSCTFConfigProducer" ) << "PtLUT is "
0129 // << "ptlut";
0130
0131 edm::LogInfo( "L1-O2O: L1MuCSCPtLutConfigOnlineProd" ) << "Returning L1MuCSCPtLut";
0132
0133 L1MuCSCPtLut* CSCTFPtLut = new L1MuCSCPtLut();
0134 CSCTFPtLut->readFromDBS(ptlut);
0135
0136 std::unique_ptr<L1MuCSCPtLut> pt_lut = std::unique_ptr<L1MuCSCPtLut>( CSCTFPtLut );
0137
0138 return pt_lut;
0139 }