CMS 3D CMS Logo

DQMEventInfo.cc
Go to the documentation of this file.
1 /*
2  * \file DQMEventInfo.cc
3  * \author M. Zanetti - CERN PH
4  * Last Update:
5  *
6  */
7 #include "DQMEventInfo.h"
10 #include <TSystem.h>
11 
12 #include <algorithm>
13 #include <cstdio>
14 #include <sstream>
15 #include <cmath>
16 
17 #include <boost/algorithm/string/join.hpp>
18 
19 
20 static inline double stampToReal(edm::Timestamp time)
21 { return (time.value() >> 32) + 1e-6*(time.value() & 0xffffffff); }
22 
23 static inline double stampToReal(const timeval &time)
24 { return time.tv_sec + 1e-6*time.tv_usec; }
25 
26 
28 
29  struct timeval now;
30  gettimeofday(&now, nullptr);
31 
32  pEvent_ = 0;
33  evtRateCount_ = 0;
35 
36  // read config parms
37  std::string folder = ps.getUntrackedParameter<std::string>("eventInfoFolder", "EventInfo") ;
38  subsystemname_ = ps.getUntrackedParameter<std::string>("subSystemFolder", "YourSubsystem") ;
39 
40  eventInfoFolder_ = subsystemname_ + "/" + folder ;
41  evtRateWindow_ = ps.getUntrackedParameter<double>("eventRateWindow", 0.5);
42  if(evtRateWindow_<=0.15) evtRateWindow_=0.15;
43 
44 }
45 
46 DQMEventInfo::~DQMEventInfo() = default;
47 
49  edm::Run const & iRun,
50  edm::EventSetup const & /* iSetup */)
51 {
53 
54  //Event specific contents
55  runId_ = ibooker.bookInt("iRun");
56  runId_->Fill(iRun.id().run());
57  lumisecId_ = ibooker.bookInt("iLumiSection");
58  lumisecId_->Fill(-1);
59  eventId_ = ibooker.bookInt("iEvent");
60  eventId_->Fill(-1);
61  eventTimeStamp_ = ibooker.bookFloat("eventTimeStamp");
62 
64  //Process specific contents
65  processTimeStamp_ = ibooker.bookFloat("processTimeStamp");
67  processLatency_ = ibooker.bookFloat("processLatency");
69  processEvents_ = ibooker.bookInt("processedEvents");
71  processEventRate_ = ibooker.bookFloat("processEventRate");
73  nUpdates_= ibooker.bookInt("processUpdates");
74  nUpdates_->Fill(-1);
75 
76  //Static Contents
77  processId_= ibooker.bookInt("processID");
78  processId_->Fill(getpid());
79  processStartTimeStamp_ = ibooker.bookFloat("processStartTimeStamp");
81  runStartTimeStamp_ = ibooker.bookFloat("runStartTimeStamp");
83  char hostname[65];
84  gethostname(hostname,64);
85  hostname[64] = 0;
86  hostName_= ibooker.bookString("hostName",hostname);
87  processName_= ibooker.bookString("processName",subsystemname_);
88  char* pwd = getcwd(nullptr, 0);
89  workingDir_= ibooker.bookString("workingDir",pwd);
90  free(pwd);
91  cmsswVer_= ibooker.bookString("CMSSW_Version",edm::getReleaseVersion());
92 
93  // Folder to be populated by sub-systems' code
94  std::string subfolder = eventInfoFolder_ + "/reportSummaryContents" ;
95  ibooker.setCurrentFolder(subfolder);
96 
97  //Online static histograms
98  const edm::ParameterSet &sourcePSet =
100  .getParameterSet("@main_input");
101 
102  if (sourcePSet.getParameter<std::string>("@module_type") == "DQMStreamerReader" ){
103  std::string evSelection;
104  std::vector<std::string> evSelectionList;
105  std::string delimiter( ", " );
106  evSelectionList = sourcePSet.getUntrackedParameter<std::vector<std::string> >("SelectEvents");
107  // add single quotes inline in the vector of HLT paths:
108  // we do copy assignment, and getUntrackedParameter returns
109  // a by-value copy of the vector of strings
110  std::for_each( evSelectionList.begin(), evSelectionList.end(),
111  []( std::string & s ){ std::string squote( "'" );
112  s = squote + s + squote;
113  }
114  );
115  evSelection = boost::algorithm::join( evSelectionList, delimiter );
116  // if no HLT paths are specified, no selections are performed:
117  // we mark this with an asterisk.
118  if( evSelection.empty() ) {
119  evSelection = std::string( "'*'" );
120  }
122  ibooker.bookString("eventSelection",evSelection);
123  }
124 
125 
126 }
127 
128 
130 
131  //Filling lumi here guarantees that the lumi number corresponds to the event when
132  // using multiple concurrent lumis in a job
134  eventId_->Fill(e.id().event()); // Handing edm::EventNumber_t to Fill method which will handle further casting
136 
137  pEvent_++;
138  evtRateCount_++;
140 
141  struct timeval now;
142  gettimeofday(&now, nullptr);
144  currentTime_ = stampToReal(now);
145 
148 
149  double delta = currentTime_ - lastAvgTime_;
150  if (delta >= (evtRateWindow_*60.0))
151  {
153  evtRateCount_ = 0;
154  lastAvgTime_ = currentTime_;
155  }
156 
157  return;
158 }
dbl * delta
Definition: mlp_gen.cc:36
double evtRateWindow_
Definition: DQMEventInfo.h:61
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
double currentTime_
Definition: DQMEventInfo.h:59
MonitorElement * hostName_
of event processed so far
Definition: DQMEventInfo.h:85
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * workingDir_
DQM "name" of the job (eg, Hcal or DT)
Definition: DQMEventInfo.h:87
double lastUpdateTime_
Definition: DQMEventInfo.h:59
RunID const & id() const
Definition: RunBase.h:39
MonitorElement * eventTimeStamp_
Definition: DQMEventInfo.h:73
RunNumber_t run() const
Definition: RunID.h:39
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
MonitorElement * processId_
Number of collector updates (TBD)
Definition: DQMEventInfo.h:79
MonitorElement * processStartTimeStamp_
The PID associated with this job.
Definition: DQMEventInfo.h:80
MonitorElement * bookInt(Args &&...args)
Definition: DQMStore.h:104
MonitorElement * bookString(Args &&...args)
Definition: DQMStore.h:103
int64_t pEvent_
Definition: DQMEventInfo.h:63
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
ParameterSet const & getProcessParameterSetContainingModule(ModuleDescription const &moduleDescription)
void Fill(long long x)
MonitorElement * cmsswVer_
Current working directory of the job.
Definition: DQMEventInfo.h:88
MonitorElement * eventId_
UTC time of the run start.
Definition: DQMEventInfo.h:71
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::string eventInfoFolder_
Definition: DQMEventInfo.h:53
MonitorElement * lumisecId_
Definition: DQMEventInfo.h:72
MonitorElement * runStartTimeStamp_
Definition: DQMEventInfo.h:70
DQMEventInfo(const edm::ParameterSet &ps)
Constructor.
Definition: DQMEventInfo.cc:27
double lastAvgTime_
Definition: DQMEventInfo.h:59
MonitorElement * processEvents_
Avg # of events in programmable window (default: 5 min)
Definition: DQMEventInfo.h:84
MonitorElement * processLatency_
The UTC time of the last event.
Definition: DQMEventInfo.h:82
MonitorElement * processName_
Hostname of the local machine.
Definition: DQMEventInfo.h:86
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DQMEventInfo.cc:48
~DQMEventInfo() override
Destructor.
std::string getReleaseVersion()
int64_t evtRateCount_
Definition: DQMEventInfo.h:62
MonitorElement * runId_
Definition: DQMEventInfo.h:69
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
ParameterSet const & getParameterSet(std::string const &) const
MonitorElement * nUpdates_
These MEs are either static or updated upon each analyze() call.
Definition: DQMEventInfo.h:78
MonitorElement * processEventRate_
Time elapsed since the last event.
Definition: DQMEventInfo.h:83
Timestamp const & beginTime() const
Definition: RunBase.h:41
edm::EventID id() const
Definition: EventBase.h:59
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:105
MonitorElement * processTimeStamp_
The UTC time of the first event processed.
Definition: DQMEventInfo.h:81
static double stampToReal(edm::Timestamp time)
Definition: DQMEventInfo.cc:20
TimeValue_t value() const
Definition: Timestamp.h:56
std::string subsystemname_
Definition: DQMEventInfo.h:54
edm::Timestamp time() const
Definition: EventBase.h:60
Definition: Run.h:45