CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTPGDBApp.cc
Go to the documentation of this file.
2 
3 #include <vector>
4 #include <time.h>
5 
6 using namespace std;
7 using namespace oracle::occi;
8 
9 EcalTPGDBApp::EcalTPGDBApp(std::string host, std::string sid, std::string user, std::string pass, int port)
10  : EcalCondDBInterface( host, sid, user, pass, port )
11 {}
12 
13 EcalTPGDBApp::EcalTPGDBApp(std::string sid, std::string user, std::string pass)
14  : EcalCondDBInterface( sid, user, pass )
15 {}
16 
17 int EcalTPGDBApp::writeToConfDB_TPGPedestals(const std::map<EcalLogicID, FEConfigPedDat> & pedset, int iovId, std::string tag) {
18 
19  int result=0;
20 
21  std::cout << "*****************************************" << std::endl;
22  std::cout << "******** Inserting Peds in conf-OMDS*****" << std::endl;
23  std::cout << "*****************************************" << std::endl;
24 
25  std::cout << "creating fe record " <<std::endl;
26  FEConfigPedInfo fe_ped_info ;
27  fe_ped_info.setIOVId(iovId) ;
28  fe_ped_info.setConfigTag(tag) ;
29  insertConfigSet(&fe_ped_info) ;
30  result = fe_ped_info.getID() ;
31 
32 
33  // Insert the dataset, identifying by iov
34  std::cout << "*********about to insert peds *********" << std::endl;
35  std::cout << " map size = "<<pedset.size()<<std::endl ;
36  insertDataArraySet(&pedset, &fe_ped_info);
37  std::cout << "*********Done peds *********" << std::endl;
38 
39  return result;
40 }
41 
42 int EcalTPGDBApp::writeToConfDB_TPGLinearCoef(const std::map<EcalLogicID, FEConfigLinDat> & linset,
43  const std::map<EcalLogicID, FEConfigLinParamDat> & linparamset, int iovId, std::string tag) {
44 
45  int result=0;
46 
47  std::cout << "*********************************************" << std::endl;
48  std::cout << "**Inserting Linarization coeff in conf-OMDS**" << std::endl;
49  std::cout << "*********************************************" << std::endl;
50 
51  std::cout << "creating fe record " <<std::endl;
52  FEConfigLinInfo fe_lin_info ;
53  fe_lin_info.setIOVId(iovId) ;
54  fe_lin_info.setConfigTag(tag) ;
55  insertConfigSet(&fe_lin_info) ;
56  result = fe_lin_info.getID() ;
57 
58  // Insert the dataset, identifying by iov
59  std::cout << "*********about to insert linearization coeff *********" << std::endl;
60  std::cout << " map size = "<<linset.size()<<std::endl ;
61  insertDataArraySet(&linset, &fe_lin_info);
62  insertDataArraySet(&linparamset, &fe_lin_info);
63  std::cout << "*********Done lineraization coeff *********" << std::endl;
64 
65  return result;
66 }
67 
68 int EcalTPGDBApp::writeToConfDB_TPGMain(int ped, int lin, int lut, int fgr, int sli, int wei, int bxt, int btt, std::string tag, int ver) {
69 
70  int result=0;
71 
72  std::cout << "*********************************************" << std::endl;
73  std::cout << "**Inserting Main FE table in conf-OMDS **" << std::endl;
74  std::cout << "*********************************************" << std::endl;
75 
76  std::cout << "creating fe record " <<std::endl;
77 
78  FEConfigMainInfo fe_main ;
79  fe_main.setPedId(ped) ;
80  fe_main.setLinId(lin) ;
81  fe_main.setLUTId(lut) ;
82  fe_main.setFgrId(fgr) ;
83  fe_main.setSliId(sli) ;
84  fe_main.setWeiId(wei) ;
85  fe_main.setBxtId(bxt) ;
86  fe_main.setBttId(btt) ;
87  fe_main.setConfigTag(tag) ;
88  fe_main.setVersion(ver) ;
89 
90  insertConfigSet(&fe_main) ;
91  result = fe_main.getId() ;
92 
93  std::cout << "*********Done Main *********" << std::endl;
94 
95  return result;
96 }
97 
98 
100  // now we do something else
101  // this is an example for reading the pedestals
102  // for a given config iconf_req
103 
104  // FC alternatively a config set can be retrieved by the tag and version
105 
106  std::cout << "*****************************************" << std::endl;
107  std::cout << "test readinf fe_ped with id="<<iconf_req << std::endl;
108  std::cout << "*****************************************" << std::endl;
109 
110  FEConfigPedInfo fe_ped_info;
111  fe_ped_info.setId(iconf_req);
112 
113  fetchConfigSet(&fe_ped_info);
114 
115  std::map<EcalLogicID, FEConfigPedDat> dataset_ped;
116  fetchDataSet(&dataset_ped, &fe_ped_info);
117 
118  typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
119  EcalLogicID ecid_xt;
120  FEConfigPedDat rd_ped;
121 
122  float ped_m12[61200];
123  float ped_m6[61200];
124  float ped_m1[61200];
125  for (int i=0; i<61200; i++){
126  ped_m12[i]=0;
127  ped_m6[i]=0;
128  ped_m1[i]=0;
129  }
130 
131  for (CIfeped p = dataset_ped.begin(); p != dataset_ped.end(); p++) {
132  ecid_xt = p->first;
133  rd_ped = p->second;
134  //int sm_num=ecid_xt.getID1();
135  int xt_num=ecid_xt.getID2();
136  ped_m12[xt_num]=rd_ped.getPedMeanG12();
137  ped_m6[xt_num]=rd_ped.getPedMeanG6();
138  ped_m1[xt_num]=rd_ped.getPedMeanG1();
139  }
140 
141  std::cout << "*****************************************" << std::endl;
142  std::cout << "test read done"<<iconf_req << std::endl;
143  std::cout << "*****************************************" << std::endl;
144 
145 }
146 
147 
148 int EcalTPGDBApp::readFromCondDB_Pedestals(std::map<EcalLogicID, MonPedestalsDat> & dataset, int runNb) {
149 
150 
151  int iovId = 0 ;
152 
153  std::cout << "Retrieving run list from DB from run nb ... "<< runNb << std::endl;
154  RunTag my_runtag;
155  LocationDef my_locdef;
156  RunTypeDef my_rundef;
157  my_locdef.setLocation("P5_Co");
158  my_rundef.setRunType("PEDESTAL");
159  my_runtag.setLocationDef(my_locdef);
160  my_runtag.setRunTypeDef(my_rundef);
161  my_runtag.setGeneralTag("LOCAL");
162 
163  // here we retrieve the Monitoring results
164  MonVersionDef monverdef;
165  monverdef.setMonitoringVersion("test01");
166  MonRunTag montag;
167  montag.setMonVersionDef(monverdef);
168  montag.setGeneralTag("CMSSW");
169 
170  MonRunList mon_list;
171  mon_list.setMonRunTag(montag);
172  mon_list.setRunTag(my_runtag);
173 
174  std::cout<<"we are in read ped from condDB and runNb is "<< runNb<<std::endl;
175 
176  mon_list = fetchMonRunListLastNRuns(my_runtag, montag, runNb , 10 );
177 
178  std::cout<<"we are in read ped from condDB"<<std::endl;
179 
180  std::vector<MonRunIOV> mon_run_vec = mon_list.getRuns();
181  std::cout <<"number of ped runs is : "<< mon_run_vec.size()<< std::endl;
182  int mon_runs = mon_run_vec.size();
183  //int sm_num = 0;
184 
185  if(mon_runs>0) {
186  for (int ii=0 ; ii<(int)mon_run_vec.size(); ii++) std::cout << "here is the run number: "<< mon_run_vec[ii].getRunIOV().getRunNumber() << std::endl;
187 
188  // for the first run of the list we retrieve the pedestals
189  int run=0;
190  std::cout <<" retrieve the data for a given run"<< std::endl;
191  std::cout << "here is the run number: "<< mon_run_vec[run].getRunIOV().getRunNumber() << std::endl;
192  iovId = mon_run_vec[run].getID();
193 
194  fetchDataSet(&dataset, &mon_run_vec[run]) ;
195  }
196  return iovId ;
197 }
198 
199 
200 int EcalTPGDBApp::writeToConfDB_TPGSliding(const std::map<EcalLogicID, FEConfigSlidingDat> & sliset, int iovId, std::string tag)
201 {
202  std::cout << "*****************************************" << std::endl;
203  std::cout << "************Inserting SLIDING************" << std::endl;
204  std::cout << "*****************************************" << std::endl;
205  int result=0;
206 
207  FEConfigSlidingInfo fe_info ;
208  fe_info.setIOVId(iovId);
209  fe_info.setConfigTag(tag);
210  insertConfigSet(&fe_info);
211 
212  // Tm tdb = fe_lut_info.getDBTime();
213  //tdb.dumpTm();
214 
215  // Insert the dataset
216  insertDataArraySet(&sliset, &fe_info);
217 
218  result=fe_info.getId();
219 
220  std::cout << "*****************************************" << std::endl;
221  std::cout << "************SLI done*********************" << std::endl;
222  std::cout << "*****************************************" << std::endl;
223  return result;
224 
225 }
226 
227 int EcalTPGDBApp::writeToConfDB_TPGLUT(const std::map<EcalLogicID, FEConfigLUTGroupDat> & lutgroupset,
228  const std::map<EcalLogicID, FEConfigLUTDat> & lutset,
229  const std::map<EcalLogicID, FEConfigLUTParamDat> & lutparamset,int iovId, std::string tag)
230 {
231  std::cout << "*****************************************" << std::endl;
232  std::cout << "************Inserting LUT************" << std::endl;
233  std::cout << "*****************************************" << std::endl;
234  int result=0;
235 
236  FEConfigLUTInfo fe_lut_info ;
237  fe_lut_info.setNumberOfGroups(iovId);
238  fe_lut_info.setConfigTag(tag);
239  insertConfigSet(&fe_lut_info);
240 
241  // Tm tdb = fe_lut_info.getDBTime();
242  //tdb.dumpTm();
243 
244  // Insert the dataset
245  insertDataArraySet(&lutgroupset, &fe_lut_info);
246  // Insert the dataset
247  insertDataArraySet(&lutset, &fe_lut_info);
248  // insert the parameters
249  insertDataArraySet(&lutparamset, &fe_lut_info);
250 
251  result=fe_lut_info.getId();
252 
253  std::cout << "*****************************************" << std::endl;
254  std::cout << "************LUT done*********************" << std::endl;
255  std::cout << "*****************************************" << std::endl;
256  return result;
257 
258 }
259 
260 int EcalTPGDBApp::writeToConfDB_TPGWeight(const std::map<EcalLogicID, FEConfigWeightGroupDat> & lutgroupset,
261  const std::map<EcalLogicID, FEConfigWeightDat> & lutset, int ngr, std::string tag)
262 {
263  std::cout << "*****************************************" << std::endl;
264  std::cout << "************Inserting weights************" << std::endl;
265  std::cout << "*****************************************" << std::endl;
266 
267  int result=0;
268 
269  FEConfigWeightInfo fe_wei_info ;
270  fe_wei_info.setNumberOfGroups(5); // this eventually refers to some other table
271  fe_wei_info.setConfigTag(tag);
272  insertConfigSet(&fe_wei_info);
273 
274  // Tm tdb = fe_lut_info.getDBTime();
275  //tdb.dumpTm();
276 
277  // Insert the dataset
278  insertDataArraySet(&lutgroupset, &fe_wei_info);
279  // Insert the dataset
280  insertDataArraySet(&lutset, &fe_wei_info);
281 
282  result=fe_wei_info.getId();
283 
284  std::cout << "*****************************************" << std::endl;
285  std::cout << "************WEIGHT done******************" << std::endl;
286  std::cout << "*****************************************" << std::endl;
287  return result;
288 
289 
290 }
291 
292 
293 int EcalTPGDBApp::writeToConfDB_TPGFgr(const std::map<EcalLogicID, FEConfigFgrGroupDat> & fgrgroupset,
294  const std::map<EcalLogicID, FEConfigFgrDat> & fgrset,
295  const std::map<EcalLogicID, FEConfigFgrParamDat> & fgrparamset,
296  const std::map<EcalLogicID, FEConfigFgrEETowerDat> & dataset3,
297  const std::map<EcalLogicID, FEConfigFgrEEStripDat> & dataset4,
298  int iovId, std::string tag)
299 {
300  std::cout << "*****************************************" << std::endl;
301  std::cout << "************Inserting Fgr************" << std::endl;
302  std::cout << "*****************************************" << std::endl;
303  int result=0;
304 
305  FEConfigFgrInfo fe_fgr_info ;
306  fe_fgr_info.setNumberOfGroups(iovId); // this eventually refers to some other table
307  fe_fgr_info.setConfigTag(tag);
308  insertConfigSet(&fe_fgr_info);
309 
310  // Tm tdb = fe_fgr_info.getDBTime();
311  //tdb.dumpTm();
312 
313  // Insert the dataset
314  insertDataArraySet(&fgrgroupset, &fe_fgr_info);
315  // Insert the dataset
316  insertDataArraySet(&fgrset, &fe_fgr_info);
317  // Insert the parameters
318  insertDataArraySet(&fgrparamset, &fe_fgr_info);
319  // Insert the parameters
320  insertDataArraySet(&dataset3, &fe_fgr_info);
321  // Insert the parameters
322  insertDataArraySet(&dataset4, &fe_fgr_info);
323 
324  result=fe_fgr_info.getId();
325 
326  std::cout << "*****************************************" << std::endl;
327  std::cout << "************Fgr done*********************" << std::endl;
328  std::cout << "*****************************************" << std::endl;
329  return result;
330 
331 }
332 
333 
334 
335 void EcalTPGDBApp::printTag( const RunTag* tag) const
336 {
337  std::cout << std::endl;
338  std::cout << "=============RunTag:" << std::endl;
339  std::cout << "GeneralTag: " << tag->getGeneralTag() << std::endl;
340  std::cout << "Location: " << tag->getLocationDef().getLocation() << std::endl;
341  std::cout << "Run Type: " << tag->getRunTypeDef().getRunType() << std::endl;
342  std::cout << "====================" << std::endl;
343 }
344 
345 void EcalTPGDBApp::printIOV( const RunIOV* iov) const
346 {
347  std::cout << std::endl;
348  std::cout << "=============RunIOV:" << std::endl;
349  RunTag tag = iov->getRunTag();
350  printTag(&tag);
351  std::cout << "Run Number: " << iov->getRunNumber() << std::endl;
352  std::cout << "Run Start: " << iov->getRunStart().str() << std::endl;
353  std::cout << "Run End: " << iov->getRunEnd().str() << std::endl;
354  std::cout << "====================" << std::endl;
355 }
356 
357 
int writeToConfDB_TPGLinearCoef(const std::map< EcalLogicID, FEConfigLinDat > &linset, const std::map< EcalLogicID, FEConfigLinParamDat > &linparamset, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:42
int i
Definition: DBlmapReader.cc:9
void printIOV(const RunIOV *iov) const
void setLocationDef(const LocationDef locDef)
Definition: RunTag.cc:53
void setLinId(int x)
LocationDef getLocationDef() const
Definition: RunTag.cc:46
int getId() const
float getPedMeanG1() const
Definition: RunTag.h:13
void insertConfigSet(ICONF *iconf)
EcalTPGDBApp(std::string host, std::string sid, std::string user, std::string pass, int port)
Definition: EcalTPGDBApp.cc:9
std::string getGeneralTag() const
Definition: RunTag.cc:27
void setBxtId(int x)
std::string getRunType() const
Definition: RunTypeDef.cc:26
void setIOVId(int iov_id)
int writeToConfDB_TPGSliding(const std::map< EcalLogicID, FEConfigSlidingDat > &sliset, int iovId, std::string tag)
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:33
void setVersion(int id)
int writeToConfDB_TPGMain(int ped, int lin, int lut, int fgr, int sli, int wei, int bxt, int btt, std::string tag, int ver)
Definition: EcalTPGDBApp.cc:68
int port
Definition: query.py:115
void setRunTag(RunTag tag)
Definition: MonRunList.cc:23
int getID2() const
Definition: EcalLogicID.cc:52
RunTag getRunTag() const
Definition: RunIOV.cc:96
Tm getRunStart() const
Definition: RunIOV.cc:62
void setLUTId(int x)
tuple iov
Definition: o2o.py:307
void setNumberOfGroups(int iov_id)
void setFgrId(int x)
void setNumberOfGroups(int iov_id)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
MonRunList fetchMonRunListLastNRuns(RunTag tag, MonRunTag monruntag, int max_run, int n_runs)
void setRunTypeDef(const RunTypeDef runTypeDef)
Definition: RunTag.cc:70
void setIOVId(int iov_id)
tuple result
Definition: query.py:137
std::string getLocation() const
Definition: LocationDef.cc:26
void setMonVersionDef(MonVersionDef ver)
Definition: MonRunTag.cc:49
int readFromCondDB_Pedestals(std::map< EcalLogicID, MonPedestalsDat > &pedset, int runNb)
float getPedMeanG12() const
void setIOVId(int iov_id)
int getId() const
void setPedId(int x)
int getId() const
void setWeiId(int x)
string host
Definition: query.py:114
std::vector< MonRunIOV > getRuns()
Definition: MonRunList.cc:46
int writeToConfDB_TPGPedestals(const std::map< EcalLogicID, FEConfigPedDat > &pedset, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:17
RunTypeDef getRunTypeDef() const
Definition: RunTag.cc:63
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
void fetchConfigSet(ICONF *iconf)
Tm getRunEnd() const
Definition: RunIOV.cc:79
float getPedMeanG6() const
void setMonitoringVersion(std::string ver)
run_t getRunNumber() const
Definition: RunIOV.cc:45
void setConfigTag(std::string x)
Definition: IODConfig.h:31
std::string str() const
Definition: Tm.cc:82
void readFromConfDB_TPGPedestals(int iconf_req)
Definition: EcalTPGDBApp.cc:99
void setMonRunTag(MonRunTag tag)
Definition: MonRunList.cc:29
void setNumberOfGroups(int n)
int writeToConfDB_TPGLUT(const std::map< EcalLogicID, FEConfigLUTGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigLUTDat > &lutdat, const std::map< EcalLogicID, FEConfigLUTParamDat > &lutparamset, int iovId, std::string tag)
void setId(int id)
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov)
void setLocation(std::string loc)
Definition: LocationDef.cc:33
tuple cout
Definition: gather_cfg.py:41
int writeToConfDB_TPGFgr(const std::map< EcalLogicID, FEConfigFgrGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigFgrDat > &lutdat, const std::map< EcalLogicID, FEConfigFgrParamDat > &fgrparamset, const std::map< EcalLogicID, FEConfigFgrEETowerDat > &dataset3, const std::map< EcalLogicID, FEConfigFgrEEStripDat > &dataset4, int iovId, std::string tag)
void printTag(const RunTag *tag) const
int writeToConfDB_TPGWeight(const std::map< EcalLogicID, FEConfigWeightGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigWeightDat > &lutdat, int iovId, std::string tag)
void setSliId(int x)
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
Definition: RunIOV.h:13
void setBttId(int x)