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, FEConfigParamDat> & 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
00069 void EcalTPGDBApp::readFromConfDB_TPGPedestals(int iconf_req ) {
00070
00071
00072
00073
00074
00075
00076 cout << "*****************************************" << endl;
00077 cout << "test readinf fe_ped with id="<<iconf_req << endl;
00078 cout << "*****************************************" << endl;
00079
00080 FEConfigPedInfo fe_ped_info;
00081 fe_ped_info.setId(iconf_req);
00082
00083 fetchConfigSet(&fe_ped_info);
00084
00085 map<EcalLogicID, FEConfigPedDat> dataset_ped;
00086 fetchDataSet(&dataset_ped, &fe_ped_info);
00087
00088 typedef map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
00089 EcalLogicID ecid_xt;
00090 FEConfigPedDat rd_ped;
00091
00092 float ped_m12[61200];
00093 float ped_m6[61200];
00094 float ped_m1[61200];
00095 for (int i=0; i<61200; i++){
00096 ped_m12[i]=0;
00097 ped_m6[i]=0;
00098 ped_m1[i]=0;
00099 }
00100
00101 for (CIfeped p = dataset_ped.begin(); p != dataset_ped.end(); p++) {
00102 ecid_xt = p->first;
00103 rd_ped = p->second;
00104 int sm_num=ecid_xt.getID1();
00105 int xt_num=ecid_xt.getID2();
00106 ped_m12[xt_num]=rd_ped.getPedMeanG12();
00107 ped_m6[xt_num]=rd_ped.getPedMeanG6();
00108 ped_m1[xt_num]=rd_ped.getPedMeanG1();
00109 }
00110
00111 cout << "*****************************************" << endl;
00112 cout << "test read done"<<iconf_req << endl;
00113 cout << "*****************************************" << endl;
00114
00115 }
00116
00117
00118 int EcalTPGDBApp::readFromCondDB_Pedestals(map<EcalLogicID, MonPedestalsDat> & dataset, int runNb) {
00119
00120
00121 int iovId = 0 ;
00122
00123 cout << "Retrieving run list from DB from run nb ... "<< runNb << endl;
00124 RunTag my_runtag;
00125 LocationDef my_locdef;
00126 RunTypeDef my_rundef;
00127 my_locdef.setLocation("P5_Co");
00128 my_rundef.setRunType("PEDESTAL");
00129 my_runtag.setLocationDef(my_locdef);
00130 my_runtag.setRunTypeDef(my_rundef);
00131 my_runtag.setGeneralTag("LOCAL");
00132
00133
00134 MonVersionDef monverdef;
00135 monverdef.setMonitoringVersion("test01");
00136 MonRunTag montag;
00137 montag.setMonVersionDef(monverdef);
00138 montag.setGeneralTag("CMSSW");
00139
00140 MonRunList mon_list;
00141 mon_list.setMonRunTag(montag);
00142 mon_list.setRunTag(my_runtag);
00143
00144 std::cout<<"we are in read ped from condDB and runNb is "<< runNb<<endl;
00145
00146 mon_list = fetchMonRunListLastNRuns(my_runtag, montag, runNb , 10 );
00147
00148 std::cout<<"we are in read ped from condDB"<<endl;
00149
00150 std::vector<MonRunIOV> mon_run_vec = mon_list.getRuns();
00151 cout <<"number of ped runs is : "<< mon_run_vec.size()<< endl;
00152 int mon_runs = mon_run_vec.size();
00153 int sm_num = 0;
00154
00155 if(mon_runs>0) {
00156 for (int ii=0 ; ii<mon_run_vec.size(); ii++) cout << "here is the run number: "<< mon_run_vec[ii].getRunIOV().getRunNumber() << endl;
00157
00158
00159 int run=0;
00160 cout <<" retrieve the data for a given run"<< endl;
00161 cout << "here is the run number: "<< mon_run_vec[run].getRunIOV().getRunNumber() << endl;
00162 iovId = mon_run_vec[run].getID();
00163
00164 fetchDataSet(&dataset, &mon_run_vec[run]) ;
00165 }
00166 return iovId ;
00167 }
00168
00169
00170 int EcalTPGDBApp::writeToConfDB_TPGSliding(const map<EcalLogicID, FEConfigSlidingDat> & sliset, int iovId, string tag)
00171 {
00172 cout << "*****************************************" << endl;
00173 cout << "************Inserting SLIDING************" << endl;
00174 cout << "*****************************************" << endl;
00175 int result=0;
00176
00177 FEConfigSlidingInfo fe_info ;
00178 fe_info.setIOVId(iovId);
00179 fe_info.setConfigTag(tag);
00180 insertConfigSet(&fe_info);
00181
00182
00183
00184
00185
00186 insertDataArraySet(&sliset, &fe_info);
00187
00188 result=fe_info.getId();
00189
00190 cout << "*****************************************" << endl;
00191 cout << "************SLI done*********************" << endl;
00192 cout << "*****************************************" << endl;
00193 return result;
00194
00195 }
00196
00197 int EcalTPGDBApp::writeToConfDB_TPGLUT(const map<EcalLogicID, FEConfigLUTGroupDat> & lutgroupset,
00198 const map<EcalLogicID, FEConfigLUTDat> & lutset, int iovId, string tag)
00199 {
00200 cout << "*****************************************" << endl;
00201 cout << "************Inserting LUT************" << endl;
00202 cout << "*****************************************" << endl;
00203 int result=0;
00204
00205 FEConfigLUTInfo fe_lut_info ;
00206 fe_lut_info.setNumberOfGroups(iovId);
00207 fe_lut_info.setConfigTag(tag);
00208 insertConfigSet(&fe_lut_info);
00209
00210
00211
00212
00213
00214 insertDataArraySet(&lutgroupset, &fe_lut_info);
00215
00216 insertDataArraySet(&lutset, &fe_lut_info);
00217
00218 result=fe_lut_info.getId();
00219
00220 cout << "*****************************************" << endl;
00221 cout << "************LUT done*********************" << endl;
00222 cout << "*****************************************" << endl;
00223 return result;
00224
00225 }
00226
00227 int EcalTPGDBApp::writeToConfDB_TPGWeight(const map<EcalLogicID, FEConfigWeightGroupDat> & lutgroupset,
00228 const map<EcalLogicID, FEConfigWeightDat> & lutset, int ngr, string tag)
00229 {
00230 cout << "*****************************************" << endl;
00231 cout << "************Inserting weights************" << endl;
00232 cout << "*****************************************" << endl;
00233
00234 int result=0;
00235
00236 FEConfigWeightInfo fe_wei_info ;
00237 fe_wei_info.setNumberOfGroups(5);
00238 fe_wei_info.setConfigTag(tag);
00239 insertConfigSet(&fe_wei_info);
00240
00241
00242
00243
00244
00245 insertDataArraySet(&lutgroupset, &fe_wei_info);
00246
00247 insertDataArraySet(&lutset, &fe_wei_info);
00248
00249 result=fe_wei_info.getId();
00250
00251 cout << "*****************************************" << endl;
00252 cout << "************WEIGHT done******************" << endl;
00253 cout << "*****************************************" << endl;
00254 return result;
00255
00256
00257 }
00258
00259
00260 int EcalTPGDBApp::writeToConfDB_TPGFgr(const map<EcalLogicID, FEConfigFgrGroupDat> & fgrgroupset,
00261 const map<EcalLogicID, FEConfigFgrDat> & fgrset, int iovId, string tag)
00262 {
00263 cout << "*****************************************" << endl;
00264 cout << "************Inserting Fgr************" << endl;
00265 cout << "*****************************************" << endl;
00266 int result=0;
00267
00268 FEConfigFgrInfo fe_fgr_info ;
00269 fe_fgr_info.setNumberOfGroups(iovId);
00270 fe_fgr_info.setConfigTag(tag);
00271 insertConfigSet(&fe_fgr_info);
00272
00273
00274
00275
00276
00277 insertDataArraySet(&fgrgroupset, &fe_fgr_info);
00278
00279 insertDataArraySet(&fgrset, &fe_fgr_info);
00280
00281 result=fe_fgr_info.getId();
00282
00283 cout << "*****************************************" << endl;
00284 cout << "************Fgr done*********************" << endl;
00285 cout << "*****************************************" << endl;
00286 return result;
00287
00288 }
00289
00290
00291
00292 void EcalTPGDBApp::printTag( const RunTag* tag) const
00293 {
00294 cout << endl;
00295 cout << "=============RunTag:" << endl;
00296 cout << "GeneralTag: " << tag->getGeneralTag() << endl;
00297 cout << "Location: " << tag->getLocationDef().getLocation() << endl;
00298 cout << "Run Type: " << tag->getRunTypeDef().getRunType() << endl;
00299 cout << "====================" << endl;
00300 }
00301
00302 void EcalTPGDBApp::printIOV( const RunIOV* iov) const
00303 {
00304 cout << endl;
00305 cout << "=============RunIOV:" << endl;
00306 RunTag tag = iov->getRunTag();
00307 printTag(&tag);
00308 cout << "Run Number: " << iov->getRunNumber() << endl;
00309 cout << "Run Start: " << iov->getRunStart().str() << endl;
00310 cout << "Run End: " << iov->getRunEnd().str() << endl;
00311 cout << "====================" << endl;
00312 }
00313
00314