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