CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripDetVOffHandler.cc
Go to the documentation of this file.
2 
4  name_(pset.getUntrackedParameter<std::string>("name","SiStripDetVOffHandler")),
5  deltaTmin_(pset.getParameter<uint32_t>("DeltaTmin")),
6  maxIOVlength_(pset.getParameter<uint32_t>("MaxIOVlength")),
7  debug_(pset.getUntrackedParameter<bool>("Debug", false))
8 { }
9 
11  LogTrace("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] Destructing ...";
12 }
13 
15 {
16  std::cout << "[SiStripDetVOffHandler::getNewObjects]" << std::endl;
17 
18  std::stringstream dbstr;
19  dbstr << "\n\n---------------------\n " << name_
20  << " - > getNewObjects\n";
21  if (tagInfo().size){
22  //check whats already inside of database
23  std::string userText("No data");
24  size_t splitPoint = logDBEntry().usertext.find_last_of("@");
25  if( splitPoint != std::string::npos ) {
26  userText = logDBEntry().usertext.substr(splitPoint);
27  }
28  dbstr << "got offlineInfo" << tagInfo().name << ", size " << tagInfo().size << " " << tagInfo().token
29  << " , last object valid since "
30  << tagInfo().lastInterval.first << " token "
31  << tagInfo().lastPayloadToken << "\n\n UserText " << userTextLog()
32  << "\n LogDBEntry \n"
33  << logDBEntry().logId << "\n"
34  << logDBEntry().destinationDB << "\n"
35  << logDBEntry().provenance << "\n"
36  << logDBEntry().usertext << "\n"
37  << logDBEntry().iovtag << "\n"
38  << logDBEntry().iovtimetype << "\n"
39  << logDBEntry().payloadIdx << "\n"
40  << logDBEntry().payloadClass << "\n"
41  << logDBEntry().payloadToken << "\n"
42  << logDBEntry().exectime << "\n"
43  << logDBEntry().execmessage << "\n"
44  << "\n\n-- user text " << userText;
45  } else {
46  dbstr << " First object for this tag ";
47  }
48  dbstr << "\n-------------------------\n";
49  edm::LogInfo ("SiStripDetVOffHandler") << dbstr.str();
50 
51  // Do the transfer!
52  std::cout << "getNewObjects setForTransfer" << std::endl;
53  setForTransfer();
54  std::cout << "getNewObjects setForTransfer end" << std::endl;
55 }
56 
58  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer]" << std::endl;
59 
60  // retrieve the last object transferred
61  if (tagInfo().size ) {
62  Ref payload = lastPayload();
63  SiStripDetVOff * lastV = new SiStripDetVOff( *payload );
64  modHVBuilder->setLastSiStripDetVOff( lastV, tagInfo().lastInterval.first );
65  }
66 
67  // build the object!
68  resultVec.clear();
69  modHVBuilder->BuildDetVOffObj();
70  resultVec = modHVBuilder->getModulesVOff(deltaTmin_, maxIOVlength_);
71 
72  if (!resultVec.empty()){
73  // assume by default that transfer is needed
74  unsigned int firstPayload = 0;
75 
76  // check if there is an existing payload and retrieve if there is
77  if (tagInfo().size > 0) {
78  Ref payload = lastPayload();
79  // resultVec does not contain duplicates, so only need to compare payload with resultVec[0]
80  SiStripDetVOff * modV = resultVec[0].first;
81  if (*modV == *payload) {
82  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element not required!";
83  cout << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element not required!" << endl;
84  firstPayload = 1;
85  }
86  else {
87  cout << "[SiStripDetVOffHandler::setForTransfer] Transfer of first element required" << endl;
88  }
89  } else {
90  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setForTransfer] No previous payload";
91  cout << "[SiStripDetVOffHandler::setForTransfer] No previous payload" << endl;
92  }
93 
94  setUserTextLog();
95 
96  for (unsigned int i = firstPayload; i < resultVec.size(); i++) {
97  this->m_to_transfer.push_back(resultVec[i]);
98  }
99 
100  } else {
101  edm::LogError("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
102  << name_ << " : NULL pointer reported by SiStripDetVOffBuilder"
103  << "\n Transfer aborted"<< std::endl;
104  }
105 }
106 
107 
109 {
110  std::stringstream ss;
111  ss << "@@@ Number of payloads transferred " << resultVec.size() << "." << std::endl;
112  std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::const_iterator it = resultVec.begin();
113  ss << "time \t #LV off \t #HV off" << std::endl;
114  for( ; it != resultVec.end(); ++it ) {
115  ss << boost::posix_time::to_iso_extended_string( cond::time::to_boost(it->second) );
116  ss << "\t\t " << it->first->getLVoffCounts() << "\t\t " << it->first->getHVoffCounts() << std::endl;
117  }
118 
119  if( debug_ ) {
120  ss << "PayloadNo/Badmodules/NoAdded/NoRemoved: ";
121  std::vector< std::vector<uint32_t> > payloadStats = modHVBuilder->getPayloadStats();
122  for (unsigned int j = 0; j < payloadStats.size(); j++) {
123  ss << j << "/" << payloadStats[j][0] << "/" << payloadStats[j][1] << "/" << payloadStats[j][2] << "\t ";
124  }
125  }
126 
127  this->m_userTextLog = ss.str();
128 
129  LogTrace("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::setUserTextLog] " << ss.str();
130 
131 
132 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
SiStripDetVOffHandler(const edm::ParameterSet &pset)
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
tuple size
Write out results.
boost::posix_time::ptime to_boost(Time_t iValue)