CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQMServices/Components/src/DQMEventInfo.cc

Go to the documentation of this file.
00001 /*
00002  * \file DQMEventInfo.cc
00003  * \author M. Zanetti - CERN PH
00004  * Last Update:
00005  * $Date: 2010/07/20 19:36:27 $
00006  * $Revision: 1.32 $
00007  * $Author: wmtan $
00008  *
00009  */
00010 #include "DQMEventInfo.h"
00011 #include "FWCore/Framework/interface/LuminosityBlock.h"
00012 #include "FWCore/Version/interface/GetReleaseVersion.h"
00013 #include <TSystem.h>
00014 
00015 #include <stdio.h>
00016 #include <sstream>
00017 #include <math.h>
00018 
00019 
00020 static inline double stampToReal(edm::Timestamp time)
00021 { return (time.value() >> 32) + 1e-6*(time.value() & 0xffffffff); }
00022 
00023 static inline double stampToReal(const timeval &time)
00024 { return time.tv_sec + 1e-6*time.tv_usec; }
00025 
00026 
00027 DQMEventInfo::DQMEventInfo(const edm::ParameterSet& ps){
00028   
00029   struct timeval now;
00030   gettimeofday(&now, 0);
00031 
00032   parameters_ = ps;
00033   pEvent_ = 0;
00034   evtRateCount_ = 0;
00035   lastAvgTime_ = currentTime_ = stampToReal(now);
00036 
00037   // read config parms  
00038   std::string folder = parameters_.getUntrackedParameter<std::string>("eventInfoFolder", "EventInfo") ;
00039   std::string subsystemname = parameters_.getUntrackedParameter<std::string>("subSystemFolder", "YourSubsystem") ;
00040   
00041   eventInfoFolder_ = subsystemname + "/" +  folder ;
00042   evtRateWindow_ = parameters_.getUntrackedParameter<double>("eventRateWindow", 0.5);
00043   if(evtRateWindow_<=0.15) evtRateWindow_=0.15;
00044 
00045   // 
00046   dbe_ = edm::Service<DQMStore>().operator->();
00047 
00048   dbe_->setCurrentFolder(eventInfoFolder_) ;
00049 
00050   //Event specific contents
00051   runId_     = dbe_->bookInt("iRun");
00052   runId_->Fill(-1);
00053   lumisecId_ = dbe_->bookInt("iLumiSection");
00054   lumisecId_->Fill(-1);
00055   eventId_   = dbe_->bookInt("iEvent");
00056   eventId_->Fill(-1);
00057   eventTimeStamp_ = dbe_->bookFloat("eventTimeStamp");
00058   
00059   dbe_->setCurrentFolder(eventInfoFolder_) ;
00060   //Process specific contents
00061   processTimeStamp_ = dbe_->bookFloat("processTimeStamp");
00062   processTimeStamp_->Fill(currentTime_);
00063   processLatency_ = dbe_->bookFloat("processLatency");
00064   processTimeStamp_->Fill(-1);
00065   processEvents_ = dbe_->bookInt("processedEvents");
00066   processEvents_->Fill(pEvent_);
00067   processEventRate_ = dbe_->bookFloat("processEventRate");
00068   processEventRate_->Fill(-1); 
00069   nUpdates_= dbe_->bookInt("processUpdates");
00070   nUpdates_->Fill(-1);
00071 
00072   //Static Contents
00073   processId_= dbe_->bookInt("processID"); 
00074   processId_->Fill(gSystem->GetPid());
00075   processStartTimeStamp_ = dbe_->bookFloat("processStartTimeStamp");
00076   processStartTimeStamp_->Fill(currentTime_);
00077   runStartTimeStamp_ = dbe_->bookFloat("runStartTimeStamp");
00078   hostName_= dbe_->bookString("hostName",gSystem->HostName());
00079   processName_= dbe_->bookString("processName",subsystemname);
00080   workingDir_= dbe_->bookString("workingDir",gSystem->pwd());
00081   cmsswVer_= dbe_->bookString("CMSSW_Version",edm::getReleaseVersion());
00082  
00083   // Folder to be populated by sub-systems' code
00084   std::string subfolder = eventInfoFolder_ + "/reportSummaryContents" ;
00085   dbe_->setCurrentFolder(subfolder);
00086 
00087 }
00088 
00089 DQMEventInfo::~DQMEventInfo(){
00090 }
00091 
00092 void DQMEventInfo::beginRun(const edm::Run& r, const edm::EventSetup &c ) 
00093 {
00094     
00095   runId_->Fill(r.id().run());
00096   runStartTimeStamp_->Fill(stampToReal(r.beginTime()));
00097   
00098 } 
00099 
00100 void DQMEventInfo::beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) {
00101 
00102   lumisecId_->Fill(l.id().luminosityBlock());
00103 
00104 }
00105 
00106 void DQMEventInfo::analyze(const edm::Event& e, const edm::EventSetup& c){
00107  
00108   eventId_->Fill(int64_t(e.id().event()));
00109   eventTimeStamp_->Fill(stampToReal(e.time()));
00110 
00111   pEvent_++;
00112   evtRateCount_++;
00113   processEvents_->Fill(pEvent_);
00114 
00115   struct timeval now;
00116   gettimeofday(&now, 0);
00117   lastUpdateTime_ = currentTime_;
00118   currentTime_ = stampToReal(now);
00119 
00120   processTimeStamp_->Fill(currentTime_);
00121   processLatency_->Fill(currentTime_ - lastUpdateTime_);
00122 
00123   double delta = currentTime_ - lastAvgTime_;
00124   if (delta >= (evtRateWindow_*60.0))
00125   {
00126     processEventRate_->Fill(evtRateCount_/delta);
00127     evtRateCount_ = 0;
00128     lastAvgTime_ = currentTime_;    
00129   }
00130   
00131   return;
00132 }