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::EcalDCSHandler Class Reference

#include <EcalDCSHandler.h>

Inheritance diagram for popcon::EcalDCSHandler:
popcon::PopConSourceHandler< EcalDCSTowerStatus >

Public Member Functions

int detIDToLogicID (int, int, int)
 
 EcalDCSHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
int * HVEELogicIDToDetID (int, int) const
 
int * HVLogicIDToDetID (int, int) const
 
std::string id () const
 
bool insertHVDataSetToOffline (const std::map< EcalLogicID, RunDCSHVDat > *dataset, EcalDCSTowerStatus *dcs_temp) const
 
bool insertLVDataSetToOffline (const std::map< EcalLogicID, RunDCSLVDat > *dataset, EcalDCSTowerStatus *dcs_temp, const std::vector< EcalLogicID > &) const
 
int * LVLogicIDToDetID (int, int) const
 
uint16_t OffDBStatus (uint16_t dbStatus, int pos)
 
void printHVDataSet (const std::map< EcalLogicID, RunDCSHVDat > *dataset, int) const
 
void printLVDataSet (const std::map< EcalLogicID, RunDCSLVDat > *dataset, int) const
 
uint16_t updateHV (RunDCSHVDat *hv, uint16_t dbStatus, int modo=0) const
 
uint16_t updateLV (RunDCSLVDat *lv, uint16_t dbStatus) const
 
 ~EcalDCSHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalDCSTowerStatus >
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 long m_firstRun
 
unsigned long m_lastRun
 
std::string m_name
 
std::string m_pass
 
std::string m_sid
 
std::string m_user
 

Additional Inherited Members

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

Detailed Description

Definition at line 52 of file EcalDCSHandler.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file EcalDCSHandler.cc.

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

12  : m_name(ps.getUntrackedParameter<std::string>("name","EcalDCSHandler")) {
13 
14  std::cout << "EcalDCS Source handler constructor\n" << std::endl;
15  m_firstRun=(unsigned long)atoi( ps.getParameter<std::string>("firstRun").c_str());
16  m_lastRun=(unsigned long)atoi( ps.getParameter<std::string>("lastRun").c_str());
17  m_sid= ps.getParameter<std::string>("OnlineDBSID");
18  m_user= ps.getParameter<std::string>("OnlineDBUser");
19  m_pass= ps.getParameter<std::string>("OnlineDBPassword");
20 
21  std::cout << m_sid<<"/"<<m_user<<std::endl;
22 
23 
24 }
unsigned long m_firstRun
unsigned long m_lastRun
tuple cout
Definition: gather_cfg.py:121
popcon::EcalDCSHandler::~EcalDCSHandler ( )

Definition at line 26 of file EcalDCSHandler.cc.

27 {
28 }

Member Function Documentation

int popcon::EcalDCSHandler::detIDToLogicID ( int  iz,
int  i,
int  j 
)

Definition at line 324 of file EcalDCSHandler.cc.

324  {
325  // returns the number from 0 to 1223 from SM1 to 36 from ch 1 to 34
326 
327  int sm=0;
328  int hv_chan=0;
329 
330 
331  sm = (i-1)/4;
332  if(iz<0) sm=sm+18;
333 
334  int ilocal=(i-1)-sm*4;
335  if(iz<0){
336  if(ilocal==0 || ilocal==1) hv_chan=1;
337  if(ilocal==2 || ilocal==3) hv_chan=2;
338  } else {
339  if(ilocal==0 || ilocal==1) hv_chan=2;
340  if(ilocal==2 || ilocal==3) hv_chan=1;
341  }
342 
343  sm=sm+1;
344 
345  hv_chan=(j-1)*2+hv_chan;
346 
347  hv_chan=(sm-1)*34+hv_chan -1 ;
348 
349  return hv_chan;
350 
351 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
void popcon::EcalDCSHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalDCSTowerStatus >.

Definition at line 626 of file EcalDCSHandler.cc.

References gather_cfg::cout, dataset::dataset, EcalBarrel, edm::hlt::Exception, RunIOV::getRunNumber(), EcalTrigTowerDetId::hashedIndex(), i, j, gen::k, NULL, EcalLogicID::NULLID, alignCSCRings::r, DetId::rawId(), EcalCondTowerObjectContainer< T >::setValue(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, dumpRecoGeometry_cfg::tagInfo, EcalTrigTowerDetId::validDetId(), and EcalScDetId::validDetId().

627 {
628  bool lot_of_printout=false;
629  std::cout << "------- Ecal DCS - > getNewObjects\n";
630 
631  std::ostringstream ss;
632  ss<<"ECAL ";
633 
634  unsigned long long max_since= 1;
635 
636  max_since=tagInfo().lastInterval.first;
637  std::cout << "max_since : " << max_since << std::endl;
638  Ref dcs_db = lastPayload();
639  std::cout << "retrieved last payload " << std::endl;
640 
641  // we copy the last valid record to a temporary object
642  EcalDCSTowerStatus* dcs_temp = new EcalDCSTowerStatus();
643 
644  // barrel
645  int iz=0;
646  for(int k=0 ; k<2; k++ ) {
647  if(k==0) iz=-1;
648  if(k==1) iz= 1;
649  for(int i=1 ; i<73; i++) {
650  for(int j=1 ; j<18; j++) {
652  EcalTrigTowerDetId ebid(iz,EcalBarrel,j,i);
653 
654  uint16_t dbStatus = 0;
655  dbStatus =(dcs_db->barrel( ebid.hashedIndex())).getStatusCode();
656 
657 
658  EcalDCSTowerStatus::const_iterator it =dcs_db->find(ebid.rawId());
659  if ( it != dcs_db->end() ) {
660  } else {
661  std::cout<<"*** error channel not found: j/i="<<j<<"/"<<i << std::endl;
662  }
663 
664  dcs_temp->setValue( ebid, dbStatus );
665  }
666  }
667  }
668  }
669 
670  // endcap
671  for(int k=0 ; k<2; k++ ) {
672  if(k==0) iz=-1;
673  if(k==1) iz=+1;
674  for(int i=1 ; i<21; i++) {
675  for(int j=1 ; j<21; j++) {
676  if (EcalScDetId::validDetId(i,j,iz )){
677  EcalScDetId eeid(i,j,iz);
678 
679  EcalDCSTowerStatus::const_iterator it =dcs_db->find(eeid.rawId());
680 
681  uint16_t dbStatus = 0;
682  if ( it != dcs_db->end() ) {
683  dbStatus = it->getStatusCode();
684  }
685  dcs_temp->setValue( eeid, dbStatus );
686  }
687  }
688  }
689  }
690 
691 
692  // now read the actual status from the online DB
693 
694 
696  std::cout << "Connection done" << std::endl;
697 
698  if (!econn)
699  {
700  std::cout << " Problem with OMDS: connection parameters " <<m_sid <<"/"<<m_user<<std::endl;
701  throw cms::Exception("OMDS not available");
702  }
703 
704 
705 
706  std::cout << "Retrieving last run from ONLINE DB ... " << std::endl;
707  std::map<EcalLogicID, RunDat> rundat;
708  RunIOV rp ;
709  run_t runmax=10000000;
710  std::string location_p5="P5_Co";
711  econn->fetchValidDataSet(&rundat , &rp, location_p5 ,runmax);
712 
713  unsigned long long irun=(unsigned long long) rp.getRunNumber();
714 
715  // just for testing purposes
716  // irun= max_since+1;
717 
718  if(max_since< irun) {
719 
720 
721  // get the map of the EE LV channels to EE crystals
722 
723  std::cout << "Retrieving endcap channel list from ONLINE DB ... " << std::endl;
724 
725  std::vector<EcalLogicID> my_EELVchan= econn->getEcalLogicIDSetOrdered( "EE_crystal_number", 1,4,
727  "EE_LV_channel", 12 ) ;
728 
729  std::cout << "done endcap channel list ... " << std::endl;
730 
731  // retrieve from last value data record
732  // always call this method at first run
733 
734  std::map<EcalLogicID, RunDCSHVDat> dataset;
735  RunIOV *r = NULL;
736  econn->fetchDataSet(&dataset, r);
737 
738  if (!dataset.size()) {
739  throw(std::runtime_error("Zero rows read back"));
740  }
741 
742 
743  if(lot_of_printout) std::cout << "read OK" << std::endl;
744  if(lot_of_printout) printHVDataSet(&dataset,10);
745 
746  std::map<EcalLogicID, RunDCSLVDat> dataset_lv;
747  econn->fetchDataSet(&dataset_lv, r);
748 
749  if (!dataset_lv.size()) {
750  throw(std::runtime_error("Zero rows read back"));
751  }
752  if(lot_of_printout) std::cout << "read OK" << std::endl;
753  if(lot_of_printout) printLVDataSet(&dataset_lv);
754 
755  bool somediff_hv= insertHVDataSetToOffline(&dataset, dcs_temp );
756  bool somediff_lv= insertLVDataSetToOffline(&dataset_lv, dcs_temp, my_EELVchan );
757 
758  if(somediff_hv || somediff_lv) {
759 
760 
761  /* Tm t_now_gmt;
762  t_now_gmt.setToCurrentGMTime();
763  uint64_t tsincetemp= t_now_gmt.microsTime()/1000000 ;
764  uint64_t tsince = tsincetemp<< 32;
765  std::cout << "Generating popcon record for time " << tsincetemp << "..." << std::flush;
766 
767  */
768 
769  std::cout << "Generating popcon record for run " << irun << "..." << std::flush;
770 
771  // this is for timestamp
772  // m_to_transfer.push_back(std::make_pair((EcalDCSTowerStatus*)dcs_temp,tsince));
773  // ss << "Time=" << t_now_gmt.str() << "_DCSchanged_"<<std::endl;
774 
775  // this is for run number
776  m_to_transfer.push_back(std::make_pair((EcalDCSTowerStatus*)dcs_temp,irun));
777  ss << "Run=" << irun << "_DCSchanged_"<<std::endl;
778 
779  m_userTextLog = ss.str()+";";
780 
781  } else {
782 
783  // Tm t_now_gmt;
784  // t_now_gmt.setToCurrentGMTime();
785 
786  std::cout<< "Run DCS record was the same as previous run " << std::endl;
787  ss << "Run=" << irun << "_DCSchanged_"<<std::endl;
788  m_userTextLog = ss.str()+";";
789 
790  delete dcs_temp;
791 
792  }
793 
794  /*
795 
796  } else {
797 
798  // here we fetch historical data
799 
800  uint64_t t_max_val= ((max_since >> 32 ) +2)*1000000 ; // time in microseconds (2 seconds more than old data)
801 
802  Tm t_test(t_max_val);
803 
804  std::list< std::pair< Tm, std::map< EcalLogicID, RunDCSHVDat > > > dataset;
805  econn->fetchDCSDataSet(&dataset, t_test);
806 
807  if (!dataset.size()) {
808  std::cout<< " DCS query retrieved zero lines "<< std::endl;
809  } else {
810 
811  int num_dcs=0;
812  std::list< std::pair< Tm, std::map< EcalLogicID, RunDCSHVDat > > >::iterator it;
813  for (it=dataset.begin(); it!=dataset.end(); ++it){
814  std::pair< Tm, std::map< EcalLogicID, RunDCSHVDat > > a_pair =(*it);
815  Tm t_pair=a_pair.first;
816  std::map< EcalLogicID, RunDCSHVDat > a_map = a_pair.second;
817  num_dcs=num_dcs+a_map.size();
818 
819  bool somediff_hv= insertHVDataSetToOffline(&a_map, dcs_temp );
820 
821 
822  if(somediff_hv ) {
823  std::cout << "some diff" << std::endl;
824  // we have to copy this record to offline
825  // we copy dcs_temp to dcs_pop
826  EcalDCSTowerStatus* dcs_pop = new EcalDCSTowerStatus();
827 
828  // barrel
829  int iz=0;
830  for(int k=0 ; k<2; k++ ) {
831  if(k==0) iz=-1;
832  if(k==1) iz= 1;
833  for(int i=1 ; i<73; i++) {
834  for(int j=1 ; j<18; j++) {
835  if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,j,i )){
836  EcalTrigTowerDetId ebid(iz,EcalBarrel,j,i);
837 
838  uint16_t dbStatus = 0;
839  dbStatus =(dcs_temp->barrel( ebid.hashedIndex())).getStatusCode();
840 
841  EcalDCSTowerStatus::const_iterator it =dcs_temp->find(ebid.rawId());
842  if ( it != dcs_temp->end() ) {
843  } else {
844  std::cout<<"*** error channel not found: j/i="<<j<<"/"<<i << std::endl;
845  }
846 
847  dcs_pop->setValue( ebid, dbStatus );
848  }
849  }
850  }
851  }
852 
853  // endcap
854  for(int k=0 ; k<2; k++ ) {
855  if(k==0) iz=-1;
856  if(k==1) iz=+1;
857  for(int i=1 ; i<21; i++) {
858  for(int j=1 ; j<21; j++) {
859  if (EcalScDetId::validDetId(i,j,iz )){
860  EcalScDetId eeid(i,j,iz);
861 
862  EcalDCSTowerStatus::const_iterator it =dcs_temp->find(eeid.rawId());
863 
864  uint16_t dbStatus = 0;
865  if ( it != dcs_temp->end() ) {
866  dbStatus = it->getStatusCode();
867  }
868  dcs_pop->setValue( eeid, dbStatus );
869  }
870  }
871  }
872  }
873 
874  uint64_t tsincetemp= t_pair.microsTime()/1000000 ;
875 
876  uint64_t tsince = tsincetemp<< 32;
877  Tm tnew(t_pair.microsTime());
878 
879  std::cout << "Generating popcon record for time " << tsince << "HRF time " << tnew.str() << "..." << std::flush;
880 
881  m_to_transfer.push_back(std::make_pair((EcalDCSTowerStatus*)dcs_pop,tsince));
882 
883  ss << "Time=" << tnew.str() << "_DCSchanged_"<<std::endl;
884  m_userTextLog = ss.str()+";";
885 
886 
887 
888 
889  }
890  }
891 
892 
893 
894  std::cout << " num DCS = "<< num_dcs << std::endl;
895  }
896 
897 
898 
899  delete dcs_temp;
900  */
901 
902  }
903 
904  delete econn;
905  std::cout << "Ecal - > end of getNewObjects -----------\n";
906 
907 }
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:64
int i
Definition: DBlmapReader.cc:9
int run_t
Definition: CaliIOV.h:11
EcalCondDBInterface * econn
void fetchValidDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *fillIOV, RunTag *tag, run_t run=(unsigned int)-1)
#define NULL
Definition: scimark2.h:8
void setValue(const uint32_t id, const Item &item)
std::vector< EcalLogicID > getEcalLogicIDSetOrdered(std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID)
cond::ValidityInterval lastInterval
Definition: Types.h:70
void printLVDataSet(const std::map< EcalLogicID, RunDCSLVDat > *dataset, int) const
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
EcalDCSTowerStatusMap EcalDCSTowerStatus
bool insertLVDataSetToOffline(const std::map< EcalLogicID, RunDCSLVDat > *dataset, EcalDCSTowerStatus *dcs_temp, const std::vector< EcalLogicID > &) const
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
void printHVDataSet(const std::map< EcalLogicID, RunDCSHVDat > *dataset, int) const
tuple dataset
Definition: dataset.py:400
run_t getRunNumber() const
Definition: RunIOV.cc:45
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
static const int NULLID
Definition: EcalLogicID.h:42
bool insertHVDataSetToOffline(const std::map< EcalLogicID, RunDCSHVDat > *dataset, EcalDCSTowerStatus *dcs_temp) const
tuple cout
Definition: gather_cfg.py:121
Definition: RunIOV.h:13
int * popcon::EcalDCSHandler::HVEELogicIDToDetID ( int  dee,
int  chan 
) const

Definition at line 355 of file EcalDCSHandler.cc.

References query::result.

355  {
356  int iz=-1;
357  if(dee==1 || dee==2) iz=1;
358  int ix1=1;
359  int ix2=1;
360  int iy1=1;
361  int iy2=1;
362 
363  if(dee==1 && chan==1) {
364  ix1=1; ix2=10;
365  iy1=11; iy2=20;
366  } else if(dee==2 && chan==1) {
367  ix1=11; ix2=20;
368  iy1=1; iy2=10;
369  } else if(dee==3 && chan==1) {
370  ix1=11; ix2=20;
371  iy1=11; iy2=20;
372  } else if(dee==4 && chan==1) {
373  ix1=1; ix2=10;
374  iy1=1; iy2=10;
375  } else if(dee==1 && chan==2) {
376  ix1=1; ix2=10;
377  iy1=1; iy2=10;
378  } else if(dee==2 && chan==2) {
379  ix1=11; ix2=20;
380  iy1=11; iy2=20;
381  } else if(dee==3 && chan==2) {
382  ix1=11; ix2=20;
383  iy1=1; iy2=10;
384  } else if(dee==4 && chan==2) {
385  ix1=1; ix2=10;
386  iy1=11; iy2=20;
387  }
388 
389  int *result = new int[5];
390 
391  result[0]=iz;
392  result[1]=ix1;
393  result[2]=ix2;
394  result[3]=iy1;
395  result[4]=iy2;
396  return result;
397 
398 }
tuple result
Definition: query.py:137
int * popcon::EcalDCSHandler::HVLogicIDToDetID ( int  sm,
int  chan 
) const

Definition at line 400 of file EcalDCSHandler.cc.

References j, and query::result.

400  {
401  // returns the numbers iz, i1, i2 and j1, j2 on which to loop for the towers
402 
403  int iz=-1;
404  if(sm>0 && sm <= 18) iz=1;
405  int j = (chan-1)/2 +1;
406  int i_local_hv = (chan-1) - (j-1)*2 + 1; // this gives 1 for odd channels and 2 for even channels
407  int i1 =0;
408  int i2 =0;
409  if( iz>0 ) { // EB plus phi turns opposite to HV numbering
410  if(i_local_hv==1) {
411  i1=3 ;
412  i2=4 ;
413  } else {
414  i1=1 ;
415  i2=2 ;
416  }
417  } else { // EB minus phi turns as HV numbering
418  if(i_local_hv==1) {
419  i1=1 ;
420  i2=2 ;
421  } else {
422  i1=3 ;
423  i2=4 ;
424  }
425  }
426  int ioffset=0;
427  if(iz==1) ioffset=(sm-1)*4;
428  if(iz==-1) ioffset=(sm-18-1)*4;
429  i1=i1+ioffset;
430  i2=i2+ioffset;
431 
432  int *result = new int[5];
433 
434  result[0]=iz;
435  result[1]=i1;
436  result[2]=i2;
437  result[3]=j;
438  result[4]=j;
439 
440  return result;
441 
442 }
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
std::string popcon::EcalDCSHandler::id ( void  ) const
inlinevirtual

Implements popcon::PopConSourceHandler< EcalDCSTowerStatus >.

Definition at line 66 of file EcalDCSHandler.h.

References m_name.

66 { return m_name;}
bool popcon::EcalDCSHandler::insertHVDataSetToOffline ( const std::map< EcalLogicID, RunDCSHVDat > *  dataset,
EcalDCSTowerStatus dcs_temp 
) const

Definition at line 162 of file EcalDCSHandler.cc.

References gather_cfg::cout, EcalBarrel, EcalCondTowerObjectContainer< T >::end(), EcalCondTowerObjectContainer< T >::find(), RunDCSHVDat::getHV(), RunDCSHVDat::getHVNominal(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getName(), AnalysisDataFormats_SUSYBSMObjects::hv, j, prof2calltree::l, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), query::result, EcalCondTowerObjectContainer< T >::setValue(), EcalTrigTowerDetId::validDetId(), and EcalScDetId::validDetId().

163 {
164  bool result=false;
165  if (dataset->size() == 0) {
166  std::cout << "No data in std::map!" << std::endl;
167  }
168  EcalLogicID ecid;
169  RunDCSHVDat hv;
170 
171 
172  typedef std::map< EcalLogicID, RunDCSHVDat >::const_iterator CI ;
173 
174  for (CI p = dataset->begin(); p != dataset->end(); ++p) {
175 
176 
177  ecid = p->first;
178  hv = p->second;
179 
180  if(ecid.getName()=="EB_HV_channel"){
181  int sm= ecid.getID1() ;
182  int chan= ecid.getID2();
183 
184  int* limits=0;
185  limits= HVLogicIDToDetID(sm,chan);
186  int iz=limits[0];
187  int i1=limits[1];
188  int i2=limits[2];
189  int j=limits[3];
190 
191  for(int ik=i1; ik<=i2; ik++){
193  EcalTrigTowerDetId ebid(iz,EcalBarrel,j,ik);
194  EcalDCSTowerStatus::const_iterator it =dcs_temp->find(ebid.rawId());
195 
196  uint16_t dbStatus = 0;
197  if ( it != dcs_temp->end() ) {
198  dbStatus = it->getStatusCode();
199  }
200  int modo=0;
201  uint16_t new_dbStatus= updateHV(&hv, dbStatus, modo);
202  if(new_dbStatus != dbStatus ) result=true;
203 
204  dcs_temp->setValue( ebid, new_dbStatus );
205 
206  if(new_dbStatus != dbStatus) {
207  std::cout <<"SM/chan:"<<sm<<"/"<<chan <<" new db status ="<< new_dbStatus << " old "<<dbStatus<<" HV: "<< hv.getHV()<<"/"<<hv.getHVNominal()<<std::endl;
208 
209  }
210  }
211  }
212  delete [] limits;
213  } else {
214  // endcaps
215  int dee= ecid.getID1() ;
216  int chan= ecid.getID2();
217 
218  int* limits=0;
219  limits= HVEELogicIDToDetID(dee,chan);
220  int iz=limits[0];
221  int i1=limits[1];
222  int i2=limits[2];
223  int j1=limits[3];
224  int j2=limits[4];
225 
226  int ex_x[6];
227  int ex_y[6];
228  if(dee==1 ) {
229  ex_x[0]=4; ex_y[0]=8;
230  ex_x[1]=4; ex_y[1]=9;
231  ex_x[2]=4; ex_y[2]=10;
232  ex_x[3]=5; ex_y[3]=9;
233  ex_x[4]=5; ex_y[4]=10;
234  ex_x[5]=6; ex_y[5]=10;
235  } else if(dee==2) {
236  ex_x[0]=17; ex_y[0]=11;
237  ex_x[1]=17; ex_y[1]=12;
238  ex_x[2]=17; ex_y[2]=13;
239  ex_x[3]=16; ex_y[3]=11;
240  ex_x[4]=16; ex_y[4]=12;
241  ex_x[5]=15; ex_y[5]=11;
242  } else if(dee==3) {
243  ex_x[0]=17; ex_y[0]=8;
244  ex_x[1]=17; ex_y[1]=9;
245  ex_x[2]=17; ex_y[2]=10;
246  ex_x[3]=16; ex_y[3]=9;
247  ex_x[4]=16; ex_y[4]=10;
248  ex_x[5]=15; ex_y[5]=10;
249  } else if(dee==4) {
250  ex_x[0]=4; ex_y[0]=11;
251  ex_x[1]=4; ex_y[1]=12;
252  ex_x[2]=4; ex_y[2]=13;
253  ex_x[3]=5; ex_y[3]=11;
254  ex_x[4]=5; ex_y[4]=12;
255  ex_x[5]=6; ex_y[5]=11;
256  }
257 
258  int modo=1;
259  if(ecid.getName()=="EE_HVD_channel") modo=2;
260 
261  for(int ik=i1; ik<=i2; ik++){
262  for(int ip=j1; ip<=j2; ip++){
263  bool not_excluded=true;
264  if(chan==2 ) { // channel 2 has half a dee minus 6 towers
265  for (int l=0; l<6; l++){
266  if(ik== ex_x[l] && ip== ex_y[l] ) not_excluded=false;
267  }
268  }
269  if(not_excluded){
270  if (EcalScDetId::validDetId(ik,ip,iz)){
271  EcalScDetId eeid(ik,ip,iz);
272  EcalDCSTowerStatus::const_iterator it =dcs_temp->find(eeid.rawId());
273 
274  uint16_t dbStatus = 0;
275  if ( it != dcs_temp->end() ) {
276  dbStatus = it->getStatusCode();
277  }
278  // FIXME - UPDATE HV A and D
279  uint16_t new_dbStatus= updateHV(&hv, dbStatus, modo);
280  if(new_dbStatus != dbStatus ) result=true;
281 
282  dcs_temp->setValue( eeid, new_dbStatus );
283 
284  if(new_dbStatus != dbStatus) {
285  std::cout <<"Dee/chan:"<<dee<<"/"<<chan <<" new db status ="<< new_dbStatus << " old "<<dbStatus<<" HV: "<< hv.getHV()<<"/"<<hv.getHVNominal()<<std::endl;
286 
287  }
288  }
289  }
290  }
291  }
292  if(chan==1){ // channel 1 has half a dee plus 6 more towers
293  for (int l=0; l<6; l++){
294  int ik=ex_x[l];
295  int ip=ex_y[l];
296  if (EcalScDetId::validDetId(ik,ip,iz)){
297  EcalScDetId eeid(ik,ip,iz);
298  EcalDCSTowerStatus::const_iterator it =dcs_temp->find(eeid.rawId());
299 
300  uint16_t dbStatus = 0;
301  if ( it != dcs_temp->end() ) {
302  dbStatus = it->getStatusCode();
303  }
304  uint16_t new_dbStatus= updateHV(&hv, dbStatus,modo);
305  if(new_dbStatus != dbStatus ) result=true;
306 
307  dcs_temp->setValue( eeid, new_dbStatus );
308 
309  if(new_dbStatus != dbStatus) {
310  std::cout <<"Dee/chan:"<<dee<<"/"<<chan <<" new db status ="<< new_dbStatus << " old "<<dbStatus<<" HV: "<< hv.getHV()<<"/"<<hv.getHVNominal()<<std::endl;
311 
312  }
313  }
314  }
315  }
316 
317  delete [] limits;
318 
319  }
320  }
321  return result;
322 }
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:64
float getHVNominal() const
Definition: RunDCSHVDat.h:39
susybsm::HSCParticleRefVector hv
Definition: classes.h:28
int * HVEELogicIDToDetID(int, int) const
void setValue(const uint32_t id, const Item &item)
const_iterator find(uint32_t rawId) const
int getID2() const
Definition: EcalLogicID.cc:51
std::string getName() const
Definition: EcalLogicID.cc:36
int * HVLogicIDToDetID(int, int) const
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
int getID1() const
Definition: EcalLogicID.cc:46
tuple dataset
Definition: dataset.py:400
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
tuple cout
Definition: gather_cfg.py:121
uint16_t updateHV(RunDCSHVDat *hv, uint16_t dbStatus, int modo=0) const
float getHV() const
Definition: RunDCSHVDat.h:38
bool popcon::EcalDCSHandler::insertLVDataSetToOffline ( const std::map< EcalLogicID, RunDCSLVDat > *  dataset,
EcalDCSTowerStatus dcs_temp,
const std::vector< EcalLogicID > &  my_EELVchan 
) const

Definition at line 504 of file EcalDCSHandler.cc.

References gather_cfg::cout, EcalBarrel, EcalCondTowerObjectContainer< T >::end(), EcalCondTowerObjectContainer< T >::find(), EcalLogicID::getID1(), EcalLogicID::getID2(), RunDCSLVDat::getLV(), RunDCSLVDat::getLVNominal(), EcalLogicID::getName(), j, n, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), query::result, EcalCondTowerObjectContainer< T >::setValue(), EcalTrigTowerDetId::validDetId(), and EcalScDetId::validDetId().

505 {
506  bool result= false;
507  if (dataset->size() == 0) {
508  std::cout << "No data in map!" << std::endl;
509  }
510  EcalLogicID ecid;
511  RunDCSLVDat lv;
512 
513 
514  typedef std::map< EcalLogicID, RunDCSLVDat >::const_iterator CI;
515  for (CI p = dataset->begin(); p != dataset->end(); ++p) {
516 
517  ecid = p->first;
518  lv = p->second;
519 
520  if(ecid.getName()=="EB_LV_channel"){
521 
522  int sm= ecid.getID1() ;
523  int chan= ecid.getID2();
524 
525  int* limits=0;
526  limits= LVLogicIDToDetID(sm,chan);
527  int iz=limits[0];
528  int i1=limits[1];
529  int i2=limits[2];
530  int j1=limits[3];
531  int j2=limits[4];
532 
533  for(int ik=i1; ik<=i2; ik++){
534  for(int j=j1; j<=j2; j++){
536  EcalTrigTowerDetId ebid(iz,EcalBarrel,j,ik);
537  EcalDCSTowerStatus::const_iterator it =dcs_temp->find(ebid.rawId());
538  uint16_t dbStatus = 0;
539  if ( it != dcs_temp->end() ) {
540  dbStatus = it->getStatusCode();
541  }
542  uint16_t new_dbStatus= updateLV(&lv, dbStatus);
543  if(new_dbStatus != dbStatus ) result=true;
544  dcs_temp->setValue( ebid, new_dbStatus );
545 
546  if(new_dbStatus != dbStatus) {
547  std::cout <<"SM/chan:"<<sm<<"/"<<chan <<" new db status ="<< new_dbStatus << " old "<<dbStatus<<" LV: "<< lv.getLV()<<"/"<<lv.getLVNominal()<<std::endl;
548 
549  }
550 
551 
552  }
553  }
554  }
555  delete [] limits;
556 
557 
558  } else {
559 
560  // endcaps
561  int dee= ecid.getID1() ;
562  int chan= ecid.getID2();
563  int n=my_EELVchan.size();
564 
565  for (int ixt=0; ixt<n; ixt++) {
566  if(my_EELVchan[ixt].getID1()==dee && my_EELVchan[ixt].getID2()==chan){
567 
568  int ilogic=my_EELVchan[ixt].getLogicID();
569 
570  if(ilogic == 2012058060 || ilogic == 2010060058
571  || ilogic == 2012043041 || ilogic == 2010041043) {
572  std::cout<< "crystal " << ilogic << " in the corner ignored" << std::endl;
573  } else {
574 
575  int iz= (ilogic/1000000)-2010;
576  if(iz==0) iz=-1;
577  if(iz==2) iz=1;
578  if(iz != 1 && iz!= -1) std::cout<< "BAD z"<< std::endl;
579 
580  int iy=ilogic- int(ilogic/1000)*1000;
581 
582  int ix=(ilogic- int(ilogic/1000000)*1000000 -iy)/1000;
583 
584  int ixtower= ((ix-1)/5) +1;
585  int iytower= ((iy-1)/5) +1;
586 
587  if(ixtower<1 || ixtower>20 || iytower <1 || iytower >20)
588  std::cout<< "BAD x/y"<<ilogic<<"/"<< ixtower<<"/"<<iytower<< std::endl;
589 
590  if (EcalScDetId::validDetId(ixtower,iytower,iz )){
591  EcalScDetId eeid(ixtower,iytower,iz );
592  EcalDCSTowerStatus::const_iterator it =dcs_temp->find(eeid.rawId());
593  uint16_t dbStatus = 0;
594  if ( it != dcs_temp->end() ) {
595  dbStatus = it->getStatusCode();
596  }
597 
598  uint16_t new_dbStatus= updateLV(&lv, dbStatus);
599  if(new_dbStatus != dbStatus ) result=true;
600  dcs_temp->setValue( eeid, new_dbStatus );
601 
602  // std::cout <<"Dee/chan:"<<dee<<"/"<<chan <<" new db status ="<< new_dbStatus << " old "<<dbStatus<<" LV: "<< lv.getLV()<<"/"<<lv.getLVNominal()<<" ilogic/x/y " <<ilogic<<"/"<< ixtower<<"/"<<iytower<<std::endl;
603 
604  if(new_dbStatus != dbStatus) {
605  std::cout <<"Dee/chan:"<<dee<<"/"<<chan <<" new db status ="<< new_dbStatus << " old "<<dbStatus<<" LV: "<< lv.getLV()<<"/"<<lv.getLVNominal()<<std::endl;
606 
607  }
608 
609  }
610 
611  }
612 
613 
614  }
615 
616  }
617 
618  }// end of endcaps
619 
620 
621 
622  }
623  return result;
624 }
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:64
uint16_t updateLV(RunDCSLVDat *lv, uint16_t dbStatus) const
int * LVLogicIDToDetID(int, int) const
float getLV() const
Definition: RunDCSLVDat.h:37
void setValue(const uint32_t id, const Item &item)
const_iterator find(uint32_t rawId) const
int getID2() const
Definition: EcalLogicID.cc:51
std::string getName() const
Definition: EcalLogicID.cc:36
float getLVNominal() const
Definition: RunDCSLVDat.h:38
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
int getID1() const
Definition: EcalLogicID.cc:46
tuple dataset
Definition: dataset.py:400
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
tuple cout
Definition: gather_cfg.py:121
int * popcon::EcalDCSHandler::LVLogicIDToDetID ( int  sm,
int  chan 
) const

Definition at line 444 of file EcalDCSHandler.cc.

References query::result.

444  {
445  // returns the numbers iz, i1, i2 and j1, j2 on which to loop for the towers
446 
447  int iz=-1;
448  if(sm>0 && sm <= 18) iz=1;
449 
450  int j1=0;
451  int j2=0;
452  int i1=0;
453  int i2=0;
454 
455  if(chan==1) {
456  i1=1;
457  i2=4;
458  j1=1;
459  j2=1;
460  } else {
461  int ch2= (chan/2)*2;
462  if(ch2==chan) {
463  j1=chan;
464  } else {
465  j1=chan-1;
466  }
467  j2 = j1+1;
468  if( iz>0 ) { // EB plus phi turns opposite to LV numbering
469  if(ch2==chan) {
470  i1=3 ;
471  i2=4 ;
472  } else {
473  i1=1 ;
474  i2=2 ;
475  }
476  } else { // EB minus phi turns as LV numbering
477  if(ch2==chan) {
478  i1=1 ;
479  i2=2 ;
480  } else {
481  i1=3 ;
482  i2=4 ;
483  }
484  }
485  }
486  int ioffset=0;
487  if(iz==1) ioffset=(sm-1)*4;
488  if(iz==-1) ioffset=(sm-18-1)*4;
489  i1=i1+ioffset;
490  i2=i2+ioffset;
491 
492 
493  int *result = new int[5];
494  result[0]=iz;
495  result[1]=i1;
496  result[2]=i2;
497  result[3]=j1;
498  result[4]=j2;
499 
500  return result;
501 }
tuple result
Definition: query.py:137
uint16_t popcon::EcalDCSHandler::OffDBStatus ( uint16_t  dbStatus,
int  pos 
)

Definition at line 86 of file EcalDCSHandler.cc.

86  {
87  uint16_t hv_off_dbstatus = ( dbStatus & (1 << pos ) ) ;
88  if(hv_off_dbstatus>0) hv_off_dbstatus=1;
89  return hv_off_dbstatus;
90 }
void popcon::EcalDCSHandler::printHVDataSet ( const std::map< EcalLogicID, RunDCSHVDat > *  dataset,
int  limit = 0 
) const

Definition at line 30 of file EcalDCSHandler.cc.

References prof2calltree::count, gather_cfg::cout, RunDCSHVDat::getHV(), RunDCSHVDat::getHVNominal(), EcalLogicID::getID1(), EcalLogicID::getID2(), RunDCSHVDat::getStatus(), AnalysisDataFormats_SUSYBSMObjects::hv, MessageLogger_cff::limit, and AlCaHLTBitMon_ParallelJobs::p.

32 {
33  std::cout << "==========printDataSet()" << std::endl;
34  if (dataset->size() == 0) {
35  std::cout << "No data in map!" << std::endl;
36  }
37  EcalLogicID ecid;
39 
40  int count = 0;
41  typedef std::map< EcalLogicID, RunDCSHVDat >::const_iterator CI;
42  for (CI p = dataset->begin(); p != dataset->end(); ++p) {
43  count++;
44  if (limit && count > limit) { return; }
45  ecid = p->first;
46  hv = p->second;
47 
48  std::cout << "SM: " << ecid.getID1() << std::endl;
49  std::cout << "Channel: " << ecid.getID2() << std::endl;
50  std::cout << "HV: " << hv.getHV() << std::endl;
51  std::cout << "HV nominal: " << hv.getHVNominal() << std::endl;
52  std::cout << "HV status: " << hv.getStatus() << std::endl;
53  std::cout << "========================" << std::endl;
54  }
55  std::cout << std::endl;
56 }
float getHVNominal() const
Definition: RunDCSHVDat.h:39
susybsm::HSCParticleRefVector hv
Definition: classes.h:28
int getStatus() const
Definition: RunDCSHVDat.h:40
int getID2() const
Definition: EcalLogicID.cc:51
int getID1() const
Definition: EcalLogicID.cc:46
tuple dataset
Definition: dataset.py:400
tuple cout
Definition: gather_cfg.py:121
float getHV() const
Definition: RunDCSHVDat.h:38
void popcon::EcalDCSHandler::printLVDataSet ( const std::map< EcalLogicID, RunDCSLVDat > *  dataset,
int  limit = 0 
) const

Definition at line 58 of file EcalDCSHandler.cc.

References prof2calltree::count, gather_cfg::cout, EcalLogicID::getID1(), EcalLogicID::getID2(), RunDCSLVDat::getLV(), RunDCSLVDat::getLVNominal(), RunDCSLVDat::getStatus(), MessageLogger_cff::limit, and AlCaHLTBitMon_ParallelJobs::p.

60 {
61  std::cout << "==========printDataSet()" << std::endl;
62  if (dataset->size() == 0) {
63  std::cout << "No data in map!" << std::endl;
64  }
65  EcalLogicID ecid;
66  RunDCSLVDat lv;
67 
68  int count = 0;
69  typedef std::map< EcalLogicID, RunDCSLVDat >::const_iterator CI;
70  for (CI p = dataset->begin(); p != dataset->end(); ++p) {
71  count++;
72  if (limit && count > limit) { return; }
73  ecid = p->first;
74  lv = p->second;
75 
76  std::cout << "SM: " << ecid.getID1() << std::endl;
77  std::cout << "Channel: " << ecid.getID2() << std::endl;
78  std::cout << "LV: " << lv.getLV() << std::endl;
79  std::cout << "LV nominal: " << lv.getLVNominal() << std::endl;
80  std::cout << "LV status: " << lv.getStatus() << std::endl;
81  std::cout << "========================" << std::endl;
82  }
83  std::cout << std::endl;
84  }
int getStatus() const
Definition: RunDCSLVDat.h:39
float getLV() const
Definition: RunDCSLVDat.h:37
int getID2() const
Definition: EcalLogicID.cc:51
float getLVNominal() const
Definition: RunDCSLVDat.h:38
int getID1() const
Definition: EcalLogicID.cc:46
tuple dataset
Definition: dataset.py:400
tuple cout
Definition: gather_cfg.py:121
uint16_t popcon::EcalDCSHandler::updateHV ( RunDCSHVDat hv,
uint16_t  dbStatus,
int  modo = 0 
) const

Definition at line 92 of file EcalDCSHandler.cc.

References RunDCSHVDat::getStatus(), EcalDCSTowerStatusHelper::HVEEDNOMINALSTATUS, EcalDCSTowerStatusHelper::HVEEDSTATUS, EcalDCSTowerStatusHelper::HVNOMINALSTATUS, RunDCSHVDat::HVNOTNOMINAL, RunDCSHVDat::HVOFF, EcalDCSTowerStatusHelper::HVSTATUS, i, query::result, and groupFilesInBlocks::temp.

92  {
93  // mode ==0 EB , mode==1 EE Anode , mode==2 EE Dynode
94 
95  uint16_t result=0;
96  uint16_t hv_on_dbstatus=0;
97  uint16_t hv_nomi_on_dbstatus=0;
98 
99  if( hv->getStatus()==RunDCSHVDat::HVNOTNOMINAL ) hv_nomi_on_dbstatus=1;
100  if( hv->getStatus()==RunDCSHVDat::HVOFF ) hv_on_dbstatus=1;
101 
102 
103 
104  uint16_t temp=0;
105 
106  if(mode == 0 || mode == 1) {
107  for (int i=0; i<16; i++) {
109  temp = temp | (1<<i) ;
110  } else {
111  temp = temp | (0<<i);
112  }
113  }
114  result= dbStatus & temp ;
115  result= ( result | ( hv_on_dbstatus << EcalDCSTowerStatusHelper::HVSTATUS ) ) | ( hv_nomi_on_dbstatus << EcalDCSTowerStatusHelper::HVNOMINALSTATUS ) ;
116  } else {
117  for (int i=0; i<16; i++) {
119  temp = temp | (1<<i) ;
120  } else {
121  temp = temp | (0<<i);
122  }
123  }
124  result= dbStatus & temp ;
125  result= ( result | ( hv_on_dbstatus << EcalDCSTowerStatusHelper::HVEEDSTATUS )) | ( hv_nomi_on_dbstatus << EcalDCSTowerStatusHelper::HVEEDNOMINALSTATUS ) ;
126  }
127 
128  return result;
129 }
int i
Definition: DBlmapReader.cc:9
static const int HVNOTNOMINAL
Definition: RunDCSHVDat.h:24
int getStatus() const
Definition: RunDCSHVDat.h:40
tuple result
Definition: query.py:137
static const int HVOFF
Definition: RunDCSHVDat.h:25
uint16_t popcon::EcalDCSHandler::updateLV ( RunDCSLVDat lv,
uint16_t  dbStatus 
) const

Definition at line 132 of file EcalDCSHandler.cc.

References RunDCSLVDat::getStatus(), i, EcalDCSTowerStatusHelper::LVNOMINALSTATUS, RunDCSLVDat::LVNOTNOMINAL, RunDCSLVDat::LVOFF, EcalDCSTowerStatusHelper::LVSTATUS, query::result, and groupFilesInBlocks::temp.

132  {
133  uint16_t result=0;
134  uint16_t lv_on_dbstatus=0;
135  uint16_t lv_nomi_on_dbstatus=0;
136  if( lv->getStatus()==RunDCSLVDat::LVNOTNOMINAL ) lv_nomi_on_dbstatus=1;
137  if( lv->getStatus()==RunDCSLVDat::LVOFF ) lv_on_dbstatus=1;
138 
139  uint16_t lv_off_dbstatus = ( dbStatus & (1 << EcalDCSTowerStatusHelper::LVSTATUS ) ) ;
140  uint16_t lv_nomi_off_dbstatus = ( dbStatus & (1 << EcalDCSTowerStatusHelper::LVNOMINALSTATUS ) ) ;
141  if(lv_off_dbstatus>0) lv_off_dbstatus=1;
142  if(lv_nomi_off_dbstatus>0) lv_nomi_off_dbstatus=1;
143 
144 
145  uint16_t temp=0;
146  for (int i=0; i<16; i++) {
148  temp = temp | (1<<i) ;
149  } else {
150  temp = temp | ( 0 << i );
151  }
152  }
153 
154 
155  result= dbStatus & temp ;
156  result= ( result | ( lv_on_dbstatus << EcalDCSTowerStatusHelper::LVSTATUS ) ) | ( lv_nomi_on_dbstatus << EcalDCSTowerStatusHelper::LVNOMINALSTATUS ) ;
157 
158 
159  return result;
160 }
int i
Definition: DBlmapReader.cc:9
int getStatus() const
Definition: RunDCSLVDat.h:39
tuple result
Definition: query.py:137
static const int LVOFF
Definition: RunDCSLVDat.h:24
static const int LVNOTNOMINAL
Definition: RunDCSLVDat.h:23

Member Data Documentation

EcalCondDBInterface* popcon::EcalDCSHandler::econn

Definition at line 67 of file EcalDCSHandler.h.

unsigned long popcon::EcalDCSHandler::m_firstRun
private

Definition at line 78 of file EcalDCSHandler.h.

Referenced by EcalDCSHandler().

unsigned long popcon::EcalDCSHandler::m_lastRun
private

Definition at line 79 of file EcalDCSHandler.h.

Referenced by EcalDCSHandler().

std::string popcon::EcalDCSHandler::m_name
private

Definition at line 84 of file EcalDCSHandler.h.

Referenced by id().

std::string popcon::EcalDCSHandler::m_pass
private

Definition at line 83 of file EcalDCSHandler.h.

Referenced by EcalDCSHandler().

std::string popcon::EcalDCSHandler::m_sid
private

Definition at line 81 of file EcalDCSHandler.h.

Referenced by EcalDCSHandler().

std::string popcon::EcalDCSHandler::m_user
private

Definition at line 82 of file EcalDCSHandler.h.

Referenced by EcalDCSHandler().