CMS 3D CMS Logo

SiStripPopConDbObjHandler.h
Go to the documentation of this file.
1 #ifndef SISTRIPPOPCON_DB_HANDLER_H
2 #define SISTRIPPOPCON_DB_HANDLER_H
3 
7 
9 
10 #include <sstream>
11 #include <vector>
12 #include <string>
13 #include <iostream>
14 #include <typeinfo>
15 
16 namespace popcon{
17 
18  template <typename T, typename U>
20  public:
21 
23  m_name(pset.getUntrackedParameter<std::string>("name","SiStripPopConDbObjHandler")),
24  m_since(pset.getUntrackedParameter<uint32_t>("since",5)),
25  m_debugMode(pset.getUntrackedParameter<bool>("debug",false)){};
26 
27  //---------------------------------------
28  //
30 
31  //---------------------------------------
32  //
33  void getNewObjects(){
34  edm::LogInfo ("SiStripPopConDbObjHandler") << "[SiStripPopConDbObjHandler::getNewObjects] for PopCon application " << m_name;
35 
36  if (m_debugMode){
37  std::stringstream ss;
38  ss << "\n\n------- " << m_name
39  << " - > getNewObjects\n";
40  if (this->tagInfo().size){
41  //check whats already inside of database
42  ss << "\ngot offlineInfo"<< this->tagInfo().name
43  << "\n size " << this->tagInfo().size
44  << "\n" << this->tagInfo().token
45  << "\n last object valid since " << this->tagInfo().lastInterval.first
46  << "\n token " << this->tagInfo().lastPayloadToken
47  << "\n UserText " << this->userTextLog()
48  << "\n LogDBEntry \n"
49  << this->logDBEntry().logId<< "\n"
50  << this->logDBEntry().destinationDB<< "\n"
51  << this->logDBEntry().provenance<< "\n"
52  << this->logDBEntry().usertext<< "\n"
53  << this->logDBEntry().iovtag<< "\n"
54  << this->logDBEntry().iovtimetype<< "\n"
55  << this->logDBEntry().payloadIdx<< "\n"
56  << this->logDBEntry().payloadClass<< "\n"
57  << this->logDBEntry().payloadToken<< "\n"
58  << this->logDBEntry().exectime<< "\n"
59  << this->logDBEntry().execmessage<< "\n";
60  if(this->logDBEntry().usertext!="")
61  ss<< "\n-- user text " << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")) ;
62 
63  } else {
64  ss << " First object for this tag ";
65  }
66  edm::LogInfo ("SiStripPopConDbObjHandler") << ss.str();
67  }
68 
69  condObjBuilder->initialize();
70 
71  if (isTransferNeeded())
73 
74  edm::LogInfo ("SiStripPopConDbObjHandler") << "[SiStripPopConDbObjHandler::getNewObjects] for PopCon application " << m_name << " Done\n--------------\n";
75  }
76 
77 
78  //---------------------------------------
79  //
80  std::string id() const { return m_name;}
81 
82  private:
83  //methods
84 
85  std::string getDataType(){return typeid(T).name();}
86 
87 
88 
89  //---------------------------------------
90  //
92 
93  edm::LogInfo ("SiStripPopConDbObjHandler") << "[SiStripPopConDbObjHandler::isTransferNeeded] checking for transfer " << std::endl;
94 
95  if(m_since<=this->tagInfo().lastInterval.first){
96  edm::LogInfo ("SiStripPopConDbObjHandler")
97  << "[SiStripPopConDbObjHandler::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(condObjBuilder->checkForCompatibility(ss_logdb.str())){
114 
115  this->m_userTextLog = "@ " + ss.str();
116 
117  edm::LogInfo ("SiStripPopConDbObjHandler")
118  << "[SiStripPopConDbObjHandler::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 {
123  edm::LogInfo ("SiStripPopConDbObjHandler")
124  << "[SiStripPopConDbObjHandler::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  }
132 
133 
134  //---------------------------------------
135  //
137  edm::LogInfo ("SiStripPopConDbObjHandler") << "[SiStripPopConDbObjHandler::setForTransfer] " << m_name << " getting data to be transferred " << std::endl;
138 
139  T *obj=0;
140  condObjBuilder->getObj(obj);
141 
142  if(!this->tagInfo().size)
143  m_since=1;
144  else
145  if (m_debugMode)
146  m_since=this->tagInfo().lastInterval.first+1;
147 
148  if (obj!=0){
149 
150  edm::LogInfo ("SiStripPopConDbObjHandler") <<"setting since = "<< m_since <<std::endl;
151  this->m_to_transfer.push_back(std::make_pair(obj,m_since));
152  }else{
153  edm::LogError ("SiStripPopConDbObjHandler") <<"[SiStripPopConDbObjHandler::setForTransfer] " << m_name << " : NULL pointer of obj " << typeid(T).name() << " reported by SiStripCondObjBuilderFromDb\n Transfer aborted"<<std::endl;
154  }
155  }
156 
157  private:
158  // data members
160  unsigned long long m_since;
163  };
164 }
165 
166 #endif //SISTRIPPOPCON_DB_HANDLER_H
size
Write out results.
SiStripPopConDbObjHandler(const edm::ParameterSet &pset)
std::string const & userTextLog() const
unsigned long long logId
Definition: Types.h:92
std::string provenance
Definition: Types.h:94
std::string payloadToken
Definition: Types.h:101
size_t size
Definition: Types.h:77
std::string execmessage
Definition: Types.h:103
std::string name
Definition: Types.h:73
cond::ValidityInterval lastInterval
Definition: Types.h:75
std::string payloadClass
Definition: Types.h:100
cond::LogDBEntry_t const & logDBEntry() const
std::string destinationDB
Definition: Types.h:93
std::string exectime
Definition: Types.h:102
std::string lastPayloadToken
Definition: Types.h:76
unsigned int payloadIdx
Definition: Types.h:98
std::string usertext
Definition: Types.h:95
long double T
std::string token
Definition: Types.h:74
cond::TagInfo_t const & tagInfo() const
std::string iovtimetype
Definition: Types.h:97
std::string iovtag
Definition: Types.h:96