CMS 3D CMS Logo

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