CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
HCALConfigDB Class Reference

Gather config data from online DB. More...

#include <HCALConfigDB.h>

Public Types

typedef hcal::ConfigurationDatabaseImpl ConfigurationDatabaseImpl
 

Public Member Functions

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

Protected Attributes

std::string accessor
 
std::string accessor2
 
ConfigurationDatabaseImpldatabase
 
ConfigurationDatabaseImpldatabase2
 

Detailed Description

Gather config data from online DB.

Author
Gena Kukartsev

Definition at line 21 of file HCALConfigDB.h.

Member Typedef Documentation

typedef hcal::ConfigurationDatabaseImpl HCALConfigDB::ConfigurationDatabaseImpl

Definition at line 23 of file HCALConfigDB.h.

Constructor & Destructor Documentation

HCALConfigDB::HCALConfigDB ( void  )

Definition at line 31 of file HCALConfigDB.cc.

32 {
33  database = nullptr;
34  database2 = nullptr;
35 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:51
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
HCALConfigDB::~HCALConfigDB ( void  )

Definition at line 45 of file HCALConfigDB.cc.

46 {
47  delete database;
48  delete database2;
49 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:51
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
HCALConfigDB::HCALConfigDB ( std::string  _accessor)

Definition at line 37 of file HCALConfigDB.cc.

38 {
39  database = nullptr;
40  database2 = nullptr;
41  accessor = _accessor;
42 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:51
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
std::string accessor
Definition: HCALConfigDB.h:43

Member Function Documentation

string HCALConfigDB::clobToString ( const oracle::occi::Clob &  _clob)

Definition at line 299 of file HCALConfigDB.cc.

References findQualityFiles::size, str, and AlCaHLTBitMon_QueryRunRegistry::string.

299  {
300  oracle::occi::Clob clob = _clob;
301  Stream *instream = clob.getStream (1,0);
302  unsigned int size = clob.length();
303  char *cbuffer = new char[size];
304  memset (cbuffer, 0, size);
305  instream->readBuffer (cbuffer, size);
306  std::string str(cbuffer,size);
307  return str;
308 }
size
Write out results.
#define str(s)
void HCALConfigDB::connect ( std::string  _accessor)

Definition at line 57 of file HCALConfigDB.cc.

References DBConfiguration_cff::connect, spr::find(), and mps_fire::i.

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), o2o_db_cfgmap.DbManagerDAQ::update_hashmap(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

58 {
59 
60  accessor = _accessor;
61 
62  std::string::size_type i = accessor . find( "occi://" );
63  if ( i!=std::string::npos )
64  {
65  database = new ConfigurationDatabaseImplOracle();
67  }
68  else
69  {
70  database = new ConfigurationDatabaseImplXMLFile();
72  }
73 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
uint16_t size_type
void connect(std::string _accessor)
Definition: HCALConfigDB.cc:57
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
std::string accessor
Definition: HCALConfigDB.h:43
void HCALConfigDB::connect ( std::string  _accessor1,
std::string  _accessor2 
)

Definition at line 77 of file HCALConfigDB.cc.

References DBConfiguration_cff::connect, spr::find(), and mps_fire::i.

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), o2o_db_cfgmap.DbManagerDAQ::update_hashmap(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

78 {
79 
80  connect (_accessor1 );
81 
82  accessor2 = _accessor2;
83 
84  std::string::size_type i = accessor2 . find( "occi://" );
85  if ( i!=std::string::npos )
86  {
87  database2 = new ConfigurationDatabaseImplOracle();
89  }
90  else
91  {
92  database2 = new ConfigurationDatabaseImplXMLFile();
94  }
95 }
std::string accessor2
Definition: HCALConfigDB.h:50
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
uint16_t size_type
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:51
void connect(std::string _accessor)
Definition: HCALConfigDB.cc:57
void HCALConfigDB::disconnect ( void  )
oracle::occi::Connection * HCALConfigDB::getConnection ( void  )

Definition at line 288 of file HCALConfigDB.cc.

Referenced by ws_sso_content_reader.HTTPSClientAuthHandler::https_open().

288  {
289  return database -> getConnection();
290 }
oracle::occi::Connection * getConnection(void)
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
oracle::occi::Environment * HCALConfigDB::getEnvironment ( void  )

Definition at line 292 of file HCALConfigDB.cc.

292  {
293  return database -> getEnvironment();
294 }
oracle::occi::Environment * getEnvironment(void)
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
std::vector< unsigned int > HCALConfigDB::getOnlineLUT ( std::string  tag,
int  crate,
int  slot,
int  topbottom,
int  fiber,
int  channel,
int  luttype 
)

Definition at line 108 of file HCALConfigDB.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, Exception, cmsRelvalreport::exit, XMLProcessor::getInstance(), mps_fire::result, and TtFullHadDaughter::Top.

109 {
110 
111  //connect( accessor );
112 
113  std::vector<unsigned int> result;
114 
115  hcal::ConfigurationDatabase::FPGASelection _fpga;
116  if ( topbottom == 0 ) _fpga = hcal::ConfigurationDatabase::Bottom;
117  else if ( topbottom == 1 ) _fpga = hcal::ConfigurationDatabase::Top;
118  else
119  {
120  std::cout << "topbottom out of range" << std::endl;
121  exit(-1);
122  }
123 
124  hcal::ConfigurationDatabase::LUTType _lt;
125  if ( luttype == 1 ) _lt = hcal::ConfigurationDatabase::LinearizerLUT;
126  else if ( luttype == 2 ) _lt = hcal::ConfigurationDatabase::CompressionLUT;
127  else
128  {
129  std::cout << "LUT type out of range" << std::endl;
130  exit(-1);
131  }
132 
133  hcal::ConfigurationDatabase::LUTId _lutid( crate, slot, _fpga, fiber, channel, _lt );
134  std::map<hcal::ConfigurationDatabase::LUTId, hcal::ConfigurationDatabase::LUT> testLUTs;
135 
137 
138  try {
139  database -> getLUTs(tag, crate, slot, testLUTs);
140  } catch (hcal::exception::ConfigurationItemNotFoundException& e) {
141  std::cout << "Found nothing!" << std::endl;
142  } catch (hcal::exception::Exception& e2) {
143  std::cout << "Exception: " << e2.what() << std::endl;
144  }
145 
146  result = testLUTs[_lutid];
147 
148  //database -> disconnect();
149 
150  return result;
151 }
static const std::string Top
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:145
std::vector< unsigned int > HCALConfigDB::getOnlineLUT ( std::string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt = hcal::ConfigurationDatabase::LinearizerLUT 
)

Definition at line 153 of file HCALConfigDB.cc.

References egammaForCoreTracking_cff::depth, MillePedeFileConverter_cfg::e, getInt(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, phi, mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, subdetector, TtFullHadDaughter::Top, toolbox::toString(), and ecaldqm::zside().

154 {
155  std::vector<unsigned int> result;
156  HcalDetId _id( _rawid );
157 
158  double _condition_data_set_id;
159  unsigned int _crate, _slot, _fiber, _channel;
160  hcal::ConfigurationDatabase::FPGASelection _fpga;
161 
162  int side = _id . zside();
163  int etaAbs = _id . ietaAbs();
164  int phi = _id . iphi();
165  int depth = _id . depth();
167  if ( _id . subdet() == HcalBarrel) subdetector = "HB";
168  else if ( _id . subdet() == HcalEndcap) subdetector = "HE";
169  else if ( _id . subdet() == HcalOuter) subdetector = "HO";
170  else if ( _id . subdet() == HcalForward) subdetector = "HF";
171 
172  oracle::occi::Connection * _connection = database -> getConnection();
173 
174  try {
175  Statement* stmt = _connection -> createStatement();
176  std::string query = ("SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
177  query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
178  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() );
179 
180  //SELECT
181  ResultSet *rs = stmt->executeQuery(query);
182 
183  _condition_data_set_id = 0.0;
184 
185  while (rs->next()) {
186  double _cdsi = rs -> getDouble(1);
187  if ( _condition_data_set_id < _cdsi )
188  {
189  _condition_data_set_id = _cdsi;
190  _crate = rs -> getInt(2);
191  _slot = rs -> getInt(3);
192  std::string fpga_ = rs -> getString(4);
193  if ( fpga_ == "top" ) _fpga = hcal::ConfigurationDatabase::Top;
194  else _fpga = hcal::ConfigurationDatabase::Bottom;
195  _fiber = rs -> getInt(5);
196  _channel = rs -> getInt(6);
197 
198  int topbottom, luttype;
199  if ( _fpga == hcal::ConfigurationDatabase::Top ) topbottom = 1;
200  else topbottom = 0;
201  if ( _lt == hcal::ConfigurationDatabase::LinearizerLUT ) luttype = 1;
202  else luttype = 2;
203 
204  result = getOnlineLUT( tag, _crate, _slot, topbottom, _fiber, _channel, luttype );
205  }
206  }
207  //Always terminate statement
208  _connection -> terminateStatement(stmt);
209  } catch (SQLException& e) {
210  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()));
211  }
212  return result;
213 }
TString subdetector
int zside(DetId const &)
int getInt(ResultSet *rset, int ipar)
Definition: query.py:1
static const std::string Top
oracle::occi::Connection * getConnection(void)
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
std::vector< unsigned int > getOnlineLUT(std::string tag, int crate, int slot, int topbottom, int fiber, int channel, int luttype)
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
std::vector< unsigned int > HCALConfigDB::getOnlineLUTFromXML ( std::string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt = hcal::ConfigurationDatabase::LinearizerLUT 
)

Definition at line 216 of file HCALConfigDB.cc.

References gather_cfg::cout, egammaForCoreTracking_cff::depth, MillePedeFileConverter_cfg::e, getInt(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, phi, mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, subdetector, TtFullHadDaughter::Top, toolbox::toString(), and ecaldqm::zside().

216  {
217 
218  std::vector<unsigned int> result;
219 
220  if ( database && database2 ){
221 
222  HcalDetId _id( _rawid );
223 
224  double _condition_data_set_id;
225  unsigned int _crate, _slot, _fiber, _channel;
226  hcal::ConfigurationDatabase::FPGASelection _fpga;
227 
228  int side = _id . zside();
229  int etaAbs = _id . ietaAbs();
230  int phi = _id . iphi();
231  int depth = _id . depth();
233  if ( _id . subdet() == HcalBarrel) subdetector = "HB";
234  else if ( _id . subdet() == HcalEndcap) subdetector = "HE";
235  else if ( _id . subdet() == HcalOuter) subdetector = "HO";
236  else if ( _id . subdet() == HcalForward) subdetector = "HF";
237 
238  oracle::occi::Connection * _connection = database2 -> getConnection();
239 
240  try {
241  Statement* stmt = _connection -> createStatement();
242  std::string query = ("SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
243  query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
244  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() );
245 
246  //SELECT
247  ResultSet *rs = stmt->executeQuery(query);
248 
249  _condition_data_set_id = 0.0;
250 
251  while (rs->next()) {
252  double _cdsi = rs -> getDouble(1);
253  if ( _condition_data_set_id < _cdsi )
254  {
255  _condition_data_set_id = _cdsi;
256  _crate = rs -> getInt(2);
257  _slot = rs -> getInt(3);
258  std::string fpga_ = rs -> getString(4);
259  if ( fpga_ == "top" ) _fpga = hcal::ConfigurationDatabase::Top;
260  else _fpga = hcal::ConfigurationDatabase::Bottom;
261  _fiber = rs -> getInt(5);
262  _channel = rs -> getInt(6);
263 
264  //
265  int topbottom, luttype;
266  if ( _fpga == hcal::ConfigurationDatabase::Top ) topbottom = 1;
267  else topbottom = 0;
268  if ( _lt == hcal::ConfigurationDatabase::LinearizerLUT ) luttype = 1;
269  else luttype = 2;
270  result = getOnlineLUT( tag, _crate, _slot, topbottom, _fiber, _channel, luttype );
271  }
272  }
273  //Always terminate statement
274  _connection -> terminateStatement(stmt);
275 
276  } catch (SQLException& e) {
277  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()));
278  }
279  }
280  else{
281  std::cout << "Either the XML file with LUTs or the database with LMap are not defined" << std::endl;
282  }
283 
284  return result;
285 }
TString subdetector
int zside(DetId const &)
int getInt(ResultSet *rset, int ipar)
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:51
Definition: query.py:1
static const std::string Top
oracle::occi::Connection * getConnection(void)
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
std::vector< unsigned int > getOnlineLUT(std::string tag, int crate, int slot, int topbottom, int fiber, int channel, int luttype)
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
void HCALConfigDB::setAccessor ( std::string  _accessor)

Definition at line 52 of file HCALConfigDB.cc.

53 {
54  accessor = _accessor;
55 }
std::string accessor
Definition: HCALConfigDB.h:43

Member Data Documentation

std::string HCALConfigDB::accessor
protected

Definition at line 43 of file HCALConfigDB.h.

std::string HCALConfigDB::accessor2
protected

Definition at line 50 of file HCALConfigDB.h.

ConfigurationDatabaseImpl* HCALConfigDB::database
protected

Definition at line 44 of file HCALConfigDB.h.

ConfigurationDatabaseImpl* HCALConfigDB::database2
protected

Definition at line 51 of file HCALConfigDB.h.