00001
00002
00003
00004
00005
00006
00007 #include <vector>
00008 #include <string>
00009
00010 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00011 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
00012 #include "DataFormats/HcalDetId/interface/HcalCastorDetId.h"
00013 #include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
00014 #include "CalibFormats/HcalObjects/interface/HcalText2DetIdConverter.h"
00015
00016 #include "CondFormats/HcalObjects/interface/AllObjects.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "CaloOnlineTools/HcalOnlineDb/interface/HcalDbOmds.h"
00019 #include "CaloOnlineTools/HcalOnlineDb/interface/RooGKCounter.h"
00020
00021 typedef oracle::occi::ResultSet ResultSet;
00022 typedef oracle::occi::SQLException SQLException;
00023
00024 template<class T>
00025 bool HcalDbOmds::from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) {
00026 std::istringstream iss(s);
00027 return !(iss >> f >> t).fail();
00028 }
00029
00030
00031
00032
00033
00034
00035 DetId HcalDbOmds::getId(oracle::occi::ResultSet * rs){
00036 std::string _name = rs->getString(1);
00037
00038 if (rs->getString(1).find("HcalDetId")!=std::string::npos){
00039
00040 return HcalDetId(get_subdetector(rs->getString(2)),
00041 rs->getInt(3),
00042 rs->getInt(4),
00043 rs->getInt(5));
00044 }
00045 else if (rs->getString(1).find("HcalCalibDetId")!=std::string::npos){
00046
00047 return HcalCalibDetId(get_subdetector(rs->getString(2)),
00048 rs->getInt(3),
00049 rs->getInt(4),
00050 rs->getInt(6));
00051 }
00052 else if (rs->getString(1).find("HcalTrigTowerDetId")!=std::string::npos){
00053
00054 return HcalTrigTowerDetId(rs->getInt(3),
00055 rs->getInt(4));
00056 }
00057 else if (rs->getString(1).find("HcalZDCDetId")!=std::string::npos){
00058
00059 return HcalZDCDetId(get_zdc_section(rs->getString(7)),
00060 rs->getInt(8)>0,
00061 rs->getInt(11));
00062 }
00063 else if (rs->getString(1).find("HcalCastorDetId")!=std::string::npos){
00064
00065 return HcalCastorDetId(rs->getInt(8)>0,
00066 rs->getInt(9)>0,
00067 rs->getInt(10));
00068 }
00069 else return 0;
00070 }
00071
00072 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00073 const std::string & fTag,
00074 const std::string & fVersion,
00075 const int fSubversion,
00076 const int fIOVBegin,
00077 const std::string & fQuery,
00078 HcalPedestals* fObject) {
00079 bool result=true;
00080 if (!fObject) fObject = new HcalPedestals;
00081 int _unit=0;
00082 try {
00083 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00084 stmt->setString(1,fTag);
00085
00086 stmt->setInt(2,fIOVBegin);
00087
00088 ResultSet *rs = stmt->executeQuery();
00089
00090
00091 for (int _i=1; _i!=12; _i++) rs->setMaxColumnSize(_i,128);
00092
00093 RooGKCounter _row(1,100);
00094 _row.setMessage("HCAL channels processed: ");
00095 _row.setPrintCount(true);
00096 _row.setNewLine(true);
00097
00098
00099
00100
00101
00102
00103 while (rs->next()) {
00104 _row.count();
00105 DetId id = getId(rs);
00106 _unit = rs->getInt(12);
00107 float cap0 = rs->getFloat(13);
00108 float cap1 = rs->getFloat(14);
00109 float cap2 = rs->getFloat(15);
00110 float cap3 = rs->getFloat(16);
00111 float variance0 = rs->getFloat(17);
00112 float variance1 = rs->getFloat(18);
00113 float variance2 = rs->getFloat(19);
00114 float variance3 = rs->getFloat(20);
00115
00116
00117
00118
00119
00120 std::cout << "DEBUG: " << std::endl;
00121
00122 HcalPedestal * fCondObject = new HcalPedestal(id.rawId(), cap0, cap1, cap2, cap3, variance0, variance1, variance2, variance3);
00123 fObject->addValues(*fCondObject);
00124 delete fCondObject;
00125 }
00126
00127 connection->terminateStatement(stmt);
00128 } catch (SQLException& e) {
00129 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00130 }
00131 bool unit_is_adc = false;
00132 if (_unit!=0) unit_is_adc = true;
00133 fObject->setUnitADC(unit_is_adc);
00134 return result;
00135 }
00136
00137
00138 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00139 const std::string & fTag,
00140 const std::string & fVersion,
00141 const int fSubversion,
00142 const int fIOVBegin,
00143 const std::string & fQuery,
00144 HcalPedestalWidths* fObject) {
00145 bool result=true;
00146 if (!fObject) fObject = new HcalPedestalWidths;
00147 int _unit=0;
00148 try {
00149 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00150 stmt->setString(1,fTag);
00151 stmt->setInt(2,fIOVBegin);
00152
00153 ResultSet *rs = stmt->executeQuery();
00154
00155 rs->setMaxColumnSize(1,128);
00156 rs->setMaxColumnSize(2,128);
00157 rs->setMaxColumnSize(3,128);
00158 rs->setMaxColumnSize(4,128);
00159 rs->setMaxColumnSize(5,128);
00160 rs->setMaxColumnSize(6,128);
00161 rs->setMaxColumnSize(7,128);
00162 rs->setMaxColumnSize(8,128);
00163 rs->setMaxColumnSize(9,128);
00164 rs->setMaxColumnSize(10,128);
00165 rs->setMaxColumnSize(11,128);
00166
00167 RooGKCounter _row(1,100);
00168 _row.setMessage("HCAL channels processed: ");
00169 _row.setPrintCount(true);
00170 _row.setNewLine(true);
00171
00172
00173
00174
00175
00176
00177 while (rs->next()) {
00178 _row.count();
00179 DetId id = getId(rs);
00180 _unit = rs->getInt(12);
00181 float covariance_00 = rs->getFloat(13);
00182 float covariance_01 = rs->getFloat(14);
00183 float covariance_02 = rs->getFloat(15);
00184 float covariance_03 = rs->getFloat(16);
00185 float covariance_10 = rs->getFloat(17);
00186 float covariance_11 = rs->getFloat(18);
00187 float covariance_12 = rs->getFloat(19);
00188 float covariance_13 = rs->getFloat(20);
00189 float covariance_20 = rs->getFloat(21);
00190 float covariance_21 = rs->getFloat(22);
00191 float covariance_22 = rs->getFloat(23);
00192 float covariance_23 = rs->getFloat(24);
00193 float covariance_30 = rs->getFloat(25);
00194 float covariance_31 = rs->getFloat(26);
00195 float covariance_32 = rs->getFloat(27);
00196 float covariance_33 = rs->getFloat(28);
00197 HcalPedestalWidth * fCondObject = new HcalPedestalWidth(id);
00198 fCondObject->setSigma(0,0,covariance_00);
00199 fCondObject->setSigma(0,1,covariance_01);
00200 fCondObject->setSigma(0,2,covariance_02);
00201 fCondObject->setSigma(0,3,covariance_03);
00202 fCondObject->setSigma(1,0,covariance_10);
00203 fCondObject->setSigma(1,1,covariance_11);
00204 fCondObject->setSigma(1,2,covariance_12);
00205 fCondObject->setSigma(1,3,covariance_13);
00206 fCondObject->setSigma(2,0,covariance_20);
00207 fCondObject->setSigma(2,1,covariance_21);
00208 fCondObject->setSigma(2,2,covariance_22);
00209 fCondObject->setSigma(2,3,covariance_23);
00210 fCondObject->setSigma(3,0,covariance_30);
00211 fCondObject->setSigma(3,1,covariance_31);
00212 fCondObject->setSigma(3,2,covariance_32);
00213 fCondObject->setSigma(3,3,covariance_33);
00214 fObject->addValues(*fCondObject);
00215 delete fCondObject;
00216 }
00217
00218 connection->terminateStatement(stmt);
00219 } catch (SQLException& e) {
00220 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00221 }
00222 bool unit_is_adc = false;
00223 if (_unit!=0) unit_is_adc = true;
00224 fObject->setUnitADC(unit_is_adc);
00225 return result;
00226 }
00227
00228
00229 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00230 const std::string & fTag,
00231 const std::string & fVersion,
00232 const int fSubversion,
00233 const int fIOVBegin,
00234 const std::string & fQuery,
00235 HcalGains* fObject) {
00236 bool result=true;
00237 if (!fObject) fObject = new HcalGains;
00238 try {
00239 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00240 stmt->setString(1,fTag);
00241 stmt->setInt(2,fIOVBegin);
00242
00243 ResultSet *rs = stmt->executeQuery();
00244
00245
00246 for (int _i=1; _i!=12; _i++) rs->setMaxColumnSize(_i,128);
00247
00248 RooGKCounter _row(1,100);
00249 _row.setMessage("HCAL channels processed: ");
00250 _row.setPrintCount(true);
00251 _row.setNewLine(true);
00252
00253
00254
00255
00256
00257
00258 while (rs->next()) {
00259 _row.count();
00260 DetId id = getId(rs);
00261 float cap0 = rs->getFloat(12);
00262 float cap1 = rs->getFloat(13);
00263 float cap2 = rs->getFloat(14);
00264 float cap3 = rs->getFloat(15);
00265
00266
00267
00268
00269
00270
00271 HcalGain * fCondObject = new HcalGain(id, cap0, cap1, cap2, cap3);
00272 fObject->addValues(*fCondObject);
00273 delete fCondObject;
00274 }
00275
00276 connection->terminateStatement(stmt);
00277 } catch (SQLException& e) {
00278 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00279 }
00280 return result;
00281 }
00282
00283
00284 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00285 const std::string & fTag,
00286 const std::string & fVersion,
00287 const int fSubversion,
00288 const int fIOVBegin,
00289 const std::string & fQuery,
00290 HcalGainWidths* fObject) {
00291 bool result=true;
00292 if (!fObject) fObject = new HcalGainWidths;
00293 try {
00294 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00295 stmt->setString(1,fTag);
00296 stmt->setInt(2,fIOVBegin);
00297
00298 ResultSet *rs = stmt->executeQuery();
00299
00300
00301 for (int _i=1; _i!=12; _i++) rs->setMaxColumnSize(_i,128);
00302
00303 RooGKCounter _row(1,100);
00304 _row.setMessage("HCAL channels processed: ");
00305 _row.setPrintCount(true);
00306 _row.setNewLine(true);
00307
00308
00309
00310
00311
00312
00313 while (rs->next()) {
00314 _row.count();
00315 DetId id = getId(rs);
00316 float cap0 = rs->getFloat(12);
00317 float cap1 = rs->getFloat(13);
00318 float cap2 = rs->getFloat(14);
00319 float cap3 = rs->getFloat(15);
00320
00321
00322
00323
00324
00325
00326 HcalGainWidth * fCondObject = new HcalGainWidth(id, cap0, cap1, cap2, cap3);
00327 fObject->addValues(*fCondObject);
00328 delete fCondObject;
00329 }
00330
00331 connection->terminateStatement(stmt);
00332 } catch (SQLException& e) {
00333 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00334 }
00335 return result;
00336 }
00337
00338
00339 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00340 const std::string & fTag,
00341 const std::string & fVersion,
00342 const int fSubversion,
00343 const int fIOVBegin,
00344 const std::string & fQuery,
00345 HcalQIEData* fObject) {
00346 bool result=true;
00347 if (!fObject) fObject = new HcalQIEData;
00348 try {
00349 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00350 stmt->setString(1,fTag);
00351 stmt->setInt(2,fIOVBegin);
00352
00353 ResultSet *rs = stmt->executeQuery();
00354
00355 rs->setMaxColumnSize(1,128);
00356 rs->setMaxColumnSize(2,128);
00357 rs->setMaxColumnSize(3,128);
00358 rs->setMaxColumnSize(4,128);
00359 rs->setMaxColumnSize(5,128);
00360 rs->setMaxColumnSize(6,128);
00361 rs->setMaxColumnSize(7,128);
00362 rs->setMaxColumnSize(8,128);
00363 rs->setMaxColumnSize(9,128);
00364 rs->setMaxColumnSize(10,128);
00365 rs->setMaxColumnSize(11,128);
00366
00367 RooGKCounter _row(1,100);
00368 _row.setMessage("HCAL channels processed: ");
00369 _row.setPrintCount(true);
00370 _row.setNewLine(true);
00371
00372
00373
00374
00375
00376
00377 while (rs->next()) {
00378 _row.count();
00379 DetId id = getId(rs);
00380 fObject->sort();
00381 float items[32];
00382 for (int _i=0; _i!=32; _i++) items[_i] = rs->getFloat(_i+12);
00383 HcalQIECoder * fCondObject = new HcalQIECoder(id.rawId());
00384 for (unsigned capid = 0; capid < 4; capid++) {
00385 for (unsigned range = 0; range < 4; range++) {
00386 fCondObject->setSlope (capid, range, items[capid*4+range]);
00387 }
00388 }
00389 for (unsigned capid = 0; capid < 4; capid++) {
00390 for (unsigned range = 0; range < 4; range++) {
00391 fCondObject->setOffset (capid, range, items[16+capid*4+range]);
00392 }
00393 }
00394 fObject->addCoder(*fCondObject);
00395 delete fCondObject;
00396 }
00397
00398 connection->terminateStatement(stmt);
00399 } catch (SQLException& e) {
00400 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00401 }
00402 return result;
00403 }
00404
00405
00406 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00407 const std::string & fTag,
00408 const std::string & fVersion,
00409 const int fSubversion,
00410 const int fIOVBegin,
00411 const std::string & fQuery,
00412 HcalCalibrationQIEData* fObject) {
00413 std::cerr << "NOT IMPLEMENTED!" << std::endl;
00414 return false;
00415 }
00416
00417
00418 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00419 const std::string & fTag,
00420 const std::string & fVersion,
00421 const int fSubversion,
00422 const int fIOVBegin,
00423 const std::string & fQuery,
00424 HcalElectronicsMap* fObject) {
00425 bool result=true;
00426 if (!fObject) fObject = new HcalElectronicsMap;
00427 try {
00428 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00429 stmt->setString(1,fTag);
00430 stmt->setInt(2,fIOVBegin);
00431
00432 ResultSet *rs = stmt->executeQuery();
00433
00434
00435 for (int _i=1; _i!=20; _i++) rs->setMaxColumnSize(_i,128);
00436
00437 RooGKCounter _row(1,100);
00438 _row.setMessage("HCAL channels processed: ");
00439 _row.setPrintCount(true);
00440 _row.setNewLine(true);
00441
00442
00443
00444
00445
00446
00447 while (rs->next()) {
00448 _row.count();
00449 DetId id = getId(rs);
00450 std::string _obj_name = rs->getString(1);
00451 int crate = rs->getInt(13);
00452 int slot = rs->getInt(14);
00453 int dcc = rs->getInt(16);
00454 int spigot = rs->getInt(17);
00455 std::string tb = rs->getString(15);
00456 int top = 1;
00457 if (tb.find("b")!=std::string::npos) top = 0;
00458 HcalElectronicsId * fCondObject = 0;
00459 if (_obj_name.find("HcalTrigTowerDetId")!=std::string::npos){
00460 int slbCh = rs->getInt(19);
00461 int slb = rs->getInt(18);
00462 fCondObject = new HcalElectronicsId(slbCh, slb, spigot, dcc,crate,slot,top);
00463 }
00464 else{
00465 int fiberCh = rs->getInt(19);
00466 int fiber = rs->getInt(18);
00467 fCondObject = new HcalElectronicsId(fiberCh, fiber, spigot, dcc);
00468 fCondObject->setHTR(crate,slot,top);
00469 }
00470 if (_obj_name.find("HcalTrigTowerDetId")!=std::string::npos){
00471 fObject->mapEId2tId(*fCondObject, id);
00472 }
00473 else if (_obj_name.find("HcalDetId")!=std::string::npos ||
00474 _obj_name.find("HcalCalibDetId")!=std::string::npos ||
00475 _obj_name.find("HcalZDCDetId")!=std::string::npos){
00476 fObject->mapEId2chId(*fCondObject, id);
00477 }
00478 else {
00479 edm::LogWarning("Format Error") << "HcalElectronicsMap-> Unknown subdetector: "
00480 << _obj_name << std::endl;
00481 }
00482 delete fCondObject;
00483 }
00484
00485 connection->terminateStatement(stmt);
00486 } catch (SQLException& e) {
00487 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00488 }
00489 fObject->sort ();
00490 return result;
00491 }
00492
00493
00494 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00495 const std::string & fTag,
00496 const std::string & fVersion,
00497 const int fSubversion,
00498 const int fIOVBegin,
00499 const std::string & fQuery,
00500 HcalChannelQuality* fObject) {
00501 std::cout << " +++++=====> HcalDbOmds::getObject" << std::endl;
00502
00503 bool result=true;
00504 if (!fObject) fObject = new HcalChannelQuality;
00505 try {
00506 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00507 stmt->setString(1,fTag);
00508 stmt->setInt(2,fIOVBegin);
00509
00510 ResultSet *rs = stmt->executeQuery();
00511
00512
00513 for (int _i=1; _i!=12; _i++) rs->setMaxColumnSize(_i,128);
00514
00515 RooGKCounter _row(1,100);
00516 _row.setMessage("HCAL channels processed: ");
00517 _row.setPrintCount(true);
00518 _row.setNewLine(true);
00519
00520
00521
00522
00523
00524
00525 while (rs->next()) {
00526 _row.count();
00527 DetId id = getId(rs);
00528 int value = rs->getInt(12);
00529
00530
00531
00532
00533
00534
00535 HcalChannelStatus * fCondObject = new HcalChannelStatus(id, value);
00536 fObject->addValues(*fCondObject);
00537 delete fCondObject;
00538 }
00539
00540 connection->terminateStatement(stmt);
00541 } catch (SQLException& e) {
00542 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00543 }
00544 return result;
00545 }
00546
00547
00548 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00549 const std::string & fTag,
00550 const std::string & fVersion,
00551 const int fSubversion,
00552 const int fIOVBegin,
00553 const std::string & fQuery,
00554 HcalRespCorrs* fObject) {
00555 bool result=true;
00556 if (!fObject) fObject = new HcalRespCorrs;
00557 try {
00558 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00559 stmt->setString(1,fTag);
00560 stmt->setInt(2,fIOVBegin);
00561
00562 ResultSet *rs = stmt->executeQuery();
00563
00564
00565 for (int _i=1; _i!=12; _i++) rs->setMaxColumnSize(_i,128);
00566
00567 RooGKCounter _row(1,100);
00568 _row.setMessage("HCAL channels processed: ");
00569 _row.setPrintCount(true);
00570 _row.setNewLine(true);
00571
00572
00573
00574
00575
00576
00577 while (rs->next()) {
00578 _row.count();
00579 DetId id = getId(rs);
00580 float value = rs->getFloat(12);
00581
00582
00583
00584
00585
00586
00587 HcalRespCorr * fCondObject = new HcalRespCorr(id, value);
00588 fObject->addValues(*fCondObject);
00589 delete fCondObject;
00590 }
00591
00592 connection->terminateStatement(stmt);
00593 } catch (SQLException& e) {
00594 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00595 }
00596 return result;
00597 }
00598
00599
00600 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00601 const std::string & fTag,
00602 const std::string & fVersion,
00603 const int fSubversion,
00604 const int fIOVBegin,
00605 const std::string & fQuery,
00606 HcalZSThresholds* fObject) {
00607 bool result=true;
00608 if (!fObject) fObject = new HcalZSThresholds;
00609 try {
00610 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00611 stmt->setString(1,fTag);
00612 stmt->setInt(2,fIOVBegin);
00613
00614 ResultSet *rs = stmt->executeQuery();
00615
00616
00617 for (int _i=1; _i!=12; _i++) rs->setMaxColumnSize(_i,128);
00618
00619 RooGKCounter _row(1,100);
00620 _row.setMessage("HCAL channels processed: ");
00621 _row.setPrintCount(true);
00622 _row.setNewLine(true);
00623
00624
00625
00626
00627
00628
00629 while (rs->next()) {
00630 _row.count();
00631 DetId id = getId(rs);
00632 int zs = rs->getInt(12);
00633
00634
00635
00636
00637
00638
00639 HcalZSThreshold * fCondObject = new HcalZSThreshold(id, zs);
00640 fObject->addValues(*fCondObject);
00641 delete fCondObject;
00642 }
00643
00644 connection->terminateStatement(stmt);
00645 } catch (SQLException& e) {
00646 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00647 }
00648 return result;
00649 }
00650
00651
00652 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00653 const std::string & fTag,
00654 const std::string & fVersion,
00655 const int fSubversion,
00656 const int fIOVBegin,
00657 const std::string & fQuery,
00658 HcalL1TriggerObjects* fObject) {
00659 bool result=true;
00660 if (!fObject) fObject = new HcalL1TriggerObjects;
00661 std::string _tag;
00662 std::string _algo;
00663 try {
00664 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00665 stmt->setString(1,fTag);
00666 stmt->setInt(2,fIOVBegin);
00667
00668 ResultSet *rs = stmt->executeQuery();
00669
00670 rs->setMaxColumnSize(1,128);
00671 rs->setMaxColumnSize(2,128);
00672 rs->setMaxColumnSize(3,128);
00673 rs->setMaxColumnSize(4,128);
00674 rs->setMaxColumnSize(5,128);
00675 rs->setMaxColumnSize(6,128);
00676 rs->setMaxColumnSize(7,128);
00677 rs->setMaxColumnSize(8,128);
00678 rs->setMaxColumnSize(9,128);
00679 rs->setMaxColumnSize(10,128);
00680 rs->setMaxColumnSize(11,128);
00681
00682 RooGKCounter _row(1,100);
00683 _row.setMessage("HCAL channels processed: ");
00684 _row.setPrintCount(true);
00685 _row.setNewLine(true);
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 while (rs->next()) {
00702 _row.count();
00703 DetId id = getId(rs);
00704 float average_pedestal = rs->getFloat(12);
00705 float response_corrected_gain = rs->getFloat(13);
00706 int flag = rs->getInt(14);
00707 std::string metadata_name = rs->getString(15);
00708 if (metadata_name.find("lut_tag")!=std::string::npos){
00709 _tag = rs->getString(16);
00710 }
00711 else if (metadata_name.find("algo_name")!=std::string::npos){
00712 _algo = rs->getString(16);
00713 }
00714 HcalL1TriggerObject * fCondObject = new HcalL1TriggerObject(id, average_pedestal, response_corrected_gain, flag);
00715 fObject->addValues(*fCondObject);
00716 delete fCondObject;
00717 }
00718
00719 connection->terminateStatement(stmt);
00720 } catch (SQLException& e) {
00721 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00722 }
00723 fObject->setTagString(_tag);
00724 fObject->setAlgoString(_algo);
00725 return result;
00726 }
00727
00728 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00729 const std::string & fTag,
00730 const std::string & fVersion,
00731 const int fSubversion,
00732 const int fIOVBegin,
00733 const std::string & fQuery,
00734 HcalValidationCorrs* fObject) {
00735 bool result=true;
00736 if (!fObject) fObject = new HcalValidationCorrs;
00737 try {
00738 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00739 stmt->setString(1,fTag);
00740
00741 stmt->setInt(2,fIOVBegin);
00742
00743 ResultSet *rs = stmt->executeQuery();
00744
00745
00746 for (int _i=1; _i!=12; _i++) rs->setMaxColumnSize(_i,128);
00747
00748 RooGKCounter _row(1,100);
00749 _row.setMessage("HCAL channels processed: ");
00750 _row.setPrintCount(true);
00751 _row.setNewLine(true);
00752
00753
00754
00755
00756
00757
00758 while (rs->next()) {
00759 _row.count();
00760 DetId id = getId(rs);
00761 float value = rs->getFloat(12);
00762
00763
00764
00765
00766
00767
00768 HcalValidationCorr * fCondObject = new HcalValidationCorr(id, value);
00769 fObject->addValues(*fCondObject);
00770 delete fCondObject;
00771 }
00772
00773 connection->terminateStatement(stmt);
00774 } catch (SQLException& e) {
00775 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00776 }
00777 return result;
00778 }
00779
00780
00781 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00782 const std::string & fTag,
00783 const std::string & fVersion,
00784 const int fSubversion,
00785 const int fIOVBegin,
00786 const std::string & fQuery,
00787 HcalLutMetadata* fObject) {
00788 bool result=true;
00789 if (!fObject) fObject = new HcalLutMetadata;
00790 try {
00791 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00792 stmt->setString(1,fTag);
00793
00794 stmt->setInt(2,fIOVBegin);
00795
00796 ResultSet *rs = stmt->executeQuery();
00797
00798
00799 for (int _i=1; _i!=12; _i++) rs->setMaxColumnSize(_i,128);
00800
00801 RooGKCounter _row(1,100);
00802 _row.setMessage("HCAL channels processed: ");
00803 _row.setPrintCount(true);
00804 _row.setNewLine(true);
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818 while (rs->next()) {
00819 if (rs->getString(1).find("fakeobjectname")!=std::string::npos){
00820 float rctlsb = rs->getFloat(12);
00821 float nominal_gain = rs->getFloat(13);
00822 fObject->setRctLsb(rctlsb);
00823 fObject->setNominalGain(nominal_gain);
00824 }
00825 else{
00826 _row.count();
00827 DetId id = getId(rs);
00828 float rcalib = rs->getFloat(12);
00829 uint32_t lut_granularity = rs->getInt(13);
00830 uint32_t output_lut_threshold = rs->getInt(14);
00831 HcalLutMetadatum * fCondObject = new HcalLutMetadatum(id,
00832 rcalib,
00833 lut_granularity,
00834 output_lut_threshold);
00835 fObject->addValues(*fCondObject);
00836 delete fCondObject;
00837 }
00838 }
00839
00840 connection->terminateStatement(stmt);
00841 } catch (SQLException& e) {
00842 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00843 }
00844 return result;
00845 }
00846
00847
00848 bool HcalDbOmds::getObject (oracle::occi::Connection * connection,
00849 const std::string & fTag,
00850 const std::string & fVersion,
00851 const int fSubversion,
00852 const int fIOVBegin,
00853 const std::string & fQuery,
00854 HcalDcsValues* fObject) {
00855 bool result=true;
00856 if (!fObject) fObject = new HcalDcsValues;
00857 try {
00858 oracle::occi::Statement* stmt = connection->createStatement(fQuery);
00859 stmt->setString(1,fTag);
00860 stmt->setString(2,fVersion);
00861 stmt->setInt(3,fSubversion);
00862 stmt->setInt(4,fIOVBegin);
00863
00864 std::cout << "DEBUG****** IOV=" << fIOVBegin << std::endl;
00865
00866 ResultSet *rs = stmt->executeQuery();
00867
00868
00869 for (int _i=1; _i!=9; _i++) rs->setMaxColumnSize(_i,128);
00870
00871 RooGKCounter _row(1,100);
00872 _row.setMessage("HCAL DCS records: ");
00873 _row.setPrintCount(true);
00874 _row.setNewLine(true);
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891 while (rs->next()) {
00892 _row.count();
00893
00894 std::string _dpname = rs->getString(1);
00895
00896
00897
00898
00899
00900
00901 HcalOtherSubdetector subd = getSubDetFromString(rs->getString(6));
00902 int sidering = rs->getInt(7);
00903 unsigned int slice = rs->getInt(8);
00904 unsigned int subchan = rs->getInt(9);
00905 HcalDcsDetId::DcsType dcs_type = getDcsTypeFromString(rs->getString(10));
00906
00907 HcalDcsDetId newId(subd, sidering, slice,
00908 dcs_type, subchan);
00909
00910 int LS = rs->getInt(2);
00911 float val = rs->getFloat(3);
00912 float upper = rs->getFloat(4);
00913 float lower = rs->getFloat(5);
00914
00915 HcalDcsValue * fCondObject = new HcalDcsValue(newId.rawId(),
00916 LS,
00917 val,
00918 upper,
00919 lower);
00920
00921 if (!(fObject->addValue(*fCondObject))) {
00922 edm::LogWarning("Data Error") << "Data for data point " << _dpname
00923 << "\nwas not added to the HcalDcsValues object." << std::endl;
00924 }
00925 delete fCondObject;
00926 }
00927 fObject->sortAll();
00928
00929 connection->terminateStatement(stmt);
00930 } catch (SQLException& e) {
00931 throw cms::Exception("ReadError") << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
00932 }
00933 return result;
00934 }
00935
00936
00937 bool HcalDbOmds::dumpObject (std::ostream& fOutput, const HcalZSThresholds& fObject) {
00938 return true;
00939 }
00940
00941
00942 HcalSubdetector HcalDbOmds::get_subdetector( std::string _det )
00943 {
00944 HcalSubdetector result;
00945 if ( _det.find("HB") != std::string::npos ) result = HcalBarrel;
00946 else if ( _det.find("HE") != std::string::npos ) result = HcalEndcap;
00947 else if ( _det.find("HF") != std::string::npos ) result = HcalForward;
00948 else if ( _det.find("HO") != std::string::npos ) result = HcalOuter;
00949 else result = HcalOther;
00950
00951 return result;
00952 }
00953
00954 HcalZDCDetId::Section HcalDbOmds::get_zdc_section( std::string _section )
00955 {
00956 HcalZDCDetId::Section result;
00957 if ( _section.find("Unknown") != std::string::npos ) result = HcalZDCDetId::Unknown;
00958 else if ( _section.find("EM") != std::string::npos ) result = HcalZDCDetId::EM;
00959 else if ( _section.find("HAD") != std::string::npos ) result = HcalZDCDetId::HAD;
00960 else if ( _section.find("LUM") != std::string::npos ) result = HcalZDCDetId::LUM;
00961 else result = HcalZDCDetId::Unknown;
00962
00963 return result;
00964 }
00965
00966
00967 HcalOtherSubdetector HcalDbOmds::getSubDetFromDpName(std::string _dpname){
00968 HcalOtherSubdetector subd;
00969 switch (_dpname.at(_dpname.find("HVcrate_")+9)) {
00970 case 'B':
00971 subd = HcalDcsBarrel;
00972 break;
00973 case 'E':
00974 subd = HcalDcsEndcap;
00975 break;
00976 case 'F':
00977 subd = HcalDcsForward;
00978 break;
00979 case 'O':
00980 subd = HcalDcsOuter;
00981 break;
00982 default:
00983 subd = HcalOtherEmpty;
00984 break;
00985 }
00986 return subd;
00987 }
00988
00989 int HcalDbOmds::getSideRingFromDpName(std::string _dpname){
00990 int _side_ring = 1000;
00991 int _side = 10;
00992 int _ring = 100;
00993 switch (_dpname.at(_dpname.find("HVcrate_")+9)) {
00994 case 'B':
00995 case 'E':
00996 case 'F':
00997 if (_dpname.at(_dpname.find("HVcrate_")+10) == 'M') _side = -1;
00998 else if (_dpname.at(_dpname.find("HVcrate_")+10) == 'P') _side = +1;
00999 _ring = 1;
01000 break;
01001 case 'O':
01002 if (_dpname.at(_dpname.find("HVcrate_")+11) == 'M') _side = -1;
01003 else if (_dpname.at(_dpname.find("HVcrate_")+11) == 'P') _side = +1;
01004 _ring = atoi(&(_dpname.at(_dpname.find("HVcrate_")+10)));
01005 break;
01006 default:
01007 break;
01008 }
01009 _side_ring = _side * _ring;
01010 return _side_ring;
01011 }
01012
01013 unsigned int HcalDbOmds::getSliceFromDpName(std::string _dpname){
01014 int result = 1000;
01015 HcalDbOmds::from_string<int>(result, _dpname.substr(_dpname.find("/S")+2,2), std::dec);
01016 return (unsigned int)result;
01017 }
01018
01019 unsigned int HcalDbOmds::getSubChannelFromDpName(std::string _dpname){
01020 unsigned int result = 1000;
01021 HcalDbOmds::from_string<unsigned int>(result, _dpname.substr(_dpname.find("/RM")+3,1), std::dec);
01022 return result;
01023 }
01024
01025
01026
01027 HcalDcsDetId::DcsType HcalDbOmds::getDcsTypeFromDpName(std::string _dpname){
01028 HcalDcsDetId::DcsType result = HcalDcsDetId::DcsType(15);
01029 std::string _type = _dpname.substr(_dpname.find("/RM")+4);
01030 if (_type.find("HV")!=std::string::npos) result = HcalDcsDetId::DcsType(1);
01031 return result;
01032 }
01033
01034 HcalOtherSubdetector HcalDbOmds::getSubDetFromString(std::string subdet){
01035 HcalOtherSubdetector subd;
01036 switch (subdet.at(1)){
01037 case 'B':
01038 subd = HcalDcsBarrel;
01039 break;
01040 case 'E':
01041 subd = HcalDcsEndcap;
01042 break;
01043 case 'F':
01044 subd = HcalDcsForward;
01045 break;
01046 case 'O':
01047 subd = HcalDcsOuter;
01048 break;
01049 default:
01050 subd = HcalOtherEmpty;
01051 break;
01052 }
01053 return subd;
01054 }
01055
01056 HcalDcsDetId::DcsType HcalDbOmds::getDcsTypeFromString(std::string type){
01057 HcalDcsDetId::DcsType result = HcalDcsDetId::DCSUNKNOWN;
01058 if (type.find("HV")!=std::string::npos) result = HcalDcsDetId::HV;
01059 else if (type.find("BV")!=std::string::npos) result = HcalDcsDetId::BV;
01060 else if (type.find("Cath")!=std::string::npos) result = HcalDcsDetId::CATH;
01061 else if (type.find("Dyn7")!=std::string::npos) result = HcalDcsDetId::DYN7;
01062 else if (type.find("Dyn8")!=std::string::npos) result = HcalDcsDetId::DYN8;
01063 else if (type.find("RM_TEMP")!=std::string::npos) result = HcalDcsDetId::RM_TEMP;
01064 else if (type.find("CCM_TEMP")!=std::string::npos) result = HcalDcsDetId::CCM_TEMP;
01065 else if (type.find("CALIB_TEMP")!=std::string::npos) result = HcalDcsDetId::CALIB_TEMP;
01066 else if (type.find("LVTTM_TEMP")!=std::string::npos) result = HcalDcsDetId::LVTTM_TEMP;
01067 else if (type.find("TEMP")!=std::string::npos) result = HcalDcsDetId::TEMP;
01068 else if (type.find("QPLL_LOCK")!=std::string::npos) result = HcalDcsDetId::QPLL_LOCK;
01069 else if (type.find("STATUS")!=std::string::npos) result = HcalDcsDetId::STATUS;
01070 else if (type.find("DCS_MAX")!=std::string::npos) result = HcalDcsDetId::DCS_MAX;
01071 return result;
01072 }
01073