CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XmasToDQMEventInfo.cc
Go to the documentation of this file.
1 /*
2  * \file DQMEventInfo.cc
3  * \author M. Zanetti - CERN PH
4  * Last Update:
5  * $Date: 2010/07/20 02:58:28 $
6  * $Revision: 1.4 $
7  * $Author: wmtan $
8  *
9  */
10 
12 #include <TSystem.h>
13 
14 // Framework
15 
17 
18 #include <stdio.h>
19 #include <sstream>
20 #include <math.h>
21 
22 using namespace edm;
23 using namespace std;
24 
26 
27  cout << "Constructor of XmasToDQMEventInfo called...." << endl;
28 
29  parameters_ = ps;
30  pEvent_ = 0;
31  evtRateCount_ = 0;
32  gettimeofday(&currentTime_,NULL);
33  lastAvgTime_ = currentTime_;
34 
36 
37  string eventinfofolder = parameters_.getUntrackedParameter<string>("eventInfoFolder", "EventInfo") ;
38  string subsystemname = parameters_.getUntrackedParameter<string>("subSystemFolder", "YourSubsystem") ;
39  string currentfolder = subsystemname + "/" + eventinfofolder ;
40  cout << "currentfolder " << currentfolder << endl;
41 
42  evtRateWindow_ = parameters_.getUntrackedParameter<double>("eventRateWindow", 0.5);
43  if(evtRateWindow_<=0.15) evtRateWindow_=0.15;
44  cout << "Event Rate averaged over " << evtRateWindow_ << " minutes" << endl;
45 
46  dbe_->setCurrentFolder(currentfolder) ;
47 
48  //Event specific contents
49  runId_ = dbe_->bookInt("iRun");
50  lumisecId_ = dbe_->bookInt("iLumiSection");
51  eventId_ = dbe_->bookInt("iEvent");
52  eventTimeStamp_ = dbe_->bookFloat("eventTimeStamp");
53 
54  dbe_->setCurrentFolder(currentfolder) ;
55  //Process specific contents
56  processTimeStamp_ = dbe_->bookFloat("processTimeStamp");
57  processTimeStamp_->Fill(getUTCtime(&currentTime_));
58  processLatency_ = dbe_->bookFloat("processLatency");
59  processTimeStamp_->Fill(-1);
60  processEvents_ = dbe_->bookInt("processedEvents");
61  processEvents_->Fill(pEvent_);
62  processEventRate_ = dbe_->bookFloat("processEventRate");
63  processEventRate_->Fill(-1);
64  nUpdates_= dbe_->bookInt("processUpdates");
65  nUpdates_->Fill(-1);
66 
67  //Static Contents
68  processId_= dbe_->bookInt("processID");
69  processId_->Fill(gSystem->GetPid());
70  processStartTimeStamp_ = dbe_->bookFloat("processStartTimeStamp");
71  processStartTimeStamp_->Fill(getUTCtime(&currentTime_));
72  runStartTimeStamp_ = dbe_->bookFloat("runStartTimeStamp");
73  hostName_= dbe_->bookString("hostName",gSystem->HostName());
74  processName_= dbe_->bookString("processName",subsystemname);
75  workingDir_= dbe_->bookString("workingDir",gSystem->pwd());
76  cmsswVer_= dbe_->bookString("CMSSW_Version",edm::getReleaseVersion());
77 // dqmPatch_= dbe_->bookString("DQM_Patch",dbe_->getDQMPatchVersion());
78 
79  // Folder to be populated by sub-systems' code
80  string subfolder = currentfolder + "/reportSummaryContents" ;
81  dbe_->setCurrentFolder(subfolder);
82 
83 }
84 
86 
87  cout<<"[XmasToDQMEventInfo]: destructor"<<endl;
88 
89 }
90 
92 
93  const edm::Timestamp time = r.beginTime();
94 
95  float sec = time.value() >> 32;
96  float usec = 0xFFFFFFFF & time.value() ;
97 
98  // cout << " begin Run " << r.run() << " " << time.value() << endl;
99  // cout << setprecision(16) << getUTCtime(&currentTime_) << endl;
100  // cout << sec+usec/1000000. << endl;
101 
102  runStartTimeStamp_->Fill(sec+usec/1000000.);
103 
104 }
105 
107 
108  static int icalls = 1;
109  cout << "XmasToDQMEventInfo::analyze call = " << icalls << std::endl;
110 
111  //runId_->Fill(e.id().run());
112  std::string runNumber;
113 
114  //xmas2dqm::wse::ToDqm::instance()->BSem_.take();
115  runNumber = xmas2dqm::wse::ToDqm::instance()->runNumber_.toString();
116  std::cout << "EventInfo runNumber ... = " << runNumber << std::endl;
117  //xmas2dqm::wse::ToDqm::instance()->BSem_.give();
118 
119  std::istringstream istrfloat(runNumber);
120  float runNumber_value;
121  istrfloat >> runNumber_value;
122  runId_->Fill(runNumber_value);
123 
124  lumisecId_->Fill(e.luminosityBlock());
125  eventId_->Fill(e.id().event());
126  eventTimeStamp_->Fill(e.time().value()/(double)0xffffffff);
127 
128  pEvent_++;
129  evtRateCount_++;
130  processEvents_->Fill(pEvent_);
131 
132  lastUpdateTime_=currentTime_;
133  gettimeofday(&currentTime_,NULL);
134  processTimeStamp_->Fill(getUTCtime(&currentTime_));
135  processLatency_->Fill(getUTCtime(&lastUpdateTime_,&currentTime_));
136 
137  float time = getUTCtime(&lastAvgTime_,&currentTime_);
138  if(time>=(evtRateWindow_*60.0)){
139  processEventRate_->Fill((float)evtRateCount_/time);
140  evtRateCount_ = 0;
141  lastAvgTime_ = currentTime_;
142  }
143 
144  icalls++;
145  return;
146 }
147 
148 double XmasToDQMEventInfo::getUTCtime(timeval* a, timeval* b){
149  double deltaT=(*a).tv_sec*1000.0+(*a).tv_usec/1000.0;
150  if(b!=NULL) deltaT=(*b).tv_sec*1000.0+(*b).tv_usec/1000.0 - deltaT;
151  return deltaT/1000.0;
152 }
EventNumber_t event() const
Definition: EventID.h:44
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
#define NULL
Definition: scimark2.h:8
void beginRun(const edm::Run &r, const edm::EventSetup &c)
xdata::String runNumber_
Definition: ToDqm.h:61
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
void Fill(long long x)
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:683
static ToDqm * instance()
Definition: ToDqm.cc:6
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
virtual ~XmasToDQMEventInfo()
Destructor.
DQMStore * dbe_
std::string getReleaseVersion()
TimeValue_t value() const
Definition: Timestamp.cc:72
double getUTCtime(timeval *a, timeval *b=NULL)
double b
Definition: hdecay.h:120
Timestamp const & beginTime() const
Definition: RunBase.h:43
edm::EventID id() const
Definition: EventBase.h:56
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
XmasToDQMEventInfo(const edm::ParameterSet &ps)
Constructor.
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:624
edm::Timestamp time() const
Definition: EventBase.h:57
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33