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)) {
69 notifyProblems(old, current, hashedIndex,
"Negative values");
70 }
else if ((current.
p1 > 10) || (current.
p2 > 10) || (current.
p3 > 10)) {
72 notifyProblems(old, current, hashedIndex,
"Values too large");
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()
111 <<
" " << std::setiosflags(std::ios::fixed) << std::setprecision(9)
112 << i->p1 <<
" " << i->p2 <<
" " << i->p3 << std::endl;
119 catch (std::runtime_error &e) {
138 "EE_crystal_number").getLogicID()
139 <<
" " << std::setiosflags(std::ios::fixed) << std::setprecision(9)
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;
163 Ref payload= lastPayload();
167 max_since=
tagInfo().lastInterval.first;
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 <<
")"
183 <<
" and SIZE = " <<
tagInfo().size
188 dumpBarrelPayload(laserRatiosMap);
189 dumpEndcapPayload(laserRatiosMap);
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) {
210 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user;
221 std::vector<EcalLogicID> crystals_EB =
222 econn->getEcalLogicIDSetOrdered(
"EB_crystal_angle",
225 "EB_crystal_number", 4 );
226 std::vector<EcalLogicID> crystals_EE =
227 econn->getEcalLogicIDSetOrdered(
"EE_crystal_number",
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;
273 std::map<int, int> logicId2Lmr = econn->getEcalLogicID2LmrMap();
275 std::cout <<
"Retrieving corrections from ONLINE DB ... " << std::endl;
285 if (m_maxtime[0] ==
'-') {
289 std::cout <<
"Subtracting " << m_maxtime.substr(1) <<
" hours "
290 <<
"to " << tmax.
str() << std::endl;
293 tmax -= atoi(m_maxtime.substr(1).c_str())*3600;
299 std::cout <<
"Setting t_max to " << m_maxtime << std::endl;
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.size() > 0) && (!m_fake)) {
372 m_to_transfer.push_back(std::make_pair(apdpns_popcon,
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
tuple ret
prodAgent to be discontinued
edm::Ref< Container > Ref
void dumpEndcapPayload(EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap const &laserMap)
std::map< int, std::map< int, LMFSextuple > > getCorrections(const Tm &t)
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)
void setToString(const std::string s)
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="")
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]
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
void dumpBarrelPayload(EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap const &laserMap)
const Item & barrel(size_t hashedIndex) const
const Items & endcapItems() const
const Item & endcap(size_t hashedIndex) const
double diff(float x, float old_x)
TimeValue_t value() const