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"
10 #include <TSystem.h>
11 
12 #include <stdio.h>
13 #include <sstream>
14 #include <math.h>
15 
16 
17 static inline double stampToReal(edm::Timestamp time)
18 { return (time.value() >> 32) + 1e-6*(time.value() & 0xffffffff); }
19 
20 static inline double stampToReal(const timeval &time)
21 { return time.tv_sec + 1e-6*time.tv_usec; }
22 
23 
25 
26  struct timeval now;
27  gettimeofday(&now, 0);
28 
29  parameters_ = ps;
30  pEvent_ = 0;
31  evtRateCount_ = 0;
33 
34  // read config parms
35  std::string folder = parameters_.getUntrackedParameter<std::string>("eventInfoFolder", "EventInfo") ;
36  subsystemname_ = parameters_.getUntrackedParameter<std::string>("subSystemFolder", "YourSubsystem") ;
37 
38  eventInfoFolder_ = subsystemname_ + "/" + folder ;
39  evtRateWindow_ = parameters_.getUntrackedParameter<double>("eventRateWindow", 0.5);
40  if(evtRateWindow_<=0.15) evtRateWindow_=0.15;
41 
42 }
43 
45 }
46 
48  edm::Run const & iRun,
49  edm::EventSetup const & /* iSetup */)
50 {
52 
53  //Event specific contents
54  runId_ = ibooker.bookInt("iRun");
55  runId_->Fill(iRun.id().run());
56  lumisecId_ = ibooker.bookInt("iLumiSection");
57  lumisecId_->Fill(-1);
58  eventId_ = ibooker.bookInt("iEvent");
59  eventId_->Fill(-1);
60  eventTimeStamp_ = ibooker.bookFloat("eventTimeStamp");
61 
63  //Process specific contents
64  processTimeStamp_ = ibooker.bookFloat("processTimeStamp");
66  processLatency_ = ibooker.bookFloat("processLatency");
68  processEvents_ = ibooker.bookInt("processedEvents");
70  processEventRate_ = ibooker.bookFloat("processEventRate");
72  nUpdates_= ibooker.bookInt("processUpdates");
73  nUpdates_->Fill(-1);
74 
75  //Static Contents
76  processId_= ibooker.bookInt("processID");
77  processId_->Fill(getpid());
78  processStartTimeStamp_ = ibooker.bookFloat("processStartTimeStamp");
80  runStartTimeStamp_ = ibooker.bookFloat("runStartTimeStamp");
82  char hostname[65];
83  gethostname(hostname,64);
84  hostname[64] = 0;
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 =
99  .getParameterSet("@main_input");
100 
101  if (sourcePSet.getParameter<std::string>("@module_type") == "EventStreamHttpReader" ){
102  std::string evSelection;
103  std::vector<std::string> evSelectionList;
104  const edm::ParameterSet &evSelectionPSet = sourcePSet.getUntrackedParameterSet("SelectEvents");
105  evSelectionList = evSelectionPSet.getParameter<std::vector<std::string> >("SelectEvents");
106  for ( std::vector<std::string>::iterator it = evSelectionList.begin(); it < evSelectionList.end(); it++ )
107  evSelection += "'"+ *it + "', ";
108 
109  evSelection.resize(evSelection.length()-2);
111  ibooker.bookString("eventSelection",evSelection);
112  }
113 
114 
115 }
116 
117 
119 {
121 }
122 
124 
125  eventId_->Fill(e.id().event()); // Handing edm::EventNumber_t to Fill method which will handle further casting
127 
128  pEvent_++;
129  evtRateCount_++;
131 
132  struct timeval now;
133  gettimeofday(&now, 0);
135  currentTime_ = stampToReal(now);
136 
139 
140  double delta = currentTime_ - lastAvgTime_;
141  if (delta >= (evtRateWindow_*60.0))
142  {
144  evtRateCount_ = 0;
145  lastAvgTime_ = currentTime_;
146  }
147 
148  return;
149 }
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
ModuleDescription const & moduleDescription() const
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.
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:24
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:47
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 & 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:44
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:17
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:43