CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Attributes
popcon::EcalPedestalsHandler Class Reference

#include <EcalPedestalsHandler.h>

Inheritance diagram for popcon::EcalPedestalsHandler:
popcon::PopConSourceHandler< EcalPedestals >

Public Member Functions

bool checkPedestal (EcalPedestals::Item *item)
 
 EcalPedestalsHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
void getNewObjectsH2 ()
 
void getNewObjectsP5 ()
 
std::string id () const
 
 ~EcalPedestalsHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalPedestals >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Public Attributes

EcalCondDBInterfaceeconn
 

Private Attributes

unsigned int m_firstRun
 
std::string m_gentag
 
unsigned int m_lastRun
 
std::string m_location
 
std::string m_locationsource
 
std::string m_name
 
std::string m_pass
 
std::string m_sid
 
std::string m_user
 
const EcalPedestalsmypedestals
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalPedestals >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< EcalPedestals
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalPedestals
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalPedestals value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalPedestals >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalPedestals >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 55 of file EcalPedestalsHandler.h.

Constructor & Destructor Documentation

popcon::EcalPedestalsHandler::EcalPedestalsHandler ( edm::ParameterSet const &  ps)

Definition at line 8 of file EcalPedestalsHandler.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), m_firstRun, m_gentag, m_lastRun, m_location, m_locationsource, m_pass, m_sid, m_user, and AlCaHLTBitMon_QueryRunRegistry::string.

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 }
tuple cout
Definition: gather_cfg.py:121
popcon::EcalPedestalsHandler::~EcalPedestalsHandler ( )

Definition at line 26 of file EcalPedestalsHandler.cc.

27 {
28 }

Member Function Documentation

bool popcon::EcalPedestalsHandler::checkPedestal ( EcalPedestals::Item item)

Definition at line 44 of file EcalPedestalsHandler.cc.

References EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, query::result, EcalPedestal::rms_x1, EcalPedestal::rms_x12, and EcalPedestal::rms_x6.

44  {
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  }
tuple result
Definition: query.py:137
void popcon::EcalPedestalsHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalPedestals >.

Definition at line 31 of file EcalPedestalsHandler.cc.

References gather_cfg::cout.

32 {
33 
34  std::cout << "------- Ecal - > getNewObjects\n";
35 
36  if(m_locationsource=="H2") {
38  } else if (m_locationsource=="P5") {
40  }
41 }
tuple cout
Definition: gather_cfg.py:121
void popcon::EcalPedestalsHandler::getNewObjectsH2 ( )

Definition at line 451 of file EcalPedestalsHandler.cc.

References gather_cfg::cout, EcalCondObjectContainer< T >::endcap(), edm::hlt::Exception, EcalLogicID::getID2(), MonPedestalsDat::getPedMeanG1(), MonPedestalsDat::getPedMeanG12(), MonPedestalsDat::getPedMeanG6(), MonPedestalsDat::getPedRMSG1(), MonPedestalsDat::getPedRMSG12(), MonPedestalsDat::getPedRMSG6(), MonRunList::getRuns(), EEDetId::hashedIndex(), EcalCondObjectContainer< T >::insert(), EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), EcalPedestal::rms_x1, EcalPedestal::rms_x12, EcalPedestal::rms_x6, RunTag::setGeneralTag(), MonRunTag::setGeneralTag(), LocationDef::setLocation(), RunTag::setLocationDef(), MonVersionDef::setMonitoringVersion(), MonRunList::setMonRunTag(), MonRunTag::setMonVersionDef(), MonRunList::setRunTag(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), dumpRecoGeometry_cfg::tagInfo, and EEDetId::validDetId().

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;
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 }
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:70
Definition: RunTag.h:13
float getPedRMSG1() const
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:33
MonRunList fetchMonRunList(const RunTag &tag, const MonRunTag &monruntag)
void setRunTag(const RunTag &tag)
Definition: MonRunList.cc:23
int getID2() const
Definition: EcalLogicID.cc:51
cond::ValidityInterval lastInterval
Definition: Types.h:70
float getPedMeanG12() const
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
float getPedRMSG12() const
void setMonVersionDef(const MonVersionDef &ver)
Definition: MonRunTag.cc:49
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:53
void insert(std::pair< uint32_t, Item > const &a)
std::vector< MonRunIOV > getRuns()
Definition: MonRunList.cc:46
EcalPedestalsMap EcalPedestals
Definition: EcalPedestals.h:53
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunList.cc:29
float getPedMeanG1() const
void setMonitoringVersion(std::string ver)
float getPedMeanG6() const
void setLocation(std::string loc)
Definition: LocationDef.cc:33
tuple cout
Definition: gather_cfg.py:121
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
const Item & endcap(size_t hashedIndex) const
Definition: RunIOV.h:13
float getPedRMSG6() const
void popcon::EcalPedestalsHandler::getNewObjectsP5 ( )

Definition at line 56 of file EcalPedestalsHandler.cc.

References EcalCondObjectContainer< T >::barrel(), gather_cfg::cout, EcalCondObjectContainer< T >::endcap(), EBDetId::ETAPHIMODE, edm::hlt::Exception, EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getID3(), EcalLogicID::getName(), MonPedestalsDat::getPedMeanG1(), MonPedestalsDat::getPedMeanG12(), MonPedestalsDat::getPedMeanG6(), MonPedestalsDat::getPedRMSG1(), MonPedestalsDat::getPedRMSG12(), MonPedestalsDat::getPedRMSG6(), MonRunList::getRuns(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), EcalCondObjectContainer< T >::insert(), EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, bookConverter::min, EBDetId::MIN_IPHI, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), EcalPedestal::rms_x1, EcalPedestal::rms_x12, EcalPedestal::rms_x6, RunTag::setGeneralTag(), MonRunTag::setGeneralTag(), LocationDef::setLocation(), RunTag::setLocationDef(), MonVersionDef::setMonitoringVersion(), MonRunList::setMonRunTag(), MonRunTag::setMonVersionDef(), MonRunList::setRunTag(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EBDetId::SMCRYSTALMODE, contentValuesCheck::ss, dumpRecoGeometry_cfg::tagInfo, EBDetId::validDetId(), EEDetId::validDetId(), and x.

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;
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 }
bool checkPedestal(EcalPedestals::Item *item)
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:70
static const int MIN_IPHI
Definition: EBDetId.h:142
Definition: RunTag.h:13
float getPedRMSG1() const
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:33
MonRunList fetchMonRunList(const RunTag &tag, const MonRunTag &monruntag)
static const int IX_MIN
Definition: EEDetId.h:294
static const int IY_MIN
Definition: EEDetId.h:298
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:124
void setRunTag(const RunTag &tag)
Definition: MonRunList.cc:23
int getID2() const
Definition: EcalLogicID.cc:51
cond::ValidityInterval lastInterval
Definition: Types.h:70
std::string getName() const
Definition: EcalLogicID.cc:36
float getPedMeanG12() const
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
float getPedRMSG12() const
int getID1() const
Definition: EcalLogicID.cc:46
void setMonVersionDef(const MonVersionDef &ver)
Definition: MonRunTag.cc:49
static const int ETAPHIMODE
Definition: EBDetId.h:166
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:53
void insert(std::pair< uint32_t, Item > const &a)
static const int IX_MAX
Definition: EEDetId.h:302
std::vector< MonRunIOV > getRuns()
Definition: MonRunList.cc:46
EcalPedestalsMap EcalPedestals
Definition: EcalPedestals.h:53
static const int MAX_IPHI
Definition: EBDetId.h:144
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::vector< Item >::const_iterator const_iterator
static const int MAX_IETA
Definition: EBDetId.h:143
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunList.cc:29
float getPedMeanG1() const
void setMonitoringVersion(std::string ver)
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:306
const Item & barrel(size_t hashedIndex) const
Definition: DDAxes.h:10
int getID3() const
Definition: EcalLogicID.cc:56
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
static const int SMCRYSTALMODE
Definition: EBDetId.h:167
const Item & endcap(size_t hashedIndex) const
Definition: RunIOV.h:13
float getPedRMSG6() const
std::string popcon::EcalPedestalsHandler::id ( void  ) const
inlinevirtual

Implements popcon::PopConSourceHandler< EcalPedestals >.

Definition at line 65 of file EcalPedestalsHandler.h.

References m_name.

65 { return m_name;}

Member Data Documentation

EcalCondDBInterface* popcon::EcalPedestalsHandler::econn

Definition at line 66 of file EcalPedestalsHandler.h.

unsigned int popcon::EcalPedestalsHandler::m_firstRun
private

Definition at line 71 of file EcalPedestalsHandler.h.

Referenced by EcalPedestalsHandler().

std::string popcon::EcalPedestalsHandler::m_gentag
private

Definition at line 75 of file EcalPedestalsHandler.h.

Referenced by EcalPedestalsHandler().

unsigned int popcon::EcalPedestalsHandler::m_lastRun
private

Definition at line 72 of file EcalPedestalsHandler.h.

Referenced by EcalPedestalsHandler().

std::string popcon::EcalPedestalsHandler::m_location
private

Definition at line 74 of file EcalPedestalsHandler.h.

Referenced by EcalPedestalsHandler().

std::string popcon::EcalPedestalsHandler::m_locationsource
private

Definition at line 79 of file EcalPedestalsHandler.h.

Referenced by EcalPedestalsHandler().

std::string popcon::EcalPedestalsHandler::m_name
private

Definition at line 80 of file EcalPedestalsHandler.h.

Referenced by id().

std::string popcon::EcalPedestalsHandler::m_pass
private

Definition at line 78 of file EcalPedestalsHandler.h.

Referenced by EcalPedestalsHandler().

std::string popcon::EcalPedestalsHandler::m_sid
private

Definition at line 76 of file EcalPedestalsHandler.h.

Referenced by EcalPedestalsHandler().

std::string popcon::EcalPedestalsHandler::m_user
private

Definition at line 77 of file EcalPedestalsHandler.h.

Referenced by EcalPedestalsHandler().

const EcalPedestals* popcon::EcalPedestalsHandler::mypedestals
private

Definition at line 69 of file EcalPedestalsHandler.h.