CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalPedestalsHandler.cc
Go to the documentation of this file.
2 
5 
6 #include<iostream>
7 
9  : m_name(ps.getUntrackedParameter<std::string>("name","EcalPedestalsHandler")) {
10 
11  std::cout << "EcalPedestals Source handler constructor\n" << std::endl;
12  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
13  m_lastRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("lastRun").c_str()));
14  m_sid= ps.getParameter<std::string>("OnlineDBSID");
15  m_user= ps.getParameter<std::string>("OnlineDBUser");
16  m_pass= ps.getParameter<std::string>("OnlineDBPassword");
17  m_locationsource= ps.getParameter<std::string>("LocationSource");
18  m_location=ps.getParameter<std::string>("Location");
19  m_gentag=ps.getParameter<std::string>("GenTag");
20 
21  std::cout << m_sid<<"/"<<m_user<<"/"<<m_pass<<"/"<<m_location<<"/"<<m_gentag << std::endl;
22 
23 
24 }
25 
27 {
28 }
29 
30 
32 {
33 
34  std::cout << "------- Ecal - > getNewObjects\n";
35 
36  if(m_locationsource=="H2") {
37  getNewObjectsH2();
38  } else if (m_locationsource=="P5") {
39  getNewObjectsP5();
40  }
41 }
42 
43 
45  // true means all is standard and OK
46  bool result=true;
47  if(item->rms_x12 >3 || item->rms_x12<=0) result=false;
48  if(item->rms_x6 >2 || item->rms_x6<=0) result=false;
49  if(item->rms_x1 >1 || item->rms_x1<=0) result=false;
50  if(item->mean_x12>300 || item->mean_x12<=100) result=false;
51  if(item->mean_x1>300 || item->mean_x1<=100) result=false;
52  if(item->mean_x6>300 || item->mean_x6<=100) result=false;
53  return result;
54  }
55 
57 {
58 
59  std::ostringstream ss;
60  ss<<"ECAL ";
61 
62  unsigned int max_since=0;
63  max_since=static_cast<unsigned int>(tagInfo().lastInterval.first);
64  std::cout << "max_since : " << max_since << std::endl;
65  Ref ped_db = lastPayload();
66 
67  // we copy the last valid record to a temporary object peds
68  EcalPedestals* peds = new EcalPedestals();
69  std::cout << "retrieved last payload " << std::endl;
70 
71  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
72  if(iEta==0) continue;
73  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
74  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
75  if (EBDetId::validDetId(iEta,iPhi))
76  {
77 
78 
79  EBDetId ebdetid(iEta,iPhi,EBDetId::ETAPHIMODE);
80  EcalPedestals::const_iterator it =ped_db->find(ebdetid.rawId());
81 
82  EcalPedestals::Item aped = (*it);
83 
84 
85  // here I copy the last valid value in the peds object
87  item.mean_x1 = aped.mean_x1;
88  item.rms_x1 = aped.rms_x1;
89  item.mean_x6 = aped.mean_x6;
90  item.rms_x6 = aped.rms_x6;
91  item.mean_x12 = aped.mean_x12;
92  item.rms_x12 = aped.rms_x12;
93 
94  peds->insert(std::make_pair(ebdetid.rawId(),item));
95 
96  }
97  }
98  }
99 
100 
101  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
102  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
103  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
104  if (EEDetId::validDetId(iX,iY,1))
105  {
106  EEDetId eedetidpos(iX,iY,1);
107 
108  EcalPedestals::const_iterator it =ped_db->find(eedetidpos.rawId());
109  EcalPedestals::Item aped = (*it);
110 
111  // unsigned int hiee = eedetidpos.hashedIndex();
112  // EcalPedestals::Item aped= ped_db->endcap(hiee);
113 
114  // here I copy the last valid value in the peds object
115  EcalPedestals::Item item;
116  item.mean_x1 = aped.mean_x1;
117  item.rms_x1 = aped.rms_x1;
118  item.mean_x6 = aped.mean_x6;
119  item.rms_x6 = aped.rms_x6;
120  item.mean_x12 = aped.mean_x12;
121  item.rms_x12 = aped.rms_x12;
122  peds->insert(std::make_pair(eedetidpos.rawId(),item));
123 
124  }
125  if(EEDetId::validDetId(iX,iY,-1))
126  {
127  EEDetId eedetidneg(iX,iY,-1);
128 
129  EcalPedestals::const_iterator it =ped_db->find(eedetidneg.rawId());
130  EcalPedestals::Item aped = (*it);
131  // unsigned int hiee = eedetidneg.hashedIndex();
132  // EcalPedestals::Item aped= ped_db->endcap(hiee);
133 
134  // here I copy the last valid value in the peds object
135  EcalPedestals::Item item;
136  item.mean_x1 = aped.mean_x1;
137  item.rms_x1 = aped.rms_x1;
138  item.mean_x6 = aped.mean_x6;
139  item.rms_x6 = aped.rms_x6;
140  item.mean_x12 = aped.mean_x12;
141  item.rms_x12 = aped.rms_x12;
142  peds->insert(std::make_pair(eedetidneg.rawId(),item));
143 
144  }
145  }
146  }
147 
148  // here we retrieve all the runs after the last from online DB
149 
150  std::cout << "Retrieving run list from ONLINE DB ... " << std::endl;
151  econn = new EcalCondDBInterface( m_sid, m_user, m_pass );
152  std::cout << "Connection done" << std::endl;
153 
154  if (!econn)
155  {
156  std::cout << " Problem with OMDS: connection parameters " <<m_sid <<"/"<<m_user<<"/"<<m_pass<<std::endl;
157  throw cms::Exception("OMDS not available");
158  }
159 
160  // these are the online conditions DB classes
161  RunList my_runlist ;
162  RunTag my_runtag;
163  LocationDef my_locdef;
164  RunTypeDef my_rundef;
165 
166  my_locdef.setLocation(m_location);
167  my_rundef.setRunType("PEDESTAL");
168  my_runtag.setLocationDef(my_locdef);
169  my_runtag.setRunTypeDef(my_rundef);
170  my_runtag.setGeneralTag(m_gentag);
171 
172 
173  // here we retrieve the Monitoring run records
174 
175  MonVersionDef monverdef;
176  monverdef.setMonitoringVersion("test01");
177 
178  MonRunTag mon_tag;
179  // mon_tag.setGeneralTag("CMSSW");
180  mon_tag.setGeneralTag("CMSSW-offline-private");
181  mon_tag.setMonVersionDef(monverdef);
182  MonRunList mon_list;
183  mon_list.setMonRunTag(mon_tag);
184  mon_list.setRunTag(my_runtag);
185  // mon_list=econn->fetchMonRunList(my_runtag, mon_tag);
186  unsigned int min_run=0;
187  if(m_firstRun<max_since) {
188  min_run=max_since+1; // we have to add 1 to the last transferred one
189  } else {
190  min_run=m_firstRun;
191  }
192 
193  unsigned int max_run=m_lastRun;
194  mon_list=econn->fetchMonRunList(my_runtag, mon_tag,min_run,max_run );
195 
196  std::vector<MonRunIOV> mon_run_vec= mon_list.getRuns();
197  int mon_runs = mon_run_vec.size();
198  std::cout <<"number of Mon runs is : "<< mon_runs<< std::endl;
199 
200  if(mon_runs > 0){
201  int krmax = std::min(mon_runs, 30);
202  for(int kr = 0; kr < krmax; kr++){
203  std::cout << "-kr------: "<<kr<<std::endl;
204 
205 
206  unsigned int irun=static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
207 
208  std::cout << "retrieve the data for run number: "<< mon_run_vec[kr].getRunIOV().getRunNumber() << std::endl;
209 
210  if (mon_run_vec[kr].getSubRunNumber() <=1){
211 
212  // retrieve the data for a given run
213  RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
214 
215  // retrieve the pedestals from OMDS for this run
216  std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
217  econn->fetchDataSet(&dataset_mon, &mon_run_vec[kr]);
218  std::cout <<"OMDS record for run "<<irun <<" is made of "<< dataset_mon.size() << std::endl;
219  int nEB = 0, nEE = 0, nEBbad = 0, nEEbad =0;
220  typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
221  EcalLogicID ecid_xt;
222  MonPedestalsDat rd_ped;
223 
224 
225  // this to validate ...
226  int nbad=0;
227  for (CImon p = dataset_mon.begin(); p != dataset_mon.end(); p++) {
228  ecid_xt = p->first;
229  rd_ped = p->second;
230  int sm_num=ecid_xt.getID1();
231  int xt_num=ecid_xt.getID2();
232  int yt_num=ecid_xt.getID3();
233 
234  EcalPedestals::Item item;
235  item.mean_x1 =rd_ped.getPedMeanG1() ;
236  item.rms_x1 =rd_ped.getPedRMSG1();
237  item.mean_x6 =rd_ped.getPedMeanG6();
238  item.rms_x6 =rd_ped.getPedRMSG6() ;
239  item.mean_x12 =rd_ped.getPedMeanG12();
240  item.rms_x12 =rd_ped.getPedRMSG12();
241 
242  if(ecid_xt.getName()=="EB_crystal_number") {
243  nEB++;
244  if(!checkPedestal(&item) ) nEBbad++;
245  }
246  else {
247  nEE++;
248  if(!checkPedestal(&item) ) nEEbad++;
249  }
250 
251  // here we check and count how many bad channels we have
252 
253  if(!checkPedestal(&item) ){
254  nbad++;
255  if(nbad < 10) std::cout <<"BAD LIST: channel " << sm_num << "/" << xt_num << "/"<< yt_num
256  << "ped/rms "<<item.mean_x12<< "/"<< item.rms_x12 << std::endl;
257  }
258  }
259 
260  // ok or bad?
261  // a bad run is for more than 5% bad channels
262 
263  // if(nbad<(dataset_mon.size()*0.1)){
264  if(nbad<(dataset_mon.size()*0.05) && (nEB > 10200 || nEE > 2460)) {
265 
266  for (CImon p = dataset_mon.begin(); p != dataset_mon.end(); p++) {
267  ecid_xt = p->first;
268  rd_ped = p->second;
269  int sm_num=ecid_xt.getID1();
270  int xt_num=ecid_xt.getID2();
271  int yt_num=ecid_xt.getID3();
272 
273 
274  EcalPedestals::Item item;
275  item.mean_x1 =rd_ped.getPedMeanG1() ;
276  item.rms_x1 =rd_ped.getPedRMSG1();
277  item.mean_x6 =rd_ped.getPedMeanG6();
278  item.rms_x6 =rd_ped.getPedRMSG6() ;
279  item.mean_x12 =rd_ped.getPedMeanG12();
280  item.rms_x12 =rd_ped.getPedRMSG12();
281 
282 
283  if(ecid_xt.getName()=="EB_crystal_number") {
284  // Barrel channel
285  EBDetId ebdetid(sm_num,xt_num,EBDetId::SMCRYSTALMODE);
286 
287  // individual objects check
288  if(item.mean_x1==-1 || item.rms_x1 ==-1 || item.mean_x6==-1 ||
289  item.rms_x6==-1 || item.mean_x12==-1 || item.rms_x12==-1 ||
290  item.mean_x1==0 || item.rms_x1 ==0 || item.mean_x6==0 ||
291  item.rms_x6==0 || item.mean_x12==0 || item.rms_x12==0 ) {
292  // if one is bad we
293  // retrieve the old valid value
294  unsigned int hieb = ebdetid.hashedIndex();
295  EcalPedestals::Item previous_ped= peds->barrel(hieb);
296  if(item.mean_x1==-1 || item.mean_x1==0) item.mean_x1 =previous_ped.mean_x1;
297  if(item.rms_x1==-1 || item.rms_x1==0) item.rms_x1 =previous_ped.rms_x1;
298  if(item.mean_x6==-1 || item.mean_x6==0) item.mean_x6 =previous_ped.mean_x6;
299  if(item.rms_x6==-1 || item.rms_x6==0) item.rms_x6 =previous_ped.rms_x6;
300  if(item.mean_x12==-1 || item.mean_x12==0)item.mean_x12=previous_ped.mean_x12;
301  if(item.rms_x12==-1 || item.rms_x12==0) item.rms_x12 =previous_ped.rms_x12;
302  }
303 
304  // here we change in the peds object only the channels that are available in the online DB
305  // otherwise we keep the previous value
306 
307  peds->insert(std::make_pair(ebdetid.rawId(),item));
308  } else {
309  // Endcap channel
310  // in this case xt_num is x
311  // yt_num is y and sm_num is the side +/- 1
312  if(EEDetId::validDetId(xt_num,yt_num,sm_num)){
313  EEDetId eedetid(xt_num,yt_num,sm_num);
314 
315  // individual objects check
316  if(item.mean_x1==-1 || item.rms_x1 ==-1 || item.mean_x6==-1 ||
317  item.rms_x6==-1 || item.mean_x12==-1 || item.rms_x12==-1 ||
318  item.mean_x1==0 || item.rms_x1 ==0 || item.mean_x6==0 ||
319  item.rms_x6==0 || item.mean_x12==0 || item.rms_x12==0 ) {
320  // if one is bad we
321  // retrieve the old valid value
322  unsigned int hiee = eedetid.hashedIndex();
323  EcalPedestals::Item previous_ped= peds->endcap(hiee);
324  if(item.mean_x1==-1 || item.mean_x1==0) item.mean_x1 =previous_ped.mean_x1;
325  if(item.rms_x1==-1 || item.rms_x1==0) item.rms_x1 =previous_ped.rms_x1;
326  if(item.mean_x6==-1 || item.mean_x6==0) item.mean_x6 =previous_ped.mean_x6;
327  if(item.rms_x6==-1 || item.rms_x6==0) item.rms_x6 =previous_ped.rms_x6;
328  if(item.mean_x12==-1 || item.mean_x12==0)item.mean_x12=previous_ped.mean_x12;
329  if(item.rms_x12==-1 || item.rms_x12==0) item.rms_x12 =previous_ped.rms_x12;
330  }
331 
332  // here we change in the peds object only the channels that are available in the online DB
333  // otherwise we keep the previous value
334  peds->insert(std::make_pair(eedetid.rawId(),item));
335  }
336 
337  }
338 
339  }
340 
341  std::cout << "Generating popcon record for run " << irun << "..." << std::flush;
342 
343  // now I copy peds in pedtemp and I ship pedtemp to popcon
344  // if I use always the same peds I always overwrite
345  // so I really have to create new objects for each new run
346  // popcon deletes everything for me
347 
348  EcalPedestals* pedtemp = new EcalPedestals();
349 
350  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
351  if(iEta==0) continue;
352  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
353  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
354  if (EBDetId::validDetId(iEta,iPhi))
355  {
356  EBDetId ebdetid(iEta,iPhi);
357  unsigned int hiee = ebdetid.hashedIndex();
358  EcalPedestals::Item aped= peds->barrel(hiee);
359 
360  // here I copy the last valid value in the peds object
361  EcalPedestals::Item item;
362  item.mean_x1 = aped.mean_x1;
363  item.rms_x1 = aped.rms_x1;
364  item.mean_x6 = aped.mean_x6;
365  item.rms_x6 = aped.rms_x6;
366  item.mean_x12 = aped.mean_x12;
367  item.rms_x12 = aped.rms_x12;
368  // here I copy the last valid value in the pedtemp object
369  pedtemp->insert(std::make_pair(ebdetid.rawId(),item));
370  if((iEta==-1 || iEta==1) && iPhi==20){
371  float x=aped.mean_x12 ;
372  std::cout<< "channel:" <<iEta<<"/"<<iPhi<< "/" << hiee << " ped mean 12="<< x << std::endl;
373  }
374  }
375  }
376  }
377  // endcaps
378  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
379  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
380  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
381  if (EEDetId::validDetId(iX,iY,1))
382  {
383  EEDetId eedetid(iX,iY,1);
384  unsigned int hiee = eedetid.hashedIndex();
385  EcalPedestals::Item aped= peds->endcap(hiee);
386  // here I copy the last valid value in the peds object
387  EcalPedestals::Item item;
388  item.mean_x1 = aped.mean_x1;
389  item.rms_x1 = aped.rms_x1;
390  item.mean_x6 = aped.mean_x6;
391  item.rms_x6 = aped.rms_x6;
392  item.mean_x12 = aped.mean_x12;
393  item.rms_x12 = aped.rms_x12;
394  // here I copy the last valid value in the pedtemp object
395  pedtemp->insert(std::make_pair(eedetid.rawId(),item));
396  }
397  if (EEDetId::validDetId(iX,iY,-1))
398  {
399  EEDetId eedetid(iX,iY,-1);
400  unsigned int hiee = eedetid.hashedIndex();
401  EcalPedestals::Item aped= peds->endcap(hiee);
402  // here I copy the last valid value in the peds object
403  EcalPedestals::Item item;
404  item.mean_x1 = aped.mean_x1;
405  item.rms_x1 = aped.rms_x1;
406  item.mean_x6 = aped.mean_x6;
407  item.rms_x6 = aped.rms_x6;
408  item.mean_x12 = aped.mean_x12;
409  item.rms_x12 = aped.rms_x12;
410  // here I copy the last valid value in the pedtemp object
411  pedtemp->insert(std::make_pair(eedetid.rawId(),item));
412  }
413  }
414  }
415 
416  Time_t snc= (Time_t) irun ;
417 
418  m_to_transfer.push_back(std::make_pair((EcalPedestals*)pedtemp,snc));
419 
420 
421  ss << "Run=" << irun << "_WAS_GOOD_"<<std::endl;
422  m_userTextLog = ss.str()+";";
423 
424 
425  } else {
426  std::cout << "Run " << irun << " was BAD !!!! not sent to the DB";
427  if(nbad >= (dataset_mon.size()*0.05))
428  std::cout << " number of bad channels = " << nbad;
429  if(nEB <= 10200)
430  std::cout << " number of EB channels = " << nEB;
431  if(nEE <= 2440)
432  std::cout << " number of EE channels = " << nEE;
433  std::cout << std::endl;
434  ss << "Run=" << irun << "_WAS_BAD_"<<std::endl;
435  m_userTextLog = ss.str()+";";
436  }
437  }
438  }
439 
440 
441  delete econn;
442  delete peds; // this is the only one that popcon does not delete
443 
444  }
445  std::cout << "Ecal - > end of getNewObjects -----------\n";
446 
447 
448 }
449 
450 
452 {
453  unsigned int max_since=0;
454  max_since=static_cast<unsigned int>(tagInfo().lastInterval.first);
455  std::cout << "max_since : " << max_since << std::endl;
456  Ref ped_db = lastPayload();
457 
458  std::cout << "retrieved last payload " << std::endl;
459 
460 
461  // we copy the last valid record to a temporary object peds
462  EcalPedestals* peds = new EcalPedestals();
463 
464  // get from offline DB the last valid pedestal set ped_db
465  // edm::ESHandle<EcalPedestals> pedestals;
466  // esetup.get<EcalPedestalsRcd>().get(pedestals);
467 
468 
469  // only positive endcap side and
470  // x from 86 to 95
471  // y from 46 to 55
472  int ixmin=86; int ixmax=95;
473  int iymin=46; int iymax=55;
474  for(int iX=ixmin; iX<=ixmax ;++iX) {
475  for(int iY=iymin; iY<=iymax; ++iY) {
476 
477  if (EEDetId::validDetId(iX,iY,1)) {
478  EEDetId eedetidpos(iX,iY,1);
479  unsigned int hiee = eedetidpos.hashedIndex();
480  EcalPedestals::Item aped= ped_db->endcap(hiee);
481 
482  // here I copy the last valid value in the peds object
483  EcalPedestals::Item item;
484  item.mean_x1 = aped.mean_x1;
485  item.rms_x1 = aped.rms_x1;
486  item.mean_x6 = aped.mean_x6;
487  item.rms_x6 = aped.rms_x6;
488  item.mean_x12 = aped.mean_x12;
489  item.rms_x12 = aped.rms_x12;
490  peds->insert(std::make_pair(eedetidpos.rawId(),item));
491  if(iX==ixmin && iY==iymin) std::cout<<"ped12 " << item.mean_x12<< std::endl;
492 
493  }
494  }
495  }
496 
497 
498  std::cout <<"WOW: we just retrieved the last valid record from DB "<< std::endl;
499 
500 
501  // here we retrieve all the runs after the last from online DB
502 
503  std::cout << "Retrieving run list from ONLINE DB ... " << std::endl;
504 
505  std::cout << "Making connection..." << std::flush;
506  econn = new EcalCondDBInterface( m_sid, m_user, m_pass );
507  std::cout << "Done." << std::endl;
508 
509  if (!econn)
510  {
511  std::cout << " connection parameters " <<m_sid <<"/"<<m_user<<"/"<<m_pass<<std::endl;
512  throw cms::Exception("OMDS not available");
513  }
514 
515  // these are the online conditions DB classes
516  RunList my_runlist ;
517  RunTag my_runtag;
518  LocationDef my_locdef;
519  RunTypeDef my_rundef;
520 
521  my_locdef.setLocation("H2_07");
522  my_rundef.setRunType("PEDESTAL");
523  my_runtag.setLocationDef(my_locdef);
524  my_runtag.setRunTypeDef(my_rundef);
525  my_runtag.setGeneralTag("LOCAL");
526 
527 
528  // here we retrieve the Monitoring run records
529 
530  MonVersionDef monverdef;
531  monverdef.setMonitoringVersion("test01");
532 
533  MonRunTag mon_tag;
534  mon_tag.setGeneralTag("CMSSW");
535  mon_tag.setMonVersionDef(monverdef);
536  MonRunList mon_list;
537  mon_list.setMonRunTag(mon_tag);
538  mon_list.setRunTag(my_runtag);
539  // mon_list=econn->fetchMonRunList(my_runtag, mon_tag);
540  unsigned int min_run=max_since+1; // we have to add 1 to the last transferred one
541 
542  unsigned int max_run=m_lastRun;
543  mon_list=econn->fetchMonRunList(my_runtag, mon_tag,min_run,max_run );
544 
545  std::vector<MonRunIOV> mon_run_vec= mon_list.getRuns();
546  size_t mon_runs=mon_run_vec.size();
547  std::cout <<"number of Mon runs is : "<< mon_runs<< std::endl;
548 
549  if(mon_runs>0){
550 
551  for(size_t kr=0; kr<mon_runs; kr++){
552 
553  unsigned int irun=static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
554 
555  std::cout << "here is first sub run : "<< mon_run_vec[kr].getSubRunNumber() << std::endl;
556  std::cout << "here is the run number: "<< mon_run_vec[kr].getRunIOV().getRunNumber() << std::endl;
557 
558  std::cout <<" retrieve the data for a given run"<< std::endl;
559 
560  if (mon_run_vec[kr].getSubRunNumber() <=1){
561 
562 
563  // retrieve the data for a given run
564  RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
565 
566  // retrieve the pedestals from OMDS for this run
567  std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
568  econn->fetchDataSet(&dataset_mon, &mon_run_vec[kr]);
569  std::cout <<"OMDS record for run "<<irun <<" is made of "<< dataset_mon.size() << std::endl;
570  typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
571  EcalLogicID ecid_xt;
572  MonPedestalsDat rd_ped;
573 
574  //int iEta=0;
575  //int iPhi=0;
576  int ix=0;
577  int iy=0;
578 
579  for (CImon p = dataset_mon.begin(); p != dataset_mon.end(); p++) {
580  ecid_xt = p->first;
581  rd_ped = p->second;
582  //int sm_num=ecid_xt.getID1();
583  int xt_num=ecid_xt.getID2(); // careful here !!! we number the channels from 1 to 1700
584 
585  //iEta=(xt_num/20)+1;
586  //iPhi=20-(xt_num-(iEta-1)*20);
587 
588  ix=95-(xt_num-1)/20;
589  iy=46+(xt_num-1)%20;
590 
591 
592  EcalPedestals::Item item;
593  item.mean_x1 =rd_ped.getPedMeanG1() ;
594  item.rms_x1 =rd_ped.getPedRMSG1();
595  item.mean_x6 =rd_ped.getPedMeanG6();
596  item.rms_x6 =rd_ped.getPedRMSG6() ;
597  item.mean_x12 =rd_ped.getPedMeanG12();
598  item.rms_x12 =rd_ped.getPedRMSG12();
599 
600  EEDetId eedetidpos(ix,iy,1);
601  // EBDetId ebdetid(iEta,iPhi);
602 
603  // here we change in the peds object only the values that are available in the online DB
604  // otherwise we keep the old value
605 
606  peds->insert(std::make_pair(eedetidpos.rawId(),item));
607  if(ix==ixmin && iy==iymin) std::cout<<"ped12 " << item.mean_x12<< std::endl;
608  }
609 
610  std::cout << "Generating popcon record for run " << irun << "..." << std::flush;
611 
612 
613  // now I copy peds in pedtemp and I ship pedtemp to popcon
614  // if I use always the same peds I always overwrite
615  // so I really have to create new objects for each new run
616  // popcon deletes everything for me
617 
618  EcalPedestals* pedtemp = new EcalPedestals();
619 
620 
621  for(int iX=ixmin; iX<=ixmax ;++iX) {
622  for(int iY=iymin; iY<=iymax; ++iY) {
623 
624  if (EEDetId::validDetId(iX,iY,1))
625  {
626  EEDetId eedetidpos(iX,iY,1);
627  unsigned int hiee = eedetidpos.hashedIndex();
628  EcalPedestals::Item aped = peds->endcap(hiee);
629 
630  EcalPedestals::Item item;
631  item.mean_x1 = aped.mean_x1;
632  item.rms_x1 = aped.rms_x1;
633  item.mean_x6 = aped.mean_x6;
634  item.rms_x6 = aped.rms_x6;
635  item.mean_x12 = aped.mean_x12;
636  item.rms_x12 = aped.rms_x12;
637  // here I copy the last valid value in the pedtemp object
638  pedtemp->insert(std::make_pair(eedetidpos.rawId(),item));
639  if(iX==ixmin && iY==iymin) std::cout<<"ped12 " << item.mean_x12<< std::endl;
640  }
641  }
642  }
643 
644 
645 
646  Time_t snc= (Time_t) irun ;
647 
648  m_to_transfer.push_back(std::make_pair((EcalPedestals*)pedtemp,snc));
649 
650  std::cout << "Ecal - > end of getNewObjectsH2 -----------\n";
651 
652 
653 
654  }
655  }
656 
657  }
658 
659 
660  delete econn;
661  delete peds; // this is the only one that popcon does not delete
662 
663 }
bool checkPedestal(EcalPedestals::Item *item)
T getParameter(std::string const &) const
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:87
static const int MIN_IPHI
Definition: EBDetId.h:143
void setLocationDef(const LocationDef locDef)
Definition: RunTag.cc:53
Definition: RunTag.h:13
float getPedRMSG1() const
#define min(a, b)
Definition: mlp_lapack.h:161
EcalPedestalsHandler(edm::ParameterSet const &)
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:33
static const int IX_MIN
Definition: EEDetId.h:295
void setRunTag(RunTag tag)
Definition: MonRunList.cc:23
static const int IY_MIN
Definition: EEDetId.h:299
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:125
int getID2() const
Definition: EcalLogicID.cc:52
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
std::string getName() const
Definition: EcalLogicID.cc:37
float getPedMeanG12() const
unsigned long long Time_t
Definition: Time.h:16
float getPedRMSG12() const
void setRunTypeDef(const RunTypeDef runTypeDef)
Definition: RunTag.cc:70
tuple result
Definition: query.py:137
int getID1() const
Definition: EcalLogicID.cc:47
void setMonVersionDef(MonVersionDef ver)
Definition: MonRunTag.cc:49
static const int ETAPHIMODE
Definition: EBDetId.h:167
void insert(std::pair< uint32_t, Item > const &a)
static const int IX_MAX
Definition: EEDetId.h:303
std::vector< MonRunIOV > getRuns()
Definition: MonRunList.cc:46
EcalPedestalsMap EcalPedestals
Definition: EcalPedestals.h:38
int hashedIndex() const
Definition: EEDetId.h:183
static const int MAX_IPHI
Definition: EBDetId.h:145
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:249
std::vector< Item >::const_iterator const_iterator
static const int MAX_IETA
Definition: EBDetId.h:144
float getPedMeanG1() const
void setMonitoringVersion(std::string ver)
void setMonRunTag(MonRunTag tag)
Definition: MonRunList.cc:29
float getPedMeanG6() const
void setLocation(std::string loc)
Definition: LocationDef.cc:33
tuple cout
Definition: gather_cfg.py:121
static const int IY_MAX
Definition: EEDetId.h:307
const Item & barrel(size_t hashedIndex) const
Definition: DDAxes.h:10
int getID3() const
Definition: EcalLogicID.cc:57
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
static const int SMCRYSTALMODE
Definition: EBDetId.h:168
const Item & endcap(size_t hashedIndex) const
Definition: RunIOV.h:13
float getPedRMSG6() const