CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DQMServices/Components/plugins/DQMLumiMonitor.cc

Go to the documentation of this file.
00001 /*
00002  * \file DQMLumiMonitor.cc
00003  * \author S. Dutta
00004  * Last Update:
00005  * $Date: 2012/05/02 19:59:18 $
00006  * $Revision: 1.6 $
00007  * $Author: dutta $
00008  *
00009  * Description: Pixel Luminosity Monitoring 
00010  *
00011 */
00012 #include "DQMServices/Components/plugins/DQMLumiMonitor.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 #include "FWCore/Framework/interface/LuminosityBlock.h"
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "DataFormats/Common/interface/Handle.h"
00018 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00019 #include "DataFormats/Luminosity/interface/LumiDetails.h"
00020 #include "DataFormats/Luminosity/interface/LumiSummary.h"
00021 #include "TPRegexp.h"
00022 
00023 
00024 // -----------------------------
00025 //  constructors and destructor
00026 // -----------------------------
00027 
00028 DQMLumiMonitor::DQMLumiMonitor( const edm::ParameterSet& ps ) : parameters_(ps) {
00029 
00030 
00031   moduleName_          = parameters_.getParameter<std::string>("ModuleName");
00032   folderName_          = parameters_.getParameter<std::string>("FolderName");
00033   pixelClusterInputTag_= parameters_.getParameter<edm::InputTag>("PixelClusterInputTag");
00034   lumiRecordName_      = parameters_.getParameter<std::string>("LumiRecordName");
00035 
00036   nClusME_ = 0;
00037   nClusVsLSME_ = 0;
00038   intLumiVsLSME_= 0;  
00039   corrIntLumiAndClusVsLSME_ = 0;
00040 }
00041 
00042 DQMLumiMonitor::~DQMLumiMonitor() {
00043 
00044 }
00045 
00046 void DQMLumiMonitor::bookHistograms() {
00047     
00048   edm::ParameterSet ClusHistoPar =  parameters_.getParameter<edm::ParameterSet>("TH1ClusPar");
00049   edm::ParameterSet LumiHistoPar =  parameters_.getParameter<edm::ParameterSet>("TH1LumiPar");
00050   edm::ParameterSet LumiSecHistoPar =  parameters_.getParameter<edm::ParameterSet>("TH1LSPar");
00051 
00052   std::string currentFolder = moduleName_ + "/" + folderName_ ;
00053   dbe_->setCurrentFolder(currentFolder.c_str());
00054 
00055   if (nClusME_ == 0) nClusME_ = dbe_->book1D("nPlxClus", " Number of Pixel Clusters ",
00056                                              ClusHistoPar.getParameter<int32_t>("Xbins"),
00057                                              ClusHistoPar.getParameter<double>("Xmin"),
00058                                              ClusHistoPar.getParameter<double>("Xmax"));
00059   else nClusME_->Reset();
00060   if (nClusVsLSME_ == 0) nClusVsLSME_ = dbe_->bookProfile("nClusVsLS", " Number of Pixel Cluster Vs LS number",
00061                                                               LumiSecHistoPar.getParameter<int32_t>("Xbins"),
00062                                                               LumiSecHistoPar.getParameter<double>("Xmin"),
00063                                                               LumiSecHistoPar.getParameter<double>("Xmax"),
00064                                                           0.0, 0.0, "");
00065   else nClusVsLSME_->Reset();
00066   if (intLumiVsLSME_ == 0) intLumiVsLSME_ = dbe_->bookProfile("intLumiVsLS", " Integrated Luminosity Vs LS number",
00067                                                               LumiSecHistoPar.getParameter<int32_t>("Xbins"),
00068                                                               LumiSecHistoPar.getParameter<double>("Xmin"),
00069                                                               LumiSecHistoPar.getParameter<double>("Xmax"),
00070                                                               0.0, 0.0, "");
00071   else intLumiVsLSME_->Reset();
00072 
00073   if (corrIntLumiAndClusVsLSME_== 0) corrIntLumiAndClusVsLSME_ = dbe_->bookProfile2D("corrIntLumiAndClusVsLS", " Correlation of nCluster and Integrated Luminosity Vs LS number",
00074                                                                                      LumiSecHistoPar.getParameter<int32_t>("Xbins"),
00075                                                                                      LumiSecHistoPar.getParameter<double>("Xmin"),
00076                                                                                      LumiSecHistoPar.getParameter<double>("Xmax"),
00077                                                                                      LumiHistoPar.getParameter<int32_t>("Xbins"),
00078                                                                                      LumiHistoPar.getParameter<double>("Xmin"),
00079                                                                                      LumiHistoPar.getParameter<double>("Xmax"),
00080                                                                                      0.0, 0.0);
00081   else corrIntLumiAndClusVsLSME_->Reset();
00082 }
00083 void DQMLumiMonitor::beginJob() {
00084   dbe_ = edm::Service<DQMStore>().operator->();
00085   intLumi_  = -1.0; 
00086   nLumi_ = -1;
00087 }
00088 
00089 void DQMLumiMonitor::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
00090   bookHistograms();
00091 
00092 }
00093 void DQMLumiMonitor::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup)  {
00094 
00095   //Access Pixel Clusters
00096   edm::Handle< edmNew::DetSetVector<SiPixelCluster> > siPixelClusters;
00097   //  edm::Handle< SiPixelClusterCollectionNew > siPixelClusters;
00098   iEvent.getByLabel(pixelClusterInputTag_, siPixelClusters);
00099   
00100   if(!siPixelClusters.isValid()) {
00101     edm::LogError("PixelLumiMonotor") << "Could not find Cluster Collection " << pixelClusterInputTag_;
00102     return;
00103   }
00104   unsigned int nClusterPix   = (*siPixelClusters).dataSize(); 
00105   nClusME_->Fill(nClusterPix);
00106   if (nLumi_ != -1) nClusVsLSME_->Fill(nLumi_, nClusterPix);
00107   if (intLumi_ != -1 || nLumi_ != -1) corrIntLumiAndClusVsLSME_->Fill(nLumi_, intLumi_, nClusterPix);
00108 }
00109 
00110 void DQMLumiMonitor::endLuminosityBlock(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& eSetup){
00111   edm::LogInfo("PixelLumiMonotor") <<" Run Number "<<lumiBlock.run() <<" Lumi Section Numnber "<< lumiBlock.luminosityBlock();
00112 
00113   nLumi_ = lumiBlock.luminosityBlock();
00114 
00115   // Access Lumi Summary
00116   edm::Handle<LumiSummary> lumiSummary_;
00117   lumiBlock.getByLabel(lumiRecordName_, lumiSummary_);
00118   if(lumiSummary_->isValid()){
00119     intLumi_ = lumiSummary_->intgDelLumi();
00120     edm::LogInfo("PixelLumiMonotor") <<" Luminosity in this Lumi Section " << intLumi_ ;
00121     intLumiVsLSME_->Fill(nLumi_, intLumi_);
00122   } else {
00123     edm::LogError("PixelLumiMonotor") << "No valid data found!";
00124   }
00125   /*
00126   // Access Lumi Details
00127   Handle<LumiDetails> lumiDetails;
00128   lumiBlock.getByLabel("expressLumiProducer", lumiDetails);
00129   if(lumiDetails->isValid()){
00130     std::cout<<"valid detail"<<std::endl;
00131   }else{
00132     std::cout << "no valid lumi detail data" <<std::endl;
00133   }  */
00134   
00135 }
00136 
00137 void DQMLumiMonitor::endRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
00138 
00139 }
00140 
00141 
00142 void DQMLumiMonitor::endJob() {
00143 
00144 }
00145 // Define this as a plug-in
00146 #include "FWCore/Framework/interface/MakerMacros.h"
00147 DEFINE_FWK_MODULE(DQMLumiMonitor);