00001 #include "CalibCalorimetry/EcalTPGTools/plugins/EcalTPGDBApp.h"
00002
00003 #include <vector>
00004 #include <time.h>
00005
00006 using namespace std;
00007 using namespace oracle::occi;
00008
00009 EcalTPGDBApp::EcalTPGDBApp(string host, string sid, string user, string pass, int port)
00010 : EcalCondDBInterface( host, sid, user, pass, port )
00011 {}
00012
00013 EcalTPGDBApp::EcalTPGDBApp(string sid, string user, string pass)
00014 : EcalCondDBInterface( sid, user, pass )
00015 {}
00016
00017 int EcalTPGDBApp::writeToConfDB_TPGPedestals(const map<EcalLogicID, FEConfigPedDat> & pedset, int iovId, string tag) {
00018
00019 int result=0;
00020
00021 cout << "*****************************************" << endl;
00022 cout << "******** Inserting Peds in conf-OMDS*****" << endl;
00023 cout << "*****************************************" << endl;
00024
00025 cout << "creating fe record " <<endl;
00026 FEConfigPedInfo fe_ped_info ;
00027 fe_ped_info.setIOVId(iovId) ;
00028 fe_ped_info.setConfigTag(tag) ;
00029 insertConfigSet(&fe_ped_info) ;
00030 result = fe_ped_info.getID() ;
00031
00032
00033
00034 cout << "*********about to insert peds *********" << endl;
00035 cout << " map size = "<<pedset.size()<<endl ;
00036 insertDataArraySet(&pedset, &fe_ped_info);
00037 cout << "*********Done peds *********" << endl;
00038
00039 return result;
00040 }
00041
00042 int EcalTPGDBApp::writeToConfDB_TPGLinearCoef(const map<EcalLogicID, FEConfigLinDat> & linset,
00043 const map<EcalLogicID, FEConfigLinParamDat> & linparamset, int iovId, string tag) {
00044
00045 int result=0;
00046
00047 cout << "*********************************************" << endl;
00048 cout << "**Inserting Linarization coeff in conf-OMDS**" << endl;
00049 cout << "*********************************************" << endl;
00050
00051 cout << "creating fe record " <<endl;
00052 FEConfigLinInfo fe_lin_info ;
00053 fe_lin_info.setIOVId(iovId) ;
00054 fe_lin_info.setConfigTag(tag) ;
00055 insertConfigSet(&fe_lin_info) ;
00056 result = fe_lin_info.getID() ;
00057
00058
00059 cout << "*********about to insert linearization coeff *********" << endl;
00060 cout << " map size = "<<linset.size()<<endl ;
00061 insertDataArraySet(&linset, &fe_lin_info);
00062 insertDataArraySet(&linparamset, &fe_lin_info);
00063 cout << "*********Done lineraization coeff *********" << endl;
00064
00065 return result;
00066 }
00067
00068 int EcalTPGDBApp::writeToConfDB_TPGMain(int ped, int lin, int lut, int fgr, int sli, int wei, int spi, int tim, int bxt, int btt, int bst, string tag, int ver) {
00069
00070 int result=0;
00071
00072 cout << "*********************************************" << endl;
00073 cout << "**Inserting Main FE table in conf-OMDS **" << endl;
00074 cout << "*********************************************" << endl;
00075
00076 cout << "creating fe record " <<endl;
00077
00078 FEConfigMainInfo fe_main ;
00079 fe_main.setPedId(ped) ;
00080 fe_main.setLinId(lin) ;
00081 fe_main.setLUTId(lut) ;
00082 fe_main.setFgrId(fgr) ;
00083 fe_main.setSliId(sli) ;
00084 fe_main.setWeiId(wei) ;
00085 fe_main.setSpiId(spi) ;
00086 fe_main.setTimId(tim) ;
00087 fe_main.setBxtId(bxt) ;
00088 fe_main.setBttId(btt) ;
00089 fe_main.setBstId(bst) ;
00090 fe_main.setConfigTag(tag) ;
00091 fe_main.setVersion(ver) ;
00092
00093 insertConfigSet(&fe_main) ;
00094 result = fe_main.getId() ;
00095
00096 cout << "*********Done Main *********" << endl;
00097
00098 return result;
00099 }
00100
00101
00102 void EcalTPGDBApp::readFromConfDB_TPGPedestals(int iconf_req ) {
00103
00104
00105
00106
00107
00108
00109 cout << "*****************************************" << endl;
00110 cout << "test readinf fe_ped with id="<<iconf_req << endl;
00111 cout << "*****************************************" << endl;
00112
00113 FEConfigPedInfo fe_ped_info;
00114 fe_ped_info.setId(iconf_req);
00115
00116 fetchConfigSet(&fe_ped_info);
00117
00118 map<EcalLogicID, FEConfigPedDat> dataset_ped;
00119 fetchDataSet(&dataset_ped, &fe_ped_info);
00120
00121 typedef map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
00122 EcalLogicID ecid_xt;
00123 FEConfigPedDat rd_ped;
00124
00125 float ped_m12[61200];
00126 float ped_m6[61200];
00127 float ped_m1[61200];
00128 for (int i=0; i<61200; i++){
00129 ped_m12[i]=0;
00130 ped_m6[i]=0;
00131 ped_m1[i]=0;
00132 }
00133
00134 for (CIfeped p = dataset_ped.begin(); p != dataset_ped.end(); p++) {
00135 ecid_xt = p->first;
00136 rd_ped = p->second;
00137
00138 int xt_num=ecid_xt.getID2();
00139 ped_m12[xt_num]=rd_ped.getPedMeanG12();
00140 ped_m6[xt_num]=rd_ped.getPedMeanG6();
00141 ped_m1[xt_num]=rd_ped.getPedMeanG1();
00142 }
00143
00144 cout << "*****************************************" << endl;
00145 cout << "test read done"<<iconf_req << endl;
00146 cout << "*****************************************" << endl;
00147
00148 }
00149
00150
00151 int EcalTPGDBApp::readFromCondDB_Pedestals(map<EcalLogicID, MonPedestalsDat> & dataset, int runNb) {
00152
00153
00154 int iovId = 0 ;
00155
00156 cout << "Retrieving run list from DB from run nb ... "<< runNb << endl;
00157 RunTag my_runtag;
00158 LocationDef my_locdef;
00159 RunTypeDef my_rundef;
00160 my_locdef.setLocation("P5_Co");
00161 my_rundef.setRunType("PEDESTAL");
00162 my_runtag.setLocationDef(my_locdef);
00163 my_runtag.setRunTypeDef(my_rundef);
00164 my_runtag.setGeneralTag("LOCAL");
00165
00166
00167 MonVersionDef monverdef;
00168 monverdef.setMonitoringVersion("test01");
00169 MonRunTag montag;
00170 montag.setMonVersionDef(monverdef);
00171 montag.setGeneralTag("CMSSW");
00172
00173 MonRunList mon_list;
00174 mon_list.setMonRunTag(montag);
00175 mon_list.setRunTag(my_runtag);
00176
00177 std::cout<<"we are in read ped from condDB and runNb is "<< runNb<<endl;
00178
00179 mon_list = fetchMonRunListLastNRuns(my_runtag, montag, runNb , 10 );
00180
00181 std::cout<<"we are in read ped from condDB"<<endl;
00182
00183 std::vector<MonRunIOV> mon_run_vec = mon_list.getRuns();
00184 cout <<"number of ped runs is : "<< mon_run_vec.size()<< endl;
00185 int mon_runs = mon_run_vec.size();
00186
00187
00188 if(mon_runs>0) {
00189 for (int ii=0 ; ii<(int)mon_run_vec.size(); ii++) cout << "here is the run number: "<< mon_run_vec[ii].getRunIOV().getRunNumber() << endl;
00190
00191
00192 int run=0;
00193 cout <<" retrieve the data for a given run"<< endl;
00194 cout << "here is the run number: "<< mon_run_vec[run].getRunIOV().getRunNumber() << endl;
00195 iovId = mon_run_vec[run].getID();
00196
00197 fetchDataSet(&dataset, &mon_run_vec[run]) ;
00198 }
00199 return iovId ;
00200 }
00201
00202
00203 int EcalTPGDBApp::writeToConfDB_TPGSliding(const map<EcalLogicID, FEConfigSlidingDat> & sliset, int iovId, string tag)
00204 {
00205 cout << "*****************************************" << endl;
00206 cout << "************Inserting SLIDING************" << endl;
00207 cout << "*****************************************" << endl;
00208 int result=0;
00209
00210 FEConfigSlidingInfo fe_info ;
00211 fe_info.setIOVId(iovId);
00212 fe_info.setConfigTag(tag);
00213 insertConfigSet(&fe_info);
00214
00215
00216
00217
00218
00219 insertDataArraySet(&sliset, &fe_info);
00220
00221 result=fe_info.getId();
00222
00223 cout << "*****************************************" << endl;
00224 cout << "************SLI done*********************" << endl;
00225 cout << "*****************************************" << endl;
00226 return result;
00227
00228 }
00229
00230
00231 int EcalTPGDBApp::writeToConfDB_TPGLUT(const map<EcalLogicID, FEConfigLUTGroupDat> & lutgroupset,
00232 const map<EcalLogicID, FEConfigLUTDat> & lutset,
00233 const map<EcalLogicID, FEConfigLUTParamDat> & lutparamset,int iovId, string tag)
00234 {
00235 cout << "*****************************************" << endl;
00236 cout << "************Inserting LUT************" << endl;
00237 cout << "*****************************************" << endl;
00238 int result=0;
00239
00240 FEConfigLUTInfo fe_lut_info ;
00241 fe_lut_info.setNumberOfGroups(iovId);
00242 fe_lut_info.setConfigTag(tag);
00243 insertConfigSet(&fe_lut_info);
00244
00245
00246
00247
00248
00249 insertDataArraySet(&lutgroupset, &fe_lut_info);
00250
00251 insertDataArraySet(&lutset, &fe_lut_info);
00252
00253 insertDataArraySet(&lutparamset, &fe_lut_info);
00254
00255 result=fe_lut_info.getId();
00256
00257 cout << "*****************************************" << endl;
00258 cout << "************LUT done*********************" << endl;
00259 cout << "*****************************************" << endl;
00260 return result;
00261
00262 }
00263
00264 int EcalTPGDBApp::writeToConfDB_TPGWeight(const map<EcalLogicID, FEConfigWeightGroupDat> & lutgroupset,
00265 const map<EcalLogicID, FEConfigWeightDat> & lutset, int ngr, string tag)
00266 {
00267 cout << "*****************************************" << endl;
00268 cout << "************Inserting weights************" << endl;
00269 cout << "*****************************************" << endl;
00270
00271 int result=0;
00272
00273 FEConfigWeightInfo fe_wei_info ;
00274 fe_wei_info.setNumberOfGroups(5);
00275 fe_wei_info.setConfigTag(tag);
00276 insertConfigSet(&fe_wei_info);
00277
00278
00279
00280
00281
00282 insertDataArraySet(&lutgroupset, &fe_wei_info);
00283
00284 insertDataArraySet(&lutset, &fe_wei_info);
00285
00286 result=fe_wei_info.getId();
00287
00288 cout << "*****************************************" << endl;
00289 cout << "************WEIGHT done******************" << endl;
00290 cout << "*****************************************" << endl;
00291 return result;
00292
00293
00294 }
00295
00296
00297 int EcalTPGDBApp::writeToConfDB_TPGFgr(const map<EcalLogicID, FEConfigFgrGroupDat> & fgrgroupset,
00298 const map<EcalLogicID, FEConfigFgrDat> & fgrset,
00299 const map<EcalLogicID, FEConfigFgrParamDat> & fgrparamset,
00300 const map<EcalLogicID, FEConfigFgrEETowerDat> & dataset3,
00301 const map<EcalLogicID, FEConfigFgrEEStripDat> & dataset4,
00302 int iovId, string tag)
00303 {
00304 cout << "*****************************************" << endl;
00305 cout << "************Inserting Fgr************" << endl;
00306 cout << "*****************************************" << endl;
00307 int result=0;
00308
00309 FEConfigFgrInfo fe_fgr_info ;
00310 fe_fgr_info.setNumberOfGroups(iovId);
00311 fe_fgr_info.setConfigTag(tag);
00312 insertConfigSet(&fe_fgr_info);
00313
00314
00315
00316
00317
00318 insertDataArraySet(&fgrgroupset, &fe_fgr_info);
00319
00320 insertDataArraySet(&fgrset, &fe_fgr_info);
00321
00322 insertDataArraySet(&fgrparamset, &fe_fgr_info);
00323
00324 insertDataArraySet(&dataset3, &fe_fgr_info);
00325
00326 insertDataArraySet(&dataset4, &fe_fgr_info);
00327
00328 result=fe_fgr_info.getId();
00329
00330 cout << "*****************************************" << endl;
00331 cout << "************Fgr done*********************" << endl;
00332 cout << "*****************************************" << endl;
00333 return result;
00334
00335 }
00336
00337 int EcalTPGDBApp::writeToConfDB_Spike(const map<EcalLogicID, FEConfigSpikeDat> & spikegroupset,
00338 string tag)
00339 {
00340 cout << "*****************************************" << endl;
00341 cout << "************Inserting Spike************" << endl;
00342 cout << "*****************************************" << endl;
00343 int result=0;
00344
00345 FEConfigSpikeInfo fe_spike_info ;
00346 fe_spike_info.setConfigTag(tag);
00347 insertConfigSet(&fe_spike_info);
00348
00349
00350
00351
00352
00353 insertDataArraySet(&spikegroupset, &fe_spike_info);
00354
00355 result=fe_spike_info.getId();
00356
00357 cout << "*****************************************" << endl;
00358 cout << "************Spike done*******************" << endl;
00359 cout << "*****************************************" << endl;
00360 return result;
00361
00362 }
00363
00364 int EcalTPGDBApp::writeToConfDB_Delay(const map<EcalLogicID, FEConfigTimingDat> & timegroupset,
00365 string tag)
00366 {
00367 cout << "*****************************************" << endl;
00368 cout << "************Inserting Delays************" << endl;
00369 cout << "*****************************************" << endl;
00370 int result=0;
00371
00372 FEConfigTimingInfo fe_time_info ;
00373 fe_time_info.setConfigTag(tag);
00374 insertConfigSet(&fe_time_info);
00375
00376
00377
00378
00379
00380 insertDataArraySet(&timegroupset, &fe_time_info);
00381
00382 result=fe_time_info.getId();
00383
00384 cout << "*****************************************" << endl;
00385 cout << "************Delays done******************" << endl;
00386 cout << "*****************************************" << endl;
00387 return result;
00388
00389 }
00390
00391
00392
00393 void EcalTPGDBApp::printTag( const RunTag* tag) const
00394 {
00395 cout << endl;
00396 cout << "=============RunTag:" << endl;
00397 cout << "GeneralTag: " << tag->getGeneralTag() << endl;
00398 cout << "Location: " << tag->getLocationDef().getLocation() << endl;
00399 cout << "Run Type: " << tag->getRunTypeDef().getRunType() << endl;
00400 cout << "====================" << endl;
00401 }
00402
00403 void EcalTPGDBApp::printIOV( const RunIOV* iov) const
00404 {
00405 cout << endl;
00406 cout << "=============RunIOV:" << endl;
00407 RunTag tag = iov->getRunTag();
00408 printTag(&tag);
00409 cout << "Run Number: " << iov->getRunNumber() << endl;
00410 cout << "Run Start: " << iov->getRunStart().str() << endl;
00411 cout << "Run End: " << iov->getRunEnd().str() << endl;
00412 cout << "====================" << endl;
00413 }
00414
00415