CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CalibTracker/SiStripDCS/src/SiStripDetVOffHandler.cc

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     //check whats already inside of database
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().payloadName      << "\n"
00041           << logDBEntry().payloadToken     << "\n"
00042           << logDBEntry().payloadContainer << "\n"
00043           << logDBEntry().exectime         << "\n"
00044           << logDBEntry().execmessage      << "\n"
00045           << "\n\n-- user text " << userText;
00046   } else {
00047     dbstr << " First object for this tag ";
00048   }
00049   dbstr << "\n-------------------------\n";
00050   edm::LogInfo   ("SiStripDetVOffHandler") << dbstr.str();
00051   
00052   // Do the transfer!
00053   std::cout << "getNewObjects setForTransfer" << std::endl;
00054   setForTransfer();
00055   std::cout << "getNewObjects setForTransfer end" << std::endl;
00056 }
00057 
00058 void popcon::SiStripDetVOffHandler::setForTransfer() { 
00059   edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer]" << std::endl;
00060 
00061   // retrieve the last object transferred
00062   if (tagInfo().size ) {
00063     Ref payload = lastPayload();
00064     SiStripDetVOff * lastV = new SiStripDetVOff( *payload );
00065     modHVBuilder->setLastSiStripDetVOff( lastV, tagInfo().lastInterval.first );
00066   }
00067 
00068   // build the object!
00069   resultVec.clear();
00070   modHVBuilder->BuildDetVOffObj();
00071   resultVec = modHVBuilder->getModulesVOff(deltaTmin_, maxIOVlength_);
00072 
00073   if (!resultVec.empty()){
00074     // assume by default that transfer is needed
00075     unsigned int firstPayload = 0;
00076     
00077     // check if there is an existing payload and retrieve if there is
00078     if (tagInfo().size > 0) {
00079       Ref payload = lastPayload();
00080       // resultVec does not contain duplicates, so only need to compare payload with resultVec[0]
00081       SiStripDetVOff * modV = resultVec[0].first;
00082       if (*modV == *payload) {
00083         edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element not required!";
00084         cout << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element not required!" << endl;
00085         firstPayload = 1;
00086       }
00087       else {
00088         cout << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element required" << endl;
00089       }
00090     } else {     
00091       edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer] No previous payload";
00092       cout << "[SiStripDetVOffHandler::setForTransfer] No previous payload" << endl;
00093     }
00094  
00095     setUserTextLog();
00096     
00097     for (unsigned int i = firstPayload; i < resultVec.size(); i++) {
00098       this->m_to_transfer.push_back(resultVec[i]);
00099     }
00100     
00101   } else {
00102     edm::LogError("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] " 
00103                                            << name_ << "  : NULL pointer reported by SiStripDetVOffBuilder"
00104                                            << "\n Transfer aborted"<< std::endl;
00105   }
00106 }
00107 
00108 
00109 void popcon::SiStripDetVOffHandler::setUserTextLog()
00110 {
00111   std::stringstream ss;
00112   ss << "@@@ Number of payloads transferred " << resultVec.size() << "." << std::endl;
00113   std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::const_iterator it = resultVec.begin();
00114   ss << "time \t #LV off \t #HV off" << std::endl;
00115   for( ; it != resultVec.end(); ++it ) {
00116     ss << boost::posix_time::to_iso_extended_string( cond::time::to_boost(it->second) );
00117     ss << "\t\t  " << it->first->getLVoffCounts() << "\t\t  " << it->first->getHVoffCounts() << std::endl;
00118   }
00119 
00120   if( debug_ ) {
00121     ss << "PayloadNo/Badmodules/NoAdded/NoRemoved: ";
00122     std::vector< std::vector<uint32_t> > payloadStats = modHVBuilder->getPayloadStats();
00123     for (unsigned int j = 0; j < payloadStats.size(); j++) {
00124       ss << j << "/" << payloadStats[j][0] << "/" << payloadStats[j][1] << "/" << payloadStats[j][2] << "\t ";
00125     }
00126   }
00127   
00128   this->m_userTextLog = ss.str();
00129   
00130   LogTrace("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setUserTextLog] " << ss.str();
00131     
00132  
00133 }