CMS 3D CMS Logo

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