CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCMap1.cc
Go to the documentation of this file.
2 #include <cstdlib>
3 
7  cscmap1::cscmap1 () 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,"cms_orcoff_prod");
17  std::cout << "Connection to mapping DB is done." << std::endl;
18  }// end of constructor cscmap1 ()
19 
24  {
25  env->terminateConnection (con);
26  oracle::occi::Environment::terminateEnvironment (env);
27  } // end of ~cscmap1 ()
28 
29  void cscmap1::chamber (int chamberid, CSCMapItem::MapItem *item)
30  {
31  oracle::occi::Statement *stmt = con->createStatement();
32 
33  stmt->setSQL("begin cms_emu_cern.cscmap.chamberid_crate(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20); end;");
34 
35  stmt->setInt (1, chamberid);
36  stmt->registerOutParam (2, oracle::occi::OCCISTRING, 10);
37  stmt->registerOutParam (3, oracle::occi::OCCIINT);
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  stmt->registerOutParam (9, oracle::occi::OCCIINT);
44  stmt->registerOutParam (10, oracle::occi::OCCISTRING, 10);
45  stmt->registerOutParam (11, oracle::occi::OCCIINT);
46  stmt->registerOutParam (12, oracle::occi::OCCIINT);
47  stmt->registerOutParam (13, oracle::occi::OCCIINT);
48  stmt->registerOutParam (14, oracle::occi::OCCIINT);
49  stmt->registerOutParam (15, oracle::occi::OCCIINT);
50  stmt->registerOutParam (16, oracle::occi::OCCIINT);
51  stmt->registerOutParam (17, oracle::occi::OCCIINT);
52  stmt->registerOutParam (18, oracle::occi::OCCIINT);
53  stmt->registerOutParam (19, oracle::occi::OCCIINT);
54  stmt->registerOutParam (20, oracle::occi::OCCIINT);
55 
56  stmt->execute(); //execute procedure
57 
58  item->chamberLabel = stmt->getString(10);
59  item->chamberId = chamberid;
60  int chamber = chamberid/10%100;
61  int rest = (chamberid - chamber*10)/1000;
62  int ring = rest%10;
63  rest = (rest - ring)/10;
64  int station = rest%10;
65  int endcap = (rest - station)/10;
66  item->endcap = endcap;
67  item->station = station;
68  item->ring = ring;
69  item->chamber = chamber;
70  item->cscIndex = stmt->getInt(13);
71  item->layerIndex = stmt->getInt(14);
72  item->stripIndex = stmt->getInt(15);
73  item->anodeIndex = stmt->getInt(16);
74  item->strips = stmt->getInt(11);
75  item->anodes = stmt->getInt(12);
76  item->crateLabel = stmt->getString(2);
77  item->crateid = stmt->getInt(3);
78  item->sector = stmt->getInt(8);
79  item->trig_sector = stmt->getInt(9);
80  item->dmb = stmt->getInt(5);
81  item->cscid = stmt->getInt(7);
82 
83  stmt->setSQL("begin cms_emu_cern.ddumap.chamberid_ddu(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19); end;");
84 
85  stmt->setInt (1, chamberid);
86  stmt->registerOutParam (2, oracle::occi::OCCIINT);
87  stmt->registerOutParam (3, oracle::occi::OCCIINT);
88  stmt->registerOutParam (4, oracle::occi::OCCIINT);
89  stmt->registerOutParam (5, oracle::occi::OCCIINT);
90  stmt->registerOutParam (6, oracle::occi::OCCISTRING, 10);
91  stmt->registerOutParam (7, oracle::occi::OCCIINT);
92  stmt->registerOutParam (8, oracle::occi::OCCIINT);
93  stmt->registerOutParam (9, oracle::occi::OCCIINT);
94  stmt->registerOutParam (10, oracle::occi::OCCISTRING, 10);
95  stmt->registerOutParam (11, oracle::occi::OCCIINT);
96  stmt->registerOutParam (12, oracle::occi::OCCISTRING, 10);
97  stmt->registerOutParam (13, oracle::occi::OCCIINT);
98  stmt->registerOutParam (14, oracle::occi::OCCISTRING, 10);
99  stmt->registerOutParam (15, oracle::occi::OCCIINT);
100  stmt->registerOutParam (16, oracle::occi::OCCIINT);
101  stmt->registerOutParam (17, oracle::occi::OCCIINT);
102  stmt->registerOutParam (18, oracle::occi::OCCIINT);
103  stmt->registerOutParam (19, oracle::occi::OCCIINT);
104 
105  stmt->execute(); //execute procedure
106 
107  item->ddu = stmt->getInt(2);
108  item->ddu_input = stmt->getInt(5);
109  item->slink = stmt->getInt(7);
110 
111  item->fed_crate = stmt->getInt(3);
112  item->ddu_slot = stmt->getInt(4);
113  item->dcc_fifo = stmt->getString(6);
114  item->fiber_crate = stmt->getInt(8);
115  item->fiber_pos = stmt->getInt(9);
116  item->fiber_socket = stmt->getString(10);
117 
118  con->terminateStatement (stmt);
119  } //end of chamber
120 
121  void cscmap1::cratedmb (int crate, int dmb, CSCMapItem::MapItem *item)
122  {
123  oracle::occi::Statement *stmt = con->createStatement();
124 
125  stmt->setSQL("begin cms_emu_cern.cscmap.crateid_chamber(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17); end;");
126 
127  stmt->setInt (1, crate);
128  stmt->setInt (2, dmb);
129  stmt->registerOutParam (3, oracle::occi::OCCISTRING, 10);
130  stmt->registerOutParam (4, oracle::occi::OCCIINT);
131  stmt->registerOutParam (5, oracle::occi::OCCIINT);
132  stmt->registerOutParam (6, oracle::occi::OCCIINT);
133  stmt->registerOutParam (7, oracle::occi::OCCIINT);
134  stmt->registerOutParam (8, oracle::occi::OCCIINT);
135  stmt->registerOutParam (9, oracle::occi::OCCIINT);
136  stmt->registerOutParam (10, oracle::occi::OCCIINT);
137  stmt->registerOutParam (11, oracle::occi::OCCISTRING, 10);
138  stmt->registerOutParam (12, oracle::occi::OCCIINT);
139  stmt->registerOutParam (13, oracle::occi::OCCIINT);
140  stmt->registerOutParam (14, oracle::occi::OCCIINT);
141  stmt->registerOutParam (15, oracle::occi::OCCIINT);
142  stmt->registerOutParam (16, oracle::occi::OCCIINT);
143  stmt->registerOutParam (17, oracle::occi::OCCIINT);
144 
145  stmt->execute(); //execute procedure
146 
147  item->chamberLabel = stmt->getString(3);
148  item->chamberId = stmt->getInt(4);
149  int chamberid = item->chamberId;
150  int chamber = chamberid/10%100;
151  int rest = (chamberid - chamber*10)/1000;
152  int ring = rest%10;
153  rest = (rest - ring)/10;
154  int station = rest%10;
155  int endcap = (rest - station)/10;
156  item->endcap = endcap;
157  item->station = station;
158  item->ring = ring;
159  item->chamber = chamber;
160  item->cscIndex = stmt->getInt(14);
161  item->layerIndex = stmt->getInt(15);
162  item->stripIndex = stmt->getInt(16);
163  item->anodeIndex = stmt->getInt(17);
164  item->strips = stmt->getInt(12);
165  item->anodes = stmt->getInt(13);
166  item->crateLabel = stmt->getString(11);
167  item->crateid = stmt->getInt(9);
168  item->sector = stmt->getInt(7);
169  item->trig_sector = stmt->getInt(8);
170  item->dmb = dmb;
171  item->cscid = stmt->getInt(5);
172 
173  stmt->setSQL("begin cms_emu_cern.ddumap.chamberid_ddu(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19); end;");
174 
175  stmt->setInt (1, chamberid);
176  stmt->registerOutParam (2, oracle::occi::OCCIINT);
177  stmt->registerOutParam (3, oracle::occi::OCCIINT);
178  stmt->registerOutParam (4, oracle::occi::OCCIINT);
179  stmt->registerOutParam (5, oracle::occi::OCCIINT);
180  stmt->registerOutParam (6, oracle::occi::OCCISTRING, 10);
181  stmt->registerOutParam (7, oracle::occi::OCCIINT);
182  stmt->registerOutParam (8, oracle::occi::OCCIINT);
183  stmt->registerOutParam (9, oracle::occi::OCCIINT);
184  stmt->registerOutParam (10, oracle::occi::OCCISTRING, 10);
185  stmt->registerOutParam (11, oracle::occi::OCCIINT);
186  stmt->registerOutParam (12, oracle::occi::OCCISTRING, 10);
187  stmt->registerOutParam (13, oracle::occi::OCCIINT);
188  stmt->registerOutParam (14, oracle::occi::OCCISTRING, 10);
189  stmt->registerOutParam (15, oracle::occi::OCCIINT);
190  stmt->registerOutParam (16, oracle::occi::OCCIINT);
191  stmt->registerOutParam (17, oracle::occi::OCCIINT);
192  stmt->registerOutParam (18, oracle::occi::OCCIINT);
193  stmt->registerOutParam (19, oracle::occi::OCCIINT);
194 
195  stmt->execute(); //execute procedure
196 
197  item->ddu = stmt->getInt(2);
198  item->ddu_input = stmt->getInt(5);
199  item->slink = stmt->getInt(7);
200 
201  item->fed_crate = stmt->getInt(3);
202  item->ddu_slot = stmt->getInt(4);
203  item->dcc_fifo = stmt->getString(6);
204  item->fiber_crate = stmt->getInt(8);
205  item->fiber_pos = stmt->getInt(9);
206  item->fiber_socket = stmt->getString(10);
207 
208  con->terminateStatement (stmt);
209  } //end of cratedmb
210 
211  void cscmap1::ruiddu (int rui, int ddu_input, CSCMapItem::MapItem *item)
212  {
213  oracle::occi::Statement *stmt = con->createStatement();
214 
215  stmt->setSQL("begin cms_emu_cern.ddumap.ddu_chamber(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19); end;");
216 
217  stmt->setInt (1, rui);
218  stmt->setInt (2, ddu_input);
219  stmt->registerOutParam (3, oracle::occi::OCCIINT);
220  stmt->registerOutParam (4, oracle::occi::OCCIINT);
221  stmt->registerOutParam (5, oracle::occi::OCCISTRING, 10);
222  stmt->registerOutParam (6, oracle::occi::OCCIINT);
223  stmt->registerOutParam (7, oracle::occi::OCCIINT);
224  stmt->registerOutParam (8, oracle::occi::OCCIINT);
225  stmt->registerOutParam (9, oracle::occi::OCCISTRING, 10);
226  stmt->registerOutParam (10, oracle::occi::OCCIINT);
227  stmt->registerOutParam (11, oracle::occi::OCCISTRING, 10);
228  stmt->registerOutParam (12, oracle::occi::OCCIINT);
229  stmt->registerOutParam (13, oracle::occi::OCCISTRING, 10);
230  stmt->registerOutParam (14, oracle::occi::OCCIINT);
231  stmt->registerOutParam (15, oracle::occi::OCCIINT);
232  stmt->registerOutParam (16, oracle::occi::OCCIINT);
233  stmt->registerOutParam (17, oracle::occi::OCCIINT);
234  stmt->registerOutParam (18, oracle::occi::OCCIINT);
235  stmt->registerOutParam (19, oracle::occi::OCCIINT);
236 
237  stmt->execute(); //execute procedure
238 
239  item->ddu = rui;
240  item->ddu_input = ddu_input;
241  item->slink = stmt->getInt(6);
242 
243  item->fed_crate = stmt->getInt(3);
244  item->ddu_slot = stmt->getInt(4);
245  item->dcc_fifo = stmt->getString(5);
246  item->fiber_crate = stmt->getInt(7);
247  item->fiber_pos = stmt->getInt(8);
248  item->fiber_socket = stmt->getString(9);
249  int chamberid = stmt->getInt(14);
250 
251  stmt->setSQL("begin cms_emu_cern.cscmap.chamberid_crate(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20); end;");
252 
253  stmt->setInt (1, chamberid);
254  stmt->registerOutParam (2, oracle::occi::OCCISTRING, 10);
255  stmt->registerOutParam (3, oracle::occi::OCCIINT);
256  stmt->registerOutParam (4, oracle::occi::OCCIINT);
257  stmt->registerOutParam (5, oracle::occi::OCCIINT);
258  stmt->registerOutParam (6, oracle::occi::OCCIINT);
259  stmt->registerOutParam (7, oracle::occi::OCCIINT);
260  stmt->registerOutParam (8, oracle::occi::OCCIINT);
261  stmt->registerOutParam (9, oracle::occi::OCCIINT);
262  stmt->registerOutParam (10, oracle::occi::OCCISTRING, 10);
263  stmt->registerOutParam (11, oracle::occi::OCCIINT);
264  stmt->registerOutParam (12, oracle::occi::OCCIINT);
265  stmt->registerOutParam (13, oracle::occi::OCCIINT);
266  stmt->registerOutParam (14, oracle::occi::OCCIINT);
267  stmt->registerOutParam (15, oracle::occi::OCCIINT);
268  stmt->registerOutParam (16, oracle::occi::OCCIINT);
269  stmt->registerOutParam (17, oracle::occi::OCCIINT);
270  stmt->registerOutParam (18, oracle::occi::OCCIINT);
271  stmt->registerOutParam (19, oracle::occi::OCCIINT);
272  stmt->registerOutParam (20, oracle::occi::OCCIINT);
273 
274  stmt->execute(); //execute procedure
275 
276  item->chamberLabel = stmt->getString(10);
277  item->chamberId = chamberid;
278  int chamber = chamberid/10%100;
279  int rest = (chamberid - chamber*10)/1000;
280  int ring = rest%10;
281  rest = (rest - ring)/10;
282  int station = rest%10;
283  int endcap = (rest - station)/10;
284  item->endcap = endcap;
285  item->station = station;
286  item->ring = ring;
287  item->chamber = chamber;
288  item->cscIndex = stmt->getInt(13);
289  item->layerIndex = stmt->getInt(14);
290  item->stripIndex = stmt->getInt(15);
291  item->anodeIndex = stmt->getInt(16);
292  item->strips = stmt->getInt(11);
293  item->anodes = stmt->getInt(12);
294  item->crateLabel = stmt->getString(2);
295  item->crateid = stmt->getInt(3);
296  item->sector = stmt->getInt(8);
297  item->trig_sector = stmt->getInt(9);
298  item->dmb = stmt->getInt(5);
299  item->cscid = stmt->getInt(7);
300 
301  stmt->execute(); //execute procedure
302 
303  con->terminateStatement (stmt);
304  } //end of ruiddu
void ruiddu(int rui, int ddu_input, CSCMapItem::MapItem *item)
Definition: CSCMap1.cc:211
std::string fiber_socket
Definition: CSCMapItem.h:40
std::string dcc_fifo
Definition: CSCMapItem.h:37
void chamber(int chamberid, CSCMapItem::MapItem *item)
Definition: CSCMap1.cc:29
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string crateLabel
Definition: CSCMapItem.h:26
cscmap1()
Definition: CSCMap1.cc:7
std::string chamberLabel
Definition: CSCMapItem.h:14
oracle::occi::Connection * con
Definition: CSCMap1.h:14
~cscmap1()
Definition: CSCMap1.cc:23
tuple cout
Definition: gather_cfg.py:121
oracle::occi::Environment * env
Definition: CSCMap1.h:13
void cratedmb(int crate, int dmb, CSCMapItem::MapItem *item)
Definition: CSCMap1.cc:121