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().payloadName<< "\n"
60  << this->logDBEntry().payloadToken<< "\n"
61  << this->logDBEntry().payloadContainer<< "\n"
62  << this->logDBEntry().exectime<< "\n"
63  << this->logDBEntry().execmessage<< "\n";
64  if(this->logDBEntry().usertext!="")
65  ss<< "\n-- user text " << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")) ;
66 
67  } else {
68  ss << " First object for this tag ";
69  }
70  edm::LogInfo ("DQMHistoryPopConHandler") << ss.str();
71 /* if (m_debugMode){ */
72 /* } */
73 
74  condObjBuilder->initialize();
75 
76  if (isTransferNeeded())
78 
79  edm::LogInfo ("DQMHistoryPopConHandler") << "[DQMHistoryPopConHandler::getNewObjects] for PopCon application " << m_name << " Done\n--------------\n";
80  }
81 
82 
83  //---------------------------------------
84  //
85  std::string id() const { return m_name;}
86 
87  private:
88  //methods
89 
90  //---------------------------------------
91  //
93 
94  edm::LogInfo ("DQMHistoryPopConHandler") << "[DQMHistoryPopConHandler::isTransferNeeded] checking for transfer " << std::endl;
95 
96  if(m_iovSequence && m_since<=this->tagInfo().lastInterval.first){
97  edm::LogInfo ("DQMHistoryPopConHandler")
98  << "[DQMHistoryPopConHandler::isTransferNeeded] \nthe current starting iov " << m_since
99  << "\nis not compatible with the last iov ("
100  << this->tagInfo().lastInterval.first << ") open for the object "
101  << this->logDBEntry().payloadName << " \nin the db "
102  << this->logDBEntry().destinationDB << " \n NO TRANSFER NEEDED";
103  return false;
104  }
105 
106  std::stringstream ss_logdb, ss;
107 
108  //get log information from previous upload
109  if (this->logDBEntry().usertext!="")
110  ss_logdb << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")+2);
111 
112 
113  condObjBuilder->getMetaDataString(ss);
114  if ((m_iovSequence && condObjBuilder->checkForCompatibility(ss_logdb.str())) || !m_iovSequence){
115 
116  this->m_userTextLog = "@ " + ss.str();
117 
118  edm::LogInfo ("DQMHistoryPopConHandler")
119  << "[DQMHistoryPopConHandler::isTransferNeeded] \nthe selected conditions will be uploaded: " << ss.str()
120  << "\n Current MetaData - "<< ss.str() << "\n Last Uploaded MetaData- " << ss_logdb.str() << "\n Fine";
121 
122  return true;
123  } else if (m_iovSequence && !condObjBuilder->checkForCompatibility(ss_logdb.str())) {
124  edm::LogInfo ("DQMHistoryPopConHandler")
125  << "[DQMHistoryPopConHandler::isTransferNeeded] \nthe current MetaData conditions " << ss.str()
126  << "\nare not compatible with the MetaData Conditions of the last iov ("
127  << this->tagInfo().lastInterval.first << ") open for the object "
128  << this->logDBEntry().payloadName << " \nin the db "
129  << this->logDBEntry().destinationDB << " \nConditions: " << ss_logdb.str() << "\n NO TRANSFER NEEDED";
130  return false;
131  }
132  return false;
133  }
134 
135 
136  //---------------------------------------
137  //
139  edm::LogInfo ("DQMHistoryPopConHandler") << "[DQMHistoryPopConHandler::setForTransfer] " << m_name << " getting data to be transferred " << std::endl;
140 
141  HDQMSummary *obj=0;
142  condObjBuilder->getObj(obj);
143 
144  if(!this->tagInfo().size)
145  m_since=1;
146  else
147  if (m_debugMode)
148  m_since=this->tagInfo().lastInterval.first+1;
149 
150  if (obj!=0){
151 
152  edm::LogInfo ("DQMHistoryPopConHandler") <<"setting since = "<< m_since <<std::endl;
153  this->m_to_transfer.push_back(std::make_pair(obj,m_since));
154  }else{
155  edm::LogError ("DQMHistoryPopConHandler") <<"[DQMHistoryPopConHandler::setForTransfer] " << m_name << " : NULL pointer of obj HDQMSummary reported by SiStripCondObjBuilderFromDb\n Transfer aborted"<<std::endl;
156  }
157  }
158 
159  private:
160  // data members
161  std::string m_name;
162  unsigned long long m_since;
166  };
167 }
168 
169 #endif //DQMHISTORYPOPCON_DB_HANDLER_H
std::string exectime
Definition: LogDBEntry.h:18
std::string usertext
Definition: LogDBEntry.h:10
std::string iovtimetype
Definition: LogDBEntry.h:12
unsigned int payloadIdx
Definition: LogDBEntry.h:13
std::string payloadToken
Definition: LogDBEntry.h:16
unsigned long long logId
Definition: LogDBEntry.h:7
std::string payloadName
Definition: LogDBEntry.h:15
std::string destinationDB
Definition: LogDBEntry.h:8
std::string lastPayloadToken
Definition: TagInfo.h:12
std::string name
Definition: TagInfo.h:9
cond::LogDBEntry const & logDBEntry() const
DQMHistoryPopConHandler(const edm::ParameterSet &pset)
tuple obj
Example code starts here #.
Definition: VarParsing.py:655
std::string execmessage
Definition: LogDBEntry.h:19
tuple pset
Definition: CrabTask.py:85
size_t size
Definition: TagInfo.h:13
std::string payloadContainer
Definition: LogDBEntry.h:17
std::string token
Definition: TagInfo.h:10
std::string provenance
Definition: LogDBEntry.h:9
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
std::string iovtag
Definition: LogDBEntry.h:11
tuple size
Write out results.