Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:45

0001 #include "OnlineDB/CSCCondDB/interface/CSCMap.h"
0002 #include <cstdlib>
0003 
0004 /**
0005    * Constructor for cscmap
0006    */
0007 cscmap::cscmap() noexcept(false) {
0008   std::string db_user;
0009   std::string db_pass;
0010   env = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
0011   char *c_user = std::getenv("CSCMAP_AUTH_USER");
0012   char *c_pass = std::getenv("CSCMAP_AUTH_PASSWORD");
0013   db_user = std::string(c_user);
0014   db_pass = std::string(c_pass);
0015   con = env->createConnection(db_user, db_pass, "devdb");
0016   std::cout << "Connection to mapping DB is done." << std::endl;
0017 }  // end of constructor cscmap ()
0018 /**
0019    * Destructor for cscmap.
0020    */
0021 cscmap::~cscmap() noexcept(false) {
0022   env->terminateConnection(con);
0023   oracle::occi::Environment::terminateEnvironment(env);
0024 }  // end of ~cscmap ()
0025 
0026 void cscmap::crate0_chamber(int crate0,
0027                             int dmb,
0028                             std::string *chamber_id,
0029                             int *chamber_num,
0030                             int *sector,
0031                             int *first_strip_index,
0032                             int *strips_per_layer,
0033                             int *chamber_index) {
0034   oracle::occi::Statement *stmt = con->createStatement();
0035   stmt->setSQL("begin cscmap.chamber0(:1, :2, :3, :4, :5, :6, :7, :8); end;");
0036 
0037   stmt->setInt(1, crate0);
0038   stmt->setInt(2, dmb);
0039   stmt->registerOutParam(3, oracle::occi::OCCISTRING, 10);
0040   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0041   stmt->registerOutParam(5, oracle::occi::OCCIINT);
0042   stmt->registerOutParam(6, oracle::occi::OCCIINT);
0043   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0044   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0045 
0046   stmt->execute();  //execute procedure
0047 
0048   *chamber_id = stmt->getString(3);
0049   *chamber_num = stmt->getInt(4);
0050   *chamber_index = stmt->getInt(5);
0051   *first_strip_index = stmt->getInt(6);
0052   *strips_per_layer = stmt->getInt(7);
0053   *sector = stmt->getInt(8);
0054 
0055   con->terminateStatement(stmt);
0056 }  //end of crate0_chamber
0057 
0058 void cscmap::crate_chamber(int crate,
0059                            int dmb,
0060                            std::string *chamber_id,
0061                            int *chamber_num,
0062                            int *sector,
0063                            int *first_strip_index,
0064                            int *strips_per_layer,
0065                            int *chamber_index) {
0066   oracle::occi::Statement *stmt = con->createStatement();
0067   stmt->setSQL("begin cscmap.chamber(:1, :2, :3, :4, :5, :6, :7, :8); end;");
0068 
0069   stmt->setInt(1, crate);
0070   stmt->setInt(2, dmb);
0071   stmt->registerOutParam(3, oracle::occi::OCCISTRING, 10);
0072   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0073   stmt->registerOutParam(5, oracle::occi::OCCIINT);
0074   stmt->registerOutParam(6, oracle::occi::OCCIINT);
0075   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0076   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0077 
0078   stmt->execute();  //execute procedure
0079 
0080   *chamber_id = stmt->getString(3);
0081   *chamber_num = stmt->getInt(4);
0082   *chamber_index = stmt->getInt(5);
0083   *first_strip_index = stmt->getInt(6);
0084   *strips_per_layer = stmt->getInt(7);
0085   *sector = stmt->getInt(8);
0086 
0087   con->terminateStatement(stmt);
0088 }  //end of crate_chamber
0089 
0090 void cscmap::chamber_crate(std::string chamber_id,
0091                            int *crate,
0092                            int *dmb,
0093                            int *sector,
0094                            int *chamber_num,
0095                            int *crate0,
0096                            int *first_strip_index,
0097                            int *strips_per_layer,
0098                            int *chamber_index) {
0099   oracle::occi::Statement *stmt = con->createStatement();
0100   stmt->setSQL("begin cscmap.crate0_proc(:1, :2, :3, :4, :5, :6, :7, :8, :9); end;");
0101 
0102   stmt->setString(1, chamber_id);
0103   stmt->registerOutParam(2, oracle::occi::OCCIINT);
0104   stmt->registerOutParam(3, oracle::occi::OCCIINT);
0105   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0106   stmt->registerOutParam(5, oracle::occi::OCCIINT);
0107   stmt->registerOutParam(6, oracle::occi::OCCIINT);
0108   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0109   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0110   stmt->registerOutParam(9, oracle::occi::OCCIINT);
0111 
0112   stmt->execute();  //execute procedure
0113 
0114   *crate0 = stmt->getInt(2);
0115   *crate = stmt->getInt(3);
0116   *dmb = stmt->getInt(4);
0117   *sector = stmt->getInt(5);
0118   *chamber_num = stmt->getInt(6);
0119   *chamber_index = stmt->getInt(7);
0120   *first_strip_index = stmt->getInt(8);
0121   *strips_per_layer = stmt->getInt(9);
0122 
0123   con->terminateStatement(stmt);
0124 }  //end of crate_chamber