CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CalibCalorimetry/EcalTPGTools/plugins/EcalTPGDBApp.cc

Go to the documentation of this file.
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   // Insert the dataset, identifying by iov
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   // Insert the dataset, identifying by iov
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   // now we do something else 
00104   // this is an example for reading the pedestals 
00105   // for a given config iconf_req 
00106 
00107   // FC alternatively a config set can be retrieved by the tag and version
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   for (CIfeped p = dataset_ped.begin(); p != dataset_ped.end(); p++) {
00126     ecid_xt = p->first;
00127     rd_ped  = p->second;
00128     //int sm_num=ecid_xt.getID1();
00129     ecid_xt.getID2();
00130     rd_ped.getPedMeanG12();
00131     rd_ped.getPedMeanG6();
00132     rd_ped.getPedMeanG1();
00133   }
00134   
00135   cout << "*****************************************" << endl;
00136   cout << "test read done"<<iconf_req  << endl;
00137   cout << "*****************************************" << endl;
00138   
00139 }
00140 
00141 
00142 int EcalTPGDBApp::readFromCondDB_Pedestals(map<EcalLogicID, MonPedestalsDat> & dataset, int runNb) {
00143 
00144 
00145   int iovId = 0 ;
00146   
00147   cout << "Retrieving run list from DB from run nb ... "<< runNb << endl;
00148   RunTag  my_runtag;
00149   LocationDef my_locdef;
00150   RunTypeDef my_rundef;
00151   my_locdef.setLocation("P5_Co");
00152   my_rundef.setRunType("PEDESTAL");
00153   my_runtag.setLocationDef(my_locdef);
00154   my_runtag.setRunTypeDef(my_rundef);
00155   my_runtag.setGeneralTag("LOCAL");
00156   
00157   // here we retrieve the Monitoring results
00158   MonVersionDef monverdef;
00159   monverdef.setMonitoringVersion("test01");
00160   MonRunTag montag;
00161   montag.setMonVersionDef(monverdef);
00162   montag.setGeneralTag("CMSSW");
00163   
00164   MonRunList mon_list;
00165   mon_list.setMonRunTag(montag);
00166   mon_list.setRunTag(my_runtag);
00167 
00168   std::cout<<"we are in read ped from condDB and runNb is "<< runNb<<endl;
00169 
00170   mon_list = fetchMonRunListLastNRuns(my_runtag, montag, runNb , 10 );
00171 
00172   std::cout<<"we are in read ped from condDB"<<endl;
00173 
00174   std::vector<MonRunIOV> mon_run_vec =  mon_list.getRuns();
00175   cout <<"number of ped runs is : "<< mon_run_vec.size()<< endl;
00176   int mon_runs = mon_run_vec.size();  
00177   //int sm_num = 0;  
00178 
00179   if(mon_runs>0) {
00180     for (int ii=0 ; ii<(int)mon_run_vec.size(); ii++) cout << "here is the run number: "<< mon_run_vec[ii].getRunIOV().getRunNumber() << endl;
00181     
00182     // for the first run of the list we retrieve the pedestals
00183     int run=0;
00184     cout <<" retrieve the data for a given run"<< endl;
00185     cout << "here is the run number: "<< mon_run_vec[run].getRunIOV().getRunNumber() << endl;
00186     iovId = mon_run_vec[run].getID();
00187     
00188     fetchDataSet(&dataset, &mon_run_vec[run]) ;   
00189   }
00190   return iovId ;
00191 }
00192 
00193 
00194 int EcalTPGDBApp::writeToConfDB_TPGSliding(const  map<EcalLogicID, FEConfigSlidingDat> & sliset, int iovId, string tag) 
00195 {
00196   cout << "*****************************************" << endl;
00197   cout << "************Inserting SLIDING************" << endl;
00198   cout << "*****************************************" << endl;
00199   int result=0; 
00200 
00201   FEConfigSlidingInfo fe_info ;
00202   fe_info.setIOVId(iovId); 
00203   fe_info.setConfigTag(tag);
00204   insertConfigSet(&fe_info);
00205   
00206   //  Tm tdb = fe_lut_info.getDBTime();
00207   //tdb.dumpTm();
00208   
00209   // Insert the dataset
00210   insertDataArraySet(&sliset, &fe_info);
00211 
00212   result=fe_info.getId();
00213 
00214   cout << "*****************************************" << endl;
00215   cout << "************SLI done*********************" << endl;
00216   cout << "*****************************************" << endl;
00217   return result;
00218 
00219 }
00220 
00221 
00222 int EcalTPGDBApp::writeToConfDB_TPGLUT(const  map<EcalLogicID, FEConfigLUTGroupDat> & lutgroupset,
00223                                         const  map<EcalLogicID, FEConfigLUTDat> & lutset, 
00224                                        const  map<EcalLogicID, FEConfigLUTParamDat> & lutparamset,int iovId, string tag) 
00225 {
00226   cout << "*****************************************" << endl;
00227   cout << "************Inserting LUT************" << endl;
00228   cout << "*****************************************" << endl;
00229   int result=0; 
00230 
00231   FEConfigLUTInfo fe_lut_info ;
00232   fe_lut_info.setNumberOfGroups(iovId); 
00233   fe_lut_info.setConfigTag(tag);
00234   insertConfigSet(&fe_lut_info);
00235   
00236   //  Tm tdb = fe_lut_info.getDBTime();
00237   //tdb.dumpTm();
00238   
00239   // Insert the dataset
00240   insertDataArraySet(&lutgroupset, &fe_lut_info);
00241   // Insert the dataset
00242   insertDataArraySet(&lutset, &fe_lut_info);
00243   // insert the parameters
00244   insertDataArraySet(&lutparamset, &fe_lut_info);
00245   
00246   result=fe_lut_info.getId();
00247 
00248   cout << "*****************************************" << endl;
00249   cout << "************LUT done*********************" << endl;
00250   cout << "*****************************************" << endl;
00251   return result;
00252 
00253 }
00254 
00255 int EcalTPGDBApp::writeToConfDB_TPGWeight(const  map<EcalLogicID, FEConfigWeightGroupDat> & lutgroupset,
00256                                         const  map<EcalLogicID, FEConfigWeightDat> & lutset, int ngr, string tag) 
00257 {  
00258   cout << "*****************************************" << endl;
00259   cout << "************Inserting weights************" << endl;
00260   cout << "*****************************************" << endl;
00261   
00262   int result=0; 
00263 
00264   FEConfigWeightInfo fe_wei_info ;
00265   fe_wei_info.setNumberOfGroups(5); // this eventually refers to some other table 
00266   fe_wei_info.setConfigTag(tag);
00267   insertConfigSet(&fe_wei_info);
00268   
00269   //  Tm tdb = fe_lut_info.getDBTime();
00270   //tdb.dumpTm();
00271   
00272   // Insert the dataset
00273   insertDataArraySet(&lutgroupset, &fe_wei_info);
00274   // Insert the dataset
00275   insertDataArraySet(&lutset, &fe_wei_info);
00276   
00277   result=fe_wei_info.getId();
00278 
00279   cout << "*****************************************" << endl;
00280   cout << "************WEIGHT done******************" << endl;
00281   cout << "*****************************************" << endl;
00282   return result;
00283 
00284   
00285 }
00286 
00287 
00288 int EcalTPGDBApp::writeToConfDB_TPGFgr(const  map<EcalLogicID, FEConfigFgrGroupDat> & fgrgroupset,
00289                                        const  map<EcalLogicID, FEConfigFgrDat> & fgrset,  
00290                                        const  map<EcalLogicID, FEConfigFgrParamDat> & fgrparamset,
00291                                        const  map<EcalLogicID, FEConfigFgrEETowerDat> & dataset3, 
00292                                        const  map<EcalLogicID, FEConfigFgrEEStripDat> & dataset4,
00293                                        int iovId, string tag) 
00294 {
00295   cout << "*****************************************" << endl;
00296   cout << "************Inserting Fgr************" << endl;
00297   cout << "*****************************************" << endl;
00298   int result=0; 
00299 
00300   FEConfigFgrInfo fe_fgr_info ;
00301   fe_fgr_info.setNumberOfGroups(iovId); // this eventually refers to some other table 
00302   fe_fgr_info.setConfigTag(tag);
00303   insertConfigSet(&fe_fgr_info);
00304   
00305   //  Tm tdb = fe_fgr_info.getDBTime();
00306   //tdb.dumpTm();
00307   
00308   // Insert the dataset
00309   insertDataArraySet(&fgrgroupset, &fe_fgr_info);
00310   // Insert the dataset
00311   insertDataArraySet(&fgrset, &fe_fgr_info);
00312   // Insert the parameters
00313   insertDataArraySet(&fgrparamset, &fe_fgr_info);
00314   // Insert the parameters
00315   insertDataArraySet(&dataset3, &fe_fgr_info);
00316   // Insert the parameters
00317   insertDataArraySet(&dataset4, &fe_fgr_info);
00318   
00319   result=fe_fgr_info.getId();
00320 
00321   cout << "*****************************************" << endl;
00322   cout << "************Fgr done*********************" << endl;
00323   cout << "*****************************************" << endl;
00324   return result;
00325 
00326 }
00327 
00328 int EcalTPGDBApp::writeToConfDB_Spike(const  map<EcalLogicID, FEConfigSpikeDat> & spikegroupset,
00329                                        string tag) 
00330 {
00331   cout << "*****************************************" << endl;
00332   cout << "************Inserting Spike************" << endl;
00333   cout << "*****************************************" << endl;
00334   int result=0; 
00335 
00336   FEConfigSpikeInfo fe_spike_info ;
00337   fe_spike_info.setConfigTag(tag);
00338   insertConfigSet(&fe_spike_info);
00339   
00340   //  Tm tdb = fe_fgr_info.getDBTime();
00341   //tdb.dumpTm();
00342   
00343   // Insert the dataset
00344   insertDataArraySet(&spikegroupset, &fe_spike_info);
00345   
00346   result=fe_spike_info.getId();
00347 
00348   cout << "*****************************************" << endl;
00349   cout << "************Spike done*******************" << endl;
00350   cout << "*****************************************" << endl;
00351   return result;
00352 
00353 }
00354 
00355 int EcalTPGDBApp::writeToConfDB_Delay(const  map<EcalLogicID, FEConfigTimingDat> & timegroupset,
00356                                        string tag) 
00357 {
00358   cout << "*****************************************" << endl;
00359   cout << "************Inserting Delays************" << endl;
00360   cout << "*****************************************" << endl;
00361   int result=0; 
00362 
00363   FEConfigTimingInfo fe_time_info ;
00364   fe_time_info.setConfigTag(tag);
00365   insertConfigSet(&fe_time_info);
00366   
00367   //  Tm tdb = fe_fgr_info.getDBTime();
00368   //tdb.dumpTm();
00369   
00370   // Insert the dataset
00371   insertDataArraySet(&timegroupset, &fe_time_info);
00372   
00373   result=fe_time_info.getId();
00374 
00375   cout << "*****************************************" << endl;
00376   cout << "************Delays done******************" << endl;
00377   cout << "*****************************************" << endl;
00378   return result;
00379 
00380 }
00381 
00382 
00383 
00384 void EcalTPGDBApp::printTag( const RunTag* tag) const
00385 {
00386   cout << endl;
00387   cout << "=============RunTag:" << endl;
00388   cout << "GeneralTag:         " << tag->getGeneralTag() << endl;
00389   cout << "Location:           " << tag->getLocationDef().getLocation() << endl;
00390   cout << "Run Type:           " << tag->getRunTypeDef().getRunType() << endl;
00391   cout << "====================" << endl;
00392 }
00393 
00394 void EcalTPGDBApp::printIOV( const RunIOV* iov) const
00395 {
00396   cout << endl;
00397   cout << "=============RunIOV:" << endl;
00398   RunTag tag = iov->getRunTag();
00399   printTag(&tag);
00400   cout << "Run Number:         " << iov->getRunNumber() << endl;
00401   cout << "Run Start:          " << iov->getRunStart().str() << endl;
00402   cout << "Run End:            " << iov->getRunEnd().str() << endl;
00403   cout << "====================" << endl;
00404 }
00405 
00406