14 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalLaserHandler")) {
16 std::cout <<
"EcalLaser Source handler constructor\n" << std::endl;
29 <<
" User: "<< m_user << std::endl;
31 std::cout <<
"*******************************************" << std::endl;
32 std::cout <<
"This is a fake run. No change to offline DB" << std::endl;
33 std::cout <<
"*******************************************" << std::endl;
49 std::cout <<
"===== " << reason <<
" =====" << std::endl;
50 if (hashedIndex < 0) {
53 << old.
p2 <<
", " << old.
p3 <<
"] ==> [" << current.
p1 <<
", " 54 << current.
p2 <<
", " << current.
p3 <<
"]" << std::endl;
58 << old.
p2 <<
", " << old.
p3 <<
"] ==> [" << current.
p1 <<
", " 59 << current.
p2 <<
", " << current.
p3 <<
"]" << std::endl;
67 if ((current.
p1 < 0) || (current.
p2 < 0) || (current.
p3 < 0)) {
70 }
else if ((current.
p1 > 10) || (current.
p2 > 10) || (current.
p3 > 10)) {
73 }
else if (((
diff(old.
p1, current.
p1) > 0.2) && (old.
p1 != 0) && (old.
p1 != 1)) ||
74 ((
diff(old.
p2, current.
p2) > 0.2) && (old.
p2 != 0) && (old.
p1 != 2)) ||
75 ((
diff(old.
p3, current.
p3) > 0.2) && (old.
p3 != 0) && (old.
p1 != 3))) {
77 notifyProblems(old, current, hashedIndex,
"Difference w.r.t. previous too large");
110 "EB_crystal_number").getLogicID()
112 << i->p1 <<
" " << i->p2 <<
" " << i->p3 << std::endl;
119 catch (std::runtime_error &e) {
138 "EE_crystal_number").getLogicID()
140 << i->p1 <<
" " << i->p2 <<
" " << i->p3 << std::endl;
147 catch (std::runtime_error &e) {
157 <<
" ---> getNewObjects" << std::endl;
159 std::cout <<
"------- Ecal -> getNewObjects\n";
162 unsigned long long max_since= 1;
169 Tm max_since_tm(max_since);
174 payload->getLaserMap();
175 std::cout <<
"payload->getLaserMap(): OK " << std::endl;
176 std::cout <<
"Its size is " << laserRatiosMap.
size() << std::endl;
178 payload->getTimeMap();
179 std::cout <<
"payload->getTimeMap(): OK " << std::endl;
180 std::cout <<
"Last Object in Offline DB has SINCE = " << max_since
182 <<
" (" << max_since_tm <<
")" 191 for (
int i=0;
i<92;
i++) {
193 if( t_min > timestamp.
t1) {
198 std::cout <<
"WOW: we just retrieved the last valid record from DB " 206 std::cout <<
"Making connection..." << std::flush;
209 }
catch (std::runtime_error &
e) {
221 std::vector<EcalLogicID> crystals_EB =
225 "EB_crystal_number", 4 );
226 std::vector<EcalLogicID> crystals_EE =
230 "EE_crystal_number", 4 );
232 std::vector<EcalLogicID>::const_iterator ieb = crystals_EB.begin();
233 std::vector<EcalLogicID>::const_iterator eeb = crystals_EB.end();
235 std::cout <<
"Got list of " << crystals_EB.size() <<
" crystals in EB" 237 std::cout <<
"Got list of " << crystals_EE.size() <<
" crystals in EE" 242 std::map<int, int> detids;
244 int iEta = ieb->getID1();
245 int iPhi = ieb->getID2();
249 detids[ieb->getLogicID()] = ebdetid;
252 std::cout <<
"Validated " << count <<
" logic ID's for EB" << std::endl;
256 std::vector<EcalLogicID>::const_iterator iee = crystals_EE.begin();
257 std::vector<EcalLogicID>::const_iterator eee = crystals_EE.end();
261 int iSide = iee->getID1();
262 int iX = iee->getID2();
263 int iY = iee->getID3();
264 EEDetId eedetidpos(iX,iY,iSide);
266 detids[iee->getLogicID()] = eedetidpos;
270 std::cout <<
"Validated " << count <<
" logic ID's for EE" << std::endl;
275 std::cout <<
"Retrieving corrections from ONLINE DB ... " << std::endl;
290 <<
"to " << tmax.
str() << std::endl;
293 tmax -= atoi(
m_maxtime.substr(1).c_str())*3600;
314 std::cout <<
"Tmin: " << tmin << std::endl;
315 std::cout <<
"Tmax: " << tmax << std::endl;
318 std::map<int, std::map<int, LMFSextuple> >
d =
321 std::cout <<
"Data organized into " << d.size() <<
" sequences" << std::endl;
323 std::map<int, std::map<int, LMFSextuple> >::const_iterator iseq = d.begin();
324 std::map<int, std::map<int, LMFSextuple> >::const_iterator eseq = d.end();
325 std::cout <<
"===== Looping on Sequences" << std::endl;
326 while (iseq != eseq) {
327 std::cout <<
"==== SEQ_ID: " << iseq->first
328 <<
" contains " << iseq->second.size() <<
" crystals" 329 << std::endl << std::flush;
331 if (iseq->second.size() == (61200 + 14648)) {
332 std::map<int, LMFSextuple>::const_iterator is = iseq->second.begin();
333 std::map<int, LMFSextuple>::const_iterator es = iseq->second.end();
335 Time_t t_last = 18446744073709551615ULL;
338 apdpnpair_temp.
p1 = is->second.p[0];
339 apdpnpair_temp.
p2 = is->second.p[1];
340 apdpnpair_temp.
p3 = is->second.p[2];
345 apdpns_popcon->
setValue(detids[is->first], apdpnpair_temp);
346 if (logicId2Lmr.find(is->first) != logicId2Lmr.end()) {
348 if ((hashedIndex >= 0) && (hashedIndex <= 91)) {
349 apdpns_popcon->
setTime( hashedIndex , timestamp_temp);
350 if (t_last > timestamp_temp.
t1.
value()) {
351 t_last = timestamp_temp.
t1.
value();
354 std::stringstream ss;
355 ss <<
"LOGIC_ID: " << is->first <<
" LMR: " << hashedIndex + 1
357 throw(std::runtime_error(
"[EcalLaserHandler::getNewObjects]" +
361 std::stringstream ss;
362 ss <<
"LOGIC_ID: " << is->first <<
" Cannot determine LMR";
363 throw(std::runtime_error(
"[EcalLaserHandler::getNewObjects]" +
369 delete apdpns_popcon;
371 if ((!iseq->second.empty()) && (!
m_fake)) {
373 Tm(t_last).cmsNanoSeconds()));
380 std::cout <<
"==== END OF LOOP ON SEQUENCES" << std::endl << std::flush;
382 std::cout <<
"Ecal -> end of getNewObjects -----------\n";
T getParameter(std::string const &) const
edm::Ref< Container > Ref
void dumpEndcapPayload(EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap const &laserMap)
std::map< int, std::map< int, LMFSextuple > > getCorrections(const Tm &t)
void getNewObjects() override
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
const Items & barrelItems() const
void notifyProblems(const EcalLaserAPDPNRatios::EcalLaserAPDPNpair &old, const EcalLaserAPDPNRatios::EcalLaserAPDPNpair ¤t, int hashedIndex, const std::string &reason)
void setToCurrentLocalTime()
static EEDetId unhashIndex(int hi)
bool checkAPDPN(const EcalLaserAPDPNRatios::EcalLaserAPDPNpair &old, const EcalLaserAPDPNRatios::EcalLaserAPDPNpair ¤t, int hashedIndex)
OldContainer m_to_transfer
uint64_t microsTime() const
bool checkAPDPNs(const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap &laserMap, const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap &apdpns_popcon)
int iphi() const
get the crystal iphi
EcalCondDBInterface * econn
int hashedIndex(int ieta, int iphi)
cond::ValidityInterval lastInterval
EcalLaserHandler(edm::ParameterSet const &)
void setTime(int hashedIndex, const EcalLaserTimeStamp &value)
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) noexcept(false)
std::map< int, int > getEcalLogicID2LmrMap()
Abs< T >::type abs(const T &t)
int ieta() const
get the crystal ieta
uint64_t cmsNanoSeconds() const
unsigned long m_sequences
static const double tmax[3]
void setToString(const std::string s) noexcept(false)
std::vector< EcalLaserTimeStamp > EcalLaserTimeStampMap
std::vector< Item >::const_iterator const_iterator
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
char data[epos_bytes_allocation]
void dumpBarrelPayload(EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap const &laserMap)
const Item & barrel(size_t hashedIndex) const
const Items & endcapItems() const
const Item & endcap(size_t hashedIndex) const
~EcalLaserHandler() override
double diff(float x, float old_x)
TimeValue_t value() const
cond::TagInfo_t const & tagInfo() const