CMS 3D CMS Logo

HCALConfigDB Class Reference

Gather config data from online DB. More...

#include <CaloOnlineTools/HcalOnlineDb/interface/HCALConfigDB.h>

List of all members.

Public Member Functions

void connect (string _accessor1, string _accessor2)
void connect (string _accessor)
void disconnect (void)
oracle::occi::Connection * getConnection (void)
oracle::occi::Environment * getEnvironment (void)
std::vector< unsigned intgetOnlineLUT (string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt=hcal::ConfigurationDatabase::LinearizerLUT)
std::vector< unsigned intgetOnlineLUT (string tag, int crate, int slot, int topbottom, int fiber, int channel, int luttype)
std::vector< unsigned intgetOnlineLUTFromXML (string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt=hcal::ConfigurationDatabase::LinearizerLUT)
 HCALConfigDB (string _accessor)
 HCALConfigDB ()
void setAccessor (string _accessor)
 ~HCALConfigDB ()

Protected Attributes

string accessor
string accessor2
ConfigurationDatabaseImpl * database
ConfigurationDatabaseImpl * database2


Detailed Description

Gather config data from online DB.

Author:
Gena Kukartsev

Definition at line 23 of file HCALConfigDB.h.


Constructor & Destructor Documentation

HCALConfigDB::HCALConfigDB ( void   ) 

Definition at line 27 of file HCALConfigDB.cc.

References database, database2, and NULL.

00028 {    
00029   database = NULL;
00030   database2 = NULL;
00031 }

HCALConfigDB::~HCALConfigDB ( void   ) 

Definition at line 41 of file HCALConfigDB.cc.

References database, database2, and NULL.

00042 {    
00043   if ( database != NULL ) delete database;
00044   if ( database2 != NULL ) delete database2;
00045 }

HCALConfigDB::HCALConfigDB ( string  _accessor  ) 

Definition at line 33 of file HCALConfigDB.cc.

References accessor, database, database2, and NULL.

00034 {    
00035   database = NULL;
00036   database2 = NULL;
00037   accessor = _accessor;
00038 }


Member Function Documentation

void HCALConfigDB::connect ( string  _accessor1,
string  _accessor2 
)

Definition at line 73 of file HCALConfigDB.cc.

References accessor2, connect(), database2, find(), and i.

00074 {
00075 
00076   connect (_accessor1 );
00077 
00078   accessor2 = _accessor2;
00079 
00080   std::string::size_type i = accessor2 . find( "occi://" );
00081   if ( i!=std::string::npos )
00082     {
00083       database2 = new ConfigurationDatabaseImplOracle();
00084       database2 -> connect( accessor2 );
00085     }
00086   else
00087     {
00088       database2 = new ConfigurationDatabaseImplXMLFile();
00089       database2 -> connect( accessor2 );
00090     }
00091 }

void HCALConfigDB::connect ( string  _accessor  ) 

Definition at line 53 of file HCALConfigDB.cc.

References accessor, database, find(), and i.

Referenced by connect().

00054 {
00055 
00056   accessor = _accessor;
00057 
00058   std::string::size_type i = accessor . find( "occi://" );
00059   if ( i!=std::string::npos )
00060     {
00061       database = new ConfigurationDatabaseImplOracle();
00062       database -> connect( accessor );
00063     }
00064   else
00065     {
00066       database = new ConfigurationDatabaseImplXMLFile();
00067       database -> connect( accessor );
00068     }
00069 }

void HCALConfigDB::disconnect ( void   ) 

Definition at line 96 of file HCALConfigDB.cc.

References database, database2, and NULL.

00097 {
00098   if ( database != NULL ) database -> disconnect();
00099   if ( database2 != NULL ) database2 -> disconnect();
00100 }

oracle::occi::Connection * HCALConfigDB::getConnection ( void   ) 

Definition at line 288 of file HCALConfigDB.cc.

References database.

Referenced by getOnlineLUT(), and getOnlineLUTFromXML().

00288                                                         {
00289   return database -> getConnection();
00290 }

oracle::occi::Environment * HCALConfigDB::getEnvironment ( void   ) 

Definition at line 292 of file HCALConfigDB.cc.

References database.

00292                                                           {
00293   return database -> getEnvironment();
00294 }

std::vector< unsigned int > HCALConfigDB::getOnlineLUT ( string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt = hcal::ConfigurationDatabase::LinearizerLUT 
)

Definition at line 149 of file HCALConfigDB.cc.

References database, e, getConnection(), getDouble(), getOnlineLUT(), getString(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, phi, HLT_VtxMuL3::result, TtFullLepDaughter::Top, and toString().

00150 {
00151   HcalDetId _id( _rawid );
00152 
00153   double _condition_data_set_id;
00154   unsigned int _crate, _slot, _fiber, _channel;
00155   hcal::ConfigurationDatabase::FPGASelection _fpga;
00156 
00157   int side   = _id . zside();
00158   int etaAbs = _id . ietaAbs();
00159   int phi    = _id . iphi();
00160   int depth  = _id . depth();
00161   string subdetector;
00162   if ( _id . subdet() == HcalBarrel) subdetector = "HB";
00163   else if ( _id . subdet() == HcalEndcap) subdetector = "HE";
00164   else if ( _id . subdet() == HcalOuter) subdetector = "HO";
00165   else if ( _id . subdet() == HcalForward) subdetector = "HF";
00166 
00167   oracle::occi::Connection * _connection = database -> getConnection();
00168 
00169   try {
00170     Statement* stmt = _connection -> createStatement();
00171     std::string query = ("SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
00172     query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
00173     query += toolbox::toString(" WHERE SIDE=%d AND ETA=%d AND PHI=%d AND DEPTH=%d AND SUBDETECTOR='%s'", side, etaAbs, phi, depth, subdetector . c_str() );
00174     
00175     //SELECT
00176     ResultSet *rs = stmt->executeQuery(query.c_str());
00177 
00178     _condition_data_set_id = 0.0;
00179 
00180     while (rs->next()) {
00181       double _cdsi = rs -> getDouble(1);
00182       if ( _condition_data_set_id < _cdsi )
00183         {
00184           _condition_data_set_id = _cdsi;
00185           _crate    = rs -> getInt(2);
00186           _slot     = rs -> getInt(3);
00187           std::string fpga_ = rs -> getString(4);
00188           if ( fpga_ == "top" ) _fpga = hcal::ConfigurationDatabase::Top;
00189           else _fpga  = hcal::ConfigurationDatabase::Bottom;
00190           _fiber    = rs -> getInt(5);
00191           _channel  = rs -> getInt(6);
00192           
00193           //cout << _cdsi << "   " << _crate << "   " << _slot << "   " << _fiber << "   " << _channel << endl;
00194         }
00195     }
00196     //Always terminate statement
00197     _connection -> terminateStatement(stmt);
00198   } catch (SQLException& e) {
00199     XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00200   }
00201 
00202   int topbottom, luttype;
00203   if ( _fpga == hcal::ConfigurationDatabase::Top ) topbottom = 1;
00204   else topbottom = 0;
00205   if ( _lt == hcal::ConfigurationDatabase::LinearizerLUT ) luttype = 1;
00206   else luttype = 2;
00207   
00208   std::vector<unsigned int> result = getOnlineLUT( tag, _crate, _slot, topbottom, _fiber, _channel, luttype );
00209   
00210   return result;
00211 }

std::vector< unsigned int > HCALConfigDB::getOnlineLUT ( string  tag,
int  crate,
int  slot,
int  topbottom,
int  fiber,
int  channel,
int  luttype 
)

Definition at line 104 of file HCALConfigDB.cc.

References GenMuonPlsPt100GeV_cfg::cout, database, e, e2, lat::endl(), Exception, cmsRelvalreport::exit, XMLProcessor::getInstance(), HLT_VtxMuL3::result, and TtFullLepDaughter::Top.

Referenced by getOnlineLUT(), and getOnlineLUTFromXML().

00105 {
00106 
00107   //connect( accessor );
00108 
00109   std::vector<unsigned int> result;
00110 
00111   hcal::ConfigurationDatabase::FPGASelection _fpga;
00112   if ( topbottom == 0 ) _fpga = hcal::ConfigurationDatabase::Bottom;
00113   else if ( topbottom == 1 ) _fpga = hcal::ConfigurationDatabase::Top;
00114   else
00115     {
00116       cout << "topbottom out of range" << endl;
00117       exit(-1);
00118     }
00119 
00120   hcal::ConfigurationDatabase::LUTType _lt;
00121   if ( luttype == 1 ) _lt = hcal::ConfigurationDatabase::LinearizerLUT;
00122   else if ( luttype == 2 ) _lt = hcal::ConfigurationDatabase::CompressionLUT;
00123   else
00124     {
00125       cout << "LUT type out of range" << endl;
00126       exit(-1);
00127     }
00128 
00129   hcal::ConfigurationDatabase::LUTId _lutid( crate, slot, _fpga, fiber, channel, _lt );
00130   std::map<hcal::ConfigurationDatabase::LUTId, hcal::ConfigurationDatabase::LUT> testLUTs;
00131 
00132   XMLProcessor * theProcessor = XMLProcessor::getInstance();
00133 
00134   try {
00135     database -> getLUTs(tag, crate, slot, testLUTs);
00136   } catch (hcal::exception::ConfigurationItemNotFoundException& e) {
00137     cout << "Found nothing!" << endl;
00138   } catch (hcal::exception::Exception& e2) {
00139     cout << "Exception: " << e2.what() << endl;
00140   }
00141 
00142   result = testLUTs[_lutid];
00143 
00144   //database -> disconnect();
00145 
00146   return result;
00147 }

std::vector< unsigned int > HCALConfigDB::getOnlineLUTFromXML ( string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt = hcal::ConfigurationDatabase::LinearizerLUT 
)

Definition at line 214 of file HCALConfigDB.cc.

References GenMuonPlsPt100GeV_cfg::cout, database, database2, e, lat::endl(), getConnection(), getDouble(), getOnlineLUT(), getString(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, phi, HLT_VtxMuL3::result, TtFullLepDaughter::Top, and toString().

00214                                                                                                                             {
00215 
00216   std::vector<unsigned int> result;
00217 
00218   if ( database && database2 ){
00219     
00220     HcalDetId _id( _rawid );
00221     
00222     double _condition_data_set_id;
00223     unsigned int _crate, _slot, _fiber, _channel;
00224     hcal::ConfigurationDatabase::FPGASelection _fpga;
00225     
00226     int side   = _id . zside();
00227     int etaAbs = _id . ietaAbs();
00228     int phi    = _id . iphi();
00229     int depth  = _id . depth();
00230     string subdetector;
00231     if ( _id . subdet() == HcalBarrel) subdetector = "HB";
00232     else if ( _id . subdet() == HcalEndcap) subdetector = "HE";
00233     else if ( _id . subdet() == HcalOuter) subdetector = "HO";
00234     else if ( _id . subdet() == HcalForward) subdetector = "HF";
00235     
00236     oracle::occi::Connection * _connection = database2 -> getConnection();
00237     
00238     try {
00239       Statement* stmt = _connection -> createStatement();
00240       std::string query = ("SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
00241       query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
00242       query += toolbox::toString(" WHERE SIDE=%d AND ETA=%d AND PHI=%d AND DEPTH=%d AND SUBDETECTOR='%s'", side, etaAbs, phi, depth, subdetector . c_str() );
00243       
00244       //SELECT
00245       ResultSet *rs = stmt->executeQuery(query.c_str());
00246       
00247       _condition_data_set_id = 0.0;
00248       
00249       while (rs->next()) {
00250         double _cdsi = rs -> getDouble(1);
00251         if ( _condition_data_set_id < _cdsi )
00252           {
00253             _condition_data_set_id = _cdsi;
00254             _crate    = rs -> getInt(2);
00255             _slot     = rs -> getInt(3);
00256             std::string fpga_ = rs -> getString(4);
00257             if ( fpga_ == "top" ) _fpga = hcal::ConfigurationDatabase::Top;
00258             else _fpga  = hcal::ConfigurationDatabase::Bottom;
00259             _fiber    = rs -> getInt(5);
00260             _channel  = rs -> getInt(6);
00261             
00262             //cout << _cdsi << "   " << _crate << "   " << _slot << "   " << _fiber << "   " << _channel << endl;
00263           }
00264       }
00265       //Always terminate statement
00266       _connection -> terminateStatement(stmt);
00267     } catch (SQLException& e) {
00268       XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle  exception : %s",e.getMessage().c_str()));
00269     }
00270     
00271     int topbottom, luttype;
00272     if ( _fpga == hcal::ConfigurationDatabase::Top ) topbottom = 1;
00273     else topbottom = 0;
00274     if ( _lt == hcal::ConfigurationDatabase::LinearizerLUT ) luttype = 1;
00275     else luttype = 2;
00276     
00277     result = getOnlineLUT( tag, _crate, _slot, topbottom, _fiber, _channel, luttype );
00278     
00279   }
00280   else{
00281     cout << "Either the XML file with LUTs or the database with LMap are not defined" << endl;
00282   }
00283 
00284   return result;
00285 }

void HCALConfigDB::setAccessor ( string  _accessor  ) 

Definition at line 48 of file HCALConfigDB.cc.

References accessor.

00049 {      
00050   accessor = _accessor;
00051 }


Member Data Documentation

string HCALConfigDB::accessor [protected]

Definition at line 44 of file HCALConfigDB.h.

Referenced by connect(), HCALConfigDB(), and setAccessor().

string HCALConfigDB::accessor2 [protected]

Definition at line 51 of file HCALConfigDB.h.

Referenced by connect().

ConfigurationDatabaseImpl* HCALConfigDB::database [protected]

Definition at line 45 of file HCALConfigDB.h.

Referenced by connect(), disconnect(), getConnection(), getEnvironment(), getOnlineLUT(), getOnlineLUTFromXML(), HCALConfigDB(), and ~HCALConfigDB().

ConfigurationDatabaseImpl* HCALConfigDB::database2 [protected]

Definition at line 52 of file HCALConfigDB.h.

Referenced by connect(), disconnect(), getOnlineLUTFromXML(), HCALConfigDB(), and ~HCALConfigDB().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:23:30 2009 for CMSSW by  doxygen 1.5.4