Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:13

0001 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
0002 #include "OnlineDB/EcalCondDB/interface/LMFDefFabric.h"
0003 #include "OnlineDB/EcalCondDB/interface/LMFLaserPulseDat.h"
0004 #include "OnlineDB/EcalCondDB/interface/LMFPnPrimDat.h"
0005 #include "OnlineDB/EcalCondDB/interface/all_lmf_types.h"
0006 #include <climits>
0007 #include <cstdlib>
0008 #include <ctime>
0009 #include <iomanip>
0010 #include <iostream>
0011 #include <string>
0012 #include <vector>
0013 
0014 using namespace std;
0015 
0016 class CondDBApp {
0017 public:
0018   /**
0019    *   App constructor; Makes the database connection
0020    */
0021   CondDBApp(string sid, string user, string pass) {
0022     try {
0023       cout << "Making connection..." << flush;
0024       econn = new EcalCondDBInterface(sid, user, pass);
0025       cout << "Done." << endl;
0026     } catch (runtime_error &e) {
0027       cerr << e.what() << endl;
0028       exit(-1);
0029     }
0030   }
0031 
0032   /**
0033    *  App destructor;  Cleans up database connection
0034    */
0035   ~CondDBApp() { delete econn; }
0036 
0037   void doRead() {
0038     LMFPnPrimDat pnPrim(econn);
0039     EcalLogicID ecid = econn->getEcalLogicID(1131190000);
0040     Tm t;
0041     t.setToString("2010-09-21 00:00:00");
0042     pnPrim.fetch(ecid, t);
0043     pnPrim.setMaxDataToDump(10);
0044     pnPrim.dump();
0045     cout << "These data were taken on " << pnPrim.getSubrunStart().str() << endl;
0046     LMFPnPrimDat *p = new LMFPnPrimDat;
0047     LMFPnPrimDat *n = new LMFPnPrimDat;
0048     pnPrim.getPrevious(p);
0049     pnPrim.getNext(n);
0050     p->dump();
0051     n->dump();
0052     delete p;
0053     delete n;
0054   }
0055 
0056 private:
0057   CondDBApp() = delete;  // hidden default constructor
0058   EcalCondDBInterface *econn;
0059 };
0060 
0061 int main(int argc, char *argv[]) {
0062   string sid;
0063   string user;
0064   string pass;
0065 
0066   if (argc != 4) {
0067     cout << "Usage:" << endl;
0068     cout << "  " << argv[0] << " <SID> <user> <pass>" << endl;
0069     exit(-1);
0070   }
0071 
0072   sid = argv[1];
0073   user = argv[2];
0074   pass = argv[3];
0075 
0076   try {
0077     CondDBApp app(sid, user, pass);
0078     app.doRead();
0079   } catch (exception &e) {
0080     cout << "ERROR:  " << e.what() << endl;
0081   } catch (...) {
0082     cout << "Unknown error caught" << endl;
0083   }
0084 
0085   cout << "All Done." << endl;
0086 
0087   return 0;
0088 }