#include <EcalADCToGeVHandler.h>
Public Member Functions | |
EcalADCToGeVHandler (edm::ParameterSet const &) | |
void | getNewObjects () |
std::string | id () const |
~EcalADCToGeVHandler () | |
Public Attributes | |
EcalCondDBInterface * | econn |
Private Attributes | |
std::string | m_file_highfield |
std::string | m_file_lowfield |
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 EcalADCToGeVConstant * | myintercalib |
Definition at line 56 of file EcalADCToGeVHandler.h.
popcon::EcalADCToGeVHandler::EcalADCToGeVHandler | ( | edm::ParameterSet const & | ps | ) |
Definition at line 9 of file EcalADCToGeVHandler.cc.
References gather_cfg::cout, edm::ParameterSet::getParameter(), m_file_highfield, m_file_lowfield, m_firstRun, m_gentag, m_lastRun, m_location, m_locationsource, m_pass, m_sid, and m_user.
: m_name(ps.getUntrackedParameter<std::string>("name","EcalADCToGeVHandler")) { std::cout << "EcalADCToGeV Source handler constructor\n" << std::endl; m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str())); m_lastRun=static_cast<unsigned int>(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_locationsource= ps.getParameter<std::string>("LocationSource"); m_location=ps.getParameter<std::string>("Location"); m_gentag=ps.getParameter<std::string>("GenTag"); m_file_lowfield= ps.getParameter<std::string>("FileLowField"); m_file_highfield= ps.getParameter<std::string>("FileHighField"); std::cout << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag << std::endl; }
popcon::EcalADCToGeVHandler::~EcalADCToGeVHandler | ( | ) |
Definition at line 31 of file EcalADCToGeVHandler.cc.
{ }
void popcon::EcalADCToGeVHandler::getNewObjects | ( | ) | [virtual] |
Implements popcon::PopConSourceHandler< EcalADCToGeVConstant >.
Definition at line 36 of file EcalADCToGeVHandler.cc.
References gather_cfg::cout, BeamSplash_cfg::dataset, Exception, EcalADCToGeVConstant::getEBValue(), RunDCSMagnetDat::getMagnetCurrent(), RunIOV::getRunNumber(), MultipleCompare::header, and EcalADCToGeVXMLTranslator::readXML().
{ std::cout << "------- Ecal - > getNewObjects\n"; std::ostringstream ss; ss<<"ECAL "; unsigned int max_since=0; max_since=static_cast<unsigned int>(tagInfo().lastInterval.first); std::cout << "max_since : " << max_since << std::endl; Ref ped_db = lastPayload(); // we parse the last record in the DB and check if it is low or high field std::cout << "retrieved last payload " << std::endl; EcalADCToGeVConstant the_cal ; float adc_eb=ped_db->getEBValue(); float adc_ee=ped_db->getEEValue(); float the_value_high_eb=0.03894; float the_value_high_ee=0.06285; bool magnet_high=true; if(adc_eb!= the_value_high_eb || adc_ee!= the_value_high_ee ) magnet_high=false; // here we connect to the online DB to check the value of the magnetic field std::cout << "Connecting to ONLINE 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"); } std::cout << "Retrieving last run from ONLINE DB ... " << std::endl; std::map<EcalLogicID, RunDat> rundat; RunIOV rp ; run_t runmax=10000000; std::string location_p5="P5_Co"; econn->fetchValidDataSet(&rundat , &rp, location_p5 ,runmax); unsigned long long irun=(unsigned long long) rp.getRunNumber(); std::cout<< "retrieved run number "<< irun <<std::endl; if(irun>max_since) { // retrieve from last value data record // always call this method at first run std::map<EcalLogicID, RunDCSMagnetDat> dataset; econn->fetchDataSet(&dataset, &rp); if (!dataset.size()) { throw(std::runtime_error("Zero rows read back")); } else { std::cout<< "retrieved magnet current"<<std::endl; } float mag_cur=0; std::map< EcalLogicID, RunDCSMagnetDat >::iterator it; for (it=dataset.begin(); it!=dataset.end(); ++it){ RunDCSMagnetDat a_mag = (*it).second; mag_cur= a_mag.getMagnetCurrent(); } std::string file_=m_file_highfield; bool something_to_transfer=false; if(mag_cur>7000. && magnet_high ) { std::cout << " the magnet is ON and the constants are for magnet ON " << std::endl; } else if(mag_cur>7000. && !magnet_high ) { something_to_transfer=true; std::cout << " the magnet is ON and the constants are for magnet OFF " << std::endl; std::cout << " I transfer the ON constants "<< std::endl; file_=m_file_highfield; } else if(mag_cur<6000. && magnet_high ) { something_to_transfer=true; std::cout << " the magnet is OFF and the constants are for magnet ON "<< std::endl; std::cout << " I transfer the OFF constants "<< std::endl; file_=m_file_lowfield; } else if( mag_cur<6000. && !magnet_high ){ std::cout << " the magnet is OFF and the constants are for magnet OFF "<< std::endl; file_=m_file_lowfield; } else { std::cout << " the magnet is in a strange situation I do nothing ... just be patient "<< std::endl; } if(something_to_transfer){ std::cout << "Generating popcon record for run " << irun << "..." << std::flush; std::cout << "going to open file "<<file_ << std::flush; EcalCondHeader header; EcalADCToGeVConstant * payload = new EcalADCToGeVConstant; EcalADCToGeVXMLTranslator::readXML(file_,header,*payload); Time_t snc= (Time_t) irun ; popcon::PopConSourceHandler<EcalADCToGeVConstant>::m_to_transfer.push_back( std::make_pair(payload,snc)); ss << "Run=" << irun << "_Magnet_changed_"<<std::endl; m_userTextLog = ss.str()+";"; } else { std::cout << "Run " << irun << " nothing sent to the DB"<< std::endl; ss<< "Run=" << irun << "_Magnet_NOT_changed_"<<std::endl; m_userTextLog = ss.str()+";"; } delete econn; } else { std::cout << "Run " << irun << " nothing sent to the DB"<< std::endl; ss<< "Run=" << irun << "_no_new_runs_"<<std::endl; m_userTextLog = ss.str()+";"; } std::cout << "Ecal - > end of getNewObjects -----------\n"; }
std::string popcon::EcalADCToGeVHandler::id | ( | void | ) | const [inline, virtual] |
Implements popcon::PopConSourceHandler< EcalADCToGeVConstant >.
Definition at line 65 of file EcalADCToGeVHandler.h.
References m_name.
{ return m_name;}
Definition at line 66 of file EcalADCToGeVHandler.h.
std::string popcon::EcalADCToGeVHandler::m_file_highfield [private] |
Definition at line 84 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
std::string popcon::EcalADCToGeVHandler::m_file_lowfield [private] |
Definition at line 83 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
unsigned int popcon::EcalADCToGeVHandler::m_firstRun [private] |
Definition at line 73 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
std::string popcon::EcalADCToGeVHandler::m_gentag [private] |
Definition at line 77 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
unsigned int popcon::EcalADCToGeVHandler::m_lastRun [private] |
Definition at line 74 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
std::string popcon::EcalADCToGeVHandler::m_location [private] |
Definition at line 76 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
std::string popcon::EcalADCToGeVHandler::m_locationsource [private] |
Definition at line 81 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
std::string popcon::EcalADCToGeVHandler::m_name [private] |
Definition at line 82 of file EcalADCToGeVHandler.h.
Referenced by id().
std::string popcon::EcalADCToGeVHandler::m_pass [private] |
Definition at line 80 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
std::string popcon::EcalADCToGeVHandler::m_sid [private] |
Definition at line 78 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
std::string popcon::EcalADCToGeVHandler::m_user [private] |
Definition at line 79 of file EcalADCToGeVHandler.h.
Referenced by EcalADCToGeVHandler().
const EcalADCToGeVConstant* popcon::EcalADCToGeVHandler::myintercalib [private] |
Definition at line 71 of file EcalADCToGeVHandler.h.