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