00001 #include "CalibTracker/SiStripDCS/interface/SiStripDetVOffBuilder.h"
00002 #include "boost/foreach.hpp"
00003 #include <sys/stat.h>
00004
00005
00006 SiStripDetVOffBuilder::SiStripDetVOffBuilder(const edm::ParameterSet& pset, const edm::ActivityRegistry&) :
00007 onlineDbConnectionString(pset.getParameter<std::string>("onlineDB")),
00008 authenticationPath(pset.getParameter<std::string>("authPath")),
00009 whichTable(pset.getParameter<std::string>("queryType")),
00010 lastValueFileName(pset.getParameter<std::string>("lastValueFile")),
00011 fromFile(pset.getParameter<bool>("lastValueFromFile")),
00012 psuDetIdMapFile_(pset.getParameter<std::string>("PsuDetIdMapFile")),
00013 debug_(pset.getParameter<bool>("debugModeOn")),
00014 tDefault(7,0),
00015 tmax_par(pset.getParameter< std::vector<int> >("Tmax")),
00016 tmin_par(pset.getParameter< std::vector<int> >("Tmin")),
00017 tset_par(pset.getParameter< std::vector<int> >("TSetMin")),
00018 detIdListFile_(pset.getParameter< std::string >("DetIdListFile")),
00019 excludedDetIdListFile_(pset.getParameter< std::string >("ExcludedDetIdListFile")),
00020 highVoltageOnThreshold_(pset.getParameter<double>("HighVoltageOnThreshold"))
00021 {
00022 lastStoredCondObj.first = NULL;
00023 lastStoredCondObj.second = 0;
00024
00025 edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder] constructor" << endl;
00026
00027
00028
00029 whichQuery=(whichTable == "STATUSCHANGE" || (whichTable == "LASTVALUE" && !fromFile));
00030
00031
00032
00033
00034
00035 tmax = coral::TimeStamp(tmax_par[0],tmax_par[1],tmax_par[2],tmax_par[3],tmax_par[4],tmax_par[5],tmax_par[6]);
00036
00037 if (whichQuery) {
00038
00039 tmin=coral::TimeStamp(tmin_par[0],tmin_par[1],tmin_par[2],tmin_par[3],tmin_par[4],tmin_par[5],tmin_par[6]);
00040 }
00041
00042 if (whichTable == "LASTVALUE") {
00043 tsetmin = coral::TimeStamp(tset_par[0],tset_par[1],tset_par[2],tset_par[3],tset_par[4],tset_par[5],tset_par[6]);
00044 }
00045
00046 if (onlineDbConnectionString == "") {
00047 edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder] DB name has not been set properly ... Returning ...";
00048 return;
00049 }
00050
00051 if (fromFile && whichTable == "LASTVALUE" && lastValueFileName == "") {
00052 edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder] File expected for lastValue table, but filename not specified ... Returning ...";
00053 return;
00054 }
00055
00056
00057 std::stringstream ss;
00058 ss << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder]\n"
00059 << " Parameters:\n"
00060 << " DB connection string: " << onlineDbConnectionString << "\n"
00061 << " Authentication path: " << authenticationPath << "\n"
00062 << " Table to be queried: " << whichTable << "\n"
00063 << " MapFile: " << psuDetIdMapFile_ << "\n";
00064
00065 if (whichQuery){
00066 ss << " Tmin: "; printPar(ss,tmin_par); ss << std::endl;
00067 }
00068 ss << " Tmax: " ; printPar(ss,tmax_par); ss << std::endl;
00069
00070 if (whichTable == "LASTVALUE"){
00071 ss << " TSetMin: "; printPar(ss,tset_par); ss << std::endl;
00072 }
00073 edm::LogError("SiStripDetVOffBuilder") << ss.str();
00074
00075 }
00076
00077
00078 SiStripDetVOffBuilder::~SiStripDetVOffBuilder() {
00079 edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__ << "]: destructing ...";
00080 }
00081
00082 void SiStripDetVOffBuilder::printPar(std::stringstream& ss, const std::vector<int>& par){
00083 BOOST_FOREACH(int val, par){
00084 ss << val << " ";
00085 }
00086 }
00087
00088 void SiStripDetVOffBuilder::BuildDetVOffObj()
00089 {
00090
00091 TimesAndValues timesAndValues;
00092
00093
00094 coralInterface.reset( new SiStripCoralIface(onlineDbConnectionString, authenticationPath, debug_) );
00095 edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Query type is " << whichTable << endl;
00096
00097 if (whichTable == "LASTVALUE") {edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Use file? " << ((fromFile) ? "TRUE" : "FALSE");}
00098
00099 if (lastStoredCondObj.second > 0) {edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: retrieved last time stamp from DB: "
00100 << lastStoredCondObj.second << endl;}
00101
00102
00103
00104
00105
00106 if (whichQuery) {
00107 if( whichTable == "STATUSCHANGE" ) {
00108 statusChange( lastStoredCondObj.second, timesAndValues );
00109 }
00110 if( whichTable == "LASTVALUE" ) {
00111 if( fromFile ) {
00112 lastValueFromFile(timesAndValues);
00113 }
00114 else {
00115 lastValue(timesAndValues);
00116 }
00117 }
00118 }
00119
00120
00121 DetIdListTimeAndStatus dStruct;
00122
00123
00124
00125
00126
00127 buildPSUdetIdMap(timesAndValues, dStruct);
00128
00129
00130
00131 modulesOff.clear();
00132 cond::Time_t saveIovTime = 0;
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 if (lastStoredCondObj.first != NULL && lastStoredCondObj.second > 0) {
00149 modulesOff.push_back( lastStoredCondObj );
00150 saveIovTime = lastStoredCondObj.second;
00151 setPayloadStats(0, 0, 0);
00152 }
00153
00154
00155
00156 for (unsigned int i = 0; i < dStruct.detidV.size(); i++) {
00157
00158
00159
00160 std::vector<uint32_t> * detids = &(dStruct.detidV[i].first);
00161
00162
00163 cond::Time_t iovtime = 0;
00164
00165 if (whichTable == "LASTVALUE") {iovtime = timesAndValues.latestTime;}
00166
00167 else {iovtime = getCondTime((dStruct.detidV[i]).second);}
00168
00169
00170 SiStripDetVOff *modV = 0;
00171
00172
00173
00174
00175 if (iovtime != saveIovTime) {
00176
00177
00178 if (modulesOff.empty()) {
00179
00180 modV = new SiStripDetVOff();
00181
00182
00183 edm::FileInPath fp(detIdListFile_);
00184 SiStripDetInfoFileReader reader(fp.fullPath());
00185 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > detInfos = reader.getAllData();
00186
00187
00188
00189
00190
00191
00192
00193 SiStripPsuDetIdMap map;
00194 std::vector< std::pair<uint32_t, std::string> > excludedDetIdMap;
00195 if( excludedDetIdListFile_ != "" ) {
00196 map.BuildMap(excludedDetIdListFile_, excludedDetIdMap);
00197 }
00198 for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = detInfos.begin(); it != detInfos.end(); ++it) {
00199 std::vector< std::pair<uint32_t, std::string> >::const_iterator exclIt = excludedDetIdMap.begin();
00200 bool excluded = false;
00201 for( ; exclIt != excludedDetIdMap.end(); ++exclIt ) {
00202 if( it->first == exclIt->first ) {
00203 excluded = true;
00204 break;
00205 }
00206 }
00207 if( !excluded ) {
00208 modV->put( it->first, 1, 1 );
00209 }
00210 }
00211
00212 }
00213 else {modV = new SiStripDetVOff( *(modulesOff.back().first) );}
00214 }
00215 else {
00216 modV = (modulesOff.back()).first;
00217 }
00218
00219
00220
00221
00222 std::vector<uint32_t> beforeV;
00223 modV->getDetIds(beforeV);
00224
00225
00226
00227
00228
00229 std::pair<int, int> hvlv = extractDetIdVector(i, modV, dStruct);
00230
00231
00232
00233 for (unsigned int j = 0; j < detids->size(); j++) {
00234 if( debug_ ) cout << "at time = " << iovtime << " detid["<<j<<"] = " << (*detids)[j] << " has hv = " << hvlv.first << " and lv = " << hvlv.second << endl;
00235 modV->put((*detids)[j],hvlv.first,hvlv.second);
00236 }
00237
00238
00239 unsigned int numAdded = 0, numRemoved = 0;
00240 if (iovtime == saveIovTime) {
00241 std::vector<uint32_t> oldStats = payloadStats.back();
00242 numAdded = oldStats[1];
00243 numRemoved = oldStats[2];
00244 }
00245 std::vector<uint32_t> afterV;
00246 modV->getDetIds(afterV);
00247
00248 if ((afterV.size() - beforeV.size()) > 0) {
00249 numAdded += afterV.size() - beforeV.size();
00250 } else if ((beforeV.size() - afterV.size()) > 0) {
00251 numRemoved += beforeV.size() - afterV.size();
00252 }
00253
00254
00255
00256 if (iovtime != saveIovTime) {
00257 SiStripDetVOff * testV = 0;
00258 if (!modulesOff.empty()) {testV = modulesOff.back().first;}
00259 if (modulesOff.empty() || !(*modV == *testV) ) {
00260 modulesOff.push_back( std::make_pair(modV,iovtime) );
00261
00262 saveIovTime = iovtime;
00263
00264 setPayloadStats(afterV.size(), numAdded, numRemoved);
00265 }
00266 } else {
00267 (payloadStats.back())[0] = afterV.size();
00268 (payloadStats.back())[1] = numAdded;
00269 (payloadStats.back())[2] = numRemoved;
00270 }
00271 }
00272
00273
00274
00275 if (lastStoredCondObj.first != NULL && lastStoredCondObj.second > 0) {
00276 if ( lastStoredCondObj.second == modulesOff[0].second &&
00277 *(lastStoredCondObj.first) == *(modulesOff[0].first) ) {
00278 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator moIt = modulesOff.begin();
00279 modulesOff.erase(moIt);
00280 std::vector< std::vector<uint32_t> >::iterator plIt = payloadStats.begin();
00281 payloadStats.erase(plIt);
00282 }
00283 }
00284
00285 if (debug_) {
00286 std::cout << std::endl;
00287 std::cout << "Size of modulesOff = " << modulesOff.size() << std::endl;
00288 for (unsigned int i = 0; i < modulesOff.size(); i++) {
00289 std::vector<uint32_t> finalids;
00290 (modulesOff[i].first)->getDetIds(finalids);
00291 std::cout << "Index = " << i << " Size of DetIds vector = " << finalids.size() << std::endl;
00292 std::cout << "Time = " << modulesOff[i].second << std::endl;
00293 for (unsigned int j = 0; j < finalids.size(); j++) {
00294 std::cout << "detid = " << finalids[j] << " LV off = " << (modulesOff[i].first)->IsModuleLVOff(finalids[j]) << " HV off = "
00295 << (modulesOff[i].first)->IsModuleHVOff(finalids[j]) << std::endl;
00296 }
00297 }
00298 }
00299 }
00300
00301 int SiStripDetVOffBuilder::findSetting(uint32_t id, coral::TimeStamp changeDate, std::vector<uint32_t> settingID, std::vector<coral::TimeStamp> settingDate) {
00302 int setting = -1;
00303
00304 std::vector<int> locations;
00305 for (unsigned int i = 0; i < settingID.size(); i++) { if (settingID[i] == id) {locations.push_back((int)i);} }
00306
00307
00308 if (locations.size() == 0) {setting = -1;}
00309 else if (locations.size() == 1) {setting = locations[0];}
00310
00311
00312 else {
00313 for (unsigned int j = 0; j < locations.size(); j++) {
00314 #ifdef USING_NEW_CORAL
00315 const boost::posix_time::ptime& testSec = changeDate.time();
00316 const boost::posix_time::ptime& limitSec = settingDate[(unsigned int)locations[j]].time();
00317 #else
00318 long testSec = changeDate.time().ns();
00319 long limitSec = settingDate[(unsigned int)locations[j]].time().ns();
00320 #endif
00321 if (testSec >= limitSec) {setting = locations[j];}
00322 }
00323 }
00324 return setting;
00325 }
00326
00327 int SiStripDetVOffBuilder::findSetting(std::string dpname, coral::TimeStamp changeDate, std::vector<std::string> settingDpname, std::vector<coral::TimeStamp> settingDate) {
00328 int setting = -1;
00329
00330 std::vector<int> locations;
00331 for (unsigned int i = 0; i < settingDpname.size(); i++) { if (settingDpname[i] == dpname) {locations.push_back((int)i);} }
00332
00333
00334 if (locations.size() == 0) {setting = -1;}
00335 else if (locations.size() == 1) {setting = locations[0];}
00336
00337
00338 else {
00339 for (unsigned int j = 0; j < locations.size(); j++) {
00340 #ifdef USING_NEW_CORAL
00341 const boost::posix_time::ptime& testSec = changeDate.time();
00342 const boost::posix_time::ptime& limitSec = settingDate[(unsigned int)locations[j]].time();
00343 #else
00344 long testSec = changeDate.time().ns();
00345 long limitSec = settingDate[(unsigned int)locations[j]].time().ns();
00346 #endif
00347 if (testSec >= limitSec) {setting = locations[j];}
00348 }
00349 }
00350 return setting;
00351 }
00352
00353 void SiStripDetVOffBuilder::readLastValueFromFile(std::vector<uint32_t> &dpIDs, std::vector<float> &vmonValues, std::vector<coral::TimeStamp> &dateChange) {
00354 std::ifstream lastValueFile(lastValueFileName.c_str());
00355 if (lastValueFile.bad()) {
00356 edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__ << "]: last Value file does not exist!";
00357 return;
00358 }
00359
00360 dpIDs.clear();
00361 vmonValues.clear();
00362 dateChange.clear();
00363 std::vector<std::string> changeDates;
00364
00365 std::string line;
00366
00367
00368
00369
00370 while( std::getline(lastValueFile,line) ) {
00371 std::istringstream ss(line);
00372 uint32_t dpid;
00373 float vmon;
00374 std::string changeDate;
00375 ss >> std::skipws >> dpid >> vmon >> changeDate;
00376 dpIDs.push_back(dpid);
00377 vmonValues.push_back(vmon);
00378 changeDates.push_back(changeDate);
00379 }
00380 lastValueFile.close();
00381
00382
00383 for (unsigned int i = 0; i < changeDates.size(); i++) {
00384 std::string part = changeDates[i].substr(0,4);
00385 int year = atoi(part.c_str());
00386 part.clear();
00387
00388 part = changeDates[i].substr(5,2);
00389 int month = atoi(part.c_str());
00390 part.clear();
00391
00392 part = changeDates[i].substr(8,2);
00393 int day = atoi(part.c_str());
00394 part.clear();
00395
00396 part = changeDates[i].substr(11,2);
00397 int hour = atoi(part.c_str());
00398 part.clear();
00399
00400 part = changeDates[i].substr(14,2);
00401 int minute = atoi(part.c_str());
00402 part.clear();
00403
00404 part = changeDates[i].substr(17,2);
00405 int second = atoi(part.c_str());
00406 part.clear();
00407
00408 coral::TimeStamp date(year,month,day,hour,minute,second,0);
00409 dateChange.push_back(date);
00410 }
00411
00412 if (changeDates.size() != dateChange.size()) {edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__ << "]: date conversion failed!!";}
00413 }
00414
00415 cond::Time_t SiStripDetVOffBuilder::getCondTime(coral::TimeStamp coralTime) {
00416
00417
00418 cond::Time_t condTime = cond::time::from_boost(coralTime.time());
00419
00420
00421
00422
00423 return condTime;
00424 }
00425
00426 coral::TimeStamp SiStripDetVOffBuilder::getCoralTime(cond::Time_t iovTime)
00427 {
00428
00429
00430
00431
00432 coral::TimeStamp coralTime(cond::time::to_boost(iovTime));
00433
00434 if( debug_ ) {
00435 unsigned long long iovSec = iovTime >> 32;
00436 uint32_t iovNanoSec = uint32_t(iovTime);
00437 cond::Time_t testTime=getCondTime(coralTime);
00438 cout << "[SiStripDetVOffBuilder::getCoralTime] Converting CondTime into CoralTime: "
00439 << " condTime = " << iovSec << " - " << iovNanoSec
00440 << " getCondTime(coralTime) = " << (testTime>>32) << " - " << (testTime&0xFFFFFFFF) << endl;
00441 }
00442
00443 return coralTime;
00444 }
00445
00446 void SiStripDetVOffBuilder::removeDuplicates( std::vector<uint32_t> & vec ) {
00447 std::sort(vec.begin(),vec.end());
00448 std::vector<uint32_t>::iterator it = std::unique(vec.begin(),vec.end());
00449 vec.resize( it - vec.begin() );
00450 }
00451
00452 void SiStripDetVOffBuilder::setLastSiStripDetVOff( SiStripDetVOff * lastPayload, cond::Time_t lastTimeStamp ) {
00453 lastStoredCondObj.first = lastPayload;
00454 lastStoredCondObj.second = lastTimeStamp;
00455 }
00456
00457 cond::Time_t SiStripDetVOffBuilder::findMostRecentTimeStamp( std::vector<coral::TimeStamp> coralDate ) {
00458 cond::Time_t latestDate = getCondTime(coralDate[0]);
00459
00460 if( debug_ ) {
00461 std::cout << "latestDate: condTime = "
00462 << (latestDate>>32)
00463 << " - "
00464 << (latestDate&0xFFFFFFFF)
00465
00466 << std::endl;
00467 }
00468
00469 for (unsigned int i = 1; i < coralDate.size(); i++) {
00470 cond::Time_t testDate = getCondTime(coralDate[i]);
00471 if (testDate > latestDate) {
00472 latestDate = testDate;
00473 }
00474 }
00475 return latestDate;
00476 }
00477
00478 void SiStripDetVOffBuilder::reduce( std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & it,
00479 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & initialIt,
00480 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > & resultVec,
00481 const bool last )
00482 {
00483
00484 int first = 0;
00485
00486 if( distance(resultVec.begin(), initialIt) == 0 ) {
00487 first = 1;
00488 }
00489
00490 if( debug_ && ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() == 0 ) && ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() == 0 ) ) {
00491 cout << "Same number of LV and HV at start and end of sequence: LV off = " << it->first->getLVoffCounts() << " HV off = " << it->first->getHVoffCounts() << endl;
00492 }
00493
00494
00495 if( ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() > 0 ) || ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() > 0 ) ) {
00496
00497
00498
00499 (it+last)->second = (initialIt)->second;
00500 discardIOVs(it, initialIt, resultVec, last, 0);
00501 if( debug_ ) cout << "Reducing IOV sequence (going off)" << endl;
00502 }
00503
00504 else if( ( it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() <= 0 ) || ( it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() <= 0 ) ) {
00505
00506 discardIOVs(it, initialIt, resultVec, last, first);
00507 if( debug_ ) cout << "Reducing IOV sequence (going on)" << endl;
00508 }
00509 }
00510
00511 void SiStripDetVOffBuilder::discardIOVs( std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & it,
00512 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & initialIt,
00513 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > & resultVec,
00514 const bool last, const unsigned int first )
00515 {
00516 if( debug_ ) {
00517 cout << "first (1->means the sequence started at the first timestamp in the query results, 0-> that it did not)= " << first << endl;
00518 cout << "initial->first (initial SiStripDetVOff object of the IOV sequence)= " << initialIt->first << ", second (initial timestamp of the IOV sequence) = " << initialIt->second << endl;
00519 cout << "last (0->means that the sequence is not ending with the last item in the query results, 1-> that it DOES!)= " << last << endl;
00520 }
00521 if( last == true ) {
00522 resultVec.erase(initialIt+first, it+1);
00523
00524 it = resultVec.end()-2;
00525 }
00526 else {
00527 it = resultVec.erase(initialIt+first, it);
00528 }
00529 }
00530
00531
00532 void SiStripDetVOffBuilder::reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength)
00533 {
00534
00535 int count = 0;
00536 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator initialIt;
00537
00538 int resultVecSize = modulesOff.size();
00539 int resultsIndex = 0;
00540
00541 if( resultVecSize > 1 ) {
00542 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator it = modulesOff.begin();
00543 for( ; it != modulesOff.end()-1; ++it, ++resultsIndex ) {
00544 unsigned long long deltaT = ((it+1)->second - it->second) >> 32;
00545 unsigned long long deltaTsequence = 0;
00546 if( count > 1 ) {
00547 deltaTsequence = ((it+1)->second - initialIt->second) >> 32;
00548 }
00549
00550 if( (deltaT < deltaTmin) && ( (count == 0) || ( deltaTsequence < maxIOVlength ) ) ) {
00551
00552 if( count == 0 ) {
00553 initialIt = it;
00554 }
00555
00556 ++count;
00557 }
00558
00559 else if( count > 1 ) {
00560 reduce(it, initialIt, modulesOff);
00561
00562 count = 0;
00563 }
00564 else {
00565
00566 count = 0;
00567 }
00568
00569 if( resultsIndex == resultVecSize-2 && count != 0 ) {
00570 reduce(it, initialIt, modulesOff, true);
00571 }
00572 }
00573 }
00574 }
00575
00576 void SiStripDetVOffBuilder::statusChange( cond::Time_t & lastTime, TimesAndValues & tStruct )
00577 {
00578
00579 if( lastTime > 0 ) {
00580 tmin = getCoralTime(lastTime);
00581 }
00582
00583 coralInterface->doQuery(whichTable, tmin ,tmax, tStruct.changeDate, tStruct.actualValue, tStruct.dpname);
00584
00585
00586
00587
00588
00589
00590
00591 tStruct.actualStatus.resize(tStruct.actualValue.size());
00592 tStruct.actualStatus.clear();
00593
00594 BOOST_FOREACH(float val, tStruct.actualValue) {
00595 tStruct.actualStatus.push_back(static_cast<int>(val));
00596 }
00597 }
00598
00599 void SiStripDetVOffBuilder::lastValue(TimesAndValues & tStruct)
00600 {
00601 coralInterface->doQuery(whichTable, tmin ,tmax, tStruct.changeDate, tStruct.actualValue, tStruct.dpname);
00602
00603 tStruct.latestTime = findMostRecentTimeStamp( tStruct.changeDate );
00604
00605
00606 tStruct.actualStatus.resize(tStruct.actualValue.size());
00607
00608
00609 std::vector<coral::TimeStamp> settingDate;
00610 std::vector<float> settingValue;
00611 std::vector<std::string> settingDpname;
00612 std::vector<uint32_t> settingDpid;
00613 coralInterface->doSettingsQuery(tsetmin,tmax,settingDate,settingValue,settingDpname,settingDpid);
00614 LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
00615 LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: " << settingDpname.size();
00616
00617 unsigned int missing = 0;
00618 std::stringstream ss;
00619 for (unsigned int j = 0; j < tStruct.dpname.size(); j++) {
00620 int setting = findSetting(tStruct.dpname[j],tStruct.changeDate[j],settingDpname,settingDate);
00621 if (setting >= 0) {
00622 if (tStruct.actualValue[j] > (highVoltageOnThreshold_*(settingValue[setting]))) {tStruct.actualStatus[j] = 1;}
00623 else {tStruct.actualStatus[j] = 0;}
00624 } else {
00625 tStruct.actualStatus[j] = -1;
00626 missing++;
00627 ss << "Channel = " << tStruct.dpname[j] << std::endl;
00628 }
00629 }
00630 LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Number of channels with no setting information " << missing;
00631 LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Number of entries in dpname vector " << tStruct.dpname.size();
00632 }
00633
00634 void SiStripDetVOffBuilder::lastValueFromFile(TimesAndValues & tStruct)
00635 {
00636 readLastValueFromFile(tStruct.dpid,tStruct.actualValue,tStruct.changeDate);
00637 tStruct.latestTime = findMostRecentTimeStamp( tStruct.changeDate );
00638 LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: File access complete \n\t Number of values read from file: " << tStruct.dpid.size();
00639
00640
00641 std::vector<coral::TimeStamp> settingDate;
00642 std::vector<float> settingValue;
00643 std::vector<std::string> settingDpname;
00644 std::vector<uint32_t> settingDpid;
00645
00646 coralInterface->doSettingsQuery(tsetmin,tmax,settingDate,settingValue,settingDpname,settingDpid);
00647 LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
00648 LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: " << settingDpname.size();
00649
00650 unsigned int missing = 0;
00651 std::stringstream ss;
00652
00653 tStruct.dpname.clear();
00654 tStruct.dpname.resize(tStruct. dpid.size());
00655 for (unsigned int j = 0; j < tStruct.dpid.size(); j++) {
00656 int setting = findSetting(tStruct.dpid[j],tStruct.changeDate[j],settingDpid,settingDate);
00657 if (setting >= 0) {
00658 if (tStruct.actualValue[j] > (highVoltageOnThreshold_*settingValue[setting])) {tStruct.actualStatus[j] = 1;}
00659 else {
00660 tStruct.actualStatus[j] = 0;
00661 }
00662 tStruct.dpname[j] = settingDpname[setting];
00663 } else {
00664 tStruct.actualStatus[j] = -1;
00665 tStruct.dpname[j] = "UNKNOWN";
00666 missing++;
00667 ss << "DP ID = " << tStruct.dpid[j] << std::endl;
00668 }
00669 }
00670 LogDebug("SiStripDetVOffBuilder") << "Number of missing psu channels = " << missing << std::endl;
00671 LogDebug("SiStripDetVOffBuilder") << "IDs are: = " << ss.str();
00672 }
00673
00674 string SiStripDetVOffBuilder::timeToStream(const cond::Time_t & condTime, const string & comment)
00675 {
00676 stringstream ss;
00677 ss << comment << (condTime>> 32) << " - " << (condTime & 0xFFFFFFFF) << std::endl;
00678 return ss.str();
00679 }
00680
00681 string SiStripDetVOffBuilder::timeToStream(const coral::TimeStamp & coralTime, const string & comment)
00682 {
00683 stringstream ss;
00684 ss << "Starting from IOV time in the database : year = " << coralTime.year()
00685 << ", month = " << coralTime.month()
00686 << ", day = " << coralTime.day()
00687 << ", hour = " << coralTime.hour()
00688 << ", minute = " << coralTime.minute()
00689 << ", second = " << coralTime.second()
00690 << ", nanosecond = " << coralTime.nanosecond() << std::endl;
00691 return ss.str();
00692 }
00693 bool SiStripDetVOffBuilder::FileExists(string FileName) {
00694
00695 struct stat FileInfo;
00696 bool Existence;
00697 int Stat;
00698
00699 Stat=stat(FileName.c_str(),&FileInfo);
00700 if (Stat==0) {
00701 Existence=true;
00702 }
00703 else {
00704 Existence=false;
00705 }
00706 return Existence;
00707 }
00708
00709 void SiStripDetVOffBuilder::buildPSUdetIdMap(TimesAndValues & psuStruct, DetIdListTimeAndStatus & detIdStruct)
00710
00711
00712
00713
00714 {
00715 SiStripPsuDetIdMap map_;
00716 if( psuDetIdMapFile_ == "" ) {
00717 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;
00718
00719 }
00720 else {
00721 map_.BuildMap(psuDetIdMapFile_,debug_);
00722 }
00723 LogTrace("SiStripDetVOffBuilder") <<"[SiStripDetVOffBuilder::BuildDetVOff] PSU(Channel)-detID map(s) built";
00724
00725 map_.printMap();
00726
00727
00728
00729
00730
00731 unsigned int ch0bad = 0, ch1bad = 0, ch2bad = 0, ch3bad = 0;
00732 std::vector<unsigned int> numLvBad, numHvBad;
00733
00734
00735
00736
00737 std::map<std::string,bool> UnmappedState, CrosstalkingState;
00738
00739 std::map<std::string,std::vector<uint32_t> > UnmappedPSUs=map_.getHVUnmappedMap();
00740
00741 if (FileExists("HVUnmappedChannelState.dat")) {
00742 std::cout<<"File HVUnmappedChannelState.dat exists!"<<std::endl;
00743 ifstream ifs("HVUnmappedChannelState.dat");
00744 string line;
00745 while( getline( ifs, line ) ) {
00746 if( line != "" ) {
00747
00748 stringstream ss(line);
00749 string PSUChannel;
00750 bool HVStatus;
00751 ss >> PSUChannel;
00752 ss >> HVStatus;
00753
00754 std::string PSU=PSUChannel.substr(0,PSUChannel.size()-10);
00755
00756 std::map<std::string,std::vector<uint32_t> >::iterator iter=UnmappedPSUs.find(PSU);
00757 if (iter!=UnmappedPSUs.end()) {
00758 UnmappedState[PSUChannel]=HVStatus;
00759 }
00760 else {
00761 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;
00762 }
00763 }
00764 }
00765
00766
00767 bool MissingChannels=false;
00768 for (std::map<std::string, vector<uint32_t> >::iterator it=UnmappedPSUs.begin(); it!=UnmappedPSUs.end(); it++) {
00769 std::string chan002=it->first+"channel002";
00770 std::string chan003=it->first+"channel003";
00771 std::map<std::string,bool>::iterator iter=UnmappedState.find(chan002);
00772 if (iter==UnmappedState.end()) {
00773 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;
00774 std::cout<<chan002<<std::endl;
00775 MissingChannels=true;
00776 }
00777 iter=UnmappedState.find(chan003);
00778 if (iter==UnmappedState.end()) {
00779 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;
00780 std::cout<<chan003<<std::endl;
00781 MissingChannels=true;
00782 }
00783 }
00784
00785 if (MissingChannels) {
00786 std::cout<<"!!!!\n"<<"Exiting now... please check the local HVUnmappedChannelState.dat and the mapfile you provided ("<<psuDetIdMapFile_<<")"<<std::endl;
00787 exit(1);
00788 }
00789 }
00790 else {
00791
00792 for (std::map<std::string, vector<uint32_t> >::iterator it=UnmappedPSUs.begin(); it!=UnmappedPSUs.end(); it++) {
00793 std::string chan002=it->first+"channel002";
00794 std::string chan003=it->first+"channel003";
00795 UnmappedState[chan002]=false;
00796 UnmappedState[chan003]=false;
00797 }
00798 }
00799
00800 std::map<std::string,std::vector<uint32_t> > CrosstalkingPSUs=map_.getHVCrosstalkingMap();
00801
00802 if (FileExists("HVCrosstalkingChannelState.dat")) {
00803 std::cout<<"File HVCrosstalkingChannelState.dat exists!"<<std::endl;
00804 ifstream ifs("HVCrosstalkingChannelState.dat");
00805 string line;
00806 while( getline( ifs, line ) ) {
00807 if( line != "" ) {
00808
00809 stringstream ss(line);
00810 string PSUChannel;
00811 bool HVStatus;
00812 ss >> PSUChannel;
00813 ss >> HVStatus;
00814
00815 std::string PSU=PSUChannel.substr(0,PSUChannel.size()-10);
00816
00817 std::map<std::string,std::vector<uint32_t> >::iterator iter=CrosstalkingPSUs.find(PSU);
00818 if (iter!=CrosstalkingPSUs.end()) {
00819 CrosstalkingState[PSUChannel]=HVStatus;
00820 }
00821 else {
00822 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;
00823 }
00824 }
00825 }
00826
00827
00828 bool MissingChannels=false;
00829 for (std::map<std::string, vector<uint32_t> >::iterator it=CrosstalkingPSUs.begin(); it!=CrosstalkingPSUs.end(); it++) {
00830 std::string chan002=it->first+"channel002";
00831 std::string chan003=it->first+"channel003";
00832 std::map<std::string,bool>::iterator iter=CrosstalkingState.find(chan002);
00833 if (iter==CrosstalkingState.end()) {
00834 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;
00835 std::cout<<chan002<<std::endl;
00836 MissingChannels=true;
00837 }
00838 iter=CrosstalkingState.find(chan003);
00839 if (iter==CrosstalkingState.end()) {
00840 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;
00841 std::cout<<chan003<<std::endl;
00842 MissingChannels=true;
00843 }
00844 }
00845
00846 if (MissingChannels) {
00847 std::cout<<"!!!!\n"<<"Exiting now... please check the local HVCrosstalkingChannelState.dat and the mapfile you provided ("<<psuDetIdMapFile_<<")"<<std::endl;
00848 exit(1);
00849 }
00850 }
00851 else {
00852
00853 for (std::map<std::string, vector<uint32_t> >::iterator it=CrosstalkingPSUs.begin(); it!=CrosstalkingPSUs.end(); it++) {
00854 std::string chan002=it->first+"channel002";
00855 std::string chan003=it->first+"channel003";
00856 CrosstalkingState[chan002]=false;
00857 CrosstalkingState[chan003]=false;
00858 }
00859 }
00860
00861 if (debug_) {
00862
00863 std::cout<<"Printing the UnmappedChannelState initial map:"<<std::endl;
00864 std::cout<<"PSUChannel\t\tHVON?(true or false)"<<std::endl;
00865 for (std::map<std::string,bool>::iterator it=UnmappedState.begin(); it!=UnmappedState.end(); it++) {
00866 std::cout<<it->first<<"\t\t"<<it->second<<std::endl;
00867 }
00868
00869 std::cout<<"Printing the CrosstalkingChannelState initial map:"<<std::endl;
00870 std::cout<<"PSUChannel\t\tHVON?(true or false)"<<std::endl;
00871 for (std::map<std::string,bool>::iterator it=CrosstalkingState.begin(); it!=CrosstalkingState.end(); it++) {
00872 std::cout<<it->first<<"\t\t"<<it->second<<std::endl;
00873 }
00874 }
00875
00876
00877
00878
00879
00880
00881 for (unsigned int dp = 0; dp < psuStruct.dpname.size(); dp++) {
00882
00883
00884 std::string PSUChannel=psuStruct.dpname[dp];
00885 if (PSUChannel != "UNKNOWN") {
00886
00887
00888 std::string Channel = PSUChannel.substr(PSUChannel.size()-10);
00889 std::string PSU = PSUChannel.substr(0,PSUChannel.size()-10);
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913 std::vector<uint32_t> ids;
00914
00915
00916
00917
00918
00919
00920 std::vector<uint32_t> unmapped_ids,crosstalking_ids;
00921 bool LVCase;
00922
00923 if (Channel=="channel000" || Channel=="channel001") {
00924 LVCase=true;
00925 ids=map_.getLvDetID(PSU);
00926 }
00927
00928 else {
00929 LVCase=false;
00930 map_.getHvDetID(PSUChannel,ids,unmapped_ids,crosstalking_ids);
00931 }
00932
00933 if ( debug_ ) {
00934 cout <<"dpname["<<dp<<"] = "<<PSUChannel<<", for time = "<<timeToStream(psuStruct.changeDate[dp])<<endl;
00935 if (!ids.empty()) {
00936 if (Channel=="channel000" || Channel=="channel001") {
00937 cout << "Corresponding to LV (PSU-)matching detids: "<<endl;
00938 for (unsigned int i_detid=0;i_detid<ids.size();i_detid++) {
00939 cout<< ids[i_detid] << std::endl;
00940 }
00941 }
00942 else {
00943 cout << "Corresponding to straight HV matching detids: "<<endl;
00944 for (unsigned int i_detid=0;i_detid<ids.size();i_detid++) {
00945 cout<< ids[i_detid] << std::endl;
00946 }
00947 }
00948 }
00949
00950 if (!unmapped_ids.empty()) {
00951 cout << "Corresponding to HV unmapped (PSU-)matching detids: "<<endl;
00952 for (unsigned int i_detid=0;i_detid<unmapped_ids.size();i_detid++) {
00953 cout<< unmapped_ids[i_detid] << std::endl;
00954 }
00955 }
00956 if (!crosstalking_ids.empty()) {
00957 cout << "Corresponding to HV crosstalking (PSU-)matching detids: "<<endl;
00958 for (unsigned int i_detid=0;i_detid<crosstalking_ids.size();i_detid++) {
00959 cout<< crosstalking_ids[i_detid] << std::endl;
00960 }
00961 }
00962 }
00963
00964
00965
00966
00967
00968
00969 if (psuStruct.actualStatus[dp] != 1) {
00970
00971
00972 if (LVCase) {
00973
00974
00975
00976
00977
00978
00979 if (!ids.empty()) {
00980
00981 ch0bad++;
00982 ch1bad++;
00983
00984
00985
00986
00987 detIdStruct.detidV.push_back( std::make_pair(ids,psuStruct.changeDate[dp]) );
00988
00989
00990 detIdStruct.StatusGood.push_back(false);
00991
00992
00993 numLvBad.insert(numLvBad.end(),ids.begin(),ids.end());
00994
00995
00996 detIdStruct.isHV.push_back(0);
00997
00998
00999 detIdStruct.psuName.push_back( PSUChannel );
01000 }
01001 }
01002
01003 else {
01004
01005 if (!ids.empty() || !unmapped_ids.empty() || !crosstalking_ids.empty()) {
01006 if (Channel=="channel002") {
01007 ch2bad++;
01008 }
01009 else if (Channel=="channel003") {
01010 ch3bad++;
01011 }
01012 }
01013
01014 std::vector<uint32_t> OFFids;
01015 OFFids.insert(OFFids.end(),ids.begin(),ids.end());
01016 OFFids.insert(OFFids.end(),unmapped_ids.begin(),unmapped_ids.end());
01017
01018 if (!crosstalking_ids.empty()) {
01019
01020 CrosstalkingState[PSUChannel]=false;
01021
01022
01023 if (!CrosstalkingState[PSUChannel.substr(0,PSUChannel.size()-1)+"2"] && !CrosstalkingState[PSUChannel.substr(0,PSUChannel.size()-1)+"3"]) {
01024 OFFids.insert(OFFids.end(),crosstalking_ids.begin(),crosstalking_ids.end());
01025 if (debug_) {
01026 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;
01027 }
01028 }
01029 }
01030
01031 if (!unmapped_ids.empty()) {
01032 UnmappedState[PSUChannel]=false;
01033 }
01034 if (!OFFids.empty()) {
01035
01036
01037
01038
01039
01040
01041
01042
01043 detIdStruct.detidV.push_back( std::make_pair(OFFids,psuStruct.changeDate[dp]) );
01044
01045
01046 detIdStruct.StatusGood.push_back(false);
01047
01048
01049 numHvBad.insert(numHvBad.end(),ids.begin(),ids.end());
01050
01051
01052 detIdStruct.isHV.push_back(1);
01053
01054
01055 detIdStruct.psuName.push_back( PSUChannel );
01056 }
01057 }
01058 }
01059
01060 else {
01061
01062
01063
01064 if (LVCase) {
01065
01066
01067
01068 if (!ids.empty()) {
01069
01070
01071
01072 detIdStruct.detidV.push_back( std::make_pair(ids,psuStruct.changeDate[dp]) );
01073
01074
01075 detIdStruct.StatusGood.push_back(true);
01076
01077
01078 detIdStruct.isHV.push_back(0);
01079
01080
01081 detIdStruct.psuName.push_back( PSUChannel );
01082 }
01083 }
01084
01085 else {
01086
01087 std::vector<uint32_t> ONids;
01088 ONids.insert(ONids.end(),ids.begin(),ids.end());
01089 ONids.insert(ONids.end(),crosstalking_ids.begin(),crosstalking_ids.end());
01090
01091 if (!unmapped_ids.empty()) {
01092
01093 UnmappedState[PSUChannel]=true;
01094
01095
01096 if (UnmappedState[PSUChannel.substr(0,PSUChannel.size()-1)+"2"] && UnmappedState[PSUChannel.substr(0,PSUChannel.size()-1)+"3"]) {
01097 ONids.insert(ONids.end(),unmapped_ids.begin(),unmapped_ids.end());
01098 if (debug_) {
01099 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;
01100 }
01101 }
01102 }
01103
01104 if (!crosstalking_ids.empty()) {
01105 CrosstalkingState[PSUChannel]=true;
01106 }
01107 if (!ONids.empty()) {
01108
01109
01110
01111
01112
01113
01114
01115
01116 detIdStruct.detidV.push_back( std::make_pair(ONids,psuStruct.changeDate[dp]) );
01117
01118
01119 detIdStruct.StatusGood.push_back(true);
01120
01121
01122 detIdStruct.isHV.push_back(1);
01123
01124
01125 detIdStruct.psuName.push_back( PSUChannel );
01126 }
01127 }
01128 }
01129 }
01130 else {
01131
01132
01133
01134 detIdStruct.notMatched++;
01135 }
01136 }
01137
01138 ofstream ofsUnmapped("HVUnmappedChannelState.dat");
01139 for (std::map<std::string,bool>::iterator it=UnmappedState.begin(); it!=UnmappedState.end(); it++) {
01140 ofsUnmapped<<it->first<<"\t"<<it->second<<std::endl;
01141 }
01142 ofstream ofsCrosstalking("HVCrosstalkingChannelState.dat");
01143 for (std::map<std::string,bool>::iterator it=CrosstalkingState.begin(); it!=CrosstalkingState.end(); it++) {
01144 ofsCrosstalking<<it->first<<"\t"<<it->second<<std::endl;
01145 }
01146
01147 removeDuplicates(numLvBad);
01148 removeDuplicates(numHvBad);
01149
01150
01151
01152 if( debug_ ) {
01153 std::cout << "Number of channels that turned OFF in this O2O interval"<<std::endl;
01154 std::cout << "Channel000 = " << ch0bad << " Channel001 = " << ch1bad << std::endl;
01155 std::cout << "Channel002 = " << ch2bad << " Channel003 = " << ch3bad << std::endl;
01156 std::cout << "Number of LV detIDs that turned OFF in this O2O interval = " << numLvBad.size() << std::endl;
01157 std::cout << "Number of HV detIDs that turned OFF in this O2O interval = " << numHvBad.size() << std::endl;
01158 }
01159
01160 LogTrace("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__ << "]: Number of PSUs retrieved from DB with map information " << detIdStruct.detidV.size();
01161 LogTrace("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__ << "]: Number of PSUs retrieved from DB with no map information " << detIdStruct.notMatched;
01162
01163 unsigned int dupCount = 0;
01164 for (unsigned int t = 0; t < numLvBad.size(); t++) {
01165 std::vector<unsigned int>::iterator iter = std::find(numHvBad.begin(),numHvBad.end(),numLvBad[t]);
01166 if (iter != numHvBad.end()) {dupCount++;}
01167 }
01168 if( debug_ ) std::cout << "Number of channels for which LV & HV turned OFF in this O2O interval = " << dupCount << std::endl;
01169
01170 }
01171
01172 void SiStripDetVOffBuilder::setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved)
01173 {
01174 std::vector<uint32_t> pStats(3,0);
01175 pStats.push_back(afterV);
01176 pStats.push_back(numAdded);
01177 pStats.push_back(numRemoved);
01178 payloadStats.push_back(pStats);
01179 }
01180
01181 pair<int, int> SiStripDetVOffBuilder::extractDetIdVector( const unsigned int i, SiStripDetVOff * modV, DetIdListTimeAndStatus & detIdStruct )
01182 {
01183
01184 int lv_off = -1, hv_off = -1;
01185 if (detIdStruct.isHV[i] == 0) {lv_off = !(detIdStruct.StatusGood[i]);}
01186 if (detIdStruct.isHV[i] == 1) {
01187 hv_off = !(detIdStruct.StatusGood[i]);
01188
01189
01190
01191
01192 if( psuDetIdMapFile_ == "" ) {
01193
01194 if (i > 0) {
01195 std::string iChannel = detIdStruct.psuName[i].substr( (detIdStruct.psuName[i].size()-3) );
01196 std::string iPsu = detIdStruct.psuName[i].substr(0, (detIdStruct.psuName[i].size()-3) );
01197 if (iChannel == "002" || iChannel == "003") {
01198 bool lastStatusOfOtherChannel = true;
01199 for (unsigned int j = 0; j < i; j++) {
01200 std::string jPsu = detIdStruct.psuName[j].substr(0, (detIdStruct.psuName[j].size()-3) );
01201 std::string jChannel = detIdStruct.psuName[j].substr( (detIdStruct.psuName[j].size()-3) );
01202 if (iPsu == jPsu && iChannel != jChannel && (jChannel == "002" || jChannel == "003")) {
01203 if( debug_ ) cout << "psu["<<i<<"] = " << detIdStruct.psuName[i] << " with status = " << detIdStruct.StatusGood[i] << " and psu["<<j<<"] = " << detIdStruct.psuName[j] << " with status " << detIdStruct.StatusGood[j] << endl;
01204 lastStatusOfOtherChannel = detIdStruct.StatusGood[j];
01205 }
01206 }
01207 if (detIdStruct.StatusGood[i] != lastStatusOfOtherChannel) {
01208 if( debug_ ) cout << "turning off hv" << endl;
01209 hv_off = 1;
01210 }
01211 }
01212 }
01213 }
01214
01215
01216
01217 }
01218
01219 return make_pair(hv_off, lv_off);
01220 }