CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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"
11 #include <TSystem.h>
12 
13 #include <stdio.h>
14 #include <sstream>
15 #include <math.h>
16 
17 
18 static inline double stampToReal(edm::Timestamp time)
19 { return (time.value() >> 32) + 1e-6*(time.value() & 0xffffffff); }
20 
21 static inline double stampToReal(const timeval &time)
22 { return time.tv_sec + 1e-6*time.tv_usec; }
23 
24 
26 
27  struct timeval now;
28  gettimeofday(&now, 0);
29 
30  parameters_ = ps;
31  pEvent_ = 0;
32  evtRateCount_ = 0;
34 
35  // read config parms
36  std::string folder = parameters_.getUntrackedParameter<std::string>("eventInfoFolder", "EventInfo") ;
37  subsystemname_ = parameters_.getUntrackedParameter<std::string>("subSystemFolder", "YourSubsystem") ;
38 
39  eventInfoFolder_ = subsystemname_ + "/" + folder ;
40  evtRateWindow_ = parameters_.getUntrackedParameter<double>("eventRateWindow", 0.5);
41  if(evtRateWindow_<=0.15) evtRateWindow_=0.15;
42 
43 }
44 
46 }
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[33];
84  gethostname(hostname,32);
85  hostName_= ibooker.bookString("hostName",hostname);
86  processName_= ibooker.bookString("processName",subsystemname_);
87  char* pwd = getcwd(NULL, 0);
88  workingDir_= ibooker.bookString("workingDir",pwd);
89  free(pwd);
90  cmsswVer_= ibooker.bookString("CMSSW_Version",edm::getReleaseVersion());
91 
92  // Folder to be populated by sub-systems' code
93  std::string subfolder = eventInfoFolder_ + "/reportSummaryContents" ;
94  ibooker.setCurrentFolder(subfolder);
95 
96  //Online static histograms
97  const edm::ParameterSet &sourcePSet = edm::getProcessParameterSet().getParameterSet("@main_input");
98  if (sourcePSet.getParameter<std::string>("@module_type") == "EventStreamHttpReader" ){
99  std::string evSelection;
100  std::vector<std::string> evSelectionList;
101  const edm::ParameterSet &evSelectionPSet = sourcePSet.getUntrackedParameterSet("SelectEvents");
102  evSelectionList = evSelectionPSet.getParameter<std::vector<std::string> >("SelectEvents");
103  for ( std::vector<std::string>::iterator it = evSelectionList.begin(); it < evSelectionList.end(); it++ )
104  evSelection += "'"+ *it + "', ";
105 
106  evSelection.resize(evSelection.length()-2);
108  ibooker.bookString("eventSelection",evSelection);
109  }
110 
111 
112 }
113 
114 
116 {
118 }
119 
121 
122  eventId_->Fill(e.id().event()); // Handing edm::EventNumber_t to Fill method which will handle further casting
124 
125  pEvent_++;
126  evtRateCount_++;
128 
129  struct timeval now;
130  gettimeofday(&now, 0);
132  currentTime_ = stampToReal(now);
133 
136 
137  double delta = currentTime_ - lastAvgTime_;
138  if (delta >= (evtRateWindow_*60.0))
139  {
141  evtRateCount_ = 0;
142  lastAvgTime_ = currentTime_;
143  }
144 
145  return;
146 }
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 &quot;name&quot; of the job (eg, Hcal or DT)
Definition: DQMEventInfo.h:90
double lastUpdateTime_
Definition: DQMEventInfo.h:62
RunID const & id() const
Definition: RunBase.h:41
MonitorElement * eventTimeStamp_
Definition: DQMEventInfo.h:76
RunNumber_t run() const
Definition: RunID.h:39
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
int64_t pEvent_
Definition: DQMEventInfo.h:66
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
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:25
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:48
std::string getReleaseVersion()
int64_t evtRateCount_
Definition: DQMEventInfo.h:65
MonitorElement * runId_
Definition: DQMEventInfo.h:72
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
ParameterSet const & getProcessParameterSet()
Definition: Registry.cc:85
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:45
Timestamp const & beginTime() const
Definition: RunBase.h:43
edm::EventID id() const
Definition: EventBase.h:60
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c)
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:18
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:41