Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:45

0001 #include "OnlineDB/CSCCondDB/interface/CSCMap1.h"
0002 #include <cstdlib>
0003 
0004 /**
0005    * Constructor for cscmap1
0006    */
0007 cscmap1::cscmap1() noexcept(false) {
0008   std::string db_user;
0009   std::string db_pass;
0010   env = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
0011   char *c_user = std::getenv("CSCMAP_AUTH_USER");
0012   char *c_pass = std::getenv("CSCMAP_AUTH_PASSWORD");
0013   db_user = std::string(c_user);
0014   db_pass = std::string(c_pass);
0015   con = env->createConnection(db_user, db_pass, "cms_orcoff_prod");
0016   std::cout << "Connection to mapping DB is done." << std::endl;
0017 }  // end of constructor cscmap1 ()
0018 
0019 /**
0020    * Destructor for cscmap1.
0021    */
0022 cscmap1::~cscmap1() noexcept(false) {
0023   env->terminateConnection(con);
0024   oracle::occi::Environment::terminateEnvironment(env);
0025 }  // end of ~cscmap1 ()
0026 
0027 void cscmap1::chamber(int chamberid, CSCMapItem::MapItem *item) {
0028   oracle::occi::Statement *stmt = con->createStatement();
0029 
0030   stmt->setSQL(
0031       "begin cms_emu_cern.cscmap.chamberid_crate(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, "
0032       ":16, :17, :18, :19, :20); end;");
0033 
0034   stmt->setInt(1, chamberid);
0035   stmt->registerOutParam(2, oracle::occi::OCCISTRING, 10);
0036   stmt->registerOutParam(3, oracle::occi::OCCIINT);
0037   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0038   stmt->registerOutParam(5, oracle::occi::OCCIINT);
0039   stmt->registerOutParam(6, oracle::occi::OCCIINT);
0040   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0041   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0042   stmt->registerOutParam(9, oracle::occi::OCCIINT);
0043   stmt->registerOutParam(10, oracle::occi::OCCISTRING, 10);
0044   stmt->registerOutParam(11, oracle::occi::OCCIINT);
0045   stmt->registerOutParam(12, oracle::occi::OCCIINT);
0046   stmt->registerOutParam(13, oracle::occi::OCCIINT);
0047   stmt->registerOutParam(14, oracle::occi::OCCIINT);
0048   stmt->registerOutParam(15, oracle::occi::OCCIINT);
0049   stmt->registerOutParam(16, oracle::occi::OCCIINT);
0050   stmt->registerOutParam(17, oracle::occi::OCCIINT);
0051   stmt->registerOutParam(18, oracle::occi::OCCIINT);
0052   stmt->registerOutParam(19, oracle::occi::OCCIINT);
0053   stmt->registerOutParam(20, oracle::occi::OCCIINT);
0054 
0055   stmt->execute();  //execute procedure
0056 
0057   item->chamberLabel = stmt->getString(10);
0058   item->chamberId = chamberid;
0059   int chamber = chamberid / 10 % 100;
0060   int rest = (chamberid - chamber * 10) / 1000;
0061   int ring = rest % 10;
0062   rest = (rest - ring) / 10;
0063   int station = rest % 10;
0064   int endcap = (rest - station) / 10;
0065   item->endcap = endcap;
0066   item->station = station;
0067   item->ring = ring;
0068   item->chamber = chamber;
0069   item->cscIndex = stmt->getInt(13);
0070   item->layerIndex = stmt->getInt(14);
0071   item->stripIndex = stmt->getInt(15);
0072   item->anodeIndex = stmt->getInt(16);
0073   item->strips = stmt->getInt(11);
0074   item->anodes = stmt->getInt(12);
0075   item->crateLabel = stmt->getString(2);
0076   item->crateid = stmt->getInt(3);
0077   item->sector = stmt->getInt(8);
0078   item->trig_sector = stmt->getInt(9);
0079   item->dmb = stmt->getInt(5);
0080   item->cscid = stmt->getInt(7);
0081 
0082   stmt->setSQL(
0083       "begin cms_emu_cern.ddumap.chamberid_ddu(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, "
0084       ":17, :18, :19); end;");
0085 
0086   stmt->setInt(1, chamberid);
0087   stmt->registerOutParam(2, oracle::occi::OCCIINT);
0088   stmt->registerOutParam(3, oracle::occi::OCCIINT);
0089   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0090   stmt->registerOutParam(5, oracle::occi::OCCIINT);
0091   stmt->registerOutParam(6, oracle::occi::OCCISTRING, 10);
0092   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0093   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0094   stmt->registerOutParam(9, oracle::occi::OCCIINT);
0095   stmt->registerOutParam(10, oracle::occi::OCCISTRING, 10);
0096   stmt->registerOutParam(11, oracle::occi::OCCIINT);
0097   stmt->registerOutParam(12, oracle::occi::OCCISTRING, 10);
0098   stmt->registerOutParam(13, oracle::occi::OCCIINT);
0099   stmt->registerOutParam(14, oracle::occi::OCCISTRING, 10);
0100   stmt->registerOutParam(15, oracle::occi::OCCIINT);
0101   stmt->registerOutParam(16, oracle::occi::OCCIINT);
0102   stmt->registerOutParam(17, oracle::occi::OCCIINT);
0103   stmt->registerOutParam(18, oracle::occi::OCCIINT);
0104   stmt->registerOutParam(19, oracle::occi::OCCIINT);
0105 
0106   stmt->execute();  //execute procedure
0107 
0108   item->ddu = stmt->getInt(2);
0109   item->ddu_input = stmt->getInt(5);
0110   item->slink = stmt->getInt(7);
0111 
0112   item->fed_crate = stmt->getInt(3);
0113   item->ddu_slot = stmt->getInt(4);
0114   item->dcc_fifo = stmt->getString(6);
0115   item->fiber_crate = stmt->getInt(8);
0116   item->fiber_pos = stmt->getInt(9);
0117   item->fiber_socket = stmt->getString(10);
0118 
0119   con->terminateStatement(stmt);
0120 }  //end of chamber
0121 
0122 void cscmap1::cratedmb(int crate, int dmb, CSCMapItem::MapItem *item) {
0123   oracle::occi::Statement *stmt = con->createStatement();
0124 
0125   stmt->setSQL(
0126       "begin cms_emu_cern.cscmap.crateid_chamber(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, "
0127       ":16, :17); end;");
0128 
0129   stmt->setInt(1, crate);
0130   stmt->setInt(2, dmb);
0131   stmt->registerOutParam(3, oracle::occi::OCCISTRING, 10);
0132   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0133   stmt->registerOutParam(5, oracle::occi::OCCIINT);
0134   stmt->registerOutParam(6, oracle::occi::OCCIINT);
0135   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0136   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0137   stmt->registerOutParam(9, oracle::occi::OCCIINT);
0138   stmt->registerOutParam(10, oracle::occi::OCCIINT);
0139   stmt->registerOutParam(11, oracle::occi::OCCISTRING, 10);
0140   stmt->registerOutParam(12, oracle::occi::OCCIINT);
0141   stmt->registerOutParam(13, oracle::occi::OCCIINT);
0142   stmt->registerOutParam(14, oracle::occi::OCCIINT);
0143   stmt->registerOutParam(15, oracle::occi::OCCIINT);
0144   stmt->registerOutParam(16, oracle::occi::OCCIINT);
0145   stmt->registerOutParam(17, oracle::occi::OCCIINT);
0146 
0147   stmt->execute();  //execute procedure
0148 
0149   item->chamberLabel = stmt->getString(3);
0150   item->chamberId = stmt->getInt(4);
0151   int chamberid = item->chamberId;
0152   int chamber = chamberid / 10 % 100;
0153   int rest = (chamberid - chamber * 10) / 1000;
0154   int ring = rest % 10;
0155   rest = (rest - ring) / 10;
0156   int station = rest % 10;
0157   int endcap = (rest - station) / 10;
0158   item->endcap = endcap;
0159   item->station = station;
0160   item->ring = ring;
0161   item->chamber = chamber;
0162   item->cscIndex = stmt->getInt(14);
0163   item->layerIndex = stmt->getInt(15);
0164   item->stripIndex = stmt->getInt(16);
0165   item->anodeIndex = stmt->getInt(17);
0166   item->strips = stmt->getInt(12);
0167   item->anodes = stmt->getInt(13);
0168   item->crateLabel = stmt->getString(11);
0169   item->crateid = stmt->getInt(9);
0170   item->sector = stmt->getInt(7);
0171   item->trig_sector = stmt->getInt(8);
0172   item->dmb = dmb;
0173   item->cscid = stmt->getInt(5);
0174 
0175   stmt->setSQL(
0176       "begin cms_emu_cern.ddumap.chamberid_ddu(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, "
0177       ":17, :18, :19); end;");
0178 
0179   stmt->setInt(1, chamberid);
0180   stmt->registerOutParam(2, oracle::occi::OCCIINT);
0181   stmt->registerOutParam(3, oracle::occi::OCCIINT);
0182   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0183   stmt->registerOutParam(5, oracle::occi::OCCIINT);
0184   stmt->registerOutParam(6, oracle::occi::OCCISTRING, 10);
0185   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0186   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0187   stmt->registerOutParam(9, oracle::occi::OCCIINT);
0188   stmt->registerOutParam(10, oracle::occi::OCCISTRING, 10);
0189   stmt->registerOutParam(11, oracle::occi::OCCIINT);
0190   stmt->registerOutParam(12, oracle::occi::OCCISTRING, 10);
0191   stmt->registerOutParam(13, oracle::occi::OCCIINT);
0192   stmt->registerOutParam(14, oracle::occi::OCCISTRING, 10);
0193   stmt->registerOutParam(15, oracle::occi::OCCIINT);
0194   stmt->registerOutParam(16, oracle::occi::OCCIINT);
0195   stmt->registerOutParam(17, oracle::occi::OCCIINT);
0196   stmt->registerOutParam(18, oracle::occi::OCCIINT);
0197   stmt->registerOutParam(19, oracle::occi::OCCIINT);
0198 
0199   stmt->execute();  //execute procedure
0200 
0201   item->ddu = stmt->getInt(2);
0202   item->ddu_input = stmt->getInt(5);
0203   item->slink = stmt->getInt(7);
0204 
0205   item->fed_crate = stmt->getInt(3);
0206   item->ddu_slot = stmt->getInt(4);
0207   item->dcc_fifo = stmt->getString(6);
0208   item->fiber_crate = stmt->getInt(8);
0209   item->fiber_pos = stmt->getInt(9);
0210   item->fiber_socket = stmt->getString(10);
0211 
0212   con->terminateStatement(stmt);
0213 }  //end of cratedmb
0214 
0215 void cscmap1::ruiddu(int rui, int ddu_input, CSCMapItem::MapItem *item) {
0216   oracle::occi::Statement *stmt = con->createStatement();
0217 
0218   stmt->setSQL(
0219       "begin cms_emu_cern.ddumap.ddu_chamber(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, "
0220       ":17, :18, :19); end;");
0221 
0222   stmt->setInt(1, rui);
0223   stmt->setInt(2, ddu_input);
0224   stmt->registerOutParam(3, oracle::occi::OCCIINT);
0225   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0226   stmt->registerOutParam(5, oracle::occi::OCCISTRING, 10);
0227   stmt->registerOutParam(6, oracle::occi::OCCIINT);
0228   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0229   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0230   stmt->registerOutParam(9, oracle::occi::OCCISTRING, 10);
0231   stmt->registerOutParam(10, oracle::occi::OCCIINT);
0232   stmt->registerOutParam(11, oracle::occi::OCCISTRING, 10);
0233   stmt->registerOutParam(12, oracle::occi::OCCIINT);
0234   stmt->registerOutParam(13, oracle::occi::OCCISTRING, 10);
0235   stmt->registerOutParam(14, oracle::occi::OCCIINT);
0236   stmt->registerOutParam(15, oracle::occi::OCCIINT);
0237   stmt->registerOutParam(16, oracle::occi::OCCIINT);
0238   stmt->registerOutParam(17, oracle::occi::OCCIINT);
0239   stmt->registerOutParam(18, oracle::occi::OCCIINT);
0240   stmt->registerOutParam(19, oracle::occi::OCCIINT);
0241 
0242   stmt->execute();  //execute procedure
0243 
0244   item->ddu = rui;
0245   item->ddu_input = ddu_input;
0246   item->slink = stmt->getInt(6);
0247 
0248   item->fed_crate = stmt->getInt(3);
0249   item->ddu_slot = stmt->getInt(4);
0250   item->dcc_fifo = stmt->getString(5);
0251   item->fiber_crate = stmt->getInt(7);
0252   item->fiber_pos = stmt->getInt(8);
0253   item->fiber_socket = stmt->getString(9);
0254   int chamberid = stmt->getInt(14);
0255 
0256   stmt->setSQL(
0257       "begin cms_emu_cern.cscmap.chamberid_crate(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, "
0258       ":16, :17, :18, :19, :20); end;");
0259 
0260   stmt->setInt(1, chamberid);
0261   stmt->registerOutParam(2, oracle::occi::OCCISTRING, 10);
0262   stmt->registerOutParam(3, oracle::occi::OCCIINT);
0263   stmt->registerOutParam(4, oracle::occi::OCCIINT);
0264   stmt->registerOutParam(5, oracle::occi::OCCIINT);
0265   stmt->registerOutParam(6, oracle::occi::OCCIINT);
0266   stmt->registerOutParam(7, oracle::occi::OCCIINT);
0267   stmt->registerOutParam(8, oracle::occi::OCCIINT);
0268   stmt->registerOutParam(9, oracle::occi::OCCIINT);
0269   stmt->registerOutParam(10, oracle::occi::OCCISTRING, 10);
0270   stmt->registerOutParam(11, oracle::occi::OCCIINT);
0271   stmt->registerOutParam(12, oracle::occi::OCCIINT);
0272   stmt->registerOutParam(13, oracle::occi::OCCIINT);
0273   stmt->registerOutParam(14, oracle::occi::OCCIINT);
0274   stmt->registerOutParam(15, oracle::occi::OCCIINT);
0275   stmt->registerOutParam(16, oracle::occi::OCCIINT);
0276   stmt->registerOutParam(17, oracle::occi::OCCIINT);
0277   stmt->registerOutParam(18, oracle::occi::OCCIINT);
0278   stmt->registerOutParam(19, oracle::occi::OCCIINT);
0279   stmt->registerOutParam(20, oracle::occi::OCCIINT);
0280 
0281   stmt->execute();  //execute procedure
0282 
0283   item->chamberLabel = stmt->getString(10);
0284   item->chamberId = chamberid;
0285   int chamber = chamberid / 10 % 100;
0286   int rest = (chamberid - chamber * 10) / 1000;
0287   int ring = rest % 10;
0288   rest = (rest - ring) / 10;
0289   int station = rest % 10;
0290   int endcap = (rest - station) / 10;
0291   item->endcap = endcap;
0292   item->station = station;
0293   item->ring = ring;
0294   item->chamber = chamber;
0295   item->cscIndex = stmt->getInt(13);
0296   item->layerIndex = stmt->getInt(14);
0297   item->stripIndex = stmt->getInt(15);
0298   item->anodeIndex = stmt->getInt(16);
0299   item->strips = stmt->getInt(11);
0300   item->anodes = stmt->getInt(12);
0301   item->crateLabel = stmt->getString(2);
0302   item->crateid = stmt->getInt(3);
0303   item->sector = stmt->getInt(8);
0304   item->trig_sector = stmt->getInt(9);
0305   item->dmb = stmt->getInt(5);
0306   item->cscid = stmt->getInt(7);
0307 
0308   stmt->execute();  //execute procedure
0309 
0310   con->terminateStatement(stmt);
0311 }  //end of ruiddu