14 : m_name(ps.getUntrackedParameter<std::string>(
"name",
"EcalLaserHandler")) {
16 std::cout <<
"EcalLaser Source handler constructor\n" << std::endl;
27 <<
" User: "<< m_user << std::endl;
42 std::cout <<
"===== " << reason <<
" =====" << std::endl;
43 if (hashedIndex < 0) {
46 << old.
p2 <<
", " << old.
p3 <<
"] ==> [" << current.
p1 <<
", "
47 << current.
p2 <<
", " << current.
p3 <<
"]" << std::endl;
51 << old.
p2 <<
", " << old.
p3 <<
"] ==> [" << current.
p1 <<
", "
52 << current.
p2 <<
", " << current.
p3 <<
"]" << std::endl;
60 if ((current.
p1 < 0) || (current.
p2 < 0) || (current.
p3 < 0)) {
62 notifyProblems(old, current, hashedIndex,
"Negative values");
63 }
else if ((current.
p1 > 10) || (current.
p2 > 10) || (current.
p3 > 0)) {
65 notifyProblems(old, current, hashedIndex,
"Values too large");
66 }
else if (((
diff(old.
p1, current.
p1) > 0.2) && (old.
p1 != 0) && (old.
p1 != 1)) ||
67 ((
diff(old.
p2, current.
p2) > 0.2) && (old.
p2 != 0) && (old.
p1 != 2)) ||
68 ((
diff(old.
p3, current.
p3) > 0.2) && (old.
p3 != 0) && (old.
p1 != 3))) {
70 notifyProblems(old, current, hashedIndex,
"Difference w.r.t. previous too large");
103 "EB_crystal_number").getLogicID()
104 <<
" " << std::setiosflags(std::ios::fixed) << std::setprecision(9)
105 << i->p1 <<
" " << i->p2 <<
" " << i->p3 << std::endl;
112 catch (std::runtime_error &e) {
131 "EE_crystal_number").getLogicID()
132 <<
" " << std::setiosflags(std::ios::fixed) << std::setprecision(9)
133 << i->p1 <<
" " << i->p2 <<
" " << i->p3 << std::endl;
140 catch (std::runtime_error &e) {
150 <<
" ---> getNewObjects" << std::endl;
152 std::cout <<
"------- Ecal -> getNewObjects\n";
155 unsigned long long max_since= 1;
156 Ref payload= lastPayload();
160 max_since=tagInfo().lastInterval.first;
161 Tm max_since_tm(max_since);
167 payload->getLaserMap();
168 std::cout <<
"payload->getLaserMap(): OK " << std::endl;
169 std::cout <<
"Its size is " << laserRatiosMap.
size() << std::endl;
171 payload->getTimeMap();
172 std::cout <<
"payload->getTimeMap(): OK " << std::endl;
173 std::cout <<
"Last Object in Offline DB has SINCE = " << max_since
174 <<
" (" << max_since_tm.
str() <<
")"
175 <<
" and SIZE = " << tagInfo().size
179 dumpBarrelPayload(laserRatiosMap);
180 dumpEndcapPayload(laserRatiosMap);
181 for (
int i=0;
i<92;
i++) {
183 if( t_min > timestamp.
t1) {
188 std::cout <<
"WOW: we just retrieved the last valid record from DB "
194 std::cout <<
"Making connection..." << std::flush;
197 }
catch (std::runtime_error &e) {
198 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user;
209 std::vector<EcalLogicID> crystals_EB =
210 econn->getEcalLogicIDSetOrdered(
"EB_crystal_angle",
213 "EB_crystal_number", 4 );
214 std::vector<EcalLogicID> crystals_EE =
215 econn->getEcalLogicIDSetOrdered(
"EE_crystal_number",
218 "EE_crystal_number", 4 );
220 std::vector<EcalLogicID>::const_iterator ieb = crystals_EB.begin();
221 std::vector<EcalLogicID>::const_iterator eeb = crystals_EB.end();
223 std::cout <<
"Got list of " << crystals_EB.size() <<
" crystals in EB"
225 std::cout <<
"Got list of " << crystals_EE.size() <<
" crystals in EE"
230 std::map<int, int> detids;
232 int iEta = ieb->getID1();
233 int iPhi = ieb->getID2();
237 detids[ieb->getLogicID()] = ebdetid;
240 std::cout <<
"Validated " << count <<
" logic ID's for EB" << std::endl;
244 std::vector<EcalLogicID>::const_iterator iee = crystals_EE.begin();
245 std::vector<EcalLogicID>::const_iterator eee = crystals_EE.end();
249 int iSide = iee->getID1();
250 int iX = iee->getID2();
251 int iY = iee->getID3();
252 EEDetId eedetidpos(iX,iY,iSide);
254 detids[iee->getLogicID()] = eedetidpos;
258 std::cout <<
"Validated " << count <<
" logic ID's for EE" << std::endl;
261 std::map<int, int> logicId2Lmr = econn->getEcalLogicID2LmrMap();
263 std::cout <<
"Retrieving corrections from ONLINE DB ... " << std::endl;
282 std::map<int, std::map<int, LMFSextuple> > d =
285 std::cout <<
"Data organized into " << d.size() <<
" sequences" << std::endl;
287 std::map<int, std::map<int, LMFSextuple> >::const_iterator iseq = d.begin();
288 std::map<int, std::map<int, LMFSextuple> >::const_iterator eseq = d.end();
289 std::cout <<
"===== Looping on Sequences" << std::endl;
290 while (iseq != eseq) {
291 std::cout <<
"==== SEQ_ID: " << iseq->first
292 <<
" contains " << iseq->second.size() <<
" crystals"
293 << std::endl << std::flush;
295 std::map<int, LMFSextuple>::const_iterator is = iseq->second.begin();
296 std::map<int, LMFSextuple>::const_iterator es = iseq->second.end();
301 apdpnpair_temp.
p1 = is->second.p[0];
302 apdpnpair_temp.
p2 = is->second.p[1];
303 apdpnpair_temp.
p3 = is->second.p[2];
308 apdpns_popcon->
setValue(detids[is->first], apdpnpair_temp);
309 if (logicId2Lmr.find(is->first) != logicId2Lmr.end()) {
311 if ((hashedIndex >= 0) && (hashedIndex <= 91)) {
312 apdpns_popcon->
setTime( hashedIndex , timestamp_temp);
313 t_last = timestamp_temp.
t1.
value();
315 std::stringstream ss;
316 ss <<
"LOGIC_ID: " << is->first <<
" LMR: " << hashedIndex + 1
318 throw(std::runtime_error(
"[EcalLaserHandler::getNewObjects]" +
322 std::stringstream ss;
323 ss <<
"LOGIC_ID: " << is->first <<
" Cannot determine LMR";
324 throw(std::runtime_error(
"[EcalLaserHandler::getNewObjects]" +
329 if (iseq->second.size() > 0) {
330 m_to_transfer.push_back(std::make_pair(apdpns_popcon, t_last));
334 std::cout <<
"==== END OF LOOP ON SEQUENCES" << std::endl << std::flush;
336 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)
const Items & barrelItems() const
void notifyProblems(const EcalLaserAPDPNRatios::EcalLaserAPDPNpair &old, const EcalLaserAPDPNRatios::EcalLaserAPDPNpair ¤t, int hashedIndex, const std::string &reason)
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 setToMicrosTime(uint64_t micros)
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="")
int ieta() const
get the crystal ieta
unsigned long m_sequences
TimeValue_t value() const
static const double tmax[3]
std::vector< EcalLaserTimeStamp > EcalLaserTimeStampMap
std::vector< Item >::const_iterator const_iterator
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
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)