CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (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 27 of file HCALConfigDB.cc.

28 {
29  database = 0;
30  database2 = 0;
31 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:51
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
HCALConfigDB::~HCALConfigDB ( void  )

Definition at line 41 of file HCALConfigDB.cc.

42 {
43  delete database;
44  delete database2;
45 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:51
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:44
HCALConfigDB::HCALConfigDB ( std::string  _accessor)

Definition at line 33 of file HCALConfigDB.cc.

34 {
35  database = 0;
36  database2 = 0;
37  accessor = _accessor;
38 }
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 ( oracle::occi::Clob  clob)

Definition at line 295 of file HCALConfigDB.cc.

References findQualityFiles::size.

295  {
296 
297  Stream *instream = clob.getStream (1,0);
298  unsigned int size = clob.length();
299  char *cbuffer = new char[size];
300  memset (cbuffer, 0, size);
301  instream->readBuffer (cbuffer, size);
302  std::string str(cbuffer,size);
303  return str;
304 }
tuple size
Write out results.
void HCALConfigDB::connect ( std::string  _accessor)

Definition at line 53 of file HCALConfigDB.cc.

References convertSQLitetoXML_cfg::connect, spr::find(), and 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(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

54 {
55 
56  accessor = _accessor;
57 
58  std::string::size_type i = accessor . find( "occi://" );
59  if ( i!=std::string::npos )
60  {
61  database = new ConfigurationDatabaseImplOracle();
63  }
64  else
65  {
66  database = new ConfigurationDatabaseImplXMLFile();
68  }
69 }
int i
Definition: DBlmapReader.cc:9
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
uint16_t size_type
void connect(std::string _accessor)
Definition: HCALConfigDB.cc:53
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 73 of file HCALConfigDB.cc.

References convertSQLitetoXML_cfg::connect, spr::find(), and 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(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

74 {
75 
76  connect (_accessor1 );
77 
78  accessor2 = _accessor2;
79 
80  std::string::size_type i = accessor2 . find( "occi://" );
81  if ( i!=std::string::npos )
82  {
83  database2 = new ConfigurationDatabaseImplOracle();
85  }
86  else
87  {
88  database2 = new ConfigurationDatabaseImplXMLFile();
90  }
91 }
int i
Definition: DBlmapReader.cc:9
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:7
uint16_t size_type
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:51
void connect(std::string _accessor)
Definition: HCALConfigDB.cc:53
void HCALConfigDB::disconnect ( void  )
oracle::occi::Connection * HCALConfigDB::getConnection ( void  )

Definition at line 284 of file HCALConfigDB.cc.

Referenced by ws_sso_content_reader.HTTPSClientAuthHandler::https_open().

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

Definition at line 288 of file HCALConfigDB.cc.

288  {
289  return database -> getEnvironment();
290 }
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 104 of file HCALConfigDB.cc.

References gather_cfg::cout, alignCSCRings::e, edm::hlt::Exception, cmsRelvalreport::exit, XMLProcessor::getInstance(), query::result, and TtFullHadDaughter::Top.

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

Definition at line 149 of file HCALConfigDB.cc.

References alignCSCRings::e, getInt(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, phi, o2o::query, query::result, TtFullHadDaughter::Top, and toString().

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

Definition at line 212 of file HCALConfigDB.cc.

References gather_cfg::cout, alignCSCRings::e, getInt(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, phi, o2o::query, query::result, TtFullHadDaughter::Top, and toString().

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

Definition at line 48 of file HCALConfigDB.cc.

49 {
50  accessor = _accessor;
51 }
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.