#include <EcalDAQHandler.h>
Public Member Functions | |
int | detIDToLogicID (int, int, int) |
EcalDAQHandler (edm::ParameterSet const &) | |
void | getNewObjects () |
std::string | id () const |
uint16_t | OffDBStatus (uint16_t dbStatus, int pos) |
~EcalDAQHandler () | |
Public Attributes | |
EcalCondDBInterface * | econn |
Private Attributes | |
unsigned long | m_firstRun |
std::string | m_gentag |
unsigned long | m_lastRun |
std::string | m_location |
std::string | m_name |
std::string | m_pass |
std::string | m_runtype |
std::string | m_sid |
std::string | m_user |
Definition at line 48 of file EcalDAQHandler.h.
popcon::EcalDAQHandler::EcalDAQHandler | ( | edm::ParameterSet const & | ps | ) |
Definition at line 132 of file EcalDAQHandler.cc.
References gather_cfg::cout, edm::ParameterSet::getParameter(), m_firstRun, m_gentag, m_lastRun, m_location, m_pass, m_runtype, m_sid, m_user, and AlCaHLTBitMon_QueryRunRegistry::string.
: m_name(ps.getUntrackedParameter<std::string>("name","EcalDAQHandler")) { std::cout << "EcalDAQ Source handler constructor\n" << std::endl; m_firstRun =(unsigned long)atoi( ps.getParameter<std::string>("firstRun").c_str()); m_lastRun =(unsigned long)atoi( ps.getParameter<std::string>("lastRun").c_str()); m_sid = ps.getParameter<std::string>("OnlineDBSID"); m_user = ps.getParameter<std::string>("OnlineDBUser"); m_pass = ps.getParameter<std::string>("OnlineDBPassword"); m_location = ps.getParameter<std::string>("location"); m_runtype = ps.getParameter<std::string>("runtype"); m_gentag = ps.getParameter<std::string>("gentag"); std::cout << m_sid << "/" << m_user << std::endl; }
popcon::EcalDAQHandler::~EcalDAQHandler | ( | ) |
Definition at line 149 of file EcalDAQHandler.cc.
{ }
int popcon::EcalDAQHandler::detIDToLogicID | ( | int | , |
int | , | ||
int | |||
) |
void popcon::EcalDAQHandler::getNewObjects | ( | ) | [virtual] |
Implements popcon::PopConSourceHandler< EcalDAQTowerStatus >.
Definition at line 160 of file EcalDAQHandler.cc.
References EcalCondTowerObjectContainer< T >::barrel(), gather_cfg::cout, debug, EcalBarrel, EcalCondTowerObjectContainer< T >::end(), Exception, EcalCondTowerObjectContainer< T >::find(), ODFEDAQConfig::getBadTTId(), RunFEConfigDat::getConfigId(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getLogicID(), RunList::getRuns(), EcalTrigTowerDetId::hashedIndex(), ietaEB, iphiEB, ixx, iyy, gen::k, min, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), RunTag::setGeneralTag(), ODFEDAQConfig::setId(), ODBadTTInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalCondTowerObjectContainer< T >::setValue(), groupFilesInBlocks::tt, EcalTrigTowerDetId::validDetId(), EcalScDetId::validDetId(), and z.
{ // bool lot_of_printout=false; std::cout << "------- Ecal DAQ - > getNewObjects\n"; std::ostringstream ss; ss<<"ECAL "; unsigned long long max_since = 1; // this is the last inserted run max_since = tagInfo().lastInterval.first; // this is the last object in the DB std::cout << " max_since : " << max_since << std::endl; Ref daq_db = lastPayload(); std::cout << "retrieved last payload " << std::endl; // we copy the last valid record to a temporary object peds EcalDAQTowerStatus* daq_temp = new EcalDAQTowerStatus(); // barrel uint16_t oldEBStatus[72][17][2]; uint16_t newEBStatus[72][17][2]; uint16_t oldEEStatus[20][20][2]; uint16_t newEEStatus[20][20][2]; int iz = -1; for(int k = 0 ; k < 2; k++ ) { if(k == 1) iz = 1; for(int iphi = 1 ; iphi < 73; iphi++) { for(int ieta = 1 ; ieta < 18; ieta++) { if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,ieta,iphi )){ EcalTrigTowerDetId ebid(iz,EcalBarrel,ieta,iphi); uint16_t dbStatus = 0; dbStatus =(daq_db->barrel( ebid.hashedIndex())).getStatusCode(); oldEBStatus[iphi - 1][ieta -1][k] = dbStatus; EcalDAQTowerStatus::const_iterator it =daq_db->find(ebid.rawId()); if ( it != daq_db->end() ) { } else { std::cout<<"*** error channel not found: eta/phi ="<< ieta << "/" << iphi << std::endl; } daq_temp->setValue( ebid, dbStatus ); if(dbStatus != 0) std::cout << "barrel side " << k << " phi " << iphi << " eta " << ieta << " status " << dbStatus << std::endl; } } // end loop over ieta } // end loop over iphi // endcap for(int ix = 1 ; ix < 21; ix++) { for(int iy = 1 ; iy < 21; iy++) { if (EcalScDetId::validDetId(ix,iy,iz )){ EcalScDetId eeid(ix,iy,iz); EcalDAQTowerStatus::const_iterator it =daq_db->find(eeid.rawId()); uint16_t dbStatus = 0; if ( it != daq_db->end() ) { dbStatus = it->getStatusCode(); } oldEEStatus[ix - 1][iy -1][k] = dbStatus; daq_temp->setValue( eeid, dbStatus ); if(dbStatus != 0) std::cout << "endcap side " << k << " x " << ix << " y " << iy << " status " << dbStatus << std::endl; } } // end loop over iy } // end loop over ix } // end loop over k (side) // now read the actual status from the online DB std::cout << "Retrieving DAQ status from OMDS DB ... " << std::endl; econn = new EcalCondDBInterface( m_sid, m_user, m_pass ); std::cout << "Connection done" << std::endl; if (!econn) { std::cout << " Problem with OMDS: connection parameters " << m_sid << "/" << m_user << "/" << m_pass << std::endl; throw cms::Exception("OMDS not available"); } // code from EcalTPGBadTTHandler.cc LocationDef my_locdef; my_locdef.setLocation(m_location); RunTypeDef my_rundef; my_rundef.setRunType(m_runtype); RunTag my_runtag; my_runtag.setLocationDef( my_locdef ); my_runtag.setRunTypeDef( my_rundef ); my_runtag.setGeneralTag(m_gentag); // range of validity int min_run = 0; if(m_firstRun < (unsigned long)max_since) { min_run= (int)max_since+1; // we have to add 1 to the last transferred one } else { min_run=(int)m_firstRun; } int max_run=(int)m_lastRun; std::cout << "min_run " << min_run << " max_run " << max_run << std::endl; RunList my_list; my_list = econn->fetchRunListByLocation(my_runtag, min_run, max_run, my_locdef); std::vector<RunIOV> run_vec = my_list.getRuns(); int num_runs = run_vec.size(); std::cout << " number of runs is : " << num_runs << std::endl; unsigned long irun=0; if(num_runs > 0){ // char outfile[800]; //sprintf(outfile,"BadChannelsEB_run%d.txt",min_run); //ofstream *daqFile; //daqFile = new ofstream(outfile,ios::out); bool debug = false; // for(int kr = 0; kr < num_runs; kr++){ int krmax = std::min(num_runs, 1000); for(int kr = 0; kr < krmax; kr++){ if(m_to_transfer.size() < 20 ) { if(run_vec[kr].getRunTag().getGeneralTag() != "GLOBAL") continue; bool somediff = false; // initialize this run status to all OK if(kr == 0) debug = true; else debug = false; irun = (unsigned long) run_vec[kr].getRunNumber(); for(int k = 0 ; k < 2; k++ ) { for(int iphi = 0 ; iphi < 72; iphi++) { for(int ieta = 0 ; ieta < 17; ieta++) { newEBStatus[iphi][ieta][k] = 0; } } for(int ix = 0 ; ix < 20; ix++) { for(int iy = 0 ; iy < 20; iy++) { newEEStatus[ix][iy][k] = 0; } } } // loop over side // these are the online conditions DB classes readout FEDs std::map<EcalLogicID, RunDat> fed_dat; econn->fetchDataSet(&fed_dat, &run_vec[kr]); // these are the online conditions DB classes unread FEs typedef std::map<EcalLogicID, RunDat>::const_iterator fedIter; // EcalLogicID ecid_xt; RunDat rdat_fe; EcalLogicID idfed; std::map<EcalLogicID, RunFEConfigDat> feconfig; econn->fetchDataSet(&feconfig, &run_vec[kr]); if(fed_dat.size() == 0 || feconfig.size() == 0) { std::cout << " run " << irun << " tag " << run_vec[kr].getRunTag().getGeneralTag() << " Run type " << run_vec[kr].getRunTag().getRunTypeDef().getRunType() << " feconfig and/or read FED size = 0, leaving..." << std::endl; continue; } if(fed_dat.size() != 54 ) { // debug = true; int SM[36] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int Sect[2][9] = {{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0}}; for (fedIter p=fed_dat.begin(); p!=fed_dat.end(); p++) { idfed = p->first; int sm = 0; int z = 0; if(idfed.getLogicID()<2000000000){// eb sm = idfed.getID1(); // std::cout << " EB " << sm; SM[sm - 1] = 1; } else { // ee z = idfed.getID1(); sm = idfed.getID2(); // std::cout << " EE " << z << " " << sm; int izz = z; if(z == -1) izz = 0; Sect[izz][sm - 1] = 1; } } // loop over all FED /* if(irun == 124089) { Sect[0][2] = 0; Sect[1][7] = 0; } */ // mark all TT/SC in the not read out FEDs for(int sm = 0; sm < 36; sm++) // barrel if(SM[sm] != 1) { //std::cout << " missing EB " << sm + 1 << std::endl; if(sm < 18) for(int tt = 0; tt < 68; tt++) newEBStatus[iphiEB[sm][tt] - 1][ietaEB[sm][tt] - 1][0] = 1; else for(int tt = 0; tt < 68; tt++) newEBStatus[iphiEB[sm - 18][tt] - 1][ietaEB[sm - 18][tt] - 1][1] = 1; } for(int z = 0; z < 2; z++) // endcaps for(int sec = 0; sec < 9; sec++) if(Sect[z][sec] != 1) { //std::cout << " missing EE " << z << " " << sec + 1 << std::endl; int sec18 = sec; if(z == 1) sec18 = sec + 9; for(int sc = 0 ; sc < 41; sc++) { if(ixx[sec18][sc][0] != 0) { newEEStatus[ixx[sec18][sc][0] - 1][iyy[sec18][sc][0] - 1][z] = 1; if(ixx[sec18][sc][1] != 0) { newEEStatus[ixx[sec18][sc][1] - 1][iyy[sec18][sc][1] - 1][z] = 1; if(ixx[sec18][sc][2] != 0) { newEEStatus[ixx[sec18][sc][2] - 1][iyy[sec18][sc][2] - 1][z] = 1; } } } } // loop over all possible SC in a sector } // not read out sector } // not all FED are read out typedef std::map<EcalLogicID, RunFEConfigDat>::const_iterator feConfIter; // EcalLogicID ecid_xt; RunFEConfigDat rd_fe; int fe_conf_id = 0; for (feConfIter p=feconfig.begin(); p!=feconfig.end(); p++) { // ecid_xt = p->first; rd_fe = p->second; fe_conf_id = rd_fe.getConfigId(); } // reading this configuration ODFEDAQConfig myconfig; myconfig.setId(fe_conf_id); econn->fetchConfigSet(&myconfig); // list of bad towers int myTT = myconfig.getBadTTId(); ODBadTTInfo mybadTT; std::vector< ODBadTTDat > badTT_dat; unsigned NbadTT = 0; /* if(myTT == 0) { std::cout << " myTT = 0" << std::endl; continue; } else { */ if(myTT != 0) { mybadTT.setId(myTT); econn->fetchConfigSet(&mybadTT); econn->fetchConfigDataSet(&badTT_dat, &mybadTT); NbadTT = badTT_dat.size(); } /* std::cout << " run " << irun << " tag " << run_vec[kr].getRunTag().getGeneralTag() << " Run type " << run_vec[kr].getRunTag().getRunTypeDef().getRunType() << " number of read FEDs " << fed_dat.size() << " number of bad FEs " << NbadTT << " fe_conf_id " << fe_conf_id << std::endl; */ // *daqFile << " run " << irun << " bad TT number " << NbadTT << "\n" << "Towers : "; for(size_t iTT = 0; iTT < NbadTT; iTT++){ int fed_id = badTT_dat[iTT].getFedId(); int tt_id = badTT_dat[iTT].getTTId(); // int SM = badTT_dat[iTT].getSMId(); // SM always 0! int side = 0; // EB/EE- //*daqFile << fed_id << "/" << tt_id << " "; // std::cout << fed_id << "/" << tt_id << "/" << SM << "/" ; // std::cout << fed_id << "/" << tt_id << "/"; if(fed_id >= 610 && fed_id <= 645) { // barrel if(tt_id > 68) { //std::cout << " Problem in Fed " << fed_id << " TT " << tt_id << " Give up " << std::endl; continue; } if(fed_id > 627) side = +1; // EB+ if(debug) std::cout << " phi " << iphiEB[fed_id - 610][tt_id - 1] << " eta " << ietaEB[fed_id - 610][tt_id - 1] << " side " << side << std::endl; newEBStatus[iphiEB[fed_id - 610][tt_id - 1] - 1][ietaEB[fed_id - 610][tt_id - 1] - 1][side] = 1; } else if(fed_id <= 609 || (fed_id >= 646 && fed_id <= 654)) { // endcap if(tt_id > 41) { //std::cout << " Problem in Fed " << fed_id << " SC " << tt_id << " Give up " << std::endl; continue; } if(fed_id < 610) { // EE- if(debug) std::cout << " x " << ixx[fed_id - 601][tt_id - 1][0] << " y " << iyy[fed_id - 601][tt_id - 1][0]; newEEStatus[ixx[fed_id - 601][tt_id - 1][0] - 1][iyy[fed_id - 601][tt_id - 1][0] - 1][side] = 1; if(ixx[fed_id - 601][tt_id - 1][1] != 0) { // partial SC if(debug) std::cout << " x2 " << ixx[fed_id - 601][tt_id - 1][1] << " y2 " << iyy[fed_id - 601][tt_id - 1][1]; newEEStatus[ixx[fed_id - 601][tt_id - 1][1] - 1][iyy[fed_id - 601][tt_id - 1][1] - 1][side] = 1; if(ixx[fed_id - 601][tt_id - 1][2] != 0) { // partial SC if(debug) std::cout << " x3 " << ixx[fed_id - 601][tt_id - 1][2] << " y3 " << iyy[fed_id - 601][tt_id - 1][2]; newEEStatus[ixx[fed_id - 601][tt_id - 1][2] - 1][iyy[fed_id - 601][tt_id - 1][2] - 1][side] = 1; } } if(debug) std::cout << " side " << side << std::endl; } else { // EE+ side = +1; if(debug) std::cout << " x " << ixx[fed_id - 637][tt_id - 1][0] << " y " << iyy[fed_id - 637][tt_id - 1][0]; newEEStatus[ixx[fed_id - 637][tt_id - 1][0] - 1][iyy[fed_id - 637][tt_id - 1][0] - 1][side] = 1; if(ixx[fed_id - 637][tt_id - 1][1] != 0) { // partial SC if(debug) std::cout << " x2 " << ixx[fed_id - 637][tt_id - 1][1] << " y2 " << iyy[fed_id - 637][tt_id - 1][1]; newEEStatus[ixx[fed_id - 637][tt_id - 1][1] - 1][iyy[fed_id - 637][tt_id - 1][1] - 1][side] = 1; if(ixx[fed_id - 637][tt_id - 1][2] != 0) { // partial SC if(debug) std::cout << " x3 " << ixx[fed_id - 637][tt_id - 1][2] << " y3 " << iyy[fed_id - 637][tt_id - 1][2]; newEEStatus[ixx[fed_id - 637][tt_id - 1][2] - 1][iyy[fed_id - 637][tt_id - 1][2] - 1][side] = 1; } } if(debug) std::cout << " side " << side << std::endl; } } else { std::cout << " Strange Fed " << fed_id << " TT/SC " << tt_id << " Give up " << std::endl; continue; } } // end loop over iTT if(debug) std::cout << std::endl; //*daqFile << std::endl; for(int k = 0 ; k < 2; k++ ) { int iz = -1; if(k == 1) iz = 1; if(debug) std::cout << " Side : " << k << " barrel " << std::endl; // barrel for(int iphi = 0 ; iphi < 72; iphi++) { for(int ieta = 0 ; ieta < 17; ieta++) { if(newEBStatus[iphi][ieta][k] != oldEBStatus[iphi][ieta][k]) { somediff = true; EcalTrigTowerDetId ebid(iz, EcalBarrel, ieta + 1, iphi + 1); daq_temp->setValue( ebid, newEBStatus[iphi][ieta][k]); if(debug) std::cout << " change in EB side " << iz << " phi " << iphi +1 << " eta " << ieta + 1 << std::endl; } // new status if(debug) std::cout << newEBStatus[iphi][ieta][k] << " " ; oldEBStatus[iphi][ieta][k] = newEBStatus[iphi][ieta][k]; } if(debug) std::cout << std::endl; } if(debug) std::cout << " endcaps " << std::endl; // endcap for(int iy = 0 ; iy < 20; iy++) { for(int ix = 0 ; ix < 20; ix++) { if (EcalScDetId::validDetId(ix + 1, iy + 1, iz )){ if(newEEStatus[ix][iy][k] != oldEEStatus[ix][iy][k]) { somediff = true; EcalScDetId eeid(ix + 1, iy + 1, iz); daq_temp->setValue( eeid, newEEStatus[ix][iy][k]); if(debug) std::cout << " change in EE side " << iz << " x " << ix +1 << " y " << iy + 1 << std::endl; } // new status if(debug) std::cout << newEEStatus[ix][iy][k] << " " ; oldEEStatus[ix][iy][k] = newEEStatus[ix][iy][k]; } // valid SC else { if(debug) std::cout << ". "; } } if(debug) std::cout << std::endl; } } // loop over side if(somediff) { // we copy the last valid record to the object that is sent to the DB EcalDAQTowerStatus* daq_pop = new EcalDAQTowerStatus(); int iz = -1; for(int k = 0 ; k < 2; k++ ) { if(k == 1) iz = 1; for(int iphi = 1 ; iphi < 73; iphi++) { for(int ieta = 1 ; ieta < 18; ieta++) { if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,ieta,iphi )){ EcalTrigTowerDetId ebid(iz,EcalBarrel,ieta,iphi); uint16_t dbStatus = 0; dbStatus =(daq_temp->barrel( ebid.hashedIndex())).getStatusCode(); daq_pop->setValue( ebid, dbStatus ); } } // end loop over ieta } // end loop over iphi // endcap for(int ix = 1 ; ix < 21; ix++) { for(int iy = 1 ; iy < 21; iy++) { if (EcalScDetId::validDetId(ix,iy,iz )){ EcalScDetId eeid(ix,iy,iz); EcalDAQTowerStatus::const_iterator it =daq_temp->find(eeid.rawId()); uint16_t dbStatus = 0; if ( it != daq_temp->end() ) { dbStatus = it->getStatusCode(); } daq_pop->setValue( eeid, dbStatus ); } } // end loop over iy } // end loop over ix } // end loop over k (side) std::cout << "Generating popcon record for run "<< irun << std::endl; m_to_transfer.push_back(std::make_pair((EcalDAQTowerStatus*)daq_pop, irun)); ss << "Run=" << irun << "_DAQchanged_"<<std::endl; m_userTextLog = ss.str()+";"; } // some change found else { std::cout<< "Run DAQ record was the same as previous run " << std::endl; ss << "Run=" << irun << "_DAQunchanged_"<<std::endl; m_userTextLog = ss.str()+";"; } // no change } // check on number of already transferred runs } // loop over runs } // check on run number > 0 // disconnect from DB delete econn; delete daq_temp; std::cout << "Ecal - > end of getNewObjects -----------\n"; }
std::string popcon::EcalDAQHandler::id | ( | void | ) | const [inline, virtual] |
Implements popcon::PopConSourceHandler< EcalDAQTowerStatus >.
Definition at line 55 of file EcalDAQHandler.h.
References m_name.
{ return m_name;}
uint16_t popcon::EcalDAQHandler::OffDBStatus | ( | uint16_t | dbStatus, |
int | pos | ||
) |
Definition at line 153 of file EcalDAQHandler.cc.
References pos.
{ uint16_t hv_off_dbstatus = ( dbStatus & (1 << pos ) ) ; if(hv_off_dbstatus>0) hv_off_dbstatus=1; return hv_off_dbstatus; }
Definition at line 56 of file EcalDAQHandler.h.
unsigned long popcon::EcalDAQHandler::m_firstRun [private] |
Definition at line 62 of file EcalDAQHandler.h.
Referenced by EcalDAQHandler().
std::string popcon::EcalDAQHandler::m_gentag [private] |
Definition at line 70 of file EcalDAQHandler.h.
Referenced by EcalDAQHandler().
unsigned long popcon::EcalDAQHandler::m_lastRun [private] |
Definition at line 63 of file EcalDAQHandler.h.
Referenced by EcalDAQHandler().
std::string popcon::EcalDAQHandler::m_location [private] |
Definition at line 68 of file EcalDAQHandler.h.
Referenced by EcalDAQHandler().
std::string popcon::EcalDAQHandler::m_name [private] |
Definition at line 67 of file EcalDAQHandler.h.
Referenced by id().
std::string popcon::EcalDAQHandler::m_pass [private] |
Definition at line 66 of file EcalDAQHandler.h.
Referenced by EcalDAQHandler().
std::string popcon::EcalDAQHandler::m_runtype [private] |
Definition at line 69 of file EcalDAQHandler.h.
Referenced by EcalDAQHandler().
std::string popcon::EcalDAQHandler::m_sid [private] |
Definition at line 64 of file EcalDAQHandler.h.
Referenced by EcalDAQHandler().
std::string popcon::EcalDAQHandler::m_user [private] |
Definition at line 65 of file EcalDAQHandler.h.
Referenced by EcalDAQHandler().