CMS 3D CMS Logo

DQMEventInfo.cc
Go to the documentation of this file.
1 /*
2  * \file DQMEventInfo.h
3  *
4  * \author M. Zanetti - INFN Padova
5  *
6 */
8 
18 
19 #include <algorithm>
20 #include <iostream>
21 #include <sstream>
22 #include <fstream>
23 #include <string>
24 #include <vector>
25 #include <memory>
26 #include <cstdio>
27 #include <cmath>
28 #include <map>
29 
30 #include <sys/time.h>
31 #include <TSystem.h>
32 
33 #include <boost/algorithm/string/join.hpp>
34 
35 class DQMEventInfo : public DQMOneEDAnalyzer<> {
36 public:
39 
41  ~DQMEventInfo() override;
42 
43 protected:
45  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
46  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
47 
48 private:
51 
53  double runStartTime_;
55  int64_t evtRateCount_;
56  int64_t pEvent_;
57 
67 
86 };
87 
88 static inline double stampToReal(edm::Timestamp time) {
89  return (time.value() >> 32) + 1e-6 * (time.value() & 0xffffffff);
90 }
91 
92 static inline double stampToReal(const timeval& time) { return time.tv_sec + 1e-6 * time.tv_usec; }
93 
95  struct timeval now;
96  gettimeofday(&now, nullptr);
97 
98  pEvent_ = 0;
99  evtRateCount_ = 0;
101 
102  // read config parms
103  std::string folder = ps.getUntrackedParameter<std::string>("eventInfoFolder", "EventInfo");
104  subsystemname_ = ps.getUntrackedParameter<std::string>("subSystemFolder", "YourSubsystem");
105 
107  evtRateWindow_ = ps.getUntrackedParameter<double>("eventRateWindow", 0.5);
108  if (evtRateWindow_ <= 0.15)
109  evtRateWindow_ = 0.15;
110 }
111 
112 DQMEventInfo::~DQMEventInfo() = default;
113 
115  edm::Run const& iRun,
116  edm::EventSetup const& /* iSetup */) {
118 
119  //Event specific contents
120  runId_ = ibooker.bookInt("iRun");
121  runId_->Fill(iRun.id().run());
122  lumisecId_ = ibooker.bookInt("iLumiSection");
123  lumisecId_->Fill(-1);
124  eventId_ = ibooker.bookInt("iEvent");
125  eventId_->Fill(-1);
126  eventTimeStamp_ = ibooker.bookFloat("eventTimeStamp");
127 
129  //Process specific contents
130  processTimeStamp_ = ibooker.bookFloat("processTimeStamp");
132  processLatency_ = ibooker.bookFloat("processLatency");
133  processTimeStamp_->Fill(-1);
134  processEvents_ = ibooker.bookInt("processedEvents");
136  processEventRate_ = ibooker.bookFloat("processEventRate");
137  processEventRate_->Fill(-1);
138  nUpdates_ = ibooker.bookInt("processUpdates");
139  nUpdates_->Fill(-1);
140 
141  //Static Contents
142  processId_ = ibooker.bookInt("processID");
143  processId_->Fill(getpid());
144  processStartTimeStamp_ = ibooker.bookFloat("processStartTimeStamp");
146  runStartTimeStamp_ = ibooker.bookFloat("runStartTimeStamp");
148  char hostname[65];
149  gethostname(hostname, 64);
150  hostname[64] = 0;
151  hostName_ = ibooker.bookString("hostName", hostname);
152  processName_ = ibooker.bookString("processName", subsystemname_);
153  char* pwd = getcwd(nullptr, 0);
154  workingDir_ = ibooker.bookString("workingDir", pwd);
155  free(pwd);
156  cmsswVer_ = ibooker.bookString("CMSSW_Version", edm::getReleaseVersion());
157 
158  // Folder to be populated by sub-systems' code
159  std::string subfolder = eventInfoFolder_ + "/reportSummaryContents";
160  ibooker.setCurrentFolder(subfolder);
161 
162  //Online static histograms
163  const edm::ParameterSet& sourcePSet =
165 
166  if (sourcePSet.getParameter<std::string>("@module_type") == "DQMStreamerReader") {
167  std::string evSelection;
168  std::vector<std::string> evSelectionList;
169  std::string delimiter(", ");
170  evSelectionList = sourcePSet.getUntrackedParameter<std::vector<std::string> >("SelectEvents");
171  // add single quotes inline in the vector of HLT paths:
172  // we do copy assignment, and getUntrackedParameter returns
173  // a by-value copy of the vector of strings
174  std::for_each(evSelectionList.begin(), evSelectionList.end(), [](std::string& s) {
175  std::string squote("'");
176  s = squote + s + squote;
177  });
178  evSelection = boost::algorithm::join(evSelectionList, delimiter);
179  // if no HLT paths are specified, no selections are performed:
180  // we mark this with an asterisk.
181  if (evSelection.empty()) {
182  evSelection = std::string("'*'");
183  }
185  ibooker.bookString("eventSelection", evSelection);
186  }
187 }
188 
190  //Filling lumi here guarantees that the lumi number corresponds to the event when
191  // using multiple concurrent lumis in a job
192  lumisecId_->Fill(e.id().luminosityBlock());
193  eventId_->Fill(e.id().event()); // Handing edm::EventNumber_t to Fill method which will handle further casting
194  eventTimeStamp_->Fill(stampToReal(e.time()));
195 
196  pEvent_++;
197  evtRateCount_++;
199 
200  struct timeval now;
201  gettimeofday(&now, nullptr);
204 
207 
208  double delta = currentTime_ - lastAvgTime_;
209  if (delta >= (evtRateWindow_ * 60.0)) {
211  evtRateCount_ = 0;
213  }
214 
215  return;
216 }
217 
stampToReal
static double stampToReal(edm::Timestamp time)
Definition: DQMEventInfo.cc:88
DQMEventInfo::currentTime_
double currentTime_
Definition: DQMEventInfo.cc:52
alignCSCRings.pwd
pwd
Definition: alignCSCRings.py:57
dqm::implementation::IBooker::bookFloat
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
DQMEventInfo::processEvents_
MonitorElement * processEvents_
Avg # of events in programmable window (default: 5 min)
Definition: DQMEventInfo.cc:77
ESHandle.h
DQMEventInfo::lastAvgTime_
double lastAvgTime_
Definition: DQMEventInfo.cc:52
edm::RunID::run
RunNumber_t run() const
Definition: RunID.h:36
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
makeHLTPrescaleTable.delimiter
delimiter
Definition: makeHLTPrescaleTable.py:181
edm::Run
Definition: Run.h:45
printsummarytable.folder
folder
Definition: printsummarytable.py:7
LuminosityBlock.h
DQMEventInfo::errSummarySegment_
MonitorElement * errSummarySegment_[10]
Subdetector-specific etaPhi summary (float)
Definition: DQMEventInfo.cc:85
DQMEventInfo::DQMEventInfo
DQMEventInfo(const edm::ParameterSet &ps)
Constructor.
Definition: DQMEventInfo.cc:94
DQMEventInfo::runStartTimeStamp_
MonitorElement * runStartTimeStamp_
Definition: DQMEventInfo.cc:63
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
DQMEventInfo::evtRateCount_
int64_t evtRateCount_
Definition: DQMEventInfo.cc:55
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMEventInfo::lastUpdateTime_
double lastUpdateTime_
Definition: DQMEventInfo.cc:52
protons_cff.time
time
Definition: protons_cff.py:39
DQMOneEDAnalyzer
Definition: DQMOneEDAnalyzer.h:20
DQMEventInfo::eventTimeStamp_
MonitorElement * eventTimeStamp_
Definition: DQMEventInfo.cc:66
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::getProcessParameterSetContainingModule
ParameterSet const & getProcessParameterSetContainingModule(ModuleDescription const &moduleDescription)
Definition: ParameterSet.cc:870
DQMEventInfo::runStartTime_
double runStartTime_
Definition: DQMEventInfo.cc:53
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
DQMEventInfo::hostName_
MonitorElement * hostName_
Definition: DQMEventInfo.cc:78
DQMEventInfo::runId_
MonitorElement * runId_
Definition: DQMEventInfo.cc:62
DQMOneEDAnalyzer.h
DQMEventInfo::processId_
MonitorElement * processId_
Number of collector updates (TBD)
Definition: DQMEventInfo.cc:72
DQMEventInfo::nUpdates_
MonitorElement * nUpdates_
These MEs are either static or updated upon each analyze() call.
Definition: DQMEventInfo.cc:71
MakerMacros.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
Run.h
DQMEventInfo::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
Definition: DQMEventInfo.cc:189
DQMEventInfo::pEvent_
int64_t pEvent_
Definition: DQMEventInfo.cc:56
DQMEventInfo::processTimeStamp_
MonitorElement * processTimeStamp_
The UTC time of the first event processed.
Definition: DQMEventInfo.cc:74
DQMEventInfo::eventInfoFolder_
std::string eventInfoFolder_
Definition: DQMEventInfo.cc:49
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::one::EDProducerBase::moduleDescription
ModuleDescription const & moduleDescription() const
Definition: EDProducerBase.h:63
DQMEventInfo::processLatency_
MonitorElement * processLatency_
The UTC time of the last event.
Definition: DQMEventInfo.cc:75
edm::ParameterSet
Definition: ParameterSet.h:47
GetReleaseVersion.h
DQMEventInfo::evtRateWindow_
double evtRateWindow_
Definition: DQMEventInfo.cc:54
dqm::implementation::IBooker::bookString
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
Definition: DQMStore.h:87
Event.h
DQMEventInfo::processEventRate_
MonitorElement * processEventRate_
Time elapsed since the last event.
Definition: DQMEventInfo.cc:76
DQMEventInfo::cmsswVer_
MonitorElement * cmsswVer_
Current working directory of the job.
Definition: DQMEventInfo.cc:81
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DQMEventInfo::errSummaryEtaPhi_
MonitorElement * errSummaryEtaPhi_
Subdetector-specific error summary (float)
Definition: DQMEventInfo.cc:84
dqm::implementation::IBooker::bookInt
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:73
DQMEventInfo::processName_
MonitorElement * processName_
Hostname of the local machine.
Definition: DQMEventInfo.cc:79
edm::EventSetup
Definition: EventSetup.h:58
DQMEventInfo::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DQMEventInfo.cc:114
DQMEventInfo::lumisecId_
MonitorElement * lumisecId_
Definition: DQMEventInfo.cc:65
DQMEventInfo::errSummary_
MonitorElement * errSummary_
DQM patch version for this job.
Definition: DQMEventInfo.cc:83
DQMEventInfo::subsystemname_
std::string subsystemname_
Definition: DQMEventInfo.cc:50
edm::getReleaseVersion
std::string getReleaseVersion()
Definition: GetReleaseVersion.cc:7
DQMEventInfo::processStartTimeStamp_
MonitorElement * processStartTimeStamp_
The PID associated with this job.
Definition: DQMEventInfo.cc:73
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
DQMEventInfo::eventId_
MonitorElement * eventId_
UTC time of the run start.
Definition: DQMEventInfo.cc:64
DQMEventInfo::workingDir_
MonitorElement * workingDir_
DQM "name" of the job (eg, Hcal or DT)
Definition: DQMEventInfo.cc:80
DQMEventInfo
Definition: DQMEventInfo.cc:35
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
DQMEventInfo::dqmPatch_
MonitorElement * dqmPatch_
CMSSW version run for this job.
Definition: DQMEventInfo.cc:82
edm::Event
Definition: Event.h:73
edm::RunBase::id
RunID const & id() const
Definition: RunBase.h:39
edm::RunBase::beginTime
Timestamp const & beginTime() const
Definition: RunBase.h:41
DQMEventInfo::~DQMEventInfo
~DQMEventInfo() override
Destructor.
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::Timestamp
Definition: Timestamp.h:30