CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/HLTriggerOffline/special/src/DQMHcalPhiSymHLT.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 /*
00004  Description: <one line class summary>
00005 
00006  Implementation:
00007      <Notes on implementation>
00008 */
00009 //
00010 // Original Author:  Grigory Safronov
00011 //         Created:  Thu Sep 10 08:28:14 CEST 2009
00012 // $Id: DQMHcalPhiSymHLT.cc,v 1.1 2009/09/10 10:18:14 safronov Exp $
00013 //
00014 //
00015 
00016 
00017 #include <memory>
00018 
00019 #include "FWCore/Framework/interface/Frameworkfwd.h"
00020 #include "FWCore/Framework/interface/EDAnalyzer.h"
00021 
00022 #include "FWCore/Framework/interface/Event.h"
00023 #include "FWCore/Framework/interface/MakerMacros.h"
00024 
00025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00026 
00027 #include "DQMServices/Core/interface/DQMStore.h"
00028 #include "DQMServices/Core/interface/MonitorElement.h"
00029 #include "FWCore/ServiceRegistry/interface/Service.h"
00030 
00031 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00032 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00033 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00034 
00035 class DQMHcalPhiSymHLT : public edm::EDAnalyzer {
00036 public:
00037   explicit DQMHcalPhiSymHLT(const edm::ParameterSet&);
00038   ~DQMHcalPhiSymHLT();
00039   
00040   MonitorElement* hFEDsize;
00041   MonitorElement* hHCALsize;
00042   MonitorElement* hFULLsize;
00043   MonitorElement* hHCALvsLumiSec;
00044 
00045 
00046   std::string folderName_;
00047   std::string outRootFileName_;
00048   edm::InputTag rawInLabel_;
00049   bool saveToRootFile_;
00050   
00051   DQMStore* dbe_;  
00052   
00053 private:
00054   virtual void beginJob() ;
00055   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00056   virtual void endJob() ;
00057 
00058   int firstLumiSec;  
00059   int iEvt;
00060 };
00061 
00062 
00063 DQMHcalPhiSymHLT::DQMHcalPhiSymHLT(const edm::ParameterSet& iConfig)
00064 {
00065   folderName_ = iConfig.getParameter<std::string>("folderName");
00066   outRootFileName_=iConfig.getParameter<std::string>("outputRootFileName");
00067   rawInLabel_=iConfig.getParameter<edm::InputTag>("rawInputLabel");
00068   saveToRootFile_=iConfig.getParameter<bool>("SaveToRootFile");
00069  
00070   iEvt=0;
00071 }
00072 
00073 DQMHcalPhiSymHLT::~DQMHcalPhiSymHLT()
00074 {
00075 }
00076 
00077 
00078 void 
00079 DQMHcalPhiSymHLT::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00080 {
00081   if (iEvt==0) firstLumiSec=iEvent.luminosityBlock();
00082   iEvt++;
00083   
00084   std::auto_ptr<FEDRawDataCollection> producedData(new FEDRawDataCollection);
00085   
00086   edm::Handle<FEDRawDataCollection> rawIn;
00087   iEvent.getByLabel(rawInLabel_,rawIn);
00088  
00089   std::vector<int> selFEDs;
00090 
00091   //get HCAL FEDs:
00092   for (int i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++)
00093     {
00094       selFEDs.push_back(i);
00095     }
00096 
00097   const FEDRawDataCollection *rdc=rawIn.product();
00098   
00099   //calculate full HCAL data size:
00100   size_t hcalSize=0;
00101   for (unsigned int k=0; k<selFEDs.size(); k++)
00102     {
00103       const FEDRawData & fedData = rdc->FEDData(selFEDs[k]);
00104       hcalSize+=fedData.size();
00105       hFEDsize->Fill(fedData.size()*pow(1024,-1),1);
00106     }
00107   hHCALsize->Fill(hcalSize*pow(1024,-1),1);
00108   hHCALvsLumiSec->Fill(iEvent.luminosityBlock()-firstLumiSec,hcalSize*pow(1024,-1),1);
00109   
00110   //calculate full data size:
00111   size_t fullSize=0;
00112   for (int j=0; j<FEDNumbering::MAXFEDID; ++j )
00113     {
00114       const FEDRawData & fedData = rdc->FEDData(j);
00115       fullSize+=fedData.size();
00116     }
00117   hFULLsize->Fill(fullSize*pow(1024,-1),1);
00118 }
00119 
00120 
00121 // ------------ method called once each job just before starting event loop  ------------
00122 void 
00123 DQMHcalPhiSymHLT::beginJob()
00124 {
00125   dbe_ = edm::Service<DQMStore>().operator->();
00126   dbe_->setCurrentFolder(folderName_);
00127   
00128   hFEDsize=dbe_->book1D("hFEDsize","HCAL FED size (kB)",1000,0,100);
00129   hFEDsize->setAxisTitle("kB",1);
00130 
00131   hHCALsize=dbe_->book1D("hHCALsize","HCAL data size (kB)",1000,0,1000);
00132   hHCALsize->setAxisTitle("kB",1);
00133 
00134   hFULLsize=dbe_->book1D("hFULLsize","Full data size (kB)",1000,0,2000);
00135   hFULLsize->setAxisTitle("kB",1);
00136 
00137   hHCALvsLumiSec=dbe_->book2D("hHCALvsLumiSec","HCAL data size (kB) vs. internal lumi block number",10000,0,10000,1000,0,1000);
00138   hHCALvsLumiSec->setAxisTitle("kB",2);
00139   hHCALvsLumiSec->setAxisTitle("internal luminosity block number",1);
00140 }
00141 
00142 void 
00143 DQMHcalPhiSymHLT::endJob() 
00144 
00145 {
00146   if(dbe_&&saveToRootFile_) 
00147     {  
00148       dbe_->save(outRootFileName_);
00149     }
00150 }
00151 
00152 //define this as a plug-in
00153 DEFINE_FWK_MODULE(DQMHcalPhiSymHLT);