CMS 3D CMS Logo

ConfigurationDatabaseImplOracle.cc

Go to the documentation of this file.
00001 // $Id: ConfigurationDatabaseImplOracle.cc,v 1.1 2008/02/12 17:02:01 kukartse Exp $
00002 
00003 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImplOracle.hh"
00004 
00005 #include "xgi/Utils.h"
00006 #include "toolbox/string.h"
00007 
00008 using namespace std;
00009 using namespace oracle::occi;
00010 using namespace hcal;
00011 //
00012 // provides factory method for instantion of ConfigurationDatabaseImplOracle application
00013 //
00014 DECLARE_PLUGGABLE(hcal::ConfigurationDatabaseImpl,ConfigurationDatabaseImplOracle)
00015 
00016 ConfigurationDatabaseImplOracle::ConfigurationDatabaseImplOracle()
00017 {
00018 
00019 }
00020 
00021 bool ConfigurationDatabaseImplOracle::canHandleMethod(const std::string& method) const {
00022   return (method=="occi");
00023 }
00024 
00025 ConfigurationDatabaseImplOracle::~ConfigurationDatabaseImplOracle() {
00026         disconnect();
00027 
00028 }
00029 
00030 void ConfigurationDatabaseImplOracle::connect(const std::string& accessor) throw (hcal::exception::ConfigurationDatabaseException) {
00031   std::map<std::string,std::string> params;
00032   std::string user, host, method, db, port,password;
00033   ConfigurationDatabaseImpl::parseAccessor(accessor,method,host,port,user,db,params);
00034   
00035   if (method!="occi") XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,std::string("Invalid accessor for Oracle : ")+accessor);
00036     
00037   if (params.find("PASSWORD")!=params.end()) password=params["PASSWORD"];
00038   if (params.find("LHWM_VERSION")!=params.end()) lhwm_version=params["LHWM_VERSION"];
00039 
00040   try {    
00041      env_ = oracle::occi::Environment::createEnvironment (oracle::occi::Environment::DEFAULT);
00042      conn_ = env_->createConnection (user, password, db);
00043    } catch (SQLException& e) {
00044            XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00045    }
00046 
00047 
00048   if (env_ == NULL || conn_ == NULL) {
00049     std::string message("Error connecting on accessor '");
00050     message+=accessor;
00051     XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,message);
00052   }
00053 }
00054 
00055 void ConfigurationDatabaseImplOracle::disconnect() {
00056 
00057    try {
00058         //terminate environment and connection
00059         env_->terminateConnection(conn_);
00060         Environment::terminateEnvironment(env_);
00061    } catch (SQLException& e) {
00062            XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00063    }
00064 
00065 
00066 }
00067 
00068 //Utility function that cnverts oracle::occi::Clob to std::string
00069 string ConfigurationDatabaseImplOracle::clobToString(oracle::occi::Clob clob){
00070 
00071                 Stream *instream = clob.getStream (1,0);
00072                 unsigned int size = clob.length();
00073                 char *cbuffer = new char[size];
00074                 memset (cbuffer, 0, size);
00075                 instream->readBuffer (cbuffer, size);
00076                 string str(cbuffer);
00077                 return str;
00078 }
00079 //inline function to convert hex2integer
00080 inline static int cvtChar(int c) {
00081   if (c>='0' && c<='9') c-='0';
00082   if ((c>='a' && c<='f')||(c>='A' && c<='F')) c-='A'+10;
00083   return c&0xF;
00084 }
00085 
00086 void ConfigurationDatabaseImplOracle::getLUTChecksums(const std::string& tag, 
00087                 std::map<hcal::ConfigurationDatabase::LUTId, 
00088                 hcal::ConfigurationDatabase::MD5Fingerprint>& checksums) throw (hcal::exception::ConfigurationDatabaseException) {
00089 
00090         if (env_ == NULL || conn_ == NULL) XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,"Database is not open");
00091         checksums.clear();
00092 
00093    try {
00094         Statement* stmt = conn_->createStatement();
00095 
00096         std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_TRIG_LOOKUP_TABLES");
00097         query+=" WHERE CRATE=-1";
00098         //query+=toolbox::toString(" WHERE TAG_NAME='%s' CRATE=-1", tag.c_str());
00099 
00100         //SELECT
00101         ResultSet *rs = stmt->executeQuery(query.c_str());
00102 
00103         while (rs->next()) {
00104                 oracle::occi::Clob clob = rs->getClob (1);
00105                 std::list<ConfigurationDatabaseStandardXMLParser::Item> items;
00106                 std::string buffer = clobToString(clob);
00107 
00108                 m_parser.parseMultiple(buffer,items);
00109                 
00110                 for (std::list<ConfigurationDatabaseStandardXMLParser::Item>::iterator i=items.begin(); i!=items.end(); ++i) {
00111         
00112                         hcal::ConfigurationDatabase::FPGASelection ifpga = 
00113                                 (hcal::ConfigurationDatabase::FPGASelection)atoi(i->parameters["topbottom"].c_str());
00114                         int islot = atoi(i->parameters["slot"].c_str());
00115                         hcal::ConfigurationDatabase::LUTType ilut_type = 
00116                                 (hcal::ConfigurationDatabase::LUTType)atoi(i->parameters["luttype"].c_str());
00117                         int crate=atoi(i->parameters["crate"].c_str());
00118                         int islb=atoi(i->parameters["slb"].c_str());
00119                         int islbch=atoi(i->parameters["slbchan"].c_str());
00120                         hcal::ConfigurationDatabase::LUTId lut_id;
00121                         lut_id=hcal::ConfigurationDatabase::LUTId(crate, islot, ifpga, islb, islbch, ilut_type);
00122 
00123                         hcal::ConfigurationDatabase::MD5Fingerprint csum(16);
00124                         std::string encoded = (std::string)i->items[0];
00125                         for (int i=0; i<16; i++) {
00126                                 //converting hex2integer
00127                                 csum[i]=cvtChar(encoded[i*2])*16+cvtChar(encoded[i*2+1]);
00128                         }
00129 
00130                         checksums[lut_id]=csum;
00131                 }
00132         }
00133         //Always terminate statement
00134         conn_->terminateStatement(stmt);
00135    } catch (SQLException& e) {
00136            XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00137    }
00138 
00139 }
00140 
00141 void ConfigurationDatabaseImplOracle::getLUTs(const std::string& tag, int crate, int slot, std::map<hcal::ConfigurationDatabase::LUTId, hcal::ConfigurationDatabase::LUT >& LUTs) throw (hcal::exception::ConfigurationDatabaseException) {
00142   if (m_lutCache.crate!=crate || m_lutCache.tag!=tag) {
00143     m_lutCache.clear();
00144     getLUTs_real(tag,crate,m_lutCache.luts);
00145     m_lutCache.crate=crate;
00146     m_lutCache.tag=tag;
00147   }
00148 
00149   LUTs.clear();
00150   std::map<hcal::ConfigurationDatabase::LUTId, hcal::ConfigurationDatabase::LUT >::const_iterator i;
00151   for (i=m_lutCache.luts.begin(); i!=m_lutCache.luts.end(); i++) {
00152     if (i->first.slot==slot)
00153       LUTs.insert(*i);
00154   }
00155 }
00156 
00157 
00158 void ConfigurationDatabaseImplOracle::getLUTs_real(const std::string& tag, int crate,  
00159                         std::map<hcal::ConfigurationDatabase::LUTId, hcal::ConfigurationDatabase::LUT >& LUTs) 
00160                                                                 throw (hcal::exception::ConfigurationDatabaseException)
00161 {
00162 
00163    try {
00164         //Lets run the SQl Query
00165         Statement* stmt = conn_->createStatement();
00166 
00167         std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_TRIG_LOOKUP_TABLES");
00168         query+=toolbox::toString(" WHERE TAG_NAME='%s' AND CRATE=%d", tag.c_str(), crate);
00169 
00170         //SELECT
00171         ResultSet *rs = stmt->executeQuery(query.c_str());
00172 
00173         LUTs.clear();
00174 
00175         while (rs->next()) {
00176                 oracle::occi::Clob clob = rs->getClob (1);
00177                 std::list<ConfigurationDatabaseStandardXMLParser::Item> items;
00178                 std::string buffer = clobToString(clob);
00179                 m_parser.parseMultiple(buffer,items);
00180 
00181                 for (std::list<ConfigurationDatabaseStandardXMLParser::Item>::iterator i=items.begin(); i!=items.end(); ++i) {
00182                         hcal::ConfigurationDatabase::FPGASelection ifpga = 
00183                                         (hcal::ConfigurationDatabase::FPGASelection)atoi(i->parameters["TOPBOTTOM"].c_str());
00184                         int islot = atoi(i->parameters["SLOT"].c_str());
00185 
00186                         //If this is the desired slot
00187                         //if (islot == slot) {
00188                                 hcal::ConfigurationDatabase::LUTType ilut_type = 
00189                                                 (hcal::ConfigurationDatabase::LUTType)atoi(i->parameters["LUT_TYPE"].c_str());
00190                                 hcal::ConfigurationDatabase::LUTId lut_id;
00191                                 if (ilut_type==hcal::ConfigurationDatabase::LinearizerLUT) {
00192                                         int ifiber=atoi(i->parameters["FIBER"].c_str());
00193                                         int ifiberch=atoi(i->parameters["FIBERCHAN"].c_str());
00194                                         lut_id=hcal::ConfigurationDatabase::LUTId(crate, islot, ifpga, ifiber, ifiberch, ilut_type);
00195                                 } else {
00196                                         int islb=atoi(i->parameters["SLB"].c_str());
00197                                         int islbch=atoi(i->parameters["SLBCHAN"].c_str());
00198                                         lut_id=hcal::ConfigurationDatabase::LUTId(crate, islot, ifpga, islb, islbch, ilut_type);
00199                                 }
00200 
00201                                 hcal::ConfigurationDatabase::LUT lut;
00202                                 lut.reserve(i->items.size());
00203 
00204                                 int strtol_base=0;
00205                                 if (i->encoding=="hex") strtol_base=16;
00206                                 else if (i->encoding=="dec") strtol_base=10;
00207 
00208                                 // convert the data
00209                                 for (unsigned int j=0; j<i->items.size(); j++) 
00210                                         lut.push_back(strtol(i->items[j].c_str(),0,strtol_base));
00211 
00212                                 LUTs.insert(make_pair(lut_id, lut));
00213                         //}    
00214                 }
00215         }
00216 
00217         //Always terminate statement
00218         conn_->terminateStatement(stmt);
00219    } catch (SQLException& e) {
00220            XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00221    }
00222 
00223 }
00224 
00225 void ConfigurationDatabaseImplOracle::getPatterns(const std::string& tag, int crate, int slot, std::map<hcal::ConfigurationDatabase::PatternId, hcal::ConfigurationDatabase::HTRPattern >& patterns) throw (hcal::exception::ConfigurationDatabaseException) {
00226   if (m_patternCache.crate!=crate || m_patternCache.tag!=tag) {
00227     m_patternCache.clear();
00228     getPatterns_real(tag,crate,m_patternCache.patterns);
00229     m_patternCache.crate=crate;
00230     m_patternCache.tag=tag;
00231   }
00232 
00233   patterns.clear();
00234   std::map<hcal::ConfigurationDatabase::PatternId, hcal::ConfigurationDatabase::HTRPattern >::const_iterator i;
00235   for (i=m_patternCache.patterns.begin(); i!=m_patternCache.patterns.end(); i++) {
00236     if (i->first.slot==slot)
00237       patterns.insert(*i);
00238   }
00239 }
00240 
00241 void ConfigurationDatabaseImplOracle::getPatterns_real(const std::string& tag, int crate,  
00242                         std::map<hcal::ConfigurationDatabase::PatternId, hcal::ConfigurationDatabase::HTRPattern >& patterns) 
00243                                                         throw (hcal::exception::ConfigurationDatabaseException) {
00244    try {
00245         //Lets run the SQl Query
00246         Statement* stmt = conn_->createStatement();
00247 
00248         std::string query = ("SELECT HTR_DATA_PATTERNS_DATA_CLOB FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_HTR_DATA_PATTERNS");
00249         query+=toolbox::toString(" WHERE TAG_NAME='%s' AND CRATE=%d", tag.c_str(), crate);
00250 
00251         //SELECT
00252         ResultSet *rs = stmt->executeQuery(query.c_str());
00253 
00254         patterns.clear();
00255 
00256         while (rs->next()) {
00257                 oracle::occi::Clob clob = rs->getClob (1);
00258                 std::list<ConfigurationDatabaseStandardXMLParser::Item> items;
00259                 std::string buffer = clobToString(clob);
00260 
00261                 m_parser.parseMultiple(buffer,items);
00262 
00263                 for (std::list<ConfigurationDatabaseStandardXMLParser::Item>::iterator i=items.begin(); i!=items.end(); ++i) {
00264                         int islot=atoi(i->parameters["SLOT"].c_str());
00265                         //If this is the desired slot
00266                         //if (islot == slot) {
00267                                 hcal::ConfigurationDatabase::FPGASelection ifpga =
00268                                         (hcal::ConfigurationDatabase::FPGASelection)atoi(i->parameters["TOPBOTTOM"].c_str());
00269                                 int ifiber=atoi(i->parameters["FIBER"].c_str());
00270 
00271                                 hcal::ConfigurationDatabase::PatternId pat_id(crate, islot, ifpga, ifiber);
00272                                 hcal::ConfigurationDatabase::HTRPattern& pat=patterns[pat_id];
00273                                 pat.reserve(i->items.size());
00274 
00275                                 int strtol_base=0;
00276                                 if (i->encoding=="hex") strtol_base=16;
00277                                 else if (i->encoding=="dec") strtol_base=10;
00278 
00279                                 // convert the data
00280                                 for (unsigned int j=0; j<i->items.size(); j++)
00281                                         pat.push_back(strtol(i->items[j].c_str(),0,strtol_base));
00282                         //}
00283                 }
00284         }
00285         //Always terminate statement
00286         conn_->terminateStatement(stmt);
00287    } catch (SQLException& e) {
00288            XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00289    }
00290 
00291 
00292 }
00293 
00294 void ConfigurationDatabaseImplOracle::getRBXdata(const std::string& tag, const std::string& rbx,
00295                         hcal::ConfigurationDatabase::RBXdatumType dtype,
00296                         std::map<ConfigurationDatabase::RBXdatumId, hcal::ConfigurationDatabase::RBXdatum>& RBXdata)
00297                         throw (hcal::exception::ConfigurationDatabaseException) {
00298 
00299         RBXdata.clear();
00300 
00301         Statement* stmt = conn_->createStatement();
00302         std::string query;
00303 
00304         //std::string datatypestr;
00305         switch (dtype) {
00306 
00307                 case (ConfigurationDatabase::eRBXpedestal):
00308                         //datatypestr="PEDESTAL";
00309 
00310                         //Lets run the SQl Query
00311                         query  = "SELECT MODULE_POSITION, QIE_CARD_POSITION, QIE_ADC_NUMBER, INTEGER_VALUE ";
00312                         query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_RBX_PEDESTAL_CONFIG ";
00313                         query += toolbox::toString(" WHERE TAG_NAME='%s' AND NAME_LABEL='%s'", tag.c_str(), rbx.c_str());
00314 
00315                         break;
00316 
00317                 case (ConfigurationDatabase::eRBXdelay):
00318                         //datatypestr="DELAY";
00319 
00320                         query  = "SELECT MODULE_POSITION, QIE_CARD_POSITION, QIE_ADC_NUMBER, INTEGER_VALUE ";
00321                         query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_RBX_DELAY_CONFIG ";
00322                         query += toolbox::toString(" WHERE TAG_NAME='%s' AND NAME_LABEL='%s'", tag.c_str(), rbx.c_str());
00323 
00324                         break;
00325 
00326                 case (ConfigurationDatabase::eRBXgolCurrent):
00327                         //datatypestr="GOL";
00328 
00329                         query  = "SELECT MODULE_POSITION, QIE_CARD_POSITION, FIBER_NUMBER, INTEGER_VALUE ";
00330                         query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_RBX_GOL_CONFIG ";
00331                         query += toolbox::toString(" WHERE TAG_NAME='%s' AND NAME_LABEL='%s'", tag.c_str(), rbx.c_str());
00332 
00333                         break;
00334                 case (ConfigurationDatabase::eRBXledData):
00335                         //datatypestr="LED";
00336                         query  = "SELECT LED_AMPLITUDE, SET_LEDS_IS_CHECKED, BUNCH_NUMBER ";
00337                         query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_RBX_INITPAR_T02_CONFIG ";
00338                         query += toolbox::toString(" WHERE TAG_NAME='%s' AND NAME_LABEL='%s'", tag.c_str(), rbx.c_str());
00339                         break;
00340 
00341 
00342                 case (ConfigurationDatabase::eRBXbroadcast):
00343                         //datatypestr="";
00344                         printf("ConfigurationDatabaseImplMySQL::getRBXdata Can't handle BROADCAST yet\n");
00345                         return;
00346                 case (ConfigurationDatabase::eRBXttcrxPhase):
00347                         //datatypestr="PHASE";
00348                         printf("ConfigurationDatabaseImplMySQL::getRBXdata Can't handle TTCRX PHASE yet\n");
00349                         return;
00350                 case (ConfigurationDatabase::eRBXqieResetDelay):
00351                         //datatypestr="";
00352                         printf("ConfigurationDatabaseImplMySQL::getRBXdata Can't handle QIE RESET DELAY yet\n");
00353                         return;
00354                 case (ConfigurationDatabase::eRBXccaPatterns):
00355                         XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,"Patterns must use getRBXPatterns, not getRBXData");
00356                         return;
00357                 default:
00358                       printf("ConfigurationDatabaseImplMySQL::getRBXdata Can't handle dtype=%d yet\n",dtype);
00359                       return;
00360         }
00361 
00362    try {
00363         //SELECT
00364         ResultSet *rs = stmt->executeQuery(query.c_str());
00365         while (rs->next()) {
00366 
00367                 if (dtype==ConfigurationDatabase::eRBXledData) {
00368                         //LED_AMPLITUDE, SET_LEDS_IS_CHECKED, BUNCH_NUMBER
00369                         unsigned int ampl = rs->getInt(1);
00370                         unsigned int enable = rs->getInt(2);
00371                         unsigned int bunch = rs->getInt(3);
00372 
00373                         if (enable) enable|=0x1; // global enable if either is on
00374                         RBXdata.insert(std::pair<ConfigurationDatabase::RBXdatumId,ConfigurationDatabase::RBXdatum>
00375                                 (ConfigurationDatabase::eLEDenable,enable));
00376                         RBXdata.insert(std::pair<ConfigurationDatabase::RBXdatumId,ConfigurationDatabase::RBXdatum>
00377                                 (ConfigurationDatabase::eLEDamplitude,ampl));
00378                         RBXdata.insert(std::pair<ConfigurationDatabase::RBXdatumId,ConfigurationDatabase::RBXdatum>
00379                                 (ConfigurationDatabase::eLEDtiming_hb,((bunch&0xFF00)>>8)));
00380                         RBXdata.insert(std::pair<ConfigurationDatabase::RBXdatumId,ConfigurationDatabase::RBXdatum>
00381                                 (ConfigurationDatabase::eLEDtiming_lb,(bunch&0xFF)));
00382                 } else {
00383                         //MODULE_POSITION, QIE_CARD_POSITION, QIE_ADC_NUMBER/FIBER_NUMBER, INTEGER_VALUE
00384                         int rm = rs->getInt(1);
00385                         int card = rs->getInt(2);
00386                         int qie_or_gol = rs->getInt(3);
00387                         unsigned int data = rs->getInt(4);
00388 
00389                         ConfigurationDatabase::RBXdatumId id(rm,card,qie_or_gol,dtype);
00390                         RBXdata.insert(std::pair<ConfigurationDatabase::RBXdatumId,ConfigurationDatabase::RBXdatum>(id,(unsigned char)(data)));
00391                 }
00392         }
00393 
00394         //Always terminate statement
00395         conn_->terminateStatement(stmt);
00396    } catch (SQLException& e) {
00397            XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00398    }
00399 
00400 }
00401 
00402 void ConfigurationDatabaseImplOracle::getZSThresholds(const std::string& tag, int crate, int slot,
00403                 std::map<hcal::ConfigurationDatabase::ZSChannelId, int>& thresholds)
00404                 throw (hcal::exception::ConfigurationDatabaseException) {
00405 
00406    try {
00407         //Lets run the SQl Query
00408         Statement* stmt = conn_->createStatement();
00409         //SELECT HTR_FIBER, FIBER_CHANNEL, ZERO_SUPPRESSION, HTR_FPGA
00410         //FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_ZERO_SUPPRESSION_LHWM
00411         //WHERE TAG_NAME='Kukartsev test 1' AND CRATE=2 AND HTR_SLOT=2
00412         //AND LHWM_VERSION='20'
00413 
00414         std::string query = ("SELECT HTR_FIBER, FIBER_CHANNEL, ZERO_SUPPRESSION, HTR_FPGA ");
00415         query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_ZERO_SUPPRESSION_LHWM ";
00416         query+=toolbox::toString(" WHERE TAG_NAME='%s' AND CRATE=%d AND HTR_SLOT=%d", tag.c_str(), crate, slot);
00417         query+=toolbox::toString(" AND LHWM_VERSION='%s'", lhwm_version.c_str());
00418 
00419         //SELECT
00420         ResultSet *rs = stmt->executeQuery(query.c_str());
00421 
00422         thresholds.clear();
00423 
00424         while (rs->next()) {
00425                 unsigned int fiber = rs->getInt(1);
00426                 unsigned int fc = rs->getInt(2);
00427                 unsigned int zs = rs->getInt(3);
00428                 std::string fpga = rs->getString(4);
00429                 int tb;
00430                 if (fpga=="top") tb = 1;
00431                 else tb = 0;
00432                 std::cout << "crate,slot,tb,fiber,fc:" << crate<<slot<<tb<<fiber<<fc<<std::endl;
00433                 hcal::ConfigurationDatabase::ZSChannelId id(crate,slot,(hcal::ConfigurationDatabase::FPGASelection)tb,fiber,fc);
00434                 thresholds[id] = zs;
00435         }
00436         //Always terminate statement
00437         conn_->terminateStatement(stmt);
00438    } catch (SQLException& e) {
00439            XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00440    }
00441 
00442 }
00443 
00444 
00445 void ConfigurationDatabaseImplOracle::getHLXMasks(const std::string& tag, int crate, int slot,
00446                         std::map<hcal::ConfigurationDatabase::FPGAId, hcal::ConfigurationDatabase::HLXMasks>& masks)
00447                                         throw (hcal::exception::ConfigurationDatabaseException) {
00448   if (m_hlxMaskCache.crate!=crate || m_hlxMaskCache.tag!=tag) {
00449     m_hlxMaskCache.clear();
00450     getHLXMasks_real(tag,crate,m_hlxMaskCache.masks);
00451     m_hlxMaskCache.crate=crate;
00452     m_hlxMaskCache.tag=tag;
00453   } 
00454   
00455   masks.clear();
00456   std::map<ConfigurationDatabase::FPGAId, ConfigurationDatabase::HLXMasks>::const_iterator i;
00457   for (i=m_hlxMaskCache.masks.begin(); i!=m_hlxMaskCache.masks.end(); i++) {
00458     if (i->first.slot==slot)
00459       masks.insert(*i);
00460   }
00461 } 
00462 
00463 
00464 void ConfigurationDatabaseImplOracle::getHLXMasks_real(const std::string& tag, int crate,
00465                 std::map<ConfigurationDatabase::FPGAId, ConfigurationDatabase::HLXMasks>& masks)
00466                 throw (hcal::exception::ConfigurationDatabaseException) {
00467    try {
00468         //Lets run the SQl Query
00469         Statement* stmt = conn_->createStatement();
00470         std::string query = ("SELECT SLOT_NUMBER, FPGA, OCC_MASK, LHC_MASK, SUM_ET_MASK ");
00471         query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_HLX_MASKS ";
00472         query += toolbox::toString(" WHERE TAG_NAME='%s' AND CRATE_NUMBER=%d ", tag.c_str(), crate);
00473 
00474         //SELECT
00475         ResultSet *rs = stmt->executeQuery(query.c_str());
00476         masks.clear();
00477         while (rs->next()) {
00478                 int islot = rs->getInt(1);
00479                 std::string fpga = rs->getString(2);
00480 
00481                 int ifpga;
00482                 if (fpga=="top") ifpga = 1;
00483                 else ifpga = 0;
00484 
00485                 hcal::ConfigurationDatabase::FPGAId fpga_id;
00486                 fpga_id=hcal::ConfigurationDatabase::FPGAId(crate, islot,
00487                                 (hcal::ConfigurationDatabase::FPGASelectionEnum)ifpga);
00488                 hcal::ConfigurationDatabase::HLXMasks hlxMask;
00489                 hlxMask.occMask = rs->getInt(3);
00490                 hlxMask.lhcMask = rs->getInt(4);
00491                 hlxMask.sumEtMask = rs->getInt(5);
00492 
00493                 masks[fpga_id]=hlxMask;
00494         }
00495         //Always terminate statement
00496         conn_->terminateStatement(stmt);
00497    } catch (SQLException& e) {
00498            XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00499    }
00500 }
00501 
00502 // added by Gena Kukartsev
00503 oracle::occi::Connection * ConfigurationDatabaseImplOracle::getConnection( void ){
00504   return conn_;
00505 }
00506 
00507 oracle::occi::Environment * ConfigurationDatabaseImplOracle::getEnvironment( void ){
00508   return env_;
00509 }
00510 

Generated on Tue Jun 9 17:25:56 2009 for CMSSW by  doxygen 1.5.4