14 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalLaserHandler")) {
15 std::cout <<
"EcalLaser Source handler constructor\n" << std::endl;
27 std::cout <<
"Starting O2O process on DB: " <<
m_sid <<
" User: " << m_user << std::endl;
29 std::cout <<
"*******************************************" << std::endl;
30 std::cout <<
"This is a fake run. No change to offline DB" << std::endl;
31 std::cout <<
"*******************************************" << std::endl;
45 std::cout <<
"===== " << reason <<
" =====" << std::endl;
46 if (hashedIndex < 0) {
49 << old.
p3 <<
"] ==> [" << current.
p1 <<
", " << current.
p2 <<
", " << current.
p3 <<
"]" << std::endl;
53 << old.
p3 <<
"] ==> [" << current.
p1 <<
", " << current.
p2 <<
", " << current.
p3 <<
"]" << std::endl;
61 if ((current.
p1 < 0) || (current.
p2 < 0) || (current.
p3 < 0)) {
63 notifyProblems(old, current, hashedIndex,
"Negative values");
64 }
else if ((current.
p1 > 10) || (current.
p2 > 10) || (current.
p3 > 10)) {
66 notifyProblems(old, current, hashedIndex,
"Values too large");
67 }
else if (((
diff(old.
p1, current.
p1) > 0.2) && (old.
p1 != 0) && (old.
p1 != 1)) ||
68 ((
diff(old.
p2, current.
p2) > 0.2) && (old.
p2 != 0) && (old.
p1 != 2)) ||
69 ((
diff(old.
p3, current.
p3) > 0.2) && (old.
p3 != 0) && (old.
p1 != 3))) {
71 notifyProblems(old, current, hashedIndex,
"Difference w.r.t. previous too large");
109 <<
" " << std::setiosflags(std::ios::fixed) << std::setprecision(9) << i->p1 <<
" " << i->p2 <<
" "
110 << i->p3 << std::endl;
116 }
catch (std::runtime_error &e) {
140 <<
" " << std::setiosflags(std::ios::fixed) << std::setprecision(9) << i->p1 <<
" " << i->p2 <<
" "
141 << i->p3 << std::endl;
147 }
catch (std::runtime_error &e) {
155 std::cerr <<
"------- " << m_name <<
" ---> getNewObjects" << std::endl;
157 std::cout <<
"------- Ecal -> getNewObjects\n";
159 unsigned long long max_since = 1;
164 max_since =
tagInfo().lastInterval.since;
166 Tm max_since_tm(max_since);
171 std::cout <<
"payload->getLaserMap(): OK " << std::endl;
172 std::cout <<
"Its size is " << laserRatiosMap.
size() << std::endl;
174 std::cout <<
"payload->getTimeMap(): OK " << std::endl;
175 std::cout <<
"Last Object in Offline DB has SINCE = " << max_since <<
" -> " << max_since_tm.
cmsNanoSeconds() <<
" ("
176 << max_since_tm <<
")"
177 <<
" and SIZE = " <<
tagInfo().size << std::endl;
181 dumpBarrelPayload(laserRatiosMap);
182 dumpEndcapPayload(laserRatiosMap);
184 for (
int i = 0;
i < 92;
i++) {
186 if (t_min > timestamp.
t1) {
187 t_min = timestamp.
t1;
191 std::cout <<
"WOW: we just retrieved the last valid record from DB " << std::endl;
197 std::cout <<
"Making connection..." << std::flush;
200 }
catch (std::runtime_error &
e) {
201 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user;
212 std::vector<EcalLogicID> crystals_EB =
econn->getEcalLogicIDSetOrdered(
214 std::vector<EcalLogicID> crystals_EE =
215 econn->getEcalLogicIDSetOrdered(
"EE_crystal_number", -1, 1, 1, 100, 1, 100,
"EE_crystal_number", 4);
217 std::vector<EcalLogicID>::const_iterator ieb = crystals_EB.begin();
218 std::vector<EcalLogicID>::const_iterator eeb = crystals_EB.end();
220 std::cout <<
"Got list of " << crystals_EB.size() <<
" crystals in EB" << std::endl;
221 std::cout <<
"Got list of " << crystals_EE.size() <<
" crystals in EE" << std::endl;
225 std::map<int, int> detids;
227 int iEta = ieb->getID1();
228 int iPhi = ieb->getID2();
232 detids[ieb->getLogicID()] = ebdetid;
235 std::cout <<
"Validated " << count <<
" logic ID's for EB" << std::endl;
239 std::vector<EcalLogicID>::const_iterator iee = crystals_EE.begin();
240 std::vector<EcalLogicID>::const_iterator eee = crystals_EE.end();
244 int iSide = iee->getID1();
245 int iX = iee->getID2();
246 int iY = iee->getID3();
247 EEDetId eedetidpos(iX, iY, iSide);
249 detids[iee->getLogicID()] = eedetidpos;
253 std::cout <<
"Validated " << count <<
" logic ID's for EE" << std::endl;
256 std::map<int, int> logicId2Lmr =
econn->getEcalLogicID2LmrMap();
258 std::cout <<
"Retrieving corrections from ONLINE DB ... " << std::endl;
268 if (m_maxtime[0] ==
'-') {
272 std::cout <<
"Subtracting " << m_maxtime.substr(1) <<
" hours "
273 <<
"to " << tmax.
str() << std::endl;
276 tmax -= atoi(m_maxtime.substr(1).c_str()) * 3600;
282 std::cout <<
"Setting t_max to " << m_maxtime << std::endl;
297 std::cout <<
"Tmin: " << tmin << std::endl;
298 std::cout <<
"Tmax: " << tmax << std::endl;
301 std::map<int, std::map<int, LMFSextuple> >
d = data.
getCorrections(tmin, tmax, m_sequences);
303 std::cout <<
"Data organized into " << d.size() <<
" sequences" << std::endl;
305 std::map<int, std::map<int, LMFSextuple> >::const_iterator iseq = d.begin();
306 std::map<int, std::map<int, LMFSextuple> >::const_iterator eseq = d.end();
307 std::cout <<
"===== Looping on Sequences" << std::endl;
308 while (iseq != eseq) {
309 std::cout <<
"==== SEQ_ID: " << iseq->first <<
" contains " << iseq->second.size() <<
" crystals" << std::endl
312 if (iseq->second.size() == (61200 + 14648)) {
313 std::map<int, LMFSextuple>::const_iterator is = iseq->second.begin();
314 std::map<int, LMFSextuple>::const_iterator es = iseq->second.end();
316 Time_t t_last = 18446744073709551615ULL;
319 apdpnpair_temp.
p1 = is->second.p[0];
320 apdpnpair_temp.
p2 = is->second.p[1];
321 apdpnpair_temp.
p3 = is->second.p[2];
326 apdpns_popcon->
setValue(detids[is->first], apdpnpair_temp);
327 if (logicId2Lmr.find(is->first) != logicId2Lmr.end()) {
329 if ((hashedIndex >= 0) && (hashedIndex <= 91)) {
330 apdpns_popcon->
setTime(hashedIndex, timestamp_temp);
331 if (t_last > timestamp_temp.
t1.
value()) {
332 t_last = timestamp_temp.
t1.
value();
335 std::stringstream
ss;
336 ss <<
"LOGIC_ID: " << is->first <<
" LMR: " << hashedIndex + 1 <<
" Out of range";
337 throw(std::runtime_error(
"[EcalLaserHandler::getNewObjects]" + ss.str()));
340 std::stringstream
ss;
341 ss <<
"LOGIC_ID: " << is->first <<
" Cannot determine LMR";
342 throw(std::runtime_error(
"[EcalLaserHandler::getNewObjects]" + ss.str()));
347 delete apdpns_popcon;
349 if ((!iseq->second.empty()) && (!m_fake)) {
350 m_to_transfer.push_back(std::make_pair(apdpns_popcon,
Tm(t_last).cmsNanoSeconds()));
357 std::cout <<
"==== END OF LOOP ON SEQUENCES" << std::endl << std::flush;
359 std::cout <<
"Ecal -> end of getNewObjects -----------\n";
tuple ret
prodAgent to be discontinued
const edm::EventSetup & c
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)
uint64_t microsTime() const
bool checkAPDPNs(const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap &laserMap, const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap &apdpns_popcon)
int iphi() const
get the crystal iphi
int hashedIndex(int ieta, int iphi)
EcalLaserHandler(edm::ParameterSet const &)
void setTime(int hashedIndex, const EcalLaserTimeStamp &value)
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
T getParameter(std::string const &) const
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
std::unique_ptr< EcalLaserAPDPNRatios > Ref
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