CMS 3D CMS Logo

CSCMap.cc
Go to the documentation of this file.
2 #include <cstdlib>
3 
7 cscmap::cscmap() noexcept(false) {
8  std::string db_user;
9  std::string db_pass;
10  env = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
11  char *c_user = std::getenv("CSCMAP_AUTH_USER");
12  char *c_pass = std::getenv("CSCMAP_AUTH_PASSWORD");
13  db_user = std::string(c_user);
14  db_pass = std::string(c_pass);
15  con = env->createConnection(db_user, db_pass, "devdb");
16  std::cout << "Connection to mapping DB is done." << std::endl;
17 } // end of constructor cscmap ()
21 cscmap::~cscmap() noexcept(false) {
22  env->terminateConnection(con);
23  oracle::occi::Environment::terminateEnvironment(env);
24 } // end of ~cscmap ()
25 
26 void cscmap::crate0_chamber(int crate0,
27  int dmb,
28  std::string *chamber_id,
29  int *chamber_num,
30  int *sector,
31  int *first_strip_index,
32  int *strips_per_layer,
33  int *chamber_index) {
34  oracle::occi::Statement *stmt = con->createStatement();
35  stmt->setSQL("begin cscmap.chamber0(:1, :2, :3, :4, :5, :6, :7, :8); end;");
36 
37  stmt->setInt(1, crate0);
38  stmt->setInt(2, dmb);
39  stmt->registerOutParam(3, oracle::occi::OCCISTRING, 10);
40  stmt->registerOutParam(4, oracle::occi::OCCIINT);
41  stmt->registerOutParam(5, oracle::occi::OCCIINT);
42  stmt->registerOutParam(6, oracle::occi::OCCIINT);
43  stmt->registerOutParam(7, oracle::occi::OCCIINT);
44  stmt->registerOutParam(8, oracle::occi::OCCIINT);
45 
46  stmt->execute(); //execute procedure
47 
48  *chamber_id = stmt->getString(3);
49  *chamber_num = stmt->getInt(4);
50  *chamber_index = stmt->getInt(5);
51  *first_strip_index = stmt->getInt(6);
52  *strips_per_layer = stmt->getInt(7);
53  *sector = stmt->getInt(8);
54 
55  con->terminateStatement(stmt);
56 } //end of crate0_chamber
57 
58 void cscmap::crate_chamber(int crate,
59  int dmb,
60  std::string *chamber_id,
61  int *chamber_num,
62  int *sector,
63  int *first_strip_index,
64  int *strips_per_layer,
65  int *chamber_index) {
66  oracle::occi::Statement *stmt = con->createStatement();
67  stmt->setSQL("begin cscmap.chamber(:1, :2, :3, :4, :5, :6, :7, :8); end;");
68 
69  stmt->setInt(1, crate);
70  stmt->setInt(2, dmb);
71  stmt->registerOutParam(3, oracle::occi::OCCISTRING, 10);
72  stmt->registerOutParam(4, oracle::occi::OCCIINT);
73  stmt->registerOutParam(5, oracle::occi::OCCIINT);
74  stmt->registerOutParam(6, oracle::occi::OCCIINT);
75  stmt->registerOutParam(7, oracle::occi::OCCIINT);
76  stmt->registerOutParam(8, oracle::occi::OCCIINT);
77 
78  stmt->execute(); //execute procedure
79 
80  *chamber_id = stmt->getString(3);
81  *chamber_num = stmt->getInt(4);
82  *chamber_index = stmt->getInt(5);
83  *first_strip_index = stmt->getInt(6);
84  *strips_per_layer = stmt->getInt(7);
85  *sector = stmt->getInt(8);
86 
87  con->terminateStatement(stmt);
88 } //end of crate_chamber
89 
91  int *crate,
92  int *dmb,
93  int *sector,
94  int *chamber_num,
95  int *crate0,
96  int *first_strip_index,
97  int *strips_per_layer,
98  int *chamber_index) {
99  oracle::occi::Statement *stmt = con->createStatement();
100  stmt->setSQL("begin cscmap.crate0_proc(:1, :2, :3, :4, :5, :6, :7, :8, :9); end;");
101 
102  stmt->setString(1, chamber_id);
103  stmt->registerOutParam(2, oracle::occi::OCCIINT);
104  stmt->registerOutParam(3, oracle::occi::OCCIINT);
105  stmt->registerOutParam(4, oracle::occi::OCCIINT);
106  stmt->registerOutParam(5, oracle::occi::OCCIINT);
107  stmt->registerOutParam(6, oracle::occi::OCCIINT);
108  stmt->registerOutParam(7, oracle::occi::OCCIINT);
109  stmt->registerOutParam(8, oracle::occi::OCCIINT);
110  stmt->registerOutParam(9, oracle::occi::OCCIINT);
111 
112  stmt->execute(); //execute procedure
113 
114  *crate0 = stmt->getInt(2);
115  *crate = stmt->getInt(3);
116  *dmb = stmt->getInt(4);
117  *sector = stmt->getInt(5);
118  *chamber_num = stmt->getInt(6);
119  *chamber_index = stmt->getInt(7);
120  *first_strip_index = stmt->getInt(8);
121  *strips_per_layer = stmt->getInt(9);
122 
123  con->terminateStatement(stmt);
124 } //end of crate_chamber
oracle::occi::Environment * env
Definition: CSCMap.h:10
cscmap() noexcept(false)
Definition: CSCMap.cc:7
void chamber_crate(std::string chamber_id, int *crate, int *dmb, int *sector, int *chamber_num, int *crate0, int *first_strip_index, int *strips_per_layer, int *chamber_index)
Definition: CSCMap.cc:90
void crate0_chamber(int crate0, int dmb, std::string *chamber_id, int *chamber_num, int *sector, int *first_strip_index, int *strips_per_layer, int *chamber_index)
Definition: CSCMap.cc:26
oracle::occi::Connection * con
Definition: CSCMap.h:11
~cscmap() noexcept(false)
Definition: CSCMap.cc:21
void crate_chamber(int crate, int dmb, std::string *chamber_id, int *chamber_num, int *sector, int *first_strip_index, int *strips_per_layer, int *chamber_index)
Definition: CSCMap.cc:58