CMS 3D CMS Logo

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