CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMHistoryPopConHandler.h
Go to the documentation of this file.
1 #ifndef SISTRIPPOPCON_DB_HANDLE_H
2 #define DQMHISTORYPOPCON_DB_HANDLER_H
3 
7 
12 
13 #include <sstream>
14 #include <vector>
15 #include <string>
16 #include <iostream>
17 #include <typeinfo>
18 
19 namespace popcon{
20 
21  template <typename U>
23  public:
24 
26  m_name(pset.getUntrackedParameter<std::string>("name","DQMHistoryPopConHandler")),
27  m_since(pset.getUntrackedParameter<uint32_t>("since",5)),
28  m_debugMode(pset.getUntrackedParameter<bool>("debug",false)),
29  m_iovSequence(pset.getUntrackedParameter<bool>("iovSequence",false)){};
30 
31  //---------------------------------------
32  //
34 
35  //---------------------------------------
36  //
37  void getNewObjects(){
38  edm::LogInfo ("DQMHistoryPopConHandler") << "[DQMHistoryPopConHandler::getNewObjects] for PopCon application " << m_name;
39 
40  std::stringstream ss;
41  ss << "\n\n------- " << m_name
42  << " - > getNewObjects\n";
43  if (this->tagInfo().size){
44  //check whats already inside of database
45  ss << "\ngot offlineInfo"<< this->tagInfo().name
46  << "\n size " << this->tagInfo().size
47  << "\n" << this->tagInfo().token
48  << "\n last object valid since " << this->tagInfo().lastInterval.first
49  << "\n token " << this->tagInfo().lastPayloadToken
50  << "\n UserText " << this->userTextLog()
51  << "\n LogDBEntry \n"
52  << this->logDBEntry().logId<< "\n"
53  << this->logDBEntry().destinationDB<< "\n"
54  << this->logDBEntry().provenance<< "\n"
55  << this->logDBEntry().usertext<< "\n"
56  << this->logDBEntry().iovtag<< "\n"
57  << this->logDBEntry().iovtimetype<< "\n"
58  << this->logDBEntry().payloadIdx<< "\n"
59  << this->logDBEntry().payloadClass<< "\n"
60  << this->logDBEntry().payloadToken<< "\n"
61  << this->logDBEntry().exectime<< "\n"
62  << this->logDBEntry().execmessage<< "\n";
63  if(this->logDBEntry().usertext!="")
64  ss<< "\n-- user text " << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")) ;
65 
66  } else {
67  ss << " First object for this tag ";
68  }
69  edm::LogInfo ("DQMHistoryPopConHandler") << ss.str();
70 /* if (m_debugMode){ */
71 /* } */
72 
73  condObjBuilder->initialize();
74 
75  if (isTransferNeeded())
77 
78  edm::LogInfo ("DQMHistoryPopConHandler") << "[DQMHistoryPopConHandler::getNewObjects] for PopCon application " << m_name << " Done\n--------------\n";
79  }
80 
81 
82  //---------------------------------------
83  //
84  std::string id() const { return m_name;}
85 
86  private:
87  //methods
88 
89  //---------------------------------------
90  //
92 
93  edm::LogInfo ("DQMHistoryPopConHandler") << "[DQMHistoryPopConHandler::isTransferNeeded] checking for transfer " << std::endl;
94 
95  if(m_iovSequence && m_since<=this->tagInfo().lastInterval.first){
96  edm::LogInfo ("DQMHistoryPopConHandler")
97  << "[DQMHistoryPopConHandler::isTransferNeeded] \nthe current starting iov " << m_since
98  << "\nis not compatible with the last iov ("
99  << this->tagInfo().lastInterval.first << ") open for the object "
100  << this->logDBEntry().payloadClass << " \nin the db "
101  << this->logDBEntry().destinationDB << " \n NO TRANSFER NEEDED";
102  return false;
103  }
104 
105  std::stringstream ss_logdb, ss;
106 
107  //get log information from previous upload
108  if (this->logDBEntry().usertext!="")
109  ss_logdb << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")+2);
110 
111 
112  condObjBuilder->getMetaDataString(ss);
113  if ((m_iovSequence && condObjBuilder->checkForCompatibility(ss_logdb.str())) || !m_iovSequence){
114 
115  this->m_userTextLog = "@ " + ss.str();
116 
117  edm::LogInfo ("DQMHistoryPopConHandler")
118  << "[DQMHistoryPopConHandler::isTransferNeeded] \nthe selected conditions will be uploaded: " << ss.str()
119  << "\n Current MetaData - "<< ss.str() << "\n Last Uploaded MetaData- " << ss_logdb.str() << "\n Fine";
120 
121  return true;
122  } else if (m_iovSequence && !condObjBuilder->checkForCompatibility(ss_logdb.str())) {
123  edm::LogInfo ("DQMHistoryPopConHandler")
124  << "[DQMHistoryPopConHandler::isTransferNeeded] \nthe current MetaData conditions " << ss.str()
125  << "\nare not compatible with the MetaData Conditions of the last iov ("
126  << this->tagInfo().lastInterval.first << ") open for the object "
127  << this->logDBEntry().payloadClass << " \nin the db "
128  << this->logDBEntry().destinationDB << " \nConditions: " << ss_logdb.str() << "\n NO TRANSFER NEEDED";
129  return false;
130  }
131  return false;
132  }
133 
134 
135  //---------------------------------------
136  //
138  edm::LogInfo ("DQMHistoryPopConHandler") << "[DQMHistoryPopConHandler::setForTransfer] " << m_name << " getting data to be transferred " << std::endl;
139 
140  HDQMSummary *obj=0;
141  condObjBuilder->getObj(obj);
142 
143  if(!this->tagInfo().size)
144  m_since=1;
145  else
146  if (m_debugMode)
147  m_since=this->tagInfo().lastInterval.first+1;
148 
149  if (obj!=0){
150 
151  edm::LogInfo ("DQMHistoryPopConHandler") <<"setting since = "<< m_since <<std::endl;
152  this->m_to_transfer.push_back(std::make_pair(obj,m_since));
153  }else{
154  edm::LogError ("DQMHistoryPopConHandler") <<"[DQMHistoryPopConHandler::setForTransfer] " << m_name << " : NULL pointer of obj HDQMSummary reported by SiStripCondObjBuilderFromDb\n Transfer aborted"<<std::endl;
155  }
156  }
157 
158  private:
159  // data members
160  std::string m_name;
161  unsigned long long m_since;
165  };
166 }
167 
168 #endif //DQMHISTORYPOPCON_DB_HANDLER_H
std::string exectime
Definition: LogDBEntry.h:27
std::string usertext
Definition: LogDBEntry.h:20
std::string iovtimetype
Definition: LogDBEntry.h:22
unsigned int payloadIdx
Definition: LogDBEntry.h:23
std::string payloadToken
Definition: LogDBEntry.h:26
unsigned long long logId
Definition: LogDBEntry.h:17
std::string payloadClass
Definition: LogDBEntry.h:25
std::string destinationDB
Definition: LogDBEntry.h:18
std::string lastPayloadToken
Definition: TagInfo.h:12
std::string name
Definition: TagInfo.h:9
cond::LogDBEntry const & logDBEntry() const
DQMHistoryPopConHandler(const edm::ParameterSet &pset)
std::string execmessage
Definition: LogDBEntry.h:28
size_t size
Definition: TagInfo.h:13
std::string token
Definition: TagInfo.h:10
std::string provenance
Definition: LogDBEntry.h:19
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
std::string iovtag
Definition: LogDBEntry.h:21
tuple size
Write out results.