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 20 of file HCALConfigDB.h.

Member Typedef Documentation

◆ ConfigurationDatabaseImpl

typedef hcal::ConfigurationDatabaseImpl HCALConfigDB::ConfigurationDatabaseImpl

Definition at line 22 of file HCALConfigDB.h.

Constructor & Destructor Documentation

◆ HCALConfigDB() [1/2]

HCALConfigDB::HCALConfigDB ( void  )

Definition at line 30 of file HCALConfigDB.cc.

30  {
31  database = nullptr;
32  database2 = nullptr;
33 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:56
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49

◆ ~HCALConfigDB()

HCALConfigDB::~HCALConfigDB ( void  )

Definition at line 41 of file HCALConfigDB.cc.

41  {
42  delete database;
43  delete database2;
44 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:56
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49

◆ HCALConfigDB() [2/2]

HCALConfigDB::HCALConfigDB ( std::string  _accessor)

Definition at line 35 of file HCALConfigDB.cc.

35  {
36  database = nullptr;
37  database2 = nullptr;
38  accessor = _accessor;
39 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:56
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49
std::string accessor
Definition: HCALConfigDB.h:48

Member Function Documentation

◆ clobToString()

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

Definition at line 297 of file HCALConfigDB.cc.

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

297  {
298  oracle::occi::Clob clob = _clob;
299  Stream* instream = clob.getStream(1, 0);
300  unsigned int size = clob.length();
301  char* cbuffer = new char[size];
302  memset(cbuffer, 0, size);
303  instream->readBuffer(cbuffer, size);
304  std::string str(cbuffer, size);
305  return str;
306 }
size
Write out results.
std::vector< Frame > Stream
Definition: TTTypes.h:65
#define str(s)

◆ connect() [1/2]

void HCALConfigDB::connect ( std::string  _accessor)

Definition at line 48 of file HCALConfigDB.cc.

References mps_fire::i.

Referenced by o2o_db_cfgmap.DbManagerDAQ::update_hashmap().

48  {
49  accessor = _accessor;
50 
51  std::string::size_type i = accessor.find("occi://");
52  if (i != std::string::npos) {
53  database = new ConfigurationDatabaseImplOracle();
54  database->connect(accessor);
55  } else {
56  database = new ConfigurationDatabaseImplXMLFile();
57  database->connect(accessor);
58  }
59 }
uint16_t size_type
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49
std::string accessor
Definition: HCALConfigDB.h:48

◆ connect() [2/2]

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

Definition at line 61 of file HCALConfigDB.cc.

References GlobalPosition_Frontier_DevDB_cff::connect, and mps_fire::i.

Referenced by o2o_db_cfgmap.DbManagerDAQ::update_hashmap().

61  {
62  connect(_accessor1);
63 
64  accessor2 = _accessor2;
65 
66  std::string::size_type i = accessor2.find("occi://");
67  if (i != std::string::npos) {
68  database2 = new ConfigurationDatabaseImplOracle();
69  database2->connect(accessor2);
70  } else {
71  database2 = new ConfigurationDatabaseImplXMLFile();
72  database2->connect(accessor2);
73  }
74 }
std::string accessor2
Definition: HCALConfigDB.h:55
uint16_t size_type
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:56
void connect(std::string _accessor)
Definition: HCALConfigDB.cc:48

◆ disconnect()

void HCALConfigDB::disconnect ( void  )

Definition at line 76 of file HCALConfigDB.cc.

76  {
77  if (database != nullptr)
78  database->disconnect();
79  if (database2 != nullptr)
80  database2->disconnect();
81 }
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:56
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49

◆ getConnection()

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

Definition at line 292 of file HCALConfigDB.cc.

Referenced by ws_sso_content_reader.HTTPSClientAuthHandler::https_open().

292 { return database->getConnection(); }
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49

◆ getEnvironment()

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

Definition at line 294 of file HCALConfigDB.cc.

294 { return database->getEnvironment(); }
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49

◆ getOnlineLUT() [1/2]

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

Definition at line 83 of file HCALConfigDB.cc.

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

84  {
85  //connect( accessor );
86 
87  std::vector<unsigned int> result;
88 
89  hcal::ConfigurationDatabase::FPGASelection _fpga;
90  if (topbottom == 0)
91  _fpga = hcal::ConfigurationDatabase::Bottom;
92  else if (topbottom == 1)
94  else {
95  std::cout << "topbottom out of range" << std::endl;
96  exit(-1);
97  }
98 
99  hcal::ConfigurationDatabase::LUTType _lt;
100  if (luttype == 1)
101  _lt = hcal::ConfigurationDatabase::LinearizerLUT;
102  else if (luttype == 2)
103  _lt = hcal::ConfigurationDatabase::CompressionLUT;
104  else {
105  std::cout << "LUT type out of range" << std::endl;
106  exit(-1);
107  }
108 
109  hcal::ConfigurationDatabase::LUTId _lutid(crate, slot, _fpga, fiber, channel, _lt);
110  std::map<hcal::ConfigurationDatabase::LUTId, hcal::ConfigurationDatabase::LUT> testLUTs;
111 
113 
114  try {
115  database->getLUTs(tag, crate, slot, testLUTs);
116  } catch (hcal::exception::ConfigurationItemNotFoundException& e) {
117  std::cout << "Found nothing!" << std::endl;
118  } catch (hcal::exception::Exception& e2) {
119  std::cout << "Exception: " << e2.what() << std::endl;
120  }
121 
122  result = testLUTs[_lutid];
123 
124  //database -> disconnect();
125 
126  return result;
127 }
static const std::string Top
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:134
def exit(msg="")

◆ getOnlineLUT() [2/2]

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

Definition at line 129 of file HCALConfigDB.cc.

References hcalRecHitTable_cff::depth, HcalDetId::depth(), MillePedeFileConverter_cfg::e, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, HcalDetId::ietaAbs(), HcalDetId::iphi(), phi, mps_fire::result, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::side(), AlCaHLTBitMon_QueryRunRegistry::string, HcalDetId::subdet(), subdetector, makeGlobalPositionRcd_cfg::tag, TtFullHadDaughter::Top, toolbox::toString(), and HcalDetId::zside().

131  {
132  std::vector<unsigned int> result;
133  HcalDetId _id(_rawid);
134 
135  double _condition_data_set_id;
136  unsigned int _crate, _slot, _fiber, _channel;
137  hcal::ConfigurationDatabase::FPGASelection _fpga;
138 
139  int side = _id.zside();
140  int etaAbs = _id.ietaAbs();
141  int phi = _id.iphi();
142  int depth = _id.depth();
144  if (_id.subdet() == HcalBarrel)
145  subdetector = "HB";
146  else if (_id.subdet() == HcalEndcap)
147  subdetector = "HE";
148  else if (_id.subdet() == HcalOuter)
149  subdetector = "HO";
150  else if (_id.subdet() == HcalForward)
151  subdetector = "HF";
152 
153  oracle::occi::Connection* _connection = database->getConnection();
154 
155  try {
156  Statement* stmt = _connection->createStatement();
157  std::string query = ("SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
158  query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
159  query += toolbox::toString(" WHERE SIDE=%d AND ETA=%d AND PHI=%d AND DEPTH=%d AND SUBDETECTOR='%s'",
160  side,
161  etaAbs,
162  phi,
163  depth,
164  subdetector.c_str());
165 
166  //SELECT
167  ResultSet* rs = stmt->executeQuery(query);
168 
169  _condition_data_set_id = 0.0;
170 
171  while (rs->next()) {
172  double _cdsi = rs->getDouble(1);
173  if (_condition_data_set_id < _cdsi) {
174  _condition_data_set_id = _cdsi;
175  _crate = rs->getInt(2);
176  _slot = rs->getInt(3);
177  std::string fpga_ = rs->getString(4);
178  if (fpga_ == "top")
180  else
181  _fpga = hcal::ConfigurationDatabase::Bottom;
182  _fiber = rs->getInt(5);
183  _channel = rs->getInt(6);
184 
185  int topbottom, luttype;
187  topbottom = 1;
188  else
189  topbottom = 0;
190  if (_lt == hcal::ConfigurationDatabase::LinearizerLUT)
191  luttype = 1;
192  else
193  luttype = 2;
194 
195  result = getOnlineLUT(tag, _crate, _slot, topbottom, _fiber, _channel, luttype);
196  }
197  }
198  //Always terminate statement
199  _connection->terminateStatement(stmt);
200  } catch (SQLException& e) {
201  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
202  ::toolbox::toString("Oracle exception : %s", e.getMessage().c_str()));
203  }
204  return result;
205 }
TString subdetector
Definition: query.py:1
static const std::string Top
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)
Definition: HCALConfigDB.cc:83
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49

◆ getOnlineLUTFromXML()

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

Definition at line 207 of file HCALConfigDB.cc.

References gather_cfg::cout, hcalRecHitTable_cff::depth, HcalDetId::depth(), MillePedeFileConverter_cfg::e, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, HcalDetId::ietaAbs(), HcalDetId::iphi(), phi, mps_fire::result, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::side(), AlCaHLTBitMon_QueryRunRegistry::string, HcalDetId::subdet(), subdetector, makeGlobalPositionRcd_cfg::tag, TtFullHadDaughter::Top, toolbox::toString(), and HcalDetId::zside().

209  {
210  std::vector<unsigned int> result;
211 
212  if (database && database2) {
213  HcalDetId _id(_rawid);
214 
215  double _condition_data_set_id;
216  unsigned int _crate, _slot, _fiber, _channel;
217  hcal::ConfigurationDatabase::FPGASelection _fpga;
218 
219  int side = _id.zside();
220  int etaAbs = _id.ietaAbs();
221  int phi = _id.iphi();
222  int depth = _id.depth();
224  if (_id.subdet() == HcalBarrel)
225  subdetector = "HB";
226  else if (_id.subdet() == HcalEndcap)
227  subdetector = "HE";
228  else if (_id.subdet() == HcalOuter)
229  subdetector = "HO";
230  else if (_id.subdet() == HcalForward)
231  subdetector = "HF";
232 
233  oracle::occi::Connection* _connection = database2->getConnection();
234 
235  try {
236  Statement* stmt = _connection->createStatement();
237  std::string query = ("SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
238  query += " FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
239  query += toolbox::toString(" WHERE SIDE=%d AND ETA=%d AND PHI=%d AND DEPTH=%d AND SUBDETECTOR='%s'",
240  side,
241  etaAbs,
242  phi,
243  depth,
244  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  _condition_data_set_id = _cdsi;
255  _crate = rs->getInt(2);
256  _slot = rs->getInt(3);
257  std::string fpga_ = rs->getString(4);
258  if (fpga_ == "top")
260  else
261  _fpga = hcal::ConfigurationDatabase::Bottom;
262  _fiber = rs->getInt(5);
263  _channel = rs->getInt(6);
264 
265  //
266  int topbottom, luttype;
268  topbottom = 1;
269  else
270  topbottom = 0;
271  if (_lt == hcal::ConfigurationDatabase::LinearizerLUT)
272  luttype = 1;
273  else
274  luttype = 2;
275  result = getOnlineLUT(tag, _crate, _slot, topbottom, _fiber, _channel, luttype);
276  }
277  }
278  //Always terminate statement
279  _connection->terminateStatement(stmt);
280 
281  } catch (SQLException& e) {
282  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
283  ::toolbox::toString("Oracle exception : %s", e.getMessage().c_str()));
284  }
285  } else {
286  std::cout << "Either the XML file with LUTs or the database with LMap are not defined" << std::endl;
287  }
288 
289  return result;
290 }
TString subdetector
ConfigurationDatabaseImpl * database2
Definition: HCALConfigDB.h:56
Definition: query.py:1
static const std::string Top
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)
Definition: HCALConfigDB.cc:83
ConfigurationDatabaseImpl * database
Definition: HCALConfigDB.h:49

◆ setAccessor()

void HCALConfigDB::setAccessor ( std::string  _accessor)

Definition at line 46 of file HCALConfigDB.cc.

46 { accessor = _accessor; }
std::string accessor
Definition: HCALConfigDB.h:48

Member Data Documentation

◆ accessor

std::string HCALConfigDB::accessor
protected

Definition at line 48 of file HCALConfigDB.h.

◆ accessor2

std::string HCALConfigDB::accessor2
protected

Definition at line 55 of file HCALConfigDB.h.

◆ database

ConfigurationDatabaseImpl* HCALConfigDB::database
protected

Definition at line 49 of file HCALConfigDB.h.

◆ database2

ConfigurationDatabaseImpl* HCALConfigDB::database2
protected

Definition at line 56 of file HCALConfigDB.h.