Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:15

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, run_t r) {
0022     try {
0023       cout << "Making connection..." << flush;
0024       econn = new EcalCondDBInterface(sid, user, pass);
0025       run = r;
0026       cout << "Done." << endl;
0027     } catch (runtime_error& e) {
0028       cerr << e.what() << endl;
0029       exit(-1);
0030     }
0031   }
0032 
0033   /**
0034    *  App destructor;  Cleans up database connection
0035    */
0036   ~CondDBApp() { delete econn; }
0037 
0038   void doRead() {
0039     std::string location = "P5_Co";
0040     RunIOV runiov = econn->fetchRunIOV(location, run);
0041     cout << "Attaching data to Run " << runiov.getRunNumber() << endl;
0042     // now create a sequence
0043     LMFSeqDat seq(econn);
0044     seq.setRunIOV(runiov).setSequenceNumber(1);
0045     //    seq.debug();
0046     seq.fetchID();
0047     //    seq.dump();
0048     LMFRunIOV lmfruniov(econn);
0049     int type = 1;
0050     int color = 1;
0051     for (int lmr = 1; lmr < 93; lmr++) {
0052       bool res = econn->fetchLMFRunIOV(seq, lmfruniov, lmr, type, color);
0053       std::cout << "LMR: " << lmr << " - " << res << std::endl;
0054       if ((lmr == 1) || (lmr == 92)) {
0055         lmfruniov.dump();
0056       }
0057     }
0058     /*
0059     lmfruniov.debug();
0060     cout << econn->getEnv() << " " << econn->getConn() << endl;
0061     std::list< LMFRunIOV > iov_l = lmfruniov.fetchBySequence( seq );
0062     cout << iov_l.size() << endl;
0063     exit(0);
0064     lmfruniov.setSequence(seq).setLmr(3);
0065     lmfruniov.fetchID();
0066     lmfruniov.dump();
0067     vector<LMFDat*> v; 
0068     LMFRunDat *lmfrundat = new LMFRunDat(econn);
0069     LMFTestPulseConfigDat *lmfconfigdat = new LMFTestPulseConfigDat(econn);
0070     LMFLaserConfigDat *lmflaserconfdat = new LMFLaserConfigDat(econn);
0071     LMFLaserPulseDat *lmfbluepulsedat = new LMFLaserPulseDat("BLUE");
0072     lmfbluepulsedat->setConnection(econn->getEnv(), econn->getConn());
0073     v.push_back(lmfrundat);
0074     v.push_back(lmfconfigdat);
0075     v.push_back(lmflaserconfdat);
0076     v.push_back(lmfbluepulsedat);
0077     for (unsigned int i = 0; i < v.size(); i++) {
0078       v[i]->setLMFRunIOV(lmfruniov);
0079       v[i]->fetch();
0080       v[i]->setMaxDataToDump(10);
0081       v[i]->dump();
0082     }
0083     delete lmfrundat;
0084     delete lmfconfigdat;
0085     delete lmflaserconfdat;
0086     delete lmfbluepulsedat;
0087     */
0088   }
0089 
0090 private:
0091   CondDBApp() = delete;  // hidden default constructor
0092   EcalCondDBInterface* econn;
0093   run_t run;
0094 };
0095 
0096 int main(int argc, char* argv[]) {
0097   string sid;
0098   string user;
0099   string pass;
0100 
0101   if (argc != 5) {
0102     cout << "Usage:" << endl;
0103     cout << "  " << argv[0] << " <SID> <user> <pass> <run>" << endl;
0104     exit(-1);
0105   }
0106 
0107   sid = argv[1];
0108   user = argv[2];
0109   pass = argv[3];
0110   int run = atoi(argv[4]);
0111 
0112   try {
0113     CondDBApp app(sid, user, pass, run);
0114     app.doRead();
0115   } catch (exception& e) {
0116     cout << "ERROR:  " << e.what() << endl;
0117   } catch (...) {
0118     cout << "Unknown error caught" << endl;
0119   }
0120 
0121   cout << "All Done." << endl;
0122 
0123   return 0;
0124 }