Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-25 06:38:18

0001 #include "DQM/HcalTasks/interface/HcalOfflineHarvesting.h"
0002 
0003 using namespace hcaldqm;
0004 using namespace hcaldqm::constants;
0005 using namespace hcaldqm::filter;
0006 
0007 HcalOfflineHarvesting::HcalOfflineHarvesting(edm::ParameterSet const& ps)
0008     : DQHarvester(ps), _reportSummaryMap(nullptr) {
0009   _summaryList.push_back(fTP);
0010   _summaryList.push_back(fDigi);
0011   _summaryList.push_back(fReco);
0012   _sumnames[fRaw] = "RawTask";
0013   _sumnames[fDigi] = "DigiTask";
0014   _sumnames[fReco] = "RecHitTask";
0015   _sumnames[fTP] = "TPTask";
0016   for (auto& it_sum : _summaryList) {
0017     _summarks[it_sum] = false;
0018   }
0019 
0020   auto iC = consumesCollector();
0021   if (std::find(_summaryList.begin(), _summaryList.end(), fRaw) != _summaryList.end()) {
0022     _sumgen[fRaw] = new hcaldqm::RawRunSummary("RawRunHarvesting", _sumnames[fRaw], ps, iC);
0023   }
0024   if (std::find(_summaryList.begin(), _summaryList.end(), fDigi) != _summaryList.end()) {
0025     _sumgen[fDigi] = new hcaldqm::DigiRunSummary("DigiRunHarvesting", _sumnames[fDigi], ps, iC);
0026   }
0027   if (std::find(_summaryList.begin(), _summaryList.end(), fReco) != _summaryList.end()) {
0028     _sumgen[fReco] = new hcaldqm::RecoRunSummary("RecoRunHarvesting", _sumnames[fReco], ps, iC);
0029   }
0030   if (std::find(_summaryList.begin(), _summaryList.end(), fTP) != _summaryList.end()) {
0031     _sumgen[fTP] = new hcaldqm::TPRunSummary("TPRunHarvesting", _sumnames[fTP], ps, iC);
0032   }
0033 }
0034 
0035 /* virtual */ void HcalOfflineHarvesting::beginRun(edm::Run const& r, edm::EventSetup const& es) {
0036   DQHarvester::beginRun(r, es);
0037 
0038   for (auto& it_sum : _summaryList) {
0039     _sumgen[it_sum]->beginRun(r, es);
0040   }
0041 }
0042 
0043 //
0044 //  For OFFLINE there is no per LS evaluation
0045 //
0046 /* virtual */ void HcalOfflineHarvesting::_dqmEndLuminosityBlock(DQMStore::IBooker& ib,
0047                                                                  DQMStore::IGetter& ig,
0048                                                                  edm::LuminosityBlock const& lb,
0049                                                                  edm::EventSetup const& es) {
0050   for (auto& it_sum : _summaryList) {
0051     if (ig.get(_subsystem + "/" + _sumnames[it_sum] + "/EventsTotal") != nullptr) {
0052       _summarks[it_sum] = true;
0053     }
0054   }
0055 
0056   //    CALL ALL THE HARVESTERS
0057   for (auto& it_sum : _summaryList) {
0058     //  run only if have to
0059     if (_summarks[it_sum]) {
0060       (_sumgen[it_sum])->endLuminosityBlock(ib, ig, lb, es);
0061     }
0062   }
0063 }
0064 
0065 //
0066 //  Evaluate and Generate Run Summary
0067 //
0068 /* virtual */ void HcalOfflineHarvesting::_dqmEndJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) {
0069   //    OBTAIN/SET WHICH MODULES ARE PRESENT
0070   std::map<Summary, std::string> datatier_names;
0071   datatier_names[fRaw] = "RAW";
0072   datatier_names[fDigi] = "DIGI";
0073   datatier_names[fReco] = "RECO";
0074   datatier_names[fTP] = "TP";
0075 
0076   int num = 0;
0077   std::map<std::string, int> datatiers;
0078   for (auto& it_sum : _summaryList) {
0079     if (_summarks[it_sum]) {
0080       datatiers.insert(std::pair<std::string, int>(datatier_names[it_sum], num));
0081       ++num;
0082     }
0083   }
0084 
0085   //    CREATE THE REPORT SUMMARY MAP
0086   //    num is #modules
0087   //    datatiers - std map [DATATIER_NAME] -> [positional value [0,num-1]]
0088   //    -> bin wise +1 should be
0089   if (!_reportSummaryMap) {
0090     ib.setCurrentFolder(_subsystem + "/EventInfo");
0091     _reportSummaryMap =
0092         ib.book2D("reportSummaryMap", "reportSummaryMap", _vCrates.size(), 0, _vCrates.size(), num, 0, num);
0093     //  x axis labels
0094 
0095     for (uint32_t i = 0; i < _vCrates.size(); i++) {
0096       char name[5];
0097       sprintf(name, "%d", _vCrates[i]);
0098       _reportSummaryMap->setBinLabel(i + 1, name, 1);
0099     }
0100     //  y axis lables
0101     for (std::map<std::string, int>::const_iterator it = datatiers.begin(); it != datatiers.end(); ++it) {
0102       std::string name = it->first;
0103       int value = it->second;
0104       _reportSummaryMap->setBinLabel(value + 1, name, 2);
0105     }
0106   }
0107 
0108   //    iterate over all summary generators and get the flags
0109   for (auto& it_sum : _summaryList) {
0110     //  IF MODULE IS NOT PRESENT IN DATA SKIP
0111     if (!_summarks[it_sum]) {
0112       continue;
0113     }
0114 
0115     //  OBTAIN ALL THE FLAGS FOR THIS MODULE
0116     //  AND SET THE REPORT STATUS MAP
0117     //  NOTE AGAIN: datatiers map [DATATIER]->[value not bin!]+1 therefore
0118     if (_debug > 0) {
0119       std::cout << _sumnames[it_sum] << std::endl;
0120     }
0121     std::vector<hcaldqm::flag::Flag> flags = (_sumgen[it_sum])->endJob(ib, ig);
0122     if (_debug > 0) {
0123       std::cout << "********************" << std::endl;
0124       std::cout << "SUMMARY" << std::endl;
0125     }
0126     for (uint32_t icrate = 0; icrate < _vCrates.size(); icrate++) {
0127       _reportSummaryMap->setBinContent(icrate + 1, datatiers[flags[icrate]._name] + 1, (int)flags[icrate]._state);
0128       if (_debug > 0) {
0129         std::cout << "Crate=" << _vCrates[icrate] << std::endl;
0130         std::cout << flags[icrate]._name << "  " << flags[icrate]._state << std::endl;
0131       }
0132     }
0133   }
0134 }
0135 
0136 DEFINE_FWK_MODULE(HcalOfflineHarvesting);