CMS 3D CMS Logo

SiStripDQMPopConSourceHandler.h
Go to the documentation of this file.
1 #ifndef DQMOffline_CalibTracker_SiStripDQMPopConSourceHandler_H
2 #define DQMOffline_CalibTracker_SiStripDQMPopConSourceHandler_H
3 
5 
9 
17 template<typename T>
19 {
20 public:
22  : m_name{pset.getUntrackedParameter<std::string>("name", "SiStripPopConDbObjHandler")}
23  , m_since{pset.getUntrackedParameter<uint32_t>("since", 5)}
24  , m_runNumber{pset.getParameter<uint32_t>("RunNb")}
25  , m_iovSequence{pset.getUntrackedParameter<bool>("iovSequence", true)} // flag: check compatibility
26  , m_debugMode{pset.getUntrackedParameter<bool>("debug", false)}
27  {}
28 
30 
31  // popcon::PopConSourceHandler interface methods
32  void getNewObjects() override;
33  std::string id() const override { return m_name; }
34 
35  virtual T* getObj() const = 0;
36 
37  virtual std::string getMetaDataString() const;
38  virtual bool checkForCompatibility( const std::string otherMetaData ) const { return otherMetaData != getMetaDataString(); }
39 
40  // additional methods needed for SiStripPopConDQMEDHarvester
41  virtual void initES(const edm::EventSetup&) {}
42  virtual void dqmEndJob(DQMStore::IBooker& booker, DQMStore::IGetter& getter) {}
43 
44 protected:
45  uint32_t getRunNumber() const { return m_runNumber; }
46 
47 private:
49  unsigned long long m_since;
50  uint32_t m_runNumber;
53 
54  // helper methods
55  bool isTransferNeeded();
56  void setForTransfer();
57 };
58 
60 
61 #include <sstream>
62 
63 template<typename T>
65 {
66  edm::LogInfo("SiStripPopConDbObjHandler") << "[SiStripPopConDbObjHandler::getNewObjects] for PopCon application " << m_name;
67 
68  if ( m_debugMode ) {
69  std::stringstream ss;
70  ss << "\n\n------- " << m_name
71  << " - > getNewObjects\n";
72  if ( this->tagInfo().size ){
73  //check whats already inside of database
74  ss << "\ngot offlineInfo" << this->tagInfo().name
75  << "\n size " << this->tagInfo().size
76  << "\n" << this->tagInfo().token
77  << "\n last object valid since " << this->tagInfo().lastInterval.first
78  << "\n token " << this->tagInfo().lastPayloadToken
79  << "\n UserText " << this->userTextLog()
80  << "\n LogDBEntry \n"
81  << this->logDBEntry().logId << "\n"
82  << this->logDBEntry().destinationDB << "\n"
83  << this->logDBEntry().provenance << "\n"
84  << this->logDBEntry().usertext << "\n"
85  << this->logDBEntry().iovtag << "\n"
86  << this->logDBEntry().iovtimetype << "\n"
87  << this->logDBEntry().payloadIdx << "\n"
88  << this->logDBEntry().payloadClass << "\n"
89  << this->logDBEntry().payloadToken << "\n"
90  << this->logDBEntry().exectime << "\n"
91  << this->logDBEntry().execmessage << "\n";
92  if ( this->logDBEntry().usertext != "" )
93  ss<< "\n-- user text " << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")) ;
94  } else {
95  ss << " First object for this tag ";
96  }
97  edm::LogInfo("SiStripPopConDbObjHandler") << ss.str();
98  }
99 
100  if (isTransferNeeded())
101  setForTransfer();
102 
103  edm::LogInfo("SiStripPopConDbObjHandler") << "[SiStripPopConDbObjHandler::getNewObjects] for PopCon application " << m_name << " Done\n--------------\n";
104 }
105 
106 template<typename T>
108 {
109  edm::LogInfo("SiStripPopConDbObjHandler") << "[SiStripPopConDbObjHandler::isTransferNeeded] checking for transfer ";
110 
111  if ( m_iovSequence && ( m_since <= this->tagInfo().lastInterval.first ) ) {
112  edm::LogInfo ("SiStripPopConDbObjHandler")
113  << "[SiStripPopConDbObjHandler::isTransferNeeded] \nthe current starting iov " << m_since
114  << "\nis not compatible with the last iov ("
115  << this->tagInfo().lastInterval.first << ") open for the object "
116  << this->logDBEntry().payloadClass << " \nin the db "
117  << this->logDBEntry().destinationDB << " \n NO TRANSFER NEEDED";
118  return false;
119  }
120 
121  std::string ss_logdb{};
122 
123  //get log information from previous upload
124  if ( this->logDBEntry().usertext != "" )
125  ss_logdb = this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")+2);
126 
128  if ( ( ! m_iovSequence ) || checkForCompatibility(ss_logdb) ) {
129  this->m_userTextLog = "@ " + ss;
130 
131  edm::LogInfo ("SiStripPopConDbObjHandler")
132  << "[SiStripPopConDbObjHandler::isTransferNeeded] \nthe selected conditions will be uploaded: " << ss
133  << "\n Current MetaData - " << ss << "\n Last Uploaded MetaData- " << ss_logdb << "\n Fine";
134 
135  return true;
136  } else if ( m_iovSequence ) {
137  edm::LogInfo ("SiStripPopConDbObjHandler")
138  << "[SiStripPopConDbObjHandler::isTransferNeeded] \nthe current MetaData conditions " << ss
139  << "\nare not compatible with the MetaData Conditions of the last iov ("
140  << this->tagInfo().lastInterval.first << ") open for the object "
141  << this->logDBEntry().payloadClass << " \nin the db "
142  << this->logDBEntry().destinationDB << " \nConditions: " << ss_logdb << "\n NO TRANSFER NEEDED";
143  return false;
144  } else {
145  return true;
146  }
147 }
148 
149 template<typename T>
151 {
152  edm::LogInfo ("SiStripPopConDbObjHandler") << "[SiStripPopConDbObjHandler::setForTransfer] " << m_name << " getting data to be transferred ";
153 
154  if ( ! this->tagInfo().size )
155  m_since=1;
156  else
157  if (m_debugMode)
158  m_since = this->tagInfo().lastInterval.first+1;
159 
160  T* obj = this->getObj();
161  if ( obj ) {
162  edm::LogInfo ("SiStripPopConDbObjHandler") <<"setting since = "<< m_since;
163  this->m_to_transfer.push_back(std::make_pair(obj,m_since));
164  } else {
165  edm::LogError ("SiStripPopConDbObjHandler") <<"[SiStripPopConDbObjHandler::setForTransfer] " << m_name << " : NULL pointer of obj " << typeid(T).name() << " reported by SiStripCondObjBuilderFromDb\n Transfer aborted";
166  }
167 }
168 
169 template <class T>
171 {
172  std::cout << "SiStripPedestalsDQMService::getMetaDataString" << std::endl;
173  std::stringstream ss;
174  ss << "Run " << m_runNumber << std::endl;
175  return ss.str();
176 }
177 
178 #endif // DQMOffline_CalibTracker_SiStripDQMPopConSourceHandler_H
size
Write out results.
T getUntrackedParameter(std::string const &, T const &) const
std::string const & userTextLog() const
virtual void initES(const edm::EventSetup &)
unsigned long long logId
Definition: Types.h:92
std::string provenance
Definition: Types.h:94
std::string payloadToken
Definition: Types.h:101
SiStripDQMPopConSourceHandler(const edm::ParameterSet &pset)
size_t size
Definition: Types.h:77
std::string execmessage
Definition: Types.h:103
virtual std::string getMetaDataString() const
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
virtual void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter)
std::string lastPayloadToken
Definition: Types.h:76
unsigned int payloadIdx
Definition: Types.h:98
virtual bool checkForCompatibility(const std::string otherMetaData) const
std::string usertext
Definition: Types.h:95
long double T
std::string token
Definition: Types.h:74
virtual T * getObj() const =0
cond::TagInfo_t const & tagInfo() const
std::string iovtimetype
Definition: Types.h:97
std::string iovtag
Definition: Types.h:96