14 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalLaserHandler")) {
15 std::cout <<
"EcalLaser Source handler constructor\n" << 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;
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");
103 ->getEcalLogicID(
"EB_crystal_angle",
109 <<
" " << std::setiosflags(
std::ios::fixed) << std::setprecision(9) <<
i->p1 <<
" " <<
i->p2 <<
" " 110 <<
i->p3 << std::endl;
116 }
catch (std::runtime_error &
e) {
134 ->getEcalLogicID(
"EE_crystal_number",
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++) {
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] ==
'-') {
270 tmax.setToCurrentLocalTime();
272 std::cout <<
"Subtracting " << m_maxtime.substr(1) <<
" hours " 273 <<
"to " <<
tmax.str() << std::endl;
274 std::cout <<
"tmax was " <<
tmax.microsTime() <<
" ns" << std::endl;
276 tmax -= atoi(m_maxtime.substr(1).c_str()) * 3600;
278 std::cout <<
"tmax is " <<
tmax.microsTime() <<
" ns" << std::endl;
282 std::cout <<
"Setting t_max to " << m_maxtime << std::endl;
284 tmax.setToString(m_maxtime);
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()) {
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";
uint64_t cmsNanoSeconds() const
T getParameter(std::string const &) const
void dumpEndcapPayload(EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap const &laserMap)
void getNewObjects() override
ret
prodAgent to be discontinued
int iphi() const
get the crystal iphi
void notifyProblems(const EcalLaserAPDPNRatios::EcalLaserAPDPNpair &old, const EcalLaserAPDPNRatios::EcalLaserAPDPNpair ¤t, int hashedIndex, const std::string &reason)
const Items & endcapItems() const
static EEDetId unhashIndex(int hi)
const Item & barrel(size_t hashedIndex) const
bool checkAPDPN(const EcalLaserAPDPNRatios::EcalLaserAPDPNpair &old, const EcalLaserAPDPNRatios::EcalLaserAPDPNpair ¤t, int hashedIndex)
int ieta() const
get the crystal ieta
bool checkAPDPNs(const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap &laserMap, const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap &apdpns_popcon)
int hashedIndex(int ieta, int iphi)
EcalLaserHandler(edm::ParameterSet const &)
const Item & endcap(size_t hashedIndex) const
void setTime(int hashedIndex, const EcalLaserTimeStamp &value)
Abs< T >::type abs(const T &t)
unsigned long m_sequences
const Items & barrelItems() const
static const double tmax[3]
TimeValue_t value() const
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
std::unique_ptr< EcalLaserAPDPNRatios > Ref
char data[epos_bytes_allocation]
void dumpBarrelPayload(EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap const &laserMap)
~EcalLaserHandler() override
double diff(float x, float old_x)