00001 #include "OnlineDB/CSCCondDB/interface/CSCMap1.h"
00002 #include <cstdlib>
00003
00007 cscmap1::cscmap1 () throw (oracle::occi::SQLException)
00008 {
00009 std::string db_user;
00010 std::string db_pass;
00011 env = oracle::occi::Environment::createEnvironment (oracle::occi::Environment::DEFAULT);
00012 char* c_user = ::getenv("CSCMAP_AUTH_USER");
00013 char* c_pass = ::getenv("CSCMAP_AUTH_PASSWORD");
00014 db_user=std::string(c_user);
00015 db_pass=std::string(c_pass);
00016 con = env->createConnection (db_user,db_pass,"cms_orcoff_prod");
00017 std::cout << "Connection to mapping DB is done." << std::endl;
00018 }
00019
00023 cscmap1::~cscmap1 () throw (oracle::occi::SQLException)
00024 {
00025 env->terminateConnection (con);
00026 oracle::occi::Environment::terminateEnvironment (env);
00027 }
00028
00029 void cscmap1::chamber (int chamberid, CSCMapItem::MapItem *item)
00030 {
00031 oracle::occi::Statement *stmt = con->createStatement();
00032
00033 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;");
00034
00035 stmt->setInt (1, chamberid);
00036 stmt->registerOutParam (2, oracle::occi::OCCISTRING, 10);
00037 stmt->registerOutParam (3, oracle::occi::OCCIINT);
00038 stmt->registerOutParam (4, oracle::occi::OCCIINT);
00039 stmt->registerOutParam (5, oracle::occi::OCCIINT);
00040 stmt->registerOutParam (6, oracle::occi::OCCIINT);
00041 stmt->registerOutParam (7, oracle::occi::OCCIINT);
00042 stmt->registerOutParam (8, oracle::occi::OCCIINT);
00043 stmt->registerOutParam (9, oracle::occi::OCCIINT);
00044 stmt->registerOutParam (10, oracle::occi::OCCISTRING, 10);
00045 stmt->registerOutParam (11, oracle::occi::OCCIINT);
00046 stmt->registerOutParam (12, oracle::occi::OCCIINT);
00047 stmt->registerOutParam (13, oracle::occi::OCCIINT);
00048 stmt->registerOutParam (14, oracle::occi::OCCIINT);
00049 stmt->registerOutParam (15, oracle::occi::OCCIINT);
00050 stmt->registerOutParam (16, oracle::occi::OCCIINT);
00051 stmt->registerOutParam (17, oracle::occi::OCCIINT);
00052 stmt->registerOutParam (18, oracle::occi::OCCIINT);
00053 stmt->registerOutParam (19, oracle::occi::OCCIINT);
00054 stmt->registerOutParam (20, oracle::occi::OCCIINT);
00055
00056 stmt->execute();
00057
00058 item->chamberLabel = stmt->getString(10);
00059 item->chamberId = chamberid;
00060 int chamber = chamberid/10%100;
00061 int rest = (chamberid - chamber*10)/1000;
00062 int ring = rest%10;
00063 rest = (rest - ring)/10;
00064 int station = rest%10;
00065 int endcap = (rest - station)/10;
00066 item->endcap = endcap;
00067 item->station = station;
00068 item->ring = ring;
00069 item->chamber = chamber;
00070 item->cscIndex = stmt->getInt(13);
00071 item->layerIndex = stmt->getInt(14);
00072 item->stripIndex = stmt->getInt(15);
00073 item->anodeIndex = stmt->getInt(16);
00074 item->strips = stmt->getInt(11);
00075 item->anodes = stmt->getInt(12);
00076 item->crateLabel = stmt->getString(2);
00077 item->crateid = stmt->getInt(3);
00078 item->sector = stmt->getInt(8);
00079 item->trig_sector = stmt->getInt(9);
00080 item->dmb = stmt->getInt(5);
00081 item->cscid = stmt->getInt(7);
00082
00083 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;");
00084
00085 stmt->setInt (1, chamberid);
00086 stmt->registerOutParam (2, oracle::occi::OCCIINT);
00087 stmt->registerOutParam (3, oracle::occi::OCCIINT);
00088 stmt->registerOutParam (4, oracle::occi::OCCIINT);
00089 stmt->registerOutParam (5, oracle::occi::OCCIINT);
00090 stmt->registerOutParam (6, oracle::occi::OCCISTRING, 10);
00091 stmt->registerOutParam (7, oracle::occi::OCCIINT);
00092 stmt->registerOutParam (8, oracle::occi::OCCIINT);
00093 stmt->registerOutParam (9, oracle::occi::OCCIINT);
00094 stmt->registerOutParam (10, oracle::occi::OCCISTRING, 10);
00095 stmt->registerOutParam (11, oracle::occi::OCCIINT);
00096 stmt->registerOutParam (12, oracle::occi::OCCISTRING, 10);
00097 stmt->registerOutParam (13, oracle::occi::OCCIINT);
00098 stmt->registerOutParam (14, oracle::occi::OCCISTRING, 10);
00099 stmt->registerOutParam (15, oracle::occi::OCCIINT);
00100 stmt->registerOutParam (16, oracle::occi::OCCIINT);
00101 stmt->registerOutParam (17, oracle::occi::OCCIINT);
00102 stmt->registerOutParam (18, oracle::occi::OCCIINT);
00103 stmt->registerOutParam (19, oracle::occi::OCCIINT);
00104
00105 stmt->execute();
00106
00107 item->ddu = stmt->getInt(2);
00108 item->ddu_input = stmt->getInt(5);
00109 item->slink = stmt->getInt(7);
00110
00111 item->fed_crate = stmt->getInt(3);
00112 item->ddu_slot = stmt->getInt(4);
00113 item->dcc_fifo = stmt->getString(6);
00114 item->fiber_crate = stmt->getInt(8);
00115 item->fiber_pos = stmt->getInt(9);
00116 item->fiber_socket = stmt->getString(10);
00117
00118 con->terminateStatement (stmt);
00119 }
00120
00121 void cscmap1::cratedmb (int crate, int dmb, CSCMapItem::MapItem *item)
00122 {
00123 oracle::occi::Statement *stmt = con->createStatement();
00124
00125 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;");
00126
00127 stmt->setInt (1, crate);
00128 stmt->setInt (2, dmb);
00129 stmt->registerOutParam (3, oracle::occi::OCCISTRING, 10);
00130 stmt->registerOutParam (4, oracle::occi::OCCIINT);
00131 stmt->registerOutParam (5, oracle::occi::OCCIINT);
00132 stmt->registerOutParam (6, oracle::occi::OCCIINT);
00133 stmt->registerOutParam (7, oracle::occi::OCCIINT);
00134 stmt->registerOutParam (8, oracle::occi::OCCIINT);
00135 stmt->registerOutParam (9, oracle::occi::OCCIINT);
00136 stmt->registerOutParam (10, oracle::occi::OCCIINT);
00137 stmt->registerOutParam (11, oracle::occi::OCCISTRING, 10);
00138 stmt->registerOutParam (12, oracle::occi::OCCIINT);
00139 stmt->registerOutParam (13, oracle::occi::OCCIINT);
00140 stmt->registerOutParam (14, oracle::occi::OCCIINT);
00141 stmt->registerOutParam (15, oracle::occi::OCCIINT);
00142 stmt->registerOutParam (16, oracle::occi::OCCIINT);
00143 stmt->registerOutParam (17, oracle::occi::OCCIINT);
00144
00145 stmt->execute();
00146
00147 item->chamberLabel = stmt->getString(3);
00148 item->chamberId = stmt->getInt(4);
00149 int chamberid = item->chamberId;
00150 int chamber = chamberid/10%100;
00151 int rest = (chamberid - chamber*10)/1000;
00152 int ring = rest%10;
00153 rest = (rest - ring)/10;
00154 int station = rest%10;
00155 int endcap = (rest - station)/10;
00156 item->endcap = endcap;
00157 item->station = station;
00158 item->ring = ring;
00159 item->chamber = chamber;
00160 item->cscIndex = stmt->getInt(14);
00161 item->layerIndex = stmt->getInt(15);
00162 item->stripIndex = stmt->getInt(16);
00163 item->anodeIndex = stmt->getInt(17);
00164 item->strips = stmt->getInt(12);
00165 item->anodes = stmt->getInt(13);
00166 item->crateLabel = stmt->getString(11);
00167 item->crateid = stmt->getInt(9);
00168 item->sector = stmt->getInt(7);
00169 item->trig_sector = stmt->getInt(8);
00170 item->dmb = dmb;
00171 item->cscid = stmt->getInt(5);
00172
00173 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;");
00174
00175 stmt->setInt (1, chamberid);
00176 stmt->registerOutParam (2, oracle::occi::OCCIINT);
00177 stmt->registerOutParam (3, oracle::occi::OCCIINT);
00178 stmt->registerOutParam (4, oracle::occi::OCCIINT);
00179 stmt->registerOutParam (5, oracle::occi::OCCIINT);
00180 stmt->registerOutParam (6, oracle::occi::OCCISTRING, 10);
00181 stmt->registerOutParam (7, oracle::occi::OCCIINT);
00182 stmt->registerOutParam (8, oracle::occi::OCCIINT);
00183 stmt->registerOutParam (9, oracle::occi::OCCIINT);
00184 stmt->registerOutParam (10, oracle::occi::OCCISTRING, 10);
00185 stmt->registerOutParam (11, oracle::occi::OCCIINT);
00186 stmt->registerOutParam (12, oracle::occi::OCCISTRING, 10);
00187 stmt->registerOutParam (13, oracle::occi::OCCIINT);
00188 stmt->registerOutParam (14, oracle::occi::OCCISTRING, 10);
00189 stmt->registerOutParam (15, oracle::occi::OCCIINT);
00190 stmt->registerOutParam (16, oracle::occi::OCCIINT);
00191 stmt->registerOutParam (17, oracle::occi::OCCIINT);
00192 stmt->registerOutParam (18, oracle::occi::OCCIINT);
00193 stmt->registerOutParam (19, oracle::occi::OCCIINT);
00194
00195 stmt->execute();
00196
00197 item->ddu = stmt->getInt(2);
00198 item->ddu_input = stmt->getInt(5);
00199 item->slink = stmt->getInt(7);
00200
00201 item->fed_crate = stmt->getInt(3);
00202 item->ddu_slot = stmt->getInt(4);
00203 item->dcc_fifo = stmt->getString(6);
00204 item->fiber_crate = stmt->getInt(8);
00205 item->fiber_pos = stmt->getInt(9);
00206 item->fiber_socket = stmt->getString(10);
00207
00208 con->terminateStatement (stmt);
00209 }
00210
00211 void cscmap1::ruiddu (int rui, int ddu_input, CSCMapItem::MapItem *item)
00212 {
00213 oracle::occi::Statement *stmt = con->createStatement();
00214
00215 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;");
00216
00217 stmt->setInt (1, rui);
00218 stmt->setInt (2, ddu_input);
00219 stmt->registerOutParam (3, oracle::occi::OCCIINT);
00220 stmt->registerOutParam (4, oracle::occi::OCCIINT);
00221 stmt->registerOutParam (5, oracle::occi::OCCISTRING, 10);
00222 stmt->registerOutParam (6, oracle::occi::OCCIINT);
00223 stmt->registerOutParam (7, oracle::occi::OCCIINT);
00224 stmt->registerOutParam (8, oracle::occi::OCCIINT);
00225 stmt->registerOutParam (9, oracle::occi::OCCISTRING, 10);
00226 stmt->registerOutParam (10, oracle::occi::OCCIINT);
00227 stmt->registerOutParam (11, oracle::occi::OCCISTRING, 10);
00228 stmt->registerOutParam (12, oracle::occi::OCCIINT);
00229 stmt->registerOutParam (13, oracle::occi::OCCISTRING, 10);
00230 stmt->registerOutParam (14, oracle::occi::OCCIINT);
00231 stmt->registerOutParam (15, oracle::occi::OCCIINT);
00232 stmt->registerOutParam (16, oracle::occi::OCCIINT);
00233 stmt->registerOutParam (17, oracle::occi::OCCIINT);
00234 stmt->registerOutParam (18, oracle::occi::OCCIINT);
00235 stmt->registerOutParam (19, oracle::occi::OCCIINT);
00236
00237 stmt->execute();
00238
00239 item->ddu = rui;
00240 item->ddu_input = ddu_input;
00241 item->slink = stmt->getInt(6);
00242
00243 item->fed_crate = stmt->getInt(3);
00244 item->ddu_slot = stmt->getInt(4);
00245 item->dcc_fifo = stmt->getString(5);
00246 item->fiber_crate = stmt->getInt(7);
00247 item->fiber_pos = stmt->getInt(8);
00248 item->fiber_socket = stmt->getString(9);
00249 int chamberid = stmt->getInt(14);
00250
00251 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;");
00252
00253 stmt->setInt (1, chamberid);
00254 stmt->registerOutParam (2, oracle::occi::OCCISTRING, 10);
00255 stmt->registerOutParam (3, oracle::occi::OCCIINT);
00256 stmt->registerOutParam (4, oracle::occi::OCCIINT);
00257 stmt->registerOutParam (5, oracle::occi::OCCIINT);
00258 stmt->registerOutParam (6, oracle::occi::OCCIINT);
00259 stmt->registerOutParam (7, oracle::occi::OCCIINT);
00260 stmt->registerOutParam (8, oracle::occi::OCCIINT);
00261 stmt->registerOutParam (9, oracle::occi::OCCIINT);
00262 stmt->registerOutParam (10, oracle::occi::OCCISTRING, 10);
00263 stmt->registerOutParam (11, oracle::occi::OCCIINT);
00264 stmt->registerOutParam (12, oracle::occi::OCCIINT);
00265 stmt->registerOutParam (13, oracle::occi::OCCIINT);
00266 stmt->registerOutParam (14, oracle::occi::OCCIINT);
00267 stmt->registerOutParam (15, oracle::occi::OCCIINT);
00268 stmt->registerOutParam (16, oracle::occi::OCCIINT);
00269 stmt->registerOutParam (17, oracle::occi::OCCIINT);
00270 stmt->registerOutParam (18, oracle::occi::OCCIINT);
00271 stmt->registerOutParam (19, oracle::occi::OCCIINT);
00272 stmt->registerOutParam (20, oracle::occi::OCCIINT);
00273
00274 stmt->execute();
00275
00276 item->chamberLabel = stmt->getString(10);
00277 item->chamberId = chamberid;
00278 int chamber = chamberid/10%100;
00279 int rest = (chamberid - chamber*10)/1000;
00280 int ring = rest%10;
00281 rest = (rest - ring)/10;
00282 int station = rest%10;
00283 int endcap = (rest - station)/10;
00284 item->endcap = endcap;
00285 item->station = station;
00286 item->ring = ring;
00287 item->chamber = chamber;
00288 item->cscIndex = stmt->getInt(13);
00289 item->layerIndex = stmt->getInt(14);
00290 item->stripIndex = stmt->getInt(15);
00291 item->anodeIndex = stmt->getInt(16);
00292 item->strips = stmt->getInt(11);
00293 item->anodes = stmt->getInt(12);
00294 item->crateLabel = stmt->getString(2);
00295 item->crateid = stmt->getInt(3);
00296 item->sector = stmt->getInt(8);
00297 item->trig_sector = stmt->getInt(9);
00298 item->dmb = stmt->getInt(5);
00299 item->cscid = stmt->getInt(7);
00300
00301 stmt->execute();
00302
00303 con->terminateStatement (stmt);
00304 }