Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-15 01:25:28

0001 #include <stdexcept>
0002 #include <string>
0003 #include "OnlineDB/Oracle/interface/Oracle.h"
0004 
0005 #include "OnlineDB/EcalCondDB/interface/FEConfigOddWeightModeDat.h"
0006 #include "OnlineDB/EcalCondDB/interface/FEConfigOddWeightInfo.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 
0009 using namespace std;
0010 using namespace oracle::occi;
0011 
0012 FEConfigOddWeightModeDat::FEConfigOddWeightModeDat() {
0013   m_env = nullptr;
0014   m_conn = nullptr;
0015   m_writeStmt = nullptr;
0016   m_readStmt = nullptr;
0017 
0018   m_en_EB_flt = 0;
0019   m_en_EE_flt = 0;
0020   m_en_EB_pf = 0;
0021   m_en_EE_pf = 0;
0022   m_dis_EB_even_pf = 0;
0023   m_dis_EE_even_pf = 0;
0024   m_fe_EB_strout = 0;
0025   m_fe_EE_strout = 0;
0026   m_fe_EB_strib2 = 0;
0027   m_fe_EE_strib2 = 0;
0028   m_fe_EB_tcpout = 0;
0029   m_fe_EB_tcpib1 = 0;
0030   m_fe_EE_tcpout = 0;
0031   m_fe_EE_tcpib1 = 0;
0032   m_fe_par15 = 0;
0033   m_fe_par16 = 0;
0034   m_fe_par17 = 0;
0035   m_fe_par18 = 0;
0036 }
0037 
0038 FEConfigOddWeightModeDat::~FEConfigOddWeightModeDat() {}
0039 
0040 void FEConfigOddWeightModeDat::prepareWrite() noexcept(false) {
0041   this->checkConnection();
0042 
0043   try {
0044     m_writeStmt = m_conn->createStatement();
0045     m_writeStmt->setSQL(
0046         "INSERT INTO " + getTable() +
0047         " (wei2_conf_id, "
0048         " enableEBOddFilter, enableEEOddFilter, enableEBOddPeakFinder,enableEEOddPeakFinder, disableEBEvenPeakFinder, "
0049         "DISABLEEEEVENPEAKFINDER, fenixEBStripOutput, fenixEEStripOutput, FenixEBStripInfoBit2, fenixEEStripInfobit2, "
0050         "EBfenixTcpOutput, EBfenixTCPInfobit1,EEFENIXTCPOUTPUT, EEFENIXTCPINFOBIT1 ,fenixpar15, fenixpar16, "
0051         "fenixpar17, fenixpar18  ) "
0052         "VALUES (:wei2_conf_id,  "
0053         " :w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15 , :w16, :w17, :w18 )");
0054   } catch (SQLException& e) {
0055     throw cms::Exception("SQLException") << "FEConfigOddWeightModeDat::prepareWrite():  " << e.getMessage();
0056   }
0057 }
0058 
0059 void FEConfigOddWeightModeDat::writeDB(const EcalLogicID* ecid,
0060                                        const FEConfigOddWeightModeDat* item,
0061                                        FEConfigOddWeightInfo* iconf) noexcept(false) {
0062   this->checkConnection();
0063   this->checkPrepare();
0064 
0065   int iconfID = iconf->fetchID();
0066   if (!iconfID) {
0067     throw(std::runtime_error("FEConfigOddWeightModeDat::writeDB:  ICONF not in DB"));
0068   }
0069 
0070   try {
0071     m_writeStmt->setInt(1, iconfID);
0072 
0073     m_writeStmt->setInt(2, item->getFenixPar1());
0074     m_writeStmt->setInt(3, item->getFenixPar2());
0075     m_writeStmt->setInt(4, item->getFenixPar3());
0076     m_writeStmt->setInt(5, item->getFenixPar4());
0077     m_writeStmt->setInt(6, item->getFenixPar5());
0078     m_writeStmt->setInt(7, item->getFenixPar6());
0079     m_writeStmt->setInt(8, item->getFenixPar7());
0080     m_writeStmt->setInt(9, item->getFenixPar8());
0081     m_writeStmt->setInt(10, item->getFenixPar9());
0082     m_writeStmt->setInt(11, item->getFenixPar10());
0083     m_writeStmt->setInt(12, item->getFenixPar11());
0084     m_writeStmt->setInt(13, item->getFenixPar12());
0085     m_writeStmt->setInt(14, item->getFenixPar13());
0086     m_writeStmt->setInt(15, item->getFenixPar14());
0087     m_writeStmt->setInt(16, item->getFenixPar15());
0088     m_writeStmt->setInt(17, item->getFenixPar16());
0089     m_writeStmt->setInt(18, item->getFenixPar17());
0090     m_writeStmt->setInt(19, item->getFenixPar18());
0091 
0092     m_writeStmt->executeUpdate();
0093   } catch (SQLException& e) {
0094     throw cms::Exception("SQLException") << "FEConfigOddWeightModeDat::writeDB():  " << e.getMessage();
0095   }
0096 }
0097 
0098 void FEConfigOddWeightModeDat::fetchData(map<EcalLogicID, FEConfigOddWeightModeDat>* fillMap,
0099                                          FEConfigOddWeightInfo* iconf) noexcept(false) {
0100   this->checkConnection();
0101   fillMap->clear();
0102 
0103   iconf->setConnection(m_env, m_conn);
0104   int iconfID = iconf->fetchID();
0105   if (!iconfID) {
0106     throw(std::runtime_error("FEConfigOddWeightModeDat::fetchData:  ICONF not in DB"));
0107     return;
0108   }
0109 
0110   try {
0111     m_readStmt->setSQL(
0112         "SELECT  enableEBOddFilter, enableEEOddFilter, enableEBOddPeakFinder,enableEEOddPeakFinder, "
0113         "disableEBEvenPeakFinder, DISABLEEEEVENPEAKFINDER, fenixEBStripOutput, fenixEBStripOutput, "
0114         "FenixEBStripInfoBit2, fenixEEStripInfobit2, EBfenixTcpOutput, EBfenixTCPInfobit1,EEFENIXTCPOUTPUT, "
0115         "EEFENIXTCPINFOBIT1 ,fenixpar15, fenixpar16, fenixpar17, fenixpar18  "
0116         "FROM " +
0117         getTable() +
0118         " d "
0119         "WHERE wei2_conf_id = :wei2_conf_id ");
0120     m_readStmt->setInt(1, iconfID);
0121     ResultSet* rset = m_readStmt->executeQuery();
0122 
0123     std::pair<EcalLogicID, FEConfigOddWeightModeDat> p;
0124     FEConfigOddWeightModeDat dat;
0125     int ig = -1;
0126     while (rset->next()) {
0127       ig++;                              // we create a dummy logic_id
0128       p.first = EcalLogicID("Group_id",  // name
0129                             ig);         // logic_id
0130 
0131       dat.setFenixPar1(rset->getInt(1));
0132       dat.setFenixPar2(rset->getInt(2));
0133       dat.setFenixPar3(rset->getInt(3));
0134       dat.setFenixPar4(rset->getInt(4));
0135       dat.setFenixPar5(rset->getInt(5));
0136       dat.setFenixPar6(rset->getInt(6));
0137       dat.setFenixPar7(rset->getInt(7));
0138       dat.setFenixPar8(rset->getInt(8));
0139       dat.setFenixPar9(rset->getInt(9));
0140       dat.setFenixPar10(rset->getInt(10));
0141       dat.setFenixPar11(rset->getInt(11));
0142       dat.setFenixPar12(rset->getInt(12));
0143       dat.setFenixPar13(rset->getInt(13));
0144       dat.setFenixPar14(rset->getInt(14));
0145       dat.setFenixPar15(rset->getInt(15));
0146       dat.setFenixPar16(rset->getInt(16));
0147       dat.setFenixPar17(rset->getInt(17));
0148       dat.setFenixPar18(rset->getInt(18));
0149 
0150       p.second = dat;
0151       fillMap->insert(p);
0152     }
0153   } catch (SQLException& e) {
0154     throw cms::Exception("SQLException") << "FEConfigOddWeightModeDat::fetchData:  " << e.getMessage();
0155   }
0156 }
0157 
0158 void FEConfigOddWeightModeDat::writeArrayDB(const std::map<EcalLogicID, FEConfigOddWeightModeDat>* data,
0159                                             FEConfigOddWeightInfo* iconf) noexcept(false) {
0160   const EcalLogicID* channel;
0161   const FEConfigOddWeightModeDat* dataitem;
0162 
0163   typedef map<EcalLogicID, FEConfigOddWeightModeDat>::const_iterator CI;
0164   for (CI p = data->begin(); p != data->end(); ++p) {
0165     channel = &(p->first);
0166     dataitem = &(p->second);
0167     writeDB(channel, dataitem, iconf);
0168   }
0169 }