Go to the documentation of this file.00001 #include "CalibTracker/SiStripDCS/interface/SiStripDetVOffHandler.h"
00002
00003 popcon::SiStripDetVOffHandler::SiStripDetVOffHandler (const edm::ParameterSet& pset) :
00004 name_(pset.getUntrackedParameter<std::string>("name","SiStripDetVOffHandler")),
00005 deltaTmin_(pset.getParameter<uint32_t>("DeltaTmin")),
00006 maxIOVlength_(pset.getParameter<uint32_t>("MaxIOVlength")),
00007 debug_(pset.getUntrackedParameter<bool>("Debug", false))
00008 { }
00009
00010 popcon::SiStripDetVOffHandler::~SiStripDetVOffHandler() {
00011 LogTrace("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] Destructing ...";
00012 }
00013
00014 void popcon::SiStripDetVOffHandler::getNewObjects()
00015 {
00016 std::cout << "[SiStripDetVOffHandler::getNewObjects]" << std::endl;
00017
00018 std::stringstream dbstr;
00019 dbstr << "\n\n---------------------\n " << name_
00020 << " - > getNewObjects\n";
00021 if (tagInfo().size){
00022
00023 std::string userText("No data");
00024 size_t splitPoint = logDBEntry().usertext.find_last_of("@");
00025 if( splitPoint != std::string::npos ) {
00026 userText = logDBEntry().usertext.substr(splitPoint);
00027 }
00028 dbstr << "got offlineInfo" << tagInfo().name << ", size " << tagInfo().size << " " << tagInfo().token
00029 << " , last object valid since "
00030 << tagInfo().lastInterval.first << " token "
00031 << tagInfo().lastPayloadToken << "\n\n UserText " << userTextLog()
00032 << "\n LogDBEntry \n"
00033 << logDBEntry().logId << "\n"
00034 << logDBEntry().destinationDB << "\n"
00035 << logDBEntry().provenance << "\n"
00036 << logDBEntry().usertext << "\n"
00037 << logDBEntry().iovtag << "\n"
00038 << logDBEntry().iovtimetype << "\n"
00039 << logDBEntry().payloadIdx << "\n"
00040 << logDBEntry().payloadClass << "\n"
00041 << logDBEntry().payloadToken << "\n"
00042 << logDBEntry().exectime << "\n"
00043 << logDBEntry().execmessage << "\n"
00044 << "\n\n-- user text " << userText;
00045 } else {
00046 dbstr << " First object for this tag ";
00047 }
00048 dbstr << "\n-------------------------\n";
00049 edm::LogInfo ("SiStripDetVOffHandler") << dbstr.str();
00050
00051
00052 std::cout << "getNewObjects setForTransfer" << std::endl;
00053 setForTransfer();
00054 std::cout << "getNewObjects setForTransfer end" << std::endl;
00055 }
00056
00057 void popcon::SiStripDetVOffHandler::setForTransfer() {
00058 edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer]" << std::endl;
00059
00060
00061 if (tagInfo().size ) {
00062 Ref payload = lastPayload();
00063 SiStripDetVOff * lastV = new SiStripDetVOff( *payload );
00064 modHVBuilder->setLastSiStripDetVOff( lastV, tagInfo().lastInterval.first );
00065 }
00066
00067
00068 resultVec.clear();
00069 modHVBuilder->BuildDetVOffObj();
00070 resultVec = modHVBuilder->getModulesVOff(deltaTmin_, maxIOVlength_);
00071
00072 if (!resultVec.empty()){
00073
00074 unsigned int firstPayload = 0;
00075
00076
00077 if (tagInfo().size > 0) {
00078 Ref payload = lastPayload();
00079
00080 SiStripDetVOff * modV = resultVec[0].first;
00081 if (*modV == *payload) {
00082 edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element not required!";
00083 cout << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element not required!" << endl;
00084 firstPayload = 1;
00085 }
00086 else {
00087 cout << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element required" << endl;
00088 }
00089 } else {
00090 edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer] No previous payload";
00091 cout << "[SiStripDetVOffHandler::setForTransfer] No previous payload" << endl;
00092 }
00093
00094 setUserTextLog();
00095
00096 for (unsigned int i = firstPayload; i < resultVec.size(); i++) {
00097 this->m_to_transfer.push_back(resultVec[i]);
00098 }
00099
00100 } else {
00101 edm::LogError("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
00102 << name_ << " : NULL pointer reported by SiStripDetVOffBuilder"
00103 << "\n Transfer aborted"<< std::endl;
00104 }
00105 }
00106
00107
00108 void popcon::SiStripDetVOffHandler::setUserTextLog()
00109 {
00110 std::stringstream ss;
00111 ss << "@@@ Number of payloads transferred " << resultVec.size() << "." << std::endl;
00112 std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::const_iterator it = resultVec.begin();
00113 ss << "time \t #LV off \t #HV off" << std::endl;
00114 for( ; it != resultVec.end(); ++it ) {
00115 ss << boost::posix_time::to_iso_extended_string( cond::time::to_boost(it->second) );
00116 ss << "\t\t " << it->first->getLVoffCounts() << "\t\t " << it->first->getHVoffCounts() << std::endl;
00117 }
00118
00119 if( debug_ ) {
00120 ss << "PayloadNo/Badmodules/NoAdded/NoRemoved: ";
00121 std::vector< std::vector<uint32_t> > payloadStats = modHVBuilder->getPayloadStats();
00122 for (unsigned int j = 0; j < payloadStats.size(); j++) {
00123 ss << j << "/" << payloadStats[j][0] << "/" << payloadStats[j][1] << "/" << payloadStats[j][2] << "\t ";
00124 }
00125 }
00126
00127 this->m_userTextLog = ss.str();
00128
00129 LogTrace("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setUserTextLog] " << ss.str();
00130
00131
00132 }