Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-12 04:20:55

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