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