CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Validation/HcalRecHits/src/NoiseRatesClient.cc

Go to the documentation of this file.
00001 #include "Validation/HcalRecHits/interface/NoiseRatesClient.h"
00002 #include "FWCore/Framework/interface/MakerMacros.h"
00003 
00004 #include "FWCore/Framework/interface/Run.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "FWCore/ServiceRegistry/interface/Service.h"
00008 
00009 #include "DQMServices/Core/interface/DQMStore.h"
00010 #include "DQMServices/Core/interface/MonitorElement.h"
00011 
00012 NoiseRatesClient::NoiseRatesClient(const edm::ParameterSet& iConfig):conf_(iConfig)
00013 {
00014 
00015   outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");
00016 
00017   dbe_ = edm::Service<DQMStore>().operator->();
00018   if (!dbe_) {
00019     edm::LogError("NoiseRatesClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
00020   }
00021   if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
00022     if(dbe_) dbe_->setVerbose(0);
00023   }
00024  
00025   debug_ = false;
00026   verbose_ = false;
00027 
00028   dirName_=iConfig.getParameter<std::string>("DQMDirName");
00029   if(dbe_) dbe_->setCurrentFolder(dirName_);
00030  
00031 }
00032 
00033 
00034 NoiseRatesClient::~NoiseRatesClient()
00035 { 
00036   
00037 }
00038 
00039 void NoiseRatesClient::beginJob()
00040 {
00041  
00042 
00043 }
00044 
00045 void NoiseRatesClient::endJob() 
00046 {
00047    if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
00048 }
00049 
00050 void NoiseRatesClient::beginRun(const edm::Run& run, const edm::EventSetup& c)
00051 {
00052  
00053 }
00054 
00055 
00056 void NoiseRatesClient::endRun(const edm::Run& run, const edm::EventSetup& c)
00057 {
00058   runClient_();
00059 }
00060 
00061 //dummy analysis function
00062 void NoiseRatesClient::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup)
00063 {
00064   
00065 }
00066 
00067 void NoiseRatesClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c)
00068 { 
00069 //  runClient_();
00070 }
00071 
00072 void NoiseRatesClient::runClient_()
00073 {
00074   if(!dbe_) return; //we dont have the DQMStore so we cant do anything
00075   dbe_->setCurrentFolder(dirName_);
00076 
00077   if (verbose_) std::cout << "\nrunClient" << std::endl; 
00078 
00079   std::vector<MonitorElement*> hcalMEs;
00080 
00081   // Since out folders are fixed to three, we can just go over these three folders
00082   // i.e., CaloTowersV/CaloTowersTask, HcalRecHitsV/HcalRecHitTask, NoiseRatesV/NoiseRatesTask.
00083   std::vector<std::string> fullPathHLTFolders = dbe_->getSubdirs();
00084   for(unsigned int i=0;i<fullPathHLTFolders.size();i++) {
00085 
00086     if (verbose_) std::cout <<"\nfullPath: "<< fullPathHLTFolders[i] << std::endl;
00087     dbe_->setCurrentFolder(fullPathHLTFolders[i]);
00088 
00089     std::vector<std::string> fullSubPathHLTFolders = dbe_->getSubdirs();
00090     for(unsigned int j=0;j<fullSubPathHLTFolders.size();j++) {
00091 
00092       if (verbose_) std::cout <<"fullSub: "<<fullSubPathHLTFolders[j] << std::endl;
00093 
00094       if( strcmp(fullSubPathHLTFolders[j].c_str(), "NoiseRatesV/NoiseRatesTask") ==0  ){
00095          hcalMEs = dbe_->getContents(fullSubPathHLTFolders[j]);
00096          if (verbose_) std::cout <<"hltMES size : "<<hcalMEs.size()<<std::endl;
00097          if( !NoiseRatesEndjob(hcalMEs) ) std::cout<<"\nError in NoiseRatesEndjob!"<<std::endl<<std::endl;
00098       }
00099 
00100     }    
00101 
00102   }
00103 
00104 }
00105 
00106 // called after entering the NoiseRatesV/NoiseRatesTask directory
00107 // hcalMEs are within that directory
00108 int NoiseRatesClient::NoiseRatesEndjob(const std::vector<MonitorElement*> &hcalMEs){
00109 
00110    int useAllHistos = 0;
00111    MonitorElement* hLumiBlockCount =0;
00112    for(unsigned int ih=0; ih<hcalMEs.size(); ih++){
00113       if( strcmp(hcalMEs[ih]->getName().c_str(), "hLumiBlockCount") ==0  ){
00114          hLumiBlockCount = hcalMEs[ih];
00115          useAllHistos =1;
00116       } 
00117    } 
00118    if( useAllHistos !=0 && useAllHistos !=1 ) return 0;
00119 
00120 // FIXME: dummy lumiCountMap.size since hLumiBlockCount is disabled
00121 // in a general case.
00122    int lumiCountMapsize = -1; // dummy
00123    if (useAllHistos) hLumiBlockCount->Fill(0.0, lumiCountMapsize);
00124 
00125    return 1;
00126 
00127 }
00128 
00129 DEFINE_FWK_MODULE(NoiseRatesClient);