File indexing completed on 2024-04-06 12:23:13
0001 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
0002 #include <climits>
0003 #include <cstdlib>
0004 #include <ctime>
0005 #include <iomanip>
0006 #include <iostream>
0007 #include <string>
0008 #include <vector>
0009
0010 using namespace std;
0011
0012 class CondDBApp {
0013 public:
0014
0015
0016
0017 CondDBApp(string sid, string user, string pass, run_t r) {
0018 try {
0019 cout << "Making connection..." << flush;
0020 econn = new EcalCondDBInterface(sid, user, pass);
0021 run = r;
0022 cout << "Done." << endl;
0023 } catch (runtime_error& e) {
0024 cerr << e.what() << endl;
0025 exit(-1);
0026 }
0027 }
0028
0029
0030
0031
0032 ~CondDBApp() { delete econn; }
0033
0034 void doRun() {
0035 RunIOV iov = econn->fetchRunIOV("P5_Co", run);
0036 std::list<ODDelaysDat> delays = econn->fetchFEDelaysForRun(&iov);
0037 std::list<ODDelaysDat>::const_iterator i = delays.begin();
0038 std::list<ODDelaysDat>::const_iterator e = delays.end();
0039 while (i != e) {
0040 std::cout << "SM: " << i->getSMId() << " FED: " << i->getFedId() << " Delay: " << i->getTimeOffset() << std::endl;
0041 i++;
0042 }
0043 }
0044
0045 private:
0046 CondDBApp() = delete;
0047 EcalCondDBInterface* econn;
0048 run_t run;
0049 };
0050
0051 int main(int argc, char* argv[]) {
0052 string sid;
0053 string user;
0054 string pass;
0055
0056 if (argc != 5) {
0057 cout << "Usage:" << endl;
0058 cout << " " << argv[0] << " <SID> <user> <pass> <run>" << endl;
0059 exit(-1);
0060 }
0061
0062 sid = argv[1];
0063 user = argv[2];
0064 pass = argv[3];
0065 int run = atoi(argv[4]);
0066
0067 try {
0068 CondDBApp app(sid, user, pass, run);
0069 app.doRun();
0070 } catch (exception& e) {
0071 cout << "ERROR: " << e.what() << endl;
0072 } catch (...) {
0073 cout << "Unknown error caught" << endl;
0074 }
0075
0076 cout << "All Done." << endl;
0077
0078 return 0;
0079 }