2 #include "boost/foreach.hpp"
7 onlineDbConnectionString(pset.getParameter<std::
string>(
"onlineDB")),
8 authenticationPath(pset.getParameter<std::
string>(
"authPath")),
9 whichTable(pset.getParameter<std::
string>(
"queryType")),
10 lastValueFileName(pset.getParameter<std::
string>(
"lastValueFile")),
11 fromFile(pset.getParameter<bool>(
"lastValueFromFile")),
12 psuDetIdMapFile_(pset.getParameter<std::
string>(
"PsuDetIdMapFile")),
13 debug_(pset.getParameter<bool>(
"debugModeOn")),
15 tmax_par(pset.getParameter< std::vector<int> >(
"Tmax")),
16 tmin_par(pset.getParameter< std::vector<int> >(
"Tmin")),
17 tset_par(pset.getParameter< std::vector<int> >(
"TSetMin")),
18 deltaTmin_(pset.getParameter<uint32_t>(
"DeltaTmin")),
19 maxIOVlength_(pset.getParameter<uint32_t>(
"MaxIOVlength")),
20 detIdListFile_(pset.getParameter< std::
string >(
"DetIdListFile")),
21 excludedDetIdListFile_(pset.getParameter< std::
string >(
"ExcludedDetIdListFile")),
22 highVoltageOnThreshold_(pset.getParameter<double>(
"HighVoltageOnThreshold"))
27 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] constructor" << endl;
49 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] DB name has not been set properly ... Returning ...";
54 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder] File expected for lastValue table, but filename not specified ... Returning ...";
60 ss <<
"[SiStripDetVOffBuilder::SiStripDetVOffBuilder]\n"
64 <<
" Table to be queried: " <<
whichTable <<
"\n"
81 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: destructing ...";
85 BOOST_FOREACH(
int val, par){
97 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Query type is " <<
whichTable << endl;
99 if (
whichTable ==
"LASTVALUE") {
edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Use file? " << ((
fromFile) ?
"TRUE" :
"FALSE");}
101 if (
lastStoredCondObj.second > 0) {
edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: retrieved last time stamp from DB: "
158 for (
unsigned int i = 0;
i < dStruct.
detidV.size();
i++) {
162 std::vector<uint32_t> * detids = &(dStruct.
detidV[
i].first);
177 if (iovtime != saveIovTime) {
187 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > detInfos =
reader.getAllData();
196 std::vector< std::pair<uint32_t, std::string> > excludedDetIdMap;
200 for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = detInfos.begin(); it != detInfos.end(); ++it) {
201 std::vector< std::pair<uint32_t, std::string> >::const_iterator exclIt = excludedDetIdMap.begin();
202 bool excluded =
false;
203 for( ; exclIt != excludedDetIdMap.end(); ++exclIt ) {
204 if( it->first == exclIt->first ) {
210 modV->
put( it->first, 1, 1 );
224 std::vector<uint32_t> beforeV;
235 for (
unsigned int j = 0;
j < detids->size();
j++) {
236 if(
debug_ )
cout <<
"at time = " << iovtime <<
" detid["<<
j<<
"] = " << (*detids)[
j] <<
" has hv = " << hvlv.first <<
" and lv = " << hvlv.second << endl;
237 modV->
put((*detids)[
j],hvlv.first,hvlv.second);
241 unsigned int numAdded = 0, numRemoved = 0;
242 if (iovtime == saveIovTime) {
244 numAdded = oldStats[1];
245 numRemoved = oldStats[2];
247 std::vector<uint32_t> afterV;
250 if ((afterV.size() - beforeV.size()) > 0) {
251 numAdded += afterV.size() - beforeV.size();
252 }
else if ((beforeV.size() - afterV.size()) > 0) {
253 numRemoved += beforeV.size() - afterV.size();
258 if (iovtime != saveIovTime) {
261 if (
modulesOff.empty() || !(*modV == *testV) ) {
262 modulesOff.push_back( std::make_pair(modV,iovtime) );
264 saveIovTime = iovtime;
297 std::vector<uint32_t> finalids;
299 std::cout <<
"Index = " <<
i <<
" Size of DetIds vector = " << finalids.size() << std::endl;
301 for (
unsigned int j = 0;
j < finalids.size();
j++) {
302 std::cout <<
"detid = " << finalids[
j] <<
" LV off = " << (
modulesOff[
i].first)->IsModuleLVOff(finalids[
j]) <<
" HV off = "
303 << (
modulesOff[
i].first)->IsModuleHVOff(finalids[j]) << std::endl;
312 std::vector<int> locations;
313 for (
unsigned int i = 0;
i < settingID.size();
i++) {
if (settingID[
i] ==
id) {locations.push_back((
int)
i);} }
316 if (locations.size() == 0) {setting = -1;}
317 else if (locations.size() == 1) {setting = locations[0];}
321 for (
unsigned int j = 0;
j < locations.size();
j++) {
322 #ifdef USING_NEW_CORAL
323 const boost::posix_time::ptime& testSec = changeDate.time();
324 const boost::posix_time::ptime& limitSec = settingDate[(
unsigned int)locations[
j]].time();
326 long testSec = changeDate.time().ns();
327 long limitSec = settingDate[(
unsigned int)locations[
j]].time().ns();
329 if (testSec >= limitSec) {setting = locations[
j];}
338 std::vector<int> locations;
339 for (
unsigned int i = 0;
i < settingDpname.size();
i++) {
if (settingDpname[
i] == dpname) {locations.push_back((
int)
i);} }
342 if (locations.size() == 0) {setting = -1;}
343 else if (locations.size() == 1) {setting = locations[0];}
347 for (
unsigned int j = 0;
j < locations.size();
j++) {
348 #ifdef USING_NEW_CORAL
349 const boost::posix_time::ptime& testSec = changeDate.time();
350 const boost::posix_time::ptime& limitSec = settingDate[(
unsigned int)locations[
j]].time();
352 long testSec = changeDate.time().ns();
353 long limitSec = settingDate[(
unsigned int)locations[
j]].time().ns();
355 if (testSec >= limitSec) {setting = locations[
j];}
364 edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: last Value file does not exist!";
371 std::vector<std::string> changeDates;
379 std::istringstream
ss(line);
383 ss >> std::skipws >> dpid >> vmon >> changeDate;
384 dpIDs.push_back(dpid);
385 vmonValues.push_back(vmon);
386 changeDates.push_back(changeDate);
391 for (
unsigned int i = 0;
i < changeDates.size();
i++) {
393 int year = atoi(part.c_str());
396 part = changeDates[
i].substr(5,2);
397 int month = atoi(part.c_str());
400 part = changeDates[
i].substr(8,2);
401 int day = atoi(part.c_str());
404 part = changeDates[
i].substr(11,2);
405 int hour = atoi(part.c_str());
408 part = changeDates[
i].substr(14,2);
409 int minute = atoi(part.c_str());
412 part = changeDates[
i].substr(17,2);
413 int second = atoi(part.c_str());
416 coral::TimeStamp date(year,month,day,hour,minute,second,0);
417 dateChange.push_back(date);
420 if (changeDates.size() != dateChange.size()) {
edm::LogError(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: date conversion failed!!";}
443 unsigned long long iovSec = iovTime >> 32;
444 uint32_t iovNanoSec = uint32_t(iovTime);
446 cout <<
"[SiStripDetVOffBuilder::getCoralTime] Converting CondTime into CoralTime: "
447 <<
" condTime = " << iovSec <<
" - " << iovNanoSec
448 <<
" getCondTime(coralTime) = " << (testTime>>32) <<
" - " << (testTime&0xFFFFFFFF) << endl;
455 std::sort(vec.begin(),vec.end());
456 std::vector<uint32_t>::iterator it = std::unique(vec.begin(),vec.end());
457 vec.resize( it - vec.begin() );
472 << (latestDate&0xFFFFFFFF)
477 for (
unsigned int i = 1;
i < coralDate.size();
i++) {
479 if (testDate > latestDate) {
480 latestDate = testDate;
487 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & initialIt,
488 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > & resultVec,
494 if(
distance(resultVec.begin(), initialIt) == 0 ) {
498 if(
debug_ && ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() == 0 ) && ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() == 0 ) ) {
499 cout <<
"Same number of LV and HV at start and end of sequence: LV off = " << it->first->getLVoffCounts() <<
" HV off = " << it->first->getHVoffCounts() << endl;
503 if( ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() > 0 ) || ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() > 0 ) ) {
509 if(
debug_ )
cout <<
"Reducing IOV sequence (going off)" << endl;
512 else if( ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() <= 0 ) || ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() <= 0 ) ) {
514 discardIOVs(it, initialIt, resultVec, last, first);
515 if(
debug_ )
cout <<
"Reducing IOV sequence (going on)" << endl;
520 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & initialIt,
521 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > & resultVec,
522 const bool last,
const unsigned int first )
525 cout <<
"first (1->means the sequence started at the first timestamp in the query results, 0-> that it did not)= " << first << endl;
526 cout <<
"initial->first (initial SiStripDetVOff object of the IOV sequence)= " << initialIt->first <<
", second (initial timestamp of the IOV sequence) = " << initialIt->second << endl;
527 cout <<
"last (0->means that the sequence is not ending with the last item in the query results, 1-> that it DOES!)= " << last << endl;
530 resultVec.erase(initialIt+first, it+1);
532 it = resultVec.end()-2;
535 it = resultVec.erase(initialIt+first, it);
544 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator initialIt;
547 int resultsIndex = 0;
549 if( resultVecSize > 1 ) {
550 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator it =
modulesOff.begin();
551 for( ; it !=
modulesOff.end()-1; ++it, ++resultsIndex ) {
552 unsigned long long deltaT = ((it+1)->
second - it->second) >> 32;
553 unsigned long long deltaTsequence = 0;
555 deltaTsequence = ((it+1)->
second - initialIt->second) >> 32;
558 if( (deltaT < deltaTmin) && ( (count == 0) || ( deltaTsequence < maxIOVlength ) ) ) {
567 else if( count > 1 ) {
577 if( resultsIndex == resultVecSize-2 && count != 0 ) {
617 std::vector<coral::TimeStamp> settingDate;
618 std::vector<float> settingValue;
619 std::vector<std::string> settingDpname;
620 std::vector<uint32_t> settingDpid;
622 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
623 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: " << settingDpname.size();
626 std::stringstream
ss;
627 for (
unsigned int j = 0;
j < tStruct.
dpname.size();
j++) {
635 ss <<
"Channel = " << tStruct.
dpname[
j] << std::endl;
638 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of channels with no setting information " <<
missing;
639 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of entries in dpname vector " << tStruct.
dpname.size();
646 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: File access complete \n\t Number of values read from file: " << tStruct.
dpid.size();
649 std::vector<coral::TimeStamp> settingDate;
650 std::vector<float> settingValue;
651 std::vector<std::string> settingDpname;
652 std::vector<uint32_t> settingDpid;
655 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
656 LogDebug(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: " << settingDpname.size();
659 std::stringstream
ss;
662 tStruct.
dpname.resize(tStruct. dpid.size());
663 for (
unsigned int j = 0;
j < tStruct.
dpid.size();
j++) {
670 tStruct.
dpname[
j] = settingDpname[setting];
675 ss <<
"DP ID = " << tStruct.
dpid[
j] << std::endl;
678 LogDebug(
"SiStripDetVOffBuilder") <<
"Number of missing psu channels = " << missing << std::endl;
679 LogDebug(
"SiStripDetVOffBuilder") <<
"IDs are: = " << ss.str();
685 ss << comment << (condTime>> 32) <<
" - " << (condTime & 0xFFFFFFFF) << std::endl;
692 ss <<
"Starting from IOV time in the database : year = " << coralTime.year()
693 <<
", month = " << coralTime.month()
694 <<
", day = " << coralTime.day()
695 <<
", hour = " << coralTime.hour()
696 <<
", minute = " << coralTime.minute()
697 <<
", second = " << coralTime.second()
698 <<
", nanosecond = " << coralTime.nanosecond() << std::endl;
703 struct stat FileInfo;
707 Stat=stat(FileName.c_str(),&FileInfo);
725 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;
731 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::BuildDetVOff] PSU(Channel)-detID map(s) built";
739 unsigned int ch0bad = 0, ch1bad = 0, ch2bad = 0, ch3bad = 0;
740 std::vector<unsigned int> numLvBad, numHvBad;
745 std::map<std::string,bool> UnmappedState, CrosstalkingState;
747 std::map<std::string,std::vector<uint32_t> > UnmappedPSUs=map_.
getHVUnmappedMap();
749 if (
FileExists(
"HVUnmappedChannelState.dat")) {
750 std::cout<<
"File HVUnmappedChannelState.dat exists!"<<std::endl;
751 std::ifstream ifs(
"HVUnmappedChannelState.dat");
753 while( getline( ifs, line ) ) {
756 stringstream
ss(line);
762 std::string PSU=PSUChannel.substr(0,PSUChannel.size()-10);
764 std::map<std::string,std::vector<uint32_t> >::iterator iter=UnmappedPSUs.find(PSU);
765 if (iter!=UnmappedPSUs.end()) {
766 UnmappedState[PSUChannel]=HVStatus;
769 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;
775 bool MissingChannels=
false;
776 for (std::map<
std::string, vector<uint32_t> >::iterator it=UnmappedPSUs.begin(); it!=UnmappedPSUs.end(); it++) {
779 std::map<std::string,bool>::iterator iter=UnmappedState.find(chan002);
780 if (iter==UnmappedState.end()) {
781 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;
783 MissingChannels=
true;
785 iter=UnmappedState.find(chan003);
786 if (iter==UnmappedState.end()) {
787 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;
789 MissingChannels=
true;
793 if (MissingChannels) {
794 std::cout<<
"!!!!\n"<<
"Exiting now... please check the local HVUnmappedChannelState.dat and the mapfile you provided ("<<
psuDetIdMapFile_<<
")"<<std::endl;
800 for (std::map<
std::string, vector<uint32_t> >::iterator it=UnmappedPSUs.begin(); it!=UnmappedPSUs.end(); it++) {
803 UnmappedState[chan002]=
false;
804 UnmappedState[chan003]=
false;
810 if (
FileExists(
"HVCrosstalkingChannelState.dat")) {
811 std::cout<<
"File HVCrosstalkingChannelState.dat exists!"<<std::endl;
812 std::ifstream ifs(
"HVCrosstalkingChannelState.dat");
814 while( getline( ifs, line ) ) {
817 stringstream
ss(line);
823 std::string PSU=PSUChannel.substr(0,PSUChannel.size()-10);
825 std::map<std::string,std::vector<uint32_t> >::iterator iter=CrosstalkingPSUs.find(PSU);
826 if (iter!=CrosstalkingPSUs.end()) {
827 CrosstalkingState[PSUChannel]=HVStatus;
830 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;
836 bool MissingChannels=
false;
837 for (std::map<
std::string, vector<uint32_t> >::iterator it=CrosstalkingPSUs.begin(); it!=CrosstalkingPSUs.end(); it++) {
840 std::map<std::string,bool>::iterator iter=CrosstalkingState.find(chan002);
841 if (iter==CrosstalkingState.end()) {
842 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;
844 MissingChannels=
true;
846 iter=CrosstalkingState.find(chan003);
847 if (iter==CrosstalkingState.end()) {
848 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;
850 MissingChannels=
true;
854 if (MissingChannels) {
855 std::cout<<
"!!!!\n"<<
"Exiting now... please check the local HVCrosstalkingChannelState.dat and the mapfile you provided ("<<
psuDetIdMapFile_<<
")"<<std::endl;
861 for (std::map<
std::string, vector<uint32_t> >::iterator it=CrosstalkingPSUs.begin(); it!=CrosstalkingPSUs.end(); it++) {
864 CrosstalkingState[chan002]=
false;
865 CrosstalkingState[chan003]=
false;
871 std::cout<<
"Printing the UnmappedChannelState initial map:"<<std::endl;
872 std::cout<<
"PSUChannel\t\tHVON?(true or false)"<<std::endl;
873 for (std::map<std::string,bool>::iterator it=UnmappedState.begin(); it!=UnmappedState.end(); it++) {
874 std::cout<<it->first<<
"\t\t"<<it->second<<std::endl;
877 std::cout<<
"Printing the CrosstalkingChannelState initial map:"<<std::endl;
878 std::cout<<
"PSUChannel\t\tHVON?(true or false)"<<std::endl;
879 for (std::map<std::string,bool>::iterator it=CrosstalkingState.begin(); it!=CrosstalkingState.end(); it++) {
880 std::cout<<it->first<<
"\t\t"<<it->second<<std::endl;
889 for (
unsigned int dp = 0;
dp < psuStruct.
dpname.size();
dp++) {
893 if (PSUChannel !=
"UNKNOWN") {
897 std::string PSU = PSUChannel.substr(0,PSUChannel.size()-10);
921 std::vector<uint32_t> ids;
928 std::vector<uint32_t> unmapped_ids,crosstalking_ids;
931 if (Channel==
"channel000" || Channel==
"channel001") {
938 map_.
getHvDetID(PSUChannel,ids,unmapped_ids,crosstalking_ids);
944 if (Channel==
"channel000" || Channel==
"channel001") {
945 cout <<
"Corresponding to LV (PSU-)matching detids: "<<endl;
946 for (
unsigned int i_detid=0;i_detid<ids.size();i_detid++) {
947 cout<< ids[i_detid] << std::endl;
951 cout <<
"Corresponding to straight HV matching detids: "<<endl;
952 for (
unsigned int i_detid=0;i_detid<ids.size();i_detid++) {
953 cout<< ids[i_detid] << std::endl;
958 if (!unmapped_ids.empty()) {
959 cout <<
"Corresponding to HV unmapped (PSU-)matching detids: "<<endl;
960 for (
unsigned int i_detid=0;i_detid<unmapped_ids.size();i_detid++) {
961 cout<< unmapped_ids[i_detid] << std::endl;
964 if (!crosstalking_ids.empty()) {
965 cout <<
"Corresponding to HV crosstalking (PSU-)matching detids: "<<endl;
966 for (
unsigned int i_detid=0;i_detid<crosstalking_ids.size();i_detid++) {
967 cout<< crosstalking_ids[i_detid] << std::endl;
1001 numLvBad.insert(numLvBad.end(),ids.begin(),ids.end());
1004 detIdStruct.
isHV.push_back(0);
1007 detIdStruct.
psuName.push_back( PSUChannel );
1013 if (!ids.empty() || !unmapped_ids.empty() || !crosstalking_ids.empty()) {
1014 if (Channel==
"channel002") {
1017 else if (Channel==
"channel003") {
1022 std::vector<uint32_t> OFFids;
1023 OFFids.insert(OFFids.end(),ids.begin(),ids.end());
1024 OFFids.insert(OFFids.end(),unmapped_ids.begin(),unmapped_ids.end());
1026 if (!crosstalking_ids.empty()) {
1028 CrosstalkingState[PSUChannel]=
false;
1031 if (!CrosstalkingState[PSUChannel.substr(0,PSUChannel.size()-1)+
"2"] && !CrosstalkingState[PSUChannel.substr(0,PSUChannel.size()-1)+
"3"]) {
1032 OFFids.insert(OFFids.end(),crosstalking_ids.begin(),crosstalking_ids.end());
1034 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;
1039 if (!unmapped_ids.empty()) {
1040 UnmappedState[PSUChannel]=
false;
1042 if (!OFFids.empty()) {
1057 numHvBad.insert(numHvBad.end(),ids.begin(),ids.end());
1060 detIdStruct.
isHV.push_back(1);
1063 detIdStruct.
psuName.push_back( PSUChannel );
1086 detIdStruct.
isHV.push_back(0);
1089 detIdStruct.
psuName.push_back( PSUChannel );
1095 std::vector<uint32_t> ONids;
1096 ONids.insert(ONids.end(),ids.begin(),ids.end());
1097 ONids.insert(ONids.end(),crosstalking_ids.begin(),crosstalking_ids.end());
1099 if (!unmapped_ids.empty()) {
1101 UnmappedState[PSUChannel]=
true;
1104 if (UnmappedState[PSUChannel.substr(0,PSUChannel.size()-1)+
"2"] && UnmappedState[PSUChannel.substr(0,PSUChannel.size()-1)+
"3"]) {
1105 ONids.insert(ONids.end(),unmapped_ids.begin(),unmapped_ids.end());
1107 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;
1112 if (!crosstalking_ids.empty()) {
1113 CrosstalkingState[PSUChannel]=
true;
1115 if (!ONids.empty()) {
1130 detIdStruct.
isHV.push_back(1);
1133 detIdStruct.
psuName.push_back( PSUChannel );
1146 std::ofstream ofsUnmapped(
"HVUnmappedChannelState.dat");
1147 for (std::map<std::string,bool>::iterator it=UnmappedState.begin(); it!=UnmappedState.end(); it++) {
1148 ofsUnmapped<<it->first<<
"\t"<<it->second<<std::endl;
1150 std::ofstream ofsCrosstalking(
"HVCrosstalkingChannelState.dat");
1151 for (std::map<std::string,bool>::iterator it=CrosstalkingState.begin(); it!=CrosstalkingState.end(); it++) {
1152 ofsCrosstalking<<it->first<<
"\t"<<it->second<<std::endl;
1161 std::cout <<
"Number of channels that turned OFF in this O2O interval"<<std::endl;
1162 std::cout <<
"Channel000 = " << ch0bad <<
" Channel001 = " << ch1bad << std::endl;
1163 std::cout <<
"Channel002 = " << ch2bad <<
" Channel003 = " << ch3bad << std::endl;
1164 std::cout <<
"Number of LV detIDs that turned OFF in this O2O interval = " << numLvBad.size() << std::endl;
1165 std::cout <<
"Number of HV detIDs that turned OFF in this O2O interval = " << numHvBad.size() << std::endl;
1168 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: Number of PSUs retrieved from DB with map information " << detIdStruct.
detidV.size();
1169 LogTrace(
"SiStripDetVOffBuilder") <<
"[SiStripDetVOffBuilder::" << __func__ <<
"]: Number of PSUs retrieved from DB with no map information " << detIdStruct.
notMatched;
1171 unsigned int dupCount = 0;
1172 for (
unsigned int t = 0;
t < numLvBad.size();
t++) {
1173 std::vector<unsigned int>::iterator iter =
std::find(numHvBad.begin(),numHvBad.end(),numLvBad[
t]);
1174 if (iter != numHvBad.end()) {dupCount++;}
1176 if(
debug_ )
std::cout <<
"Number of channels for which LV & HV turned OFF in this O2O interval = " << dupCount << std::endl;
1182 std::vector<uint32_t> pStats(3,0);
1183 pStats.push_back(afterV);
1184 pStats.push_back(numAdded);
1185 pStats.push_back(numRemoved);
1192 int lv_off = -1, hv_off = -1;
1193 if (detIdStruct.
isHV[i] == 0) {lv_off = !(detIdStruct.
StatusGood[
i]);}
1194 if (detIdStruct.
isHV[i] == 1) {
1205 if (iChannel ==
"002" || iChannel ==
"003") {
1206 bool lastStatusOfOtherChannel =
true;
1207 for (
unsigned int j = 0;
j <
i;
j++) {
1210 if (iPsu == jPsu && iChannel != jChannel && (jChannel ==
"002" || jChannel ==
"003")) {
1212 lastStatusOfOtherChannel = detIdStruct.
StatusGood[
j];
1215 if (detIdStruct.
StatusGood[i] != lastStatusOfOtherChannel) {
1216 if(
debug_ )
cout <<
"turning off hv" << endl;
1227 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_
std::auto_ptr< SiStripCoralIface > coralInterface
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)
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)
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