Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:31

0001 #include "FWCore/Framework/interface/MakerMacros.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "Validation/HcalRecHits/interface/NoiseRatesClient.h"
0004 
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/Run.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ServiceRegistry/interface/Service.h"
0009 
0010 #include "DQMServices/Core/interface/DQMStore.h"
0011 
0012 NoiseRatesClient::NoiseRatesClient(const edm::ParameterSet &iConfig) : conf_(iConfig) {
0013   outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");
0014 
0015   debug_ = false;
0016   verbose_ = false;
0017 
0018   dirName_ = iConfig.getParameter<std::string>("DQMDirName");
0019 }
0020 
0021 NoiseRatesClient::~NoiseRatesClient() {}
0022 
0023 void NoiseRatesClient::dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig) { runClient_(ib, ig); }
0024 
0025 void NoiseRatesClient::runClient_(DQMStore::IBooker &ib, DQMStore::IGetter &ig) {
0026   ig.setCurrentFolder(dirName_);
0027 
0028   if (verbose_)
0029     edm::LogVerbatim("NoiseRates") << "\nrunClient";
0030 
0031   std::vector<MonitorElement *> hcalMEs;
0032 
0033   // Since out folders are fixed to three, we can just go over these three
0034   // folders i.e., CaloTowersV/CaloTowersTask, HcalRecHitsV/HcalRecHitTask,
0035   // NoiseRatesV/NoiseRatesTask.
0036   std::vector<std::string> fullPathHLTFolders = ig.getSubdirs();
0037   for (unsigned int i = 0; i < fullPathHLTFolders.size(); i++) {
0038     if (verbose_)
0039       edm::LogVerbatim("NoiseRates") << "\nfullPath: " << fullPathHLTFolders[i];
0040     ig.setCurrentFolder(fullPathHLTFolders[i]);
0041 
0042     std::vector<std::string> fullSubPathHLTFolders = ig.getSubdirs();
0043     for (unsigned int j = 0; j < fullSubPathHLTFolders.size(); j++) {
0044       if (verbose_)
0045         edm::LogVerbatim("NoiseRates") << "fullSub: " << fullSubPathHLTFolders[j];
0046 
0047       if (strcmp(fullSubPathHLTFolders[j].c_str(), "NoiseRatesV/NoiseRatesTask") == 0) {
0048         hcalMEs = ig.getContents(fullSubPathHLTFolders[j]);
0049         if (verbose_)
0050           edm::LogVerbatim("NoiseRates") << "hltMES size : " << hcalMEs.size();
0051         if (!NoiseRatesEndjob(hcalMEs))
0052           edm::LogVerbatim("NoiseRates") << "\nError in NoiseRatesEndjob!\n";
0053       }
0054     }
0055   }
0056 }
0057 
0058 // called after entering the NoiseRatesV/NoiseRatesTask directory
0059 // hcalMEs are within that directory
0060 int NoiseRatesClient::NoiseRatesEndjob(const std::vector<MonitorElement *> &hcalMEs) {
0061   int useAllHistos = 0;
0062   MonitorElement *hLumiBlockCount = nullptr;
0063   for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
0064     if (strcmp(hcalMEs[ih]->getName().c_str(), "hLumiBlockCount") == 0) {
0065       hLumiBlockCount = hcalMEs[ih];
0066       useAllHistos = 1;
0067     }
0068   }
0069   if (useAllHistos != 0 && useAllHistos != 1)
0070     return 0;
0071 
0072   // FIXME: dummy lumiCountMap.size since hLumiBlockCount is disabled
0073   // in a general case.
0074   int lumiCountMapsize = -1;  // dummy
0075   if (useAllHistos)
0076     hLumiBlockCount->Fill(0.0, lumiCountMapsize);
0077 
0078   return 1;
0079 }
0080 
0081 DEFINE_FWK_MODULE(NoiseRatesClient);