9 : onlineDbConnectionString(pset.getParameter<std::
string>(
"onlineDB")),
10 authenticationPath(pset.getParameter<std::
string>(
"authPath")),
11 whichTable(pset.getParameter<std::
string>(
"queryType")),
12 lastValueFileName(pset.getParameter<std::
string>(
"lastValueFile")),
13 fromFile(pset.getParameter<bool>(
"lastValueFromFile")),
14 psuDetIdMapFile_(pset.getParameter<std::
string>(
"PsuDetIdMapFile")),
15 debug_(pset.getParameter<bool>(
"debugModeOn")),
17 tmax_par(pset.getParameter<std::
vector<int> >(
"Tmax")),
18 tmin_par(pset.getParameter<std::
vector<int> >(
"Tmin")),
19 tset_par(pset.getParameter<std::
vector<int> >(
"TSetMin")),
20 deltaTmin_(pset.getParameter<uint32_t>(
"DeltaTmin")),
21 maxIOVlength_(pset.getParameter<uint32_t>(
"MaxIOVlength")),
22 detIdListFile_(pset.getParameter<std::
string>(
"DetIdListFile")),
23 excludedDetIdListFile_(pset.getParameter<std::
string>(
"ExcludedDetIdListFile")),
24 highVoltageOnThreshold_(pset.getParameter<double>(
"HighVoltageOnThreshold")) {
28 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] constructor" << endl;
52 <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] DB name has not been set properly ... Returning ...";
57 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] File expected for "
58 "lastValue table, but filename not specified ... Returning ...";
64 ss <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder]\n"
68 <<
" Table to be queried: " <<
whichTable <<
"\n"
90 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: destructing ...";
105 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Query type is " <<
whichTable
110 <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Use file? " << ((
fromFile) ?
"TRUE" :
"FALSE");
115 <<
"[SiStripDetVOffBuilder::BuildDetVOff]: retrieved last time stamp from DB: " <<
lastStoredCondObj.second
168 for (
unsigned int i = 0;
i < dStruct.
detidV.size();
i++) {
171 std::vector<uint32_t>* detids = &(dStruct.
detidV[
i].first);
190 if (iovtime != saveIovTime) {
207 std::vector<std::pair<uint32_t, std::string> > excludedDetIdMap;
211 for (
const auto& it : detInfo.getAllData()) {
212 bool excluded =
false;
213 for (
const auto& exclIt : excludedDetIdMap) {
214 if (it.first == exclIt.first) {
220 modV->
put(it.first, 1, 1);
234 std::vector<uint32_t> beforeV;
246 for (
unsigned int j = 0;
j < detids->size();
j++) {
248 cout <<
"at time = " << iovtime <<
" detid[" <<
j <<
"] = " << (*detids)[
j] <<
" has hv = " << hvlv.first
249 <<
" and lv = " << hvlv.second << endl;
250 modV->
put((*detids)[
j], hvlv.first, hvlv.second);
254 unsigned int numAdded = 0, numRemoved = 0;
255 if (iovtime == saveIovTime) {
257 numAdded = oldStats[1];
258 numRemoved = oldStats[2];
260 std::vector<uint32_t> afterV;
263 if ((afterV.size() - beforeV.size()) > 0) {
264 numAdded += afterV.size() - beforeV.size();
265 }
else if ((beforeV.size() - afterV.size()) > 0) {
266 numRemoved += beforeV.size() - afterV.size();
270 if (iovtime != saveIovTime) {
275 if (
modulesOff.empty() || !(*modV == *testV)) {
276 modulesOff.push_back(std::make_pair(modV, iovtime));
278 saveIovTime = iovtime;
310 std::vector<uint32_t> finalids;
312 std::cout <<
"Index = " <<
i <<
" Size of DetIds vector = " << finalids.size() << std::endl;
314 for (
unsigned int j = 0;
j < finalids.size();
j++) {
315 std::cout <<
"detid = " << finalids[
j] <<
" LV off = " << (
modulesOff[
i].first)->IsModuleLVOff(finalids[
j])
316 <<
" HV off = " << (
modulesOff[
i].first)->IsModuleHVOff(finalids[j]) << std::endl;
323 const coral::TimeStamp& changeDate,
324 const std::vector<uint32_t>& settingID,
325 const std::vector<coral::TimeStamp>& settingDate) {
328 std::vector<int> locations;
329 for (
unsigned int i = 0;
i < settingID.size();
i++) {
330 if (settingID[
i] ==
id) {
331 locations.push_back((
int)
i);
336 if (locations.empty()) {
338 }
else if (locations.size() == 1) {
339 setting = locations[0];
344 for (
unsigned int j = 0;
j < locations.size();
j++) {
345 #ifdef USING_NEW_CORAL
346 const boost::posix_time::ptime& testSec = changeDate.time();
347 const boost::posix_time::ptime& limitSec = settingDate[(
unsigned int)locations[
j]].time();
349 long testSec = changeDate.time().ns();
350 long limitSec = settingDate[(
unsigned int)locations[
j]].time().ns();
352 if (testSec >= limitSec) {
353 setting = locations[
j];
361 const coral::TimeStamp& changeDate,
362 const std::vector<std::string>& settingDpname,
363 const std::vector<coral::TimeStamp>& settingDate) {
366 std::vector<int> locations;
367 for (
unsigned int i = 0;
i < settingDpname.size();
i++) {
368 if (settingDpname[
i] == dpname) {
369 locations.push_back((
int)
i);
374 if (locations.empty()) {
376 }
else if (locations.size() == 1) {
377 setting = locations[0];
382 for (
unsigned int j = 0;
j < locations.size();
j++) {
383 #ifdef USING_NEW_CORAL
384 const boost::posix_time::ptime& testSec = changeDate.time();
385 const boost::posix_time::ptime& limitSec = settingDate[(
unsigned int)locations[
j]].time();
387 long testSec = changeDate.time().ns();
388 long limitSec = settingDate[(
unsigned int)locations[
j]].time().ns();
390 if (testSec >= limitSec) {
391 setting = locations[
j];
399 std::vector<float>& vmonValues,
400 std::vector<coral::TimeStamp>& dateChange) {
404 <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: last Value file does not exist!";
411 std::vector<std::string> changeDates;
419 std::istringstream
ss(line);
423 ss >> std::skipws >> dpid >> vmon >> changeDate;
424 dpIDs.push_back(dpid);
425 vmonValues.push_back(vmon);
426 changeDates.push_back(changeDate);
431 for (
unsigned int i = 0;
i < changeDates.size();
i++) {
433 int year = atoi(part.c_str());
436 part = changeDates[
i].substr(5, 2);
437 int month = atoi(part.c_str());
440 part = changeDates[
i].substr(8, 2);
441 int day = atoi(part.c_str());
444 part = changeDates[
i].substr(11, 2);
445 int hour = atoi(part.c_str());
448 part = changeDates[
i].substr(14, 2);
449 int minute = atoi(part.c_str());
452 part = changeDates[
i].substr(17, 2);
453 int second = atoi(part.c_str());
456 coral::TimeStamp date(year, month, day, hour, minute, second, 0);
457 dateChange.push_back(date);
460 if (changeDates.size() != dateChange.size()) {
461 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: date conversion failed!!";
483 unsigned long long iovSec = iovTime >> 32;
484 uint32_t iovNanoSec = uint32_t(iovTime);
486 cout <<
"[SiStripDetVOffBuilder::getCoralTime] Converting CondTime into CoralTime: "
487 <<
" condTime = " << iovSec <<
" - " << iovNanoSec <<
" getCondTime(coralTime) = " << (testTime >> 32) <<
" - "
488 << (testTime & 0xFFFFFFFF) << endl;
495 std::sort(vec.begin(), vec.end());
496 std::vector<uint32_t>::iterator it =
std::unique(vec.begin(), vec.end());
497 vec.resize(it - vec.begin());
509 std::cout <<
"latestDate: condTime = " << (latestDate >> 32) <<
" - "
510 << (latestDate & 0xFFFFFFFF)
515 for (
unsigned int i = 1;
i < coralDate.size();
i++) {
517 if (testDate > latestDate) {
518 latestDate = testDate;
525 std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& initialIt,
526 std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >& resultVec,
531 if (
distance(resultVec.begin(), initialIt) == 0) {
535 if (
debug_ && (it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() == 0) &&
536 (it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() == 0)) {
537 cout <<
"Same number of LV and HV at start and end of sequence: LV off = " << it->first->getLVoffCounts()
538 <<
" HV off = " << it->first->getHVoffCounts() << endl;
542 if ((it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() > 0) ||
543 (it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() > 0)) {
550 cout <<
"Reducing IOV sequence (going off)" << endl;
553 else if ((it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() <= 0) ||
554 (it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() <= 0)) {
556 discardIOVs(it, initialIt, resultVec, last, first);
558 cout <<
"Reducing IOV sequence (going on)" << endl;
563 std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& initialIt,
564 std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >& resultVec,
566 const unsigned int first) {
568 cout <<
"first (1->means the sequence started at the first timestamp in the query results, 0-> that it did not)= "
570 cout <<
"initial->first (initial SiStripDetVOff object of the IOV sequence)= " << initialIt->first
571 <<
", second (initial timestamp of the IOV sequence) = " << initialIt->second << endl;
572 cout <<
"last (0->means that the sequence is not ending with the last item in the query results, 1-> that it "
577 resultVec.erase(initialIt + first, it + 1);
579 it = resultVec.end() - 2;
581 it = resultVec.erase(initialIt + first, it);
588 std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator initialIt;
591 int resultsIndex = 0;
593 if (resultVecSize > 1) {
594 std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator it =
modulesOff.begin();
595 for (; it !=
modulesOff.end() - 1; ++it, ++resultsIndex) {
596 unsigned long long deltaT = ((it + 1)->
second - it->second) >> 32;
597 unsigned long long deltaTsequence = 0;
599 deltaTsequence = ((it + 1)->
second - initialIt->second) >> 32;
602 if ((deltaT < deltaTmin) && ((count == 0) || (deltaTsequence < maxIOVlength))) {
611 else if (count > 1) {
620 if (resultsIndex == resultVecSize - 2 && count != 0) {
658 std::vector<coral::TimeStamp> settingDate;
659 std::vector<float> settingValue;
660 std::vector<std::string> settingDpname;
661 std::vector<uint32_t> settingDpid;
663 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
664 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: "
665 << settingDpname.size();
668 std::stringstream
ss;
669 for (
unsigned int j = 0;
j < tStruct.
dpname.size();
j++) {
680 ss <<
"Channel = " << tStruct.
dpname[
j] << std::endl;
684 <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of channels with no setting information " <<
missing;
685 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of entries in dpname vector "
693 <<
"[SiStripDetVOffBuilder::BuildDetVOff]: File access complete \n\t Number of values read from file: "
694 << tStruct.
dpid.size();
697 std::vector<coral::TimeStamp> settingDate;
698 std::vector<float> settingValue;
699 std::vector<std::string> settingDpname;
700 std::vector<uint32_t> settingDpid;
703 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
704 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: "
705 << settingDpname.size();
708 std::stringstream
ss;
712 for (
unsigned int j = 0;
j < tStruct.
dpid.size();
j++) {
720 tStruct.
dpname[
j] = settingDpname[setting];
725 ss <<
"DP ID = " << tStruct.
dpid[
j] << std::endl;
728 LogDebug(
"SiStripDetVOffBuilder") <<
"Number of missing psu channels = " << missing << std::endl;
729 LogDebug(
"SiStripDetVOffBuilder") <<
"IDs are: = " << ss.str();
734 ss << comment << (condTime >> 32) <<
" - " << (condTime & 0xFFFFFFFF) << std::endl;
740 ss <<
"Starting from IOV time in the database : year = " << coralTime.year() <<
", month = " << coralTime.month()
741 <<
", day = " << coralTime.day() <<
", hour = " << coralTime.hour() <<
", minute = " << coralTime.minute()
742 <<
", second = " << coralTime.second() <<
", nanosecond = " << coralTime.nanosecond() << std::endl;
747 struct stat FileInfo;
768 std::cout <<
"PLEASE provide the name of a valid PSUDetIDMapFile in the cfg: currently still necessary to have a "
769 "file, soon will access the info straight from the DB!"
775 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff] PSU(Channel)-detID map(s) built";
783 unsigned int ch0bad = 0, ch1bad = 0, ch2bad = 0, ch3bad = 0;
784 std::vector<unsigned int> numLvBad, numHvBad;
789 std::map<std::string, bool> UnmappedState, CrosstalkingState;
791 std::map<std::string, std::vector<uint32_t> > UnmappedPSUs = map_.
getHVUnmappedMap();
793 if (
FileExists(
"HVUnmappedChannelState.dat")) {
794 std::cout <<
"File HVUnmappedChannelState.dat exists!" << std::endl;
795 std::ifstream ifs(
"HVUnmappedChannelState.dat");
797 while (getline(ifs, line)) {
800 stringstream
ss(line);
806 std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
808 std::map<std::string, std::vector<uint32_t> >::iterator iter = UnmappedPSUs.find(PSU);
809 if (iter != UnmappedPSUs.end()) {
810 UnmappedState[PSUChannel] = HVStatus;
812 std::cout <<
"WARNING!!! There are channels in the local file with the channel status for HVUnmapped "
813 "channels, that ARE NOT CONSIDERED AS UNMAPPED in the current map!"
820 bool MissingChannels =
false;
821 for (std::map<
std::string, vector<uint32_t> >::iterator it = UnmappedPSUs.begin(); it != UnmappedPSUs.end(); it++) {
824 std::map<std::string, bool>::iterator iter = UnmappedState.find(chan002);
825 if (iter == UnmappedState.end()) {
826 std::cout <<
"ERROR! The local file with the channel status for HVUnmapped channels IS MISSING one of the "
827 "following unmapped channel voltage status information:"
830 MissingChannels =
true;
832 iter = UnmappedState.find(chan003);
833 if (iter == UnmappedState.end()) {
834 std::cout <<
"ERROR! The local file with the channel status for HVUnmapped channels IS MISSING one of the "
835 "following unmapped channel voltage status information:"
838 MissingChannels =
true;
842 if (MissingChannels) {
844 <<
"Exiting now... please check the local HVUnmappedChannelState.dat and the mapfile you provided ("
850 for (std::map<
std::string, vector<uint32_t> >::iterator it = UnmappedPSUs.begin(); it != UnmappedPSUs.end(); it++) {
853 UnmappedState[chan002] =
false;
854 UnmappedState[chan003] =
false;
860 if (
FileExists(
"HVCrosstalkingChannelState.dat")) {
861 std::cout <<
"File HVCrosstalkingChannelState.dat exists!" << std::endl;
862 std::ifstream ifs(
"HVCrosstalkingChannelState.dat");
864 while (getline(ifs, line)) {
867 stringstream
ss(line);
873 std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
875 std::map<std::string, std::vector<uint32_t> >::iterator iter = CrosstalkingPSUs.find(PSU);
876 if (iter != CrosstalkingPSUs.end()) {
877 CrosstalkingState[PSUChannel] = HVStatus;
879 std::cout <<
"WARNING!!! There are channels in the local file with the channel status for HVUnmapped "
880 "channels, that ARE NOT CONSIDERED AS UNMAPPED in the current map!"
887 bool MissingChannels =
false;
888 for (std::map<
std::string, vector<uint32_t> >::iterator it = CrosstalkingPSUs.begin(); it != CrosstalkingPSUs.end();
892 std::map<std::string, bool>::iterator iter = CrosstalkingState.find(chan002);
893 if (iter == CrosstalkingState.end()) {
894 std::cout <<
"ERROR! The local file with the channel status for HVCrosstalking channels IS MISSING one of the "
895 "following unmapped channel voltage status information:"
898 MissingChannels =
true;
900 iter = CrosstalkingState.find(chan003);
901 if (iter == CrosstalkingState.end()) {
902 std::cout <<
"ERROR! The local file with the channel status for HVCrosstalking channels IS MISSING one of the "
903 "following unmapped channel voltage status information:"
906 MissingChannels =
true;
910 if (MissingChannels) {
912 <<
"Exiting now... please check the local HVCrosstalkingChannelState.dat and the mapfile you provided ("
918 for (std::map<
std::string, vector<uint32_t> >::iterator it = CrosstalkingPSUs.begin(); it != CrosstalkingPSUs.end();
922 CrosstalkingState[chan002] =
false;
923 CrosstalkingState[chan003] =
false;
929 std::cout <<
"Printing the UnmappedChannelState initial map:" << std::endl;
930 std::cout <<
"PSUChannel\t\tHVON?(true or false)" << std::endl;
931 for (std::map<std::string, bool>::iterator it = UnmappedState.begin(); it != UnmappedState.end(); it++) {
932 std::cout << it->first <<
"\t\t" << it->second << std::endl;
935 std::cout <<
"Printing the CrosstalkingChannelState initial map:" << std::endl;
936 std::cout <<
"PSUChannel\t\tHVON?(true or false)" << std::endl;
937 for (std::map<std::string, bool>::iterator it = CrosstalkingState.begin(); it != CrosstalkingState.end(); it++) {
938 std::cout << it->first <<
"\t\t" << it->second << std::endl;
947 for (
unsigned int dp = 0; dp < psuStruct.
dpname.size(); dp++) {
951 if (PSUChannel !=
"UNKNOWN") {
954 PSUChannel.substr(PSUChannel.size() - 10);
955 std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
979 std::vector<uint32_t> ids;
986 std::vector<uint32_t> unmapped_ids, crosstalking_ids;
989 if (Channel ==
"channel000" || Channel ==
"channel001") {
1007 if (Channel ==
"channel000" || Channel ==
"channel001") {
1008 cout <<
"Corresponding to LV (PSU-)matching detids: " << endl;
1009 for (
unsigned int i_detid = 0; i_detid < ids.size(); i_detid++) {
1010 cout << ids[i_detid] << std::endl;
1013 cout <<
"Corresponding to straight HV matching detids: " << endl;
1014 for (
unsigned int i_detid = 0; i_detid < ids.size(); i_detid++) {
1015 cout << ids[i_detid] << std::endl;
1020 if (!unmapped_ids.empty()) {
1021 cout <<
"Corresponding to HV unmapped (PSU-)matching detids: " << endl;
1022 for (
unsigned int i_detid = 0; i_detid < unmapped_ids.size(); i_detid++) {
1023 cout << unmapped_ids[i_detid] << std::endl;
1026 if (!crosstalking_ids.empty()) {
1027 cout <<
"Corresponding to HV crosstalking (PSU-)matching detids: " << endl;
1028 for (
unsigned int i_detid = 0; i_detid < crosstalking_ids.size(); i_detid++) {
1029 cout << crosstalking_ids[i_detid] << std::endl;
1057 detIdStruct.
detidV.push_back(std::make_pair(ids, psuStruct.
changeDate[dp]));
1063 numLvBad.insert(numLvBad.end(), ids.begin(), ids.end());
1066 detIdStruct.
isHV.push_back(0);
1069 detIdStruct.
psuName.push_back(PSUChannel);
1075 if (!ids.empty() || !unmapped_ids.empty() || !crosstalking_ids.empty()) {
1076 if (Channel ==
"channel002") {
1078 }
else if (Channel ==
"channel003") {
1083 std::vector<uint32_t> OFFids;
1084 OFFids.insert(OFFids.end(), ids.begin(), ids.end());
1085 OFFids.insert(OFFids.end(), unmapped_ids.begin(), unmapped_ids.end());
1087 if (!crosstalking_ids
1090 CrosstalkingState[PSUChannel] =
false;
1093 if (!CrosstalkingState[PSUChannel.substr(0, PSUChannel.size() - 1) +
"2"] &&
1094 !CrosstalkingState[PSUChannel.substr(0, PSUChannel.size() - 1) +
"3"]) {
1097 crosstalking_ids.begin(),
1098 crosstalking_ids.end());
1100 std::cout <<
"Adding the unmapped detids corresponding to (HV1/2 cross-talking) PSU "
1101 << PSUChannel.substr(0, PSUChannel.size() - 10) <<
" to the list of detids turning OFF"
1109 UnmappedState[PSUChannel] =
false;
1111 if (!OFFids.empty()) {
1120 detIdStruct.
detidV.push_back(std::make_pair(OFFids, psuStruct.
changeDate[dp]));
1126 numHvBad.insert(numHvBad.end(), ids.begin(), ids.end());
1129 detIdStruct.
isHV.push_back(1);
1132 detIdStruct.
psuName.push_back(PSUChannel);
1149 detIdStruct.
detidV.push_back(std::make_pair(ids, psuStruct.
changeDate[dp]));
1155 detIdStruct.
isHV.push_back(0);
1158 detIdStruct.
psuName.push_back(PSUChannel);
1164 std::vector<uint32_t> ONids;
1165 ONids.insert(ONids.end(), ids.begin(), ids.end());
1167 ONids.end(), crosstalking_ids.begin(), crosstalking_ids.end());
1172 UnmappedState[PSUChannel] =
true;
1175 if (UnmappedState[PSUChannel.substr(0, PSUChannel.size() - 1) +
"2"] &&
1176 UnmappedState[PSUChannel.substr(0, PSUChannel.size() - 1) +
"3"]) {
1177 ONids.insert(ONids.end(),
1178 unmapped_ids.begin(),
1179 unmapped_ids.end());
1181 std::cout <<
"Adding the detids corresponding to HV-unmapped PSU "
1182 << PSUChannel.substr(0, PSUChannel.size() - 10) <<
" to the list of detids turning ON"
1188 if (!crosstalking_ids
1190 CrosstalkingState[PSUChannel] =
true;
1192 if (!ONids.empty()) {
1201 detIdStruct.
detidV.push_back(std::make_pair(ONids, psuStruct.
changeDate[dp]));
1207 detIdStruct.
isHV.push_back(1);
1210 detIdStruct.
psuName.push_back(PSUChannel);
1223 std::ofstream ofsUnmapped(
"HVUnmappedChannelState.dat");
1224 for (std::map<std::string, bool>::iterator it = UnmappedState.begin(); it != UnmappedState.end(); it++) {
1225 ofsUnmapped << it->first <<
"\t" << it->second << std::endl;
1227 std::ofstream ofsCrosstalking(
"HVCrosstalkingChannelState.dat");
1228 for (std::map<std::string, bool>::iterator it = CrosstalkingState.begin(); it != CrosstalkingState.end(); it++) {
1229 ofsCrosstalking << it->first <<
"\t" << it->second << std::endl;
1237 std::cout <<
"Number of channels that turned OFF in this O2O interval" << std::endl;
1238 std::cout <<
"Channel000 = " << ch0bad <<
" Channel001 = " << ch1bad << std::endl;
1239 std::cout <<
"Channel002 = " << ch2bad <<
" Channel003 = " << ch3bad << std::endl;
1240 std::cout <<
"Number of LV detIDs that turned OFF in this O2O interval = " << numLvBad.size() << std::endl;
1241 std::cout <<
"Number of HV detIDs that turned OFF in this O2O interval = " << numHvBad.size() << std::endl;
1244 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__
1245 <<
"]: Number of PSUs retrieved from DB with map information "
1246 << detIdStruct.
detidV.size();
1247 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__
1248 <<
"]: Number of PSUs retrieved from DB with no map information "
1251 unsigned int dupCount = 0;
1252 for (
unsigned int t = 0;
t < numLvBad.size();
t++) {
1253 std::vector<unsigned int>::iterator iter =
std::find(numHvBad.begin(), numHvBad.end(), numLvBad[
t]);
1254 if (iter != numHvBad.end()) {
1259 std::cout <<
"Number of channels for which LV & HV turned OFF in this O2O interval = " << dupCount << std::endl;
1263 std::vector<uint32_t> pStats(3, 0);
1264 pStats.push_back(afterV);
1265 pStats.push_back(numAdded);
1266 pStats.push_back(numRemoved);
1274 int lv_off = -1, hv_off = -1;
1275 if (detIdStruct.
isHV[i] == 0) {
1278 if (detIdStruct.
isHV[i] == 1) {
1289 if (iChannel ==
"002" || iChannel ==
"003") {
1290 bool lastStatusOfOtherChannel =
true;
1291 for (
unsigned int j = 0;
j <
i;
j++) {
1294 if (iPsu == jPsu && iChannel != jChannel && (jChannel ==
"002" || jChannel ==
"003")) {
1296 cout <<
"psu[" << i <<
"] = " << detIdStruct.
psuName[
i]
1297 <<
" with status = " << detIdStruct.
StatusGood[
i] <<
" and psu[" <<
j
1298 <<
"] = " << detIdStruct.
psuName[
j] <<
" with status " << detIdStruct.
StatusGood[
j] << endl;
1299 lastStatusOfOtherChannel = detIdStruct.
StatusGood[
j];
1302 if (detIdStruct.
StatusGood[i] != lastStatusOfOtherChannel) {
1304 cout <<
"turning off hv" << endl;
1314 return make_pair(hv_off, lv_off);
SiStripDetVOffBuilder(const edm::ParameterSet &, const edm::ActivityRegistry &)
std::string lastValueFileName
std::vector< int > actualStatus
std::map< std::string, std::vector< uint32_t > > getHVUnmappedMap()
std::string authenticationPath
void discardIOVs(std::vector< std::pair< SiStripDetVOff *, cond::Time_t > >::iterator &it, std::vector< std::pair< SiStripDetVOff *, cond::Time_t > >::iterator &initialIt, std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > &resultVec, const bool last, const unsigned int first)
Removes IOVs as dictated by reduction.
std::pair< int, int > extractDetIdVector(const unsigned int i, SiStripDetVOff *modV, DetIdListTimeAndStatus &detIdStruct)
void printPar(std::stringstream &ss, const std::vector< int > &par)
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > modulesOff
void buildPSUdetIdMap(TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
std::string psuDetIdMapFile_
Extension to SiStripConfigDb to map PSU channels to DetIDs using DCU-PSU map and DCU-DetID map...
bool put(const uint32_t DetId, const int HVoff, const int LVoff)
Insert information for a single detId.
DetIdTimeStampVector detidV
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
double highVoltageOnThreshold_
std::string detIdListFile_
int findSetting(uint32_t id, const coral::TimeStamp &changeDate, const std::vector< uint32_t > &settingID, const std::vector< coral::TimeStamp > &settingDate)
void removeDuplicates(std::vector< uint32_t > &vec)
std::vector< std::string > dpname
U second(std::pair< T, U > const &p)
bool FileExists(std::string filename)
std::pair< SiStripDetVOff *, cond::Time_t > lastStoredCondObj
std::unique_ptr< SiStripCoralIface > coralInterface
unsigned long long Time_t
std::vector< uint32_t > dpid
std::string excludedDetIdListFile_
cond::Time_t getCondTime(const coral::TimeStamp &coralTime)
std::vector< bool > StatusGood
std::vector< coral::TimeStamp > changeDate
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::vector< unsigned int > isHV
std::vector< uint32_t > getLvDetID(std::string psu)
void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength)
std::vector< std::vector< uint32_t > > payloadStats
SiStripDetInfo read(std::string filePath)
void lastValue(TimesAndValues &tStruct)
void getHvDetID(std::string psuchannel, std::vector< uint32_t > &ids, std::vector< uint32_t > &unmapped_ids, std::vector< uint32_t > &crosstalking_ids)
Time_t from_boost(boost::posix_time::ptime bt)
void readLastValueFromFile(std::vector< uint32_t > &dpIDs, std::vector< float > &vmonValues, std::vector< coral::TimeStamp > &dateChange)
cond::Time_t findMostRecentTimeStamp(const std::vector< coral::TimeStamp > &coralDate)
void lastValueFromFile(TimesAndValues &tStruct)
std::vector< int > tmax_par
coral::TimeStamp getCoralTime(cond::Time_t iovTime)
void setLastSiStripDetVOff(SiStripDetVOff *lastPayload, cond::Time_t lastTimeStamp)
void BuildMap(const std::string &mapFile, const bool debug)
std::vector< int > tmin_par
std::map< std::string, std::vector< uint32_t > > getHVCrosstalkingMap()
void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved)
std::vector< float > actualValue
void reduce(std::vector< std::pair< SiStripDetVOff *, cond::Time_t > >::iterator &it, std::vector< std::pair< SiStripDetVOff *, cond::Time_t > >::iterator &initialIt, std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > &resultVec, const bool last=false)
Operates the reduction of the fast sequences of ramping up and down of the voltages.
std::vector< std::string > psuName
void statusChange(cond::Time_t &lastTime, TimesAndValues &tStruct)
std::string timeToStream(const coral::TimeStamp &coralTime, const string &comment="")
std::vector< int > tset_par
boost::posix_time::ptime to_boost(Time_t iValue)
std::string onlineDbConnectionString