#include <EcalLaserHandler.h>
Definition at line 55 of file EcalLaserHandler.h.
popcon::EcalLaserHandler::~EcalLaserHandler | ( | ) |
Definition at line 30 of file EcalLaserHandler.cc.
{
// do nothing
}
popcon::EcalLaserHandler::EcalLaserHandler | ( | edm::ParameterSet const & | ps | ) |
Definition at line 13 of file EcalLaserHandler.cc.
References gather_cfg::cout, edm::ParameterSet::getParameter(), m_debug, m_maxtime, m_pass, m_sequences, m_sid, and m_user.
: m_name(ps.getUntrackedParameter<std::string>("name","EcalLaserHandler")) { std::cout << "EcalLaser Source handler constructor\n" << std::endl; m_sequences = 1; m_sid= ps.getParameter<std::string>("OnlineDBSID"); m_user= ps.getParameter<std::string>("OnlineDBUser"); m_pass= ps.getParameter<std::string>("OnlineDBPassword"); m_debug=ps.getParameter<bool>("debug"); m_sequences=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("sequences").c_str())); m_maxtime=ps.getParameter<std::string>("maxtime").c_str(); std::cout << "Starting O2O process on DB: " << m_sid << " User: "<< m_user << std::endl; }
bool popcon::EcalLaserHandler::checkAPDPN | ( | const EcalLaserAPDPNRatios::EcalLaserAPDPNpair & | old, |
const EcalLaserAPDPNRatios::EcalLaserAPDPNpair & | current, | ||
int | hashedIndex | ||
) |
Definition at line 56 of file EcalLaserHandler.cc.
References diffTreeTool::diff, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, and runTheMatrix::ret.
{ bool ret = true; if ((current.p1 < 0) || (current.p2 < 0) || (current.p3 < 0)) { ret = false; notifyProblems(old, current, hashedIndex, "Negative values"); } else if ((current.p1 > 10) || (current.p2 > 10) || (current.p3 > 0)) { ret = false; notifyProblems(old, current, hashedIndex, "Values too large"); } else if (((diff(old.p1, current.p1) > 0.2) && (old.p1 != 0) && (old.p1 != 1)) || ((diff(old.p2, current.p2) > 0.2) && (old.p2 != 0) && (old.p1 != 2)) || ((diff(old.p3, current.p3) > 0.2) && (old.p3 != 0) && (old.p1 != 3))) { ret = false; notifyProblems(old, current, hashedIndex, "Difference w.r.t. previous too large"); } return ret; }
bool popcon::EcalLaserHandler::checkAPDPNs | ( | const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap & | laserMap, |
const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap & | apdpns_popcon | ||
) |
Definition at line 75 of file EcalLaserHandler.cc.
References EcalCondObjectContainer< T >::barrel(), cond::rpcobimon::current, EcalCondObjectContainer< T >::endcap(), ecalpyutils::hashedIndex(), and runTheMatrix::ret.
{ bool ret = true; for (int hashedIndex = 0; hashedIndex < 61200; hashedIndex++) { EcalLaserAPDPNRatios::EcalLaserAPDPNpair old = laserMap.barrel(hashedIndex); EcalLaserAPDPNRatios::EcalLaserAPDPNpair current = apdpns_popcon.barrel(hashedIndex); ret = checkAPDPN(old, current, hashedIndex); } for (int hashedIndex = 0; hashedIndex < 14648; hashedIndex++) { EcalLaserAPDPNRatios::EcalLaserAPDPNpair old = laserMap.endcap(hashedIndex); EcalLaserAPDPNRatios::EcalLaserAPDPNpair current = apdpns_popcon.endcap(hashedIndex); ret = checkAPDPN(old, current, -hashedIndex); } return ret; }
double popcon::EcalLaserHandler::diff | ( | float | x, |
float | old_x | ||
) |
void popcon::EcalLaserHandler::dumpBarrelPayload | ( | EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap const & | laserMap | ) |
Definition at line 91 of file EcalLaserHandler.cc.
References EcalCondObjectContainer< T >::barrelItems(), trackerHits::c, benchmark_cfg::cerr, gather_cfg::cout, Exception, EcalCondDBInterface::getEcalLogicID(), i, EBDetId::ieta(), EBDetId::iphi(), EcalLogicID::NULLID, and EBDetId::unhashIndex().
{ int c = 0; EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap::const_iterator i = laserMap.barrelItems().begin(); EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap::const_iterator e = laserMap.barrelItems().end(); EBDetId eb; try { EcalCondDBInterface *econn = new EcalCondDBInterface( m_sid, m_user, m_pass ); while (i != e) { if (c % 1000 == 0) { std::cout << std::setw(5) << c << ": " << eb.unhashIndex(c) << " " << econn->getEcalLogicID("EB_crystal_angle", eb.unhashIndex(c).ieta(), eb.unhashIndex(c).iphi(), EcalLogicID::NULLID, "EB_crystal_number").getLogicID() << " " << std::setiosflags(std::ios::fixed) << std::setprecision(9) << i->p1 << " " << i->p2 << " " << i->p3 << std::endl; } i++; c++; } delete econn; } catch (std::runtime_error &e) { std::cerr << e.what() << std::endl; delete econn; throw cms::Exception("OMDS not available"); } }
void popcon::EcalLaserHandler::dumpEndcapPayload | ( | EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap const & | laserMap | ) |
Definition at line 119 of file EcalLaserHandler.cc.
References trackerHits::c, benchmark_cfg::cerr, gather_cfg::cout, EcalCondObjectContainer< T >::endcapItems(), Exception, EcalCondDBInterface::getEcalLogicID(), i, EEDetId::ix(), EEDetId::iy(), EEDetId::unhashIndex(), and EEDetId::zside().
{ int c = 0; EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap::const_iterator i = laserMap.endcapItems().begin(); EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap::const_iterator e = laserMap.endcapItems().end(); EEDetId ee; try { EcalCondDBInterface *econn = new EcalCondDBInterface( m_sid, m_user, m_pass ); while (i != e) { if (c % 1000 == 0) { std::cout << std::setw(5) << c << ": " << ee.unhashIndex(c) << " " << econn->getEcalLogicID("EE_crystal_number", ee.unhashIndex(c).zside(), ee.unhashIndex(c).ix(), ee.unhashIndex(c).iy(), "EE_crystal_number").getLogicID() << " " << std::setiosflags(std::ios::fixed) << std::setprecision(9) << i->p1 << " " << i->p2 << " " << i->p3 << std::endl; } i++; c++; } delete econn; } catch (std::runtime_error &e) { std::cerr << e.what() << std::endl; delete econn; throw cms::Exception("OMDS not available"); } }
void popcon::EcalLaserHandler::getNewObjects | ( | ) | [virtual] |
Implements popcon::PopConSourceHandler< EcalLaserAPDPNRatios >.
Definition at line 147 of file EcalLaserHandler.cc.
References benchmark_cfg::cerr, prof2calltree::count, gather_cfg::cout, runTheMatrix::data, LMFCorrCoefDat::debug(), Exception, LMFCorrCoefDat::getCorrections(), ecalpyutils::hashedIndex(), i, Tm::microsTime(), EcalLogicID::NULLID, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, EcalLaserAPDPNRatios::setTime(), Tm::setToMicrosTime(), Tm::setToString(), EcalLaserAPDPNRatios::setValue(), EcalCondObjectContainer< T >::size(), Tm::str(), EcalLaserAPDPNRatios::EcalLaserTimeStamp::t1, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t2, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t3, cond::timestamp, tmax, and edm::Timestamp::value().
{ std::cerr << "------- " << m_name << " ---> getNewObjects" << std::endl; std::cout << "------- Ecal -> getNewObjects\n"; unsigned long long max_since= 1; Ref payload= lastPayload(); // here popcon tells us which is the last since of the last object in the // offline DB max_since=tagInfo().lastInterval.first; Tm max_since_tm(max_since); // get the last object in the orcoff edm::Timestamp t_min= edm::Timestamp(18446744073709551615ULL); const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = payload->getLaserMap(); std::cout << "payload->getLaserMap(): OK " << std::endl; std::cout << "Its size is " << laserRatiosMap.size() << std::endl; const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = payload->getTimeMap(); std::cout << "payload->getTimeMap(): OK " << std::endl; std::cout << "Last Object in Offline DB has SINCE = " << max_since << " (" << max_since_tm.str() << ")" << " and SIZE = " << tagInfo().size << std::endl; // loop through light modules and determine the minimum date among the // available channels dumpBarrelPayload(laserRatiosMap); dumpEndcapPayload(laserRatiosMap); for (int i=0; i<92; i++) { EcalLaserAPDPNRatios::EcalLaserTimeStamp timestamp = laserTimeMap[i]; if( t_min > timestamp.t1) { t_min=timestamp.t1; } } std::cout <<"WOW: we just retrieved the last valid record from DB " << std::endl; std::cout <<"Its tmin is "<< Tm(t_min.value()).str() << std::endl; // connect to the database try { std::cout << "Making connection..." << std::flush; econn = new EcalCondDBInterface( m_sid, m_user, m_pass ); std::cout << "Done." << std::endl; } catch (std::runtime_error &e) { std::cout << " connection parameters " << m_sid << "/" << m_user; if (m_debug) { std::cout << "/" << m_pass <<std::endl; } else { std::cout << "/**********" <<std::endl; } std::cerr << e.what() << std::endl; throw cms::Exception("OMDS not available"); } // retrieve the lists of logic_ids, to build the detids std::vector<EcalLogicID> crystals_EB = econn->getEcalLogicIDSetOrdered( "EB_crystal_angle", -85,85,1,360, EcalLogicID::NULLID,EcalLogicID::NULLID, "EB_crystal_number", 4 ); std::vector<EcalLogicID> crystals_EE = econn->getEcalLogicIDSetOrdered( "EE_crystal_number", -1,1,1,100, 1,100, "EE_crystal_number", 4 ); std::vector<EcalLogicID>::const_iterator ieb = crystals_EB.begin(); std::vector<EcalLogicID>::const_iterator eeb = crystals_EB.end(); std::cout << "Got list of " << crystals_EB.size() << " crystals in EB" << std::endl; std::cout << "Got list of " << crystals_EE.size() << " crystals in EE" << std::endl; // loop through barrel int count = 0; // prepare a map to associate EB logic id's to detids std::map<int, int> detids; while (ieb != eeb) { int iEta = ieb->getID1(); int iPhi = ieb->getID2(); count++; EBDetId ebdetid(iEta,iPhi); // unsigned int hieb = ebdetid.hashedIndex(); detids[ieb->getLogicID()] = ebdetid; ieb++; } std::cout << "Validated " << count << " logic ID's for EB" << std::endl; // do the same for EE std::vector<EcalLogicID>::const_iterator iee = crystals_EE.begin(); std::vector<EcalLogicID>::const_iterator eee = crystals_EE.end(); count = 0; while (iee != eee) { int iSide = iee->getID1(); int iX = iee->getID2(); int iY = iee->getID3(); EEDetId eedetidpos(iX,iY,iSide); // int hi = eedetidpos.hashedIndex(); detids[iee->getLogicID()] = eedetidpos; count ++; iee++; } std::cout << "Validated " << count << " logic ID's for EE" << std::endl; // get association between ecal logic id and LMR std::map<int, int> logicId2Lmr = econn->getEcalLogicID2LmrMap(); std::cout << "Retrieving corrections from ONLINE DB ... " << std::endl; LMFCorrCoefDat data(econn); if (m_debug) { data.debug(); } // get all data in the database taken after the last available time in ORCOFF // we associate another map, whose key is the crystal ID and whose value is a // sextuple (p1, p2, p3, t1, t2, t3) Tm tmax; tmax.setToString(m_maxtime); Tm tmin = Tm(t_min.value()); // GO DEBUGGING Tm tgo; tgo.setToString("2011-02-24 23:59:59"); if (tmin.microsTime() < tgo.microsTime()) { tmin.setToMicrosTime(tgo.microsTime()); } std::map<int, std::map<int, LMFSextuple> > d = data.getCorrections(tmin, tmax, m_sequences); // sice must be equal to the number of different SEQ_ID's found std::cout << "Data organized into " << d.size() << " sequences" << std::endl; // iterate over sequences std::map<int, std::map<int, LMFSextuple> >::const_iterator iseq = d.begin(); std::map<int, std::map<int, LMFSextuple> >::const_iterator eseq = d.end(); std::cout << "===== Looping on Sequences" << std::endl; while (iseq != eseq) { std::cout << "==== SEQ_ID: " << iseq->first << " contains " << iseq->second.size() << " crystals" << std::endl << std::flush; // iterate over crystals std::map<int, LMFSextuple>::const_iterator is = iseq->second.begin(); std::map<int, LMFSextuple>::const_iterator es = iseq->second.end(); EcalLaserAPDPNRatios* apdpns_popcon = new EcalLaserAPDPNRatios(); Time_t t_last = t_min.value(); while (is != es) { EcalLaserAPDPNRatios::EcalLaserAPDPNpair apdpnpair_temp; apdpnpair_temp.p1 = is->second.p[0]; apdpnpair_temp.p2 = is->second.p[1]; apdpnpair_temp.p3 = is->second.p[2]; EcalLaserAPDPNRatios::EcalLaserTimeStamp timestamp_temp; timestamp_temp.t1 = edm::Timestamp(is->second.t[0].microsTime()); timestamp_temp.t2 = edm::Timestamp(is->second.t[1].microsTime()); timestamp_temp.t3 = edm::Timestamp(is->second.t[2].microsTime()); apdpns_popcon->setValue(detids[is->first], apdpnpair_temp); if (logicId2Lmr.find(is->first) != logicId2Lmr.end()) { int hashedIndex = logicId2Lmr[is->first] - 1; if ((hashedIndex >= 0) && (hashedIndex <= 91)) { apdpns_popcon->setTime( hashedIndex , timestamp_temp); t_last = timestamp_temp.t1.value(); } else { std::stringstream ss; ss << "LOGIC_ID: " << is->first << " LMR: " << hashedIndex + 1 << " Out of range"; throw(std::runtime_error("[EcalLaserHandler::getNewObjects]" + ss.str())); } } else { std::stringstream ss; ss << "LOGIC_ID: " << is->first << " Cannot determine LMR"; throw(std::runtime_error("[EcalLaserHandler::getNewObjects]" + ss.str())); } is++; } if (iseq->second.size() > 0) { m_to_transfer.push_back(std::make_pair(apdpns_popcon, t_last)); } iseq++; } std::cout << "==== END OF LOOP ON SEQUENCES" << std::endl << std::flush; delete econn; std::cout << "Ecal -> end of getNewObjects -----------\n"; }
std::string popcon::EcalLaserHandler::id | ( | void | ) | const [inline, virtual] |
Implements popcon::PopConSourceHandler< EcalLaserAPDPNRatios >.
Definition at line 65 of file EcalLaserHandler.h.
References m_name.
{ return m_name;}
void popcon::EcalLaserHandler::notifyProblems | ( | const EcalLaserAPDPNRatios::EcalLaserAPDPNpair & | old, |
const EcalLaserAPDPNRatios::EcalLaserAPDPNpair & | current, | ||
int | hashedIndex, | ||
const std::string & | reason | ||
) |
Definition at line 39 of file EcalLaserHandler.cc.
References gather_cfg::cout, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, EBDetId::unhashIndex(), and EEDetId::unhashIndex().
{ std::cout << "===== " << reason << " =====" << std::endl; if (hashedIndex < 0) { EEDetId ee; std::cout << "Triplets for " << ee.unhashIndex(-hashedIndex) << " bad: [" << old.p1 << ", " << old.p2 << ", " << old.p3 << "] ==> [" << current.p1 << ", " << current.p2 << ", " << current.p3 << "]" << std::endl; } else { EBDetId eb; std::cout << "Triplets for " << eb.unhashIndex(hashedIndex) << " bad: [" << old.p1 << ", " << old.p2 << ", " << old.p3 << "] ==> [" << current.p1 << ", " << current.p2 << ", " << current.p3 << "]" << std::endl; } }
Definition at line 64 of file EcalLaserHandler.h.
bool popcon::EcalLaserHandler::m_debug [private] |
Definition at line 86 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler().
std::string popcon::EcalLaserHandler::m_maxtime [private] |
Definition at line 85 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler().
std::string popcon::EcalLaserHandler::m_name [private] |
Definition at line 84 of file EcalLaserHandler.h.
Referenced by id().
std::string popcon::EcalLaserHandler::m_pass [private] |
Definition at line 83 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler().
unsigned long popcon::EcalLaserHandler::m_sequences [private] |
Definition at line 80 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler().
std::string popcon::EcalLaserHandler::m_sid [private] |
Definition at line 81 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler().
std::string popcon::EcalLaserHandler::m_user [private] |
Definition at line 82 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler().
const EcalLaserAPDPNRatios* popcon::EcalLaserHandler::myapdpns [private] |
Definition at line 79 of file EcalLaserHandler.h.