CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/DQMOffline/Hcal/src/HcalNoiseRatesClient.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Hcal/interface/HcalNoiseRatesClient.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 HcalNoiseRatesClient::HcalNoiseRatesClient(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("HcalNoiseRatesClient") << "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 HcalNoiseRatesClient::~HcalNoiseRatesClient()
00035 { 
00036   
00037 }
00038 
00039 void HcalNoiseRatesClient::beginJob()
00040 {
00041  
00042 
00043 }
00044 
00045 void HcalNoiseRatesClient::endJob() 
00046 {
00047    if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
00048 }
00049 
00050 void HcalNoiseRatesClient::beginRun(const edm::Run& run, const edm::EventSetup& c)
00051 {
00052  
00053 }
00054 
00055 
00056 void HcalNoiseRatesClient::endRun(const edm::Run& run, const edm::EventSetup& c)
00057 {
00058   runClient_();
00059 }
00060 
00061 //dummy analysis function
00062 void HcalNoiseRatesClient::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup)
00063 {
00064   
00065 }
00066 
00067 void HcalNoiseRatesClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c)
00068 { 
00069 //  runClient_();
00070 }
00071 
00072 void HcalNoiseRatesClient::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., CaloTowersD/CaloTowersTask, HcalRecHitsD/HcalRecHitTask, HcalNoiseRatesD/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(), "HcalNoiseRatesD/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 HcalNoiseRatesD/NoiseRatesTask directory
00107 // hcalMEs are within that directory
00108 int HcalNoiseRatesClient::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(HcalNoiseRatesClient);