6 onlineDbConnectionString(pset.getParameter<
std::
string>(
"onlineDB")),
8 whichTable(pset.getParameter<
std::
string>(
"queryType")),
9 lastValueFileName(pset.getParameter<
std::
string>(
"lastValueFile")),
10 fromFile(pset.getParameter<
bool>(
"lastValueFromFile")),
11 psuDetIdMapFile_(pset.getParameter<
std::
string>(
"PsuDetIdMapFile")),
12 debug_(pset.getParameter<
bool>(
"debugModeOn")),
14 tmax_par(pset.getParameter<
std::vector<
int> >(
"Tmax")),
15 tmin_par(pset.getParameter<
std::vector<
int> >(
"Tmin")),
16 tset_par(pset.getParameter<
std::vector<
int> >(
"TSetMin")),
17 deltaTmin_(pset.getParameter<uint32_t>(
"DeltaTmin")),
18 maxIOVlength_(pset.getParameter<uint32_t>(
"MaxIOVlength")),
19 detIdListFile_(pset.getParameter<
std::
string >(
"DetIdListFile")),
20 excludedDetIdListFile_(pset.getParameter<
std::
string >(
"ExcludedDetIdListFile")),
21 highVoltageOnThreshold_(pset.getParameter<double>(
"HighVoltageOnThreshold"))
26 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] constructor" << endl;
48 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] DB name has not been set properly ... Returning ...";
53 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] File expected for lastValue table, but filename not specified ... Returning ...";
59 ss <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder]\n" 63 <<
" Table to be queried: " <<
whichTable <<
"\n" 80 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: destructing ...";
96 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Query type is " <<
whichTable << endl;
98 if (
whichTable ==
"LASTVALUE") {
edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Use file? " << ((
fromFile) ?
"TRUE" :
"FALSE");}
100 if (
lastStoredCondObj.second > 0) {
edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: retrieved last time stamp from DB: " 157 for (
unsigned int i = 0;
i < dStruct.
detidV.size();
i++) {
161 std::vector<uint32_t> * detids = &(dStruct.
detidV[
i].first);
176 if (iovtime != saveIovTime) {
186 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >& detInfos =
reader.getAllData();
195 std::vector< std::pair<uint32_t, std::string> > excludedDetIdMap;
199 for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = detInfos.begin(); it != detInfos.end(); ++it) {
200 std::vector< std::pair<uint32_t, std::string> >::const_iterator exclIt = excludedDetIdMap.begin();
201 bool excluded =
false;
202 for( ; exclIt != excludedDetIdMap.end(); ++exclIt ) {
203 if( it->first == exclIt->first ) {
209 modV->
put( it->first, 1, 1 );
223 std::vector<uint32_t> beforeV;
234 for (
unsigned int j = 0; j < detids->size(); j++) {
235 if(
debug_ )
cout <<
"at time = " << iovtime <<
" detid["<<j<<
"] = " << (*detids)[j] <<
" has hv = " << hvlv.first <<
" and lv = " << hvlv.second << endl;
236 modV->
put((*detids)[j],hvlv.first,hvlv.second);
240 unsigned int numAdded = 0, numRemoved = 0;
241 if (iovtime == saveIovTime) {
243 numAdded = oldStats[1];
244 numRemoved = oldStats[2];
246 std::vector<uint32_t> afterV;
249 if ((afterV.size() - beforeV.size()) > 0) {
250 numAdded += afterV.size() - beforeV.size();
251 }
else if ((beforeV.size() - afterV.size()) > 0) {
252 numRemoved += beforeV.size() - afterV.size();
257 if (iovtime != saveIovTime) {
260 if (
modulesOff.empty() || !(*modV == *testV) ) {
261 modulesOff.push_back( std::make_pair(modV,iovtime) );
263 saveIovTime = iovtime;
296 std::vector<uint32_t> finalids;
298 std::cout <<
"Index = " <<
i <<
" Size of DetIds vector = " << finalids.size() << std::endl;
300 for (
unsigned int j = 0; j < finalids.size(); j++) {
301 std::cout <<
"detid = " << finalids[j] <<
" LV off = " << (
modulesOff[
i].first)->IsModuleLVOff(finalids[j]) <<
" HV off = " 302 << (
modulesOff[
i].first)->IsModuleHVOff(finalids[j]) << std::endl;
311 std::vector<int> locations;
312 for (
unsigned int i = 0;
i < settingID.size();
i++) {
if (settingID[
i] ==
id) {locations.push_back((
int)
i);} }
315 if (locations.empty()) {setting = -1;}
316 else if (locations.size() == 1) {setting = locations[0];}
320 for (
unsigned int j = 0; j < locations.size(); j++) {
321 #ifdef USING_NEW_CORAL 322 const boost::posix_time::ptime& testSec = changeDate.time();
323 const boost::posix_time::ptime& limitSec = settingDate[(
unsigned int)locations[j]].
time();
325 long testSec = changeDate.time().ns();
326 long limitSec = settingDate[(
unsigned int)locations[j]].
time().ns();
328 if (testSec >= limitSec) {setting = locations[j];}
337 std::vector<int> locations;
338 for (
unsigned int i = 0;
i < settingDpname.size();
i++) {
if (settingDpname[
i] == dpname) {locations.push_back((
int)
i);} }
341 if (locations.empty()) {setting = -1;}
342 else if (locations.size() == 1) {setting = locations[0];}
346 for (
unsigned int j = 0; j < locations.size(); j++) {
347 #ifdef USING_NEW_CORAL 348 const boost::posix_time::ptime& testSec = changeDate.time();
349 const boost::posix_time::ptime& limitSec = settingDate[(
unsigned int)locations[j]].
time();
351 long testSec = changeDate.time().ns();
352 long limitSec = settingDate[(
unsigned int)locations[j]].
time().ns();
354 if (testSec >= limitSec) {setting = locations[j];}
362 if (lastValueFile.bad()) {
363 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: last Value file does not exist!";
370 std::vector<std::string> changeDates;
377 while( std::getline(lastValueFile,line) ) {
378 std::istringstream ss(line);
382 ss >> std::skipws >> dpid >> vmon >> changeDate;
383 dpIDs.push_back(dpid);
384 vmonValues.push_back(vmon);
385 changeDates.push_back(changeDate);
387 lastValueFile.close();
390 for (
unsigned int i = 0;
i < changeDates.size();
i++) {
392 int year = atoi(part.c_str());
395 part = changeDates[
i].substr(5,2);
396 int month = atoi(part.c_str());
399 part = changeDates[
i].substr(8,2);
400 int day = atoi(part.c_str());
403 part = changeDates[
i].substr(11,2);
404 int hour = atoi(part.c_str());
407 part = changeDates[
i].substr(14,2);
408 int minute = atoi(part.c_str());
411 part = changeDates[
i].substr(17,2);
412 int second = atoi(part.c_str());
415 coral::TimeStamp
date(year,month,day,hour,minute,second,0);
416 dateChange.push_back(date);
419 if (changeDates.size() != dateChange.size()) {
edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: date conversion failed!!";}
442 unsigned long long iovSec = iovTime >> 32;
443 uint32_t iovNanoSec = uint32_t(iovTime);
445 cout <<
"[SiStripDetVOffBuilder::getCoralTime] Converting CondTime into CoralTime: " 446 <<
" condTime = " << iovSec <<
" - " << iovNanoSec
447 <<
" getCondTime(coralTime) = " << (testTime>>32) <<
" - " << (testTime&0xFFFFFFFF) << endl;
454 std::sort(vec.begin(),vec.end());
455 std::vector<uint32_t>::iterator it =
std::unique(vec.begin(),vec.end());
456 vec.resize( it - vec.begin() );
471 << (latestDate&0xFFFFFFFF)
476 for (
unsigned int i = 1;
i < coralDate.size();
i++) {
478 if (testDate > latestDate) {
479 latestDate = testDate;
486 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & initialIt,
487 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > & resultVec,
493 if(
distance(resultVec.begin(), initialIt) == 0 ) {
497 if(
debug_ && ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() == 0 ) && ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() == 0 ) ) {
498 cout <<
"Same number of LV and HV at start and end of sequence: LV off = " << it->first->getLVoffCounts() <<
" HV off = " << it->first->getHVoffCounts() << endl;
502 if( ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() > 0 ) || ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() > 0 ) ) {
508 if(
debug_ )
cout <<
"Reducing IOV sequence (going off)" << endl;
511 else if( ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() <= 0 ) || ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() <= 0 ) ) {
513 discardIOVs(it, initialIt, resultVec, last, first);
514 if(
debug_ )
cout <<
"Reducing IOV sequence (going on)" << endl;
519 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & initialIt,
520 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > & resultVec,
521 const bool last,
const unsigned int first )
524 cout <<
"first (1->means the sequence started at the first timestamp in the query results, 0-> that it did not)= " << first << endl;
525 cout <<
"initial->first (initial SiStripDetVOff object of the IOV sequence)= " << initialIt->first <<
", second (initial timestamp of the IOV sequence) = " << initialIt->second << endl;
526 cout <<
"last (0->means that the sequence is not ending with the last item in the query results, 1-> that it DOES!)= " << last << endl;
529 resultVec.erase(initialIt+first, it+1);
531 it = resultVec.end()-2;
534 it = resultVec.erase(initialIt+first, it);
543 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator initialIt;
546 int resultsIndex = 0;
548 if( resultVecSize > 1 ) {
549 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator it =
modulesOff.begin();
550 for( ; it !=
modulesOff.end()-1; ++it, ++resultsIndex ) {
551 unsigned long long deltaT = ((it+1)->
second - it->second) >> 32;
552 unsigned long long deltaTsequence = 0;
554 deltaTsequence = ((it+1)->
second - initialIt->second) >> 32;
557 if( (deltaT < deltaTmin) && ( (count == 0) || ( deltaTsequence < maxIOVlength ) ) ) {
566 else if( count > 1 ) {
576 if( resultsIndex == resultVecSize-2 && count != 0 ) {
616 std::vector<coral::TimeStamp> settingDate;
617 std::vector<float> settingValue;
618 std::vector<std::string> settingDpname;
619 std::vector<uint32_t> settingDpid;
621 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
622 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: " << settingDpname.size();
624 unsigned int missing = 0;
625 std::stringstream ss;
626 for (
unsigned int j = 0; j < tStruct.
dpname.size(); j++) {
634 ss <<
"Channel = " << tStruct.
dpname[j] << std::endl;
637 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of channels with no setting information " << missing;
638 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of entries in dpname vector " << tStruct.
dpname.size();
645 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: File access complete \n\t Number of values read from file: " << tStruct.
dpid.size();
648 std::vector<coral::TimeStamp> settingDate;
649 std::vector<float> settingValue;
650 std::vector<std::string> settingDpname;
651 std::vector<uint32_t> settingDpid;
654 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
655 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: " << settingDpname.size();
657 unsigned int missing = 0;
658 std::stringstream ss;
661 tStruct.
dpname.resize(tStruct. dpid.size());
662 for (
unsigned int j = 0; j < tStruct.
dpid.size(); j++) {
669 tStruct.
dpname[j] = settingDpname[setting];
672 tStruct.
dpname[j] =
"UNKNOWN";
674 ss <<
"DP ID = " << tStruct.
dpid[j] << std::endl;
677 LogDebug(
"SiStripDetVOffBuilder") <<
"Number of missing psu channels = " << missing << std::endl;
678 LogDebug(
"SiStripDetVOffBuilder") <<
"IDs are: = " << ss.str();
684 ss << comment << (condTime>> 32) <<
" - " << (condTime & 0xFFFFFFFF) << std::endl;
691 ss <<
"Starting from IOV time in the database : year = " << coralTime.year()
692 <<
", month = " << coralTime.month()
693 <<
", day = " << coralTime.day()
694 <<
", hour = " << coralTime.hour()
695 <<
", minute = " << coralTime.minute()
696 <<
", second = " << coralTime.second()
697 <<
", nanosecond = " << coralTime.nanosecond() << std::endl;
702 struct stat FileInfo;
706 Stat=
stat(FileName.c_str(),&FileInfo);
724 std::cout<<
"PLEASE provide the name of a valid PSUDetIDMapFile in the cfg: currently still necessary to have a file, soon will access the info straight from the DB!"<<endl;
730 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff] PSU(Channel)-detID map(s) built";
738 unsigned int ch0bad = 0, ch1bad = 0, ch2bad = 0, ch3bad = 0;
739 std::vector<unsigned int> numLvBad, numHvBad;
744 std::map<std::string,bool> UnmappedState, CrosstalkingState;
746 std::map<std::string,std::vector<uint32_t> > UnmappedPSUs=map_.
getHVUnmappedMap();
748 if (
FileExists(
"HVUnmappedChannelState.dat")) {
749 std::cout<<
"File HVUnmappedChannelState.dat exists!"<<std::endl;
750 std::ifstream ifs(
"HVUnmappedChannelState.dat");
752 while( getline( ifs, line ) ) {
753 if( !line.empty() ) {
755 stringstream ss(line);
761 std::string PSU=PSUChannel.substr(0,PSUChannel.size()-10);
763 std::map<std::string,std::vector<uint32_t> >::iterator iter=UnmappedPSUs.find(PSU);
764 if (iter!=UnmappedPSUs.end()) {
765 UnmappedState[PSUChannel]=HVStatus;
768 std::cout<<
"WARNING!!! There are channels in the local file with the channel status for HVUnmapped channels, that ARE NOT CONSIDERED AS UNMAPPED in the current map!"<<std::endl;
774 bool MissingChannels=
false;
775 for (
std::map<
std::string, vector<uint32_t> >::iterator it=UnmappedPSUs.begin(); it!=UnmappedPSUs.end(); it++) {
778 std::map<std::string,bool>::iterator iter=UnmappedState.find(chan002);
779 if (iter==UnmappedState.end()) {
780 std::cout<<
"ERROR! The local file with the channel status for HVUnmapped channels IS MISSING one of the following unmapped channel voltage status information:"<<std::endl;
782 MissingChannels=
true;
784 iter=UnmappedState.find(chan003);
785 if (iter==UnmappedState.end()) {
786 std::cout<<
"ERROR! The local file with the channel status for HVUnmapped channels IS MISSING one of the following unmapped channel voltage status information:"<<std::endl;
788 MissingChannels=
true;
792 if (MissingChannels) {
793 std::cout<<
"!!!!\n"<<
"Exiting now... please check the local HVUnmappedChannelState.dat and the mapfile you provided ("<<
psuDetIdMapFile_<<
")"<<std::endl;
799 for (
std::map<
std::string, vector<uint32_t> >::iterator it=UnmappedPSUs.begin(); it!=UnmappedPSUs.end(); it++) {
802 UnmappedState[chan002]=
false;
803 UnmappedState[chan003]=
false;
809 if (
FileExists(
"HVCrosstalkingChannelState.dat")) {
810 std::cout<<
"File HVCrosstalkingChannelState.dat exists!"<<std::endl;
811 std::ifstream ifs(
"HVCrosstalkingChannelState.dat");
813 while( getline( ifs, line ) ) {
814 if( !line.empty() ) {
816 stringstream ss(line);
822 std::string PSU=PSUChannel.substr(0,PSUChannel.size()-10);
824 std::map<std::string,std::vector<uint32_t> >::iterator iter=CrosstalkingPSUs.find(PSU);
825 if (iter!=CrosstalkingPSUs.end()) {
826 CrosstalkingState[PSUChannel]=HVStatus;
829 std::cout<<
"WARNING!!! There are channels in the local file with the channel status for HVUnmapped channels, that ARE NOT CONSIDERED AS UNMAPPED in the current map!"<<std::endl;
835 bool MissingChannels=
false;
836 for (
std::map<
std::string, vector<uint32_t> >::iterator it=CrosstalkingPSUs.begin(); it!=CrosstalkingPSUs.end(); it++) {
839 std::map<std::string,bool>::iterator iter=CrosstalkingState.find(chan002);
840 if (iter==CrosstalkingState.end()) {
841 std::cout<<
"ERROR! The local file with the channel status for HVCrosstalking channels IS MISSING one of the following unmapped channel voltage status information:"<<std::endl;
843 MissingChannels=
true;
845 iter=CrosstalkingState.find(chan003);
846 if (iter==CrosstalkingState.end()) {
847 std::cout<<
"ERROR! The local file with the channel status for HVCrosstalking channels IS MISSING one of the following unmapped channel voltage status information:"<<std::endl;
849 MissingChannels=
true;
853 if (MissingChannels) {
854 std::cout<<
"!!!!\n"<<
"Exiting now... please check the local HVCrosstalkingChannelState.dat and the mapfile you provided ("<<
psuDetIdMapFile_<<
")"<<std::endl;
860 for (
std::map<
std::string, vector<uint32_t> >::iterator it=CrosstalkingPSUs.begin(); it!=CrosstalkingPSUs.end(); it++) {
863 CrosstalkingState[chan002]=
false;
864 CrosstalkingState[chan003]=
false;
870 std::cout<<
"Printing the UnmappedChannelState initial map:"<<std::endl;
871 std::cout<<
"PSUChannel\t\tHVON?(true or false)"<<std::endl;
872 for (std::map<std::string,bool>::iterator it=UnmappedState.begin(); it!=UnmappedState.end(); it++) {
873 std::cout<<it->first<<
"\t\t"<<it->second<<std::endl;
876 std::cout<<
"Printing the CrosstalkingChannelState initial map:"<<std::endl;
877 std::cout<<
"PSUChannel\t\tHVON?(true or false)"<<std::endl;
878 for (std::map<std::string,bool>::iterator it=CrosstalkingState.begin(); it!=CrosstalkingState.end(); it++) {
879 std::cout<<it->first<<
"\t\t"<<it->second<<std::endl;
888 for (
unsigned int dp = 0; dp < psuStruct.
dpname.size(); dp++) {
892 if (PSUChannel !=
"UNKNOWN") {
896 std::string PSU = PSUChannel.substr(0,PSUChannel.size()-10);
920 std::vector<uint32_t>
ids;
927 std::vector<uint32_t> unmapped_ids,crosstalking_ids;
930 if (Channel==
"channel000" || Channel==
"channel001") {
937 map_.
getHvDetID(PSUChannel,ids,unmapped_ids,crosstalking_ids);
943 if (Channel==
"channel000" || Channel==
"channel001") {
944 cout <<
"Corresponding to LV (PSU-)matching detids: "<<endl;
945 for (
unsigned int i_detid=0;i_detid<ids.size();i_detid++) {
946 cout<< ids[i_detid] << std::endl;
950 cout <<
"Corresponding to straight HV matching detids: "<<endl;
951 for (
unsigned int i_detid=0;i_detid<ids.size();i_detid++) {
952 cout<< ids[i_detid] << std::endl;
957 if (!unmapped_ids.empty()) {
958 cout <<
"Corresponding to HV unmapped (PSU-)matching detids: "<<endl;
959 for (
unsigned int i_detid=0;i_detid<unmapped_ids.size();i_detid++) {
960 cout<< unmapped_ids[i_detid] << std::endl;
963 if (!crosstalking_ids.empty()) {
964 cout <<
"Corresponding to HV crosstalking (PSU-)matching detids: "<<endl;
965 for (
unsigned int i_detid=0;i_detid<crosstalking_ids.size();i_detid++) {
966 cout<< crosstalking_ids[i_detid] << std::endl;
994 detIdStruct.
detidV.push_back( std::make_pair(ids,psuStruct.
changeDate[dp]) );
1000 numLvBad.insert(numLvBad.end(),ids.begin(),ids.end());
1003 detIdStruct.
isHV.push_back(0);
1006 detIdStruct.
psuName.push_back( PSUChannel );
1012 if (!ids.empty() || !unmapped_ids.empty() || !crosstalking_ids.empty()) {
1013 if (Channel==
"channel002") {
1016 else if (Channel==
"channel003") {
1021 std::vector<uint32_t> OFFids;
1022 OFFids.insert(OFFids.end(),ids.begin(),ids.end());
1023 OFFids.insert(OFFids.end(),unmapped_ids.begin(),unmapped_ids.end());
1025 if (!crosstalking_ids.empty()) {
1027 CrosstalkingState[PSUChannel]=
false;
1030 if (!CrosstalkingState[PSUChannel.substr(0,PSUChannel.size()-1)+
"2"] && !CrosstalkingState[PSUChannel.substr(0,PSUChannel.size()-1)+
"3"]) {
1031 OFFids.insert(OFFids.end(),crosstalking_ids.begin(),crosstalking_ids.end());
1033 std::cout<<
"Adding the unmapped detids corresponding to (HV1/2 cross-talking) PSU "<<PSUChannel.substr(0,PSUChannel.size()-10)<<
" to the list of detids turning OFF"<<std::endl;
1038 if (!unmapped_ids.empty()) {
1039 UnmappedState[PSUChannel]=
false;
1041 if (!OFFids.empty()) {
1050 detIdStruct.
detidV.push_back( std::make_pair(OFFids,psuStruct.
changeDate[dp]) );
1056 numHvBad.insert(numHvBad.end(),ids.begin(),ids.end());
1059 detIdStruct.
isHV.push_back(1);
1062 detIdStruct.
psuName.push_back( PSUChannel );
1079 detIdStruct.
detidV.push_back( std::make_pair(ids,psuStruct.
changeDate[dp]) );
1085 detIdStruct.
isHV.push_back(0);
1088 detIdStruct.
psuName.push_back( PSUChannel );
1094 std::vector<uint32_t> ONids;
1095 ONids.insert(ONids.end(),ids.begin(),ids.end());
1096 ONids.insert(ONids.end(),crosstalking_ids.begin(),crosstalking_ids.end());
1098 if (!unmapped_ids.empty()) {
1100 UnmappedState[PSUChannel]=
true;
1103 if (UnmappedState[PSUChannel.substr(0,PSUChannel.size()-1)+
"2"] && UnmappedState[PSUChannel.substr(0,PSUChannel.size()-1)+
"3"]) {
1104 ONids.insert(ONids.end(),unmapped_ids.begin(),unmapped_ids.end());
1106 std::cout<<
"Adding the detids corresponding to HV-unmapped PSU "<<PSUChannel.substr(0,PSUChannel.size()-10)<<
" to the list of detids turning ON"<<std::endl;
1111 if (!crosstalking_ids.empty()) {
1112 CrosstalkingState[PSUChannel]=
true;
1114 if (!ONids.empty()) {
1123 detIdStruct.
detidV.push_back( std::make_pair(ONids,psuStruct.
changeDate[dp]) );
1129 detIdStruct.
isHV.push_back(1);
1132 detIdStruct.
psuName.push_back( PSUChannel );
1145 std::ofstream ofsUnmapped(
"HVUnmappedChannelState.dat");
1146 for (std::map<std::string,bool>::iterator it=UnmappedState.begin(); it!=UnmappedState.end(); it++) {
1147 ofsUnmapped<<it->first<<
"\t"<<it->second<<std::endl;
1149 std::ofstream ofsCrosstalking(
"HVCrosstalkingChannelState.dat");
1150 for (std::map<std::string,bool>::iterator it=CrosstalkingState.begin(); it!=CrosstalkingState.end(); it++) {
1151 ofsCrosstalking<<it->first<<
"\t"<<it->second<<std::endl;
1160 std::cout <<
"Number of channels that turned OFF in this O2O interval"<<std::endl;
1161 std::cout <<
"Channel000 = " << ch0bad <<
" Channel001 = " << ch1bad << std::endl;
1162 std::cout <<
"Channel002 = " << ch2bad <<
" Channel003 = " << ch3bad << std::endl;
1163 std::cout <<
"Number of LV detIDs that turned OFF in this O2O interval = " << numLvBad.size() << std::endl;
1164 std::cout <<
"Number of HV detIDs that turned OFF in this O2O interval = " << numHvBad.size() << std::endl;
1167 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: Number of PSUs retrieved from DB with map information " << detIdStruct.
detidV.size();
1168 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: Number of PSUs retrieved from DB with no map information " << detIdStruct.
notMatched;
1170 unsigned int dupCount = 0;
1171 for (
unsigned int t = 0;
t < numLvBad.size();
t++) {
1172 std::vector<unsigned int>::iterator iter =
std::find(numHvBad.begin(),numHvBad.end(),numLvBad[
t]);
1173 if (iter != numHvBad.end()) {dupCount++;}
1175 if(
debug_ )
std::cout <<
"Number of channels for which LV & HV turned OFF in this O2O interval = " << dupCount << std::endl;
1181 std::vector<uint32_t> pStats(3,0);
1182 pStats.push_back(afterV);
1183 pStats.push_back(numAdded);
1184 pStats.push_back(numRemoved);
1191 int lv_off = -1, hv_off = -1;
1192 if (detIdStruct.
isHV[i] == 0) {lv_off = !(detIdStruct.
StatusGood[
i]);}
1193 if (detIdStruct.
isHV[i] == 1) {
1204 if (iChannel ==
"002" || iChannel ==
"003") {
1205 bool lastStatusOfOtherChannel =
true;
1206 for (
unsigned int j = 0; j <
i; j++) {
1209 if (iPsu == jPsu && iChannel != jChannel && (jChannel ==
"002" || jChannel ==
"003")) {
1211 lastStatusOfOtherChannel = detIdStruct.
StatusGood[j];
1214 if (detIdStruct.
StatusGood[i] != lastStatusOfOtherChannel) {
1215 if(
debug_ )
cout <<
"turning off hv" << endl;
1226 return make_pair(hv_off, lv_off);
SiStripDetVOffBuilder(const edm::ParameterSet &, const edm::ActivityRegistry &)
std::string lastValueFileName
std::vector< int > actualStatus
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)
std::map< std::string, std::vector< uint32_t > > getHVCrosstalkingMap()
void printPar(std::stringstream &ss, const std::vector< int > &par)
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
std::map< std::string, std::vector< uint32_t > > getHVUnmappedMap()
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::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
def unique(seq, keepstr=True)
std::vector< unsigned int > isHV
std::vector< uint32_t > getLvDetID(std::string psu)
void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength)
An interface class to the PVSS cond DB.
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::vector< std::vector< uint32_t > > payloadStats
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::string fullPath() const
std::vector< std::string > psuName
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > modulesOff
void statusChange(cond::Time_t &lastTime, TimesAndValues &tStruct)
std::pair< SiStripDetVOff *, cond::Time_t > lastStoredCondObj
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