CMS 3D CMS Logo

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