CMS 3D CMS Logo

HcalOfflineHarvesting.cc
Go to the documentation of this file.
2 
3 using namespace hcaldqm;
4 using namespace hcaldqm::constants;
5 using namespace hcaldqm::filter;
6 
8  : DQHarvester(ps), _reportSummaryMap(nullptr) {
9  _summaryList.push_back(fTP);
10  _summaryList.push_back(fDigi);
11  _summaryList.push_back(fReco);
12  _sumnames[fRaw] = "RawTask";
13  _sumnames[fDigi] = "DigiTask";
14  _sumnames[fReco] = "RecHitTask";
15  _sumnames[fTP] = "TPTask";
16  for (auto& it_sum : _summaryList) {
17  _summarks[it_sum] = false;
18  }
19 
20  auto iC = consumesCollector();
21  if (std::find(_summaryList.begin(), _summaryList.end(), fRaw) != _summaryList.end()) {
22  _sumgen[fRaw] = new hcaldqm::RawRunSummary("RawRunHarvesting", _sumnames[fRaw], ps, iC);
23  }
24  if (std::find(_summaryList.begin(), _summaryList.end(), fDigi) != _summaryList.end()) {
25  _sumgen[fDigi] = new hcaldqm::DigiRunSummary("DigiRunHarvesting", _sumnames[fDigi], ps, iC);
26  }
27  if (std::find(_summaryList.begin(), _summaryList.end(), fReco) != _summaryList.end()) {
28  _sumgen[fReco] = new hcaldqm::RecoRunSummary("RecoRunHarvesting", _sumnames[fReco], ps, iC);
29  }
30  if (std::find(_summaryList.begin(), _summaryList.end(), fTP) != _summaryList.end()) {
31  _sumgen[fTP] = new hcaldqm::TPRunSummary("TPRunHarvesting", _sumnames[fTP], ps, iC);
32  }
33 }
34 
35 /* virtual */ void HcalOfflineHarvesting::beginRun(edm::Run const& r, edm::EventSetup const& es) {
36  DQHarvester::beginRun(r, es);
37 
38  for (auto& it_sum : _summaryList) {
39  _sumgen[it_sum]->beginRun(r, es);
40  }
41 }
42 
43 //
44 // For OFFLINE there is no per LS evaluation
45 //
48  edm::LuminosityBlock const& lb,
49  edm::EventSetup const& es) {
50  for (auto& it_sum : _summaryList) {
51  if (ig.get(_subsystem + "/" + _sumnames[it_sum] + "/EventsTotal") != nullptr) {
52  _summarks[it_sum] = true;
53  }
54  }
55 
56  // CALL ALL THE HARVESTERS
57  for (auto& it_sum : _summaryList) {
58  // run only if have to
59  if (_summarks[it_sum]) {
60  (_sumgen[it_sum])->endLuminosityBlock(ib, ig, lb, es);
61  }
62  }
63 }
64 
65 //
66 // Evaluate and Generate Run Summary
67 //
69  // OBTAIN/SET WHICH MODULES ARE PRESENT
70  std::map<Summary, std::string> datatier_names;
71  datatier_names[fRaw] = "RAW";
72  datatier_names[fDigi] = "DIGI";
73  datatier_names[fReco] = "RECO";
74  datatier_names[fTP] = "TP";
75 
76  int num = 0;
77  std::map<std::string, int> datatiers;
78  for (auto& it_sum : _summaryList) {
79  if (_summarks[it_sum]) {
80  datatiers.insert(std::pair<std::string, int>(datatier_names[it_sum], num));
81  ++num;
82  }
83  }
84 
85  // CREATE THE REPORT SUMMARY MAP
86  // num is #modules
87  // datatiers - std map [DATATIER_NAME] -> [positional value [0,num-1]]
88  // -> bin wise +1 should be
89  if (!_reportSummaryMap) {
90  ib.setCurrentFolder(_subsystem + "/EventInfo");
92  ib.book2D("reportSummaryMap", "reportSummaryMap", _vCrates.size(), 0, _vCrates.size(), num, 0, num);
93  // x axis labels
94 
95  for (uint32_t i = 0; i < _vCrates.size(); i++) {
96  char name[5];
97  sprintf(name, "%d", _vCrates[i]);
99  }
100  // y axis lables
101  for (std::map<std::string, int>::const_iterator it = datatiers.begin(); it != datatiers.end(); ++it) {
102  std::string name = it->first;
103  int value = it->second;
105  }
106  }
107 
108  // iterate over all summary generators and get the flags
109  for (auto& it_sum : _summaryList) {
110  // IF MODULE IS NOT PRESENT IN DATA SKIP
111  if (!_summarks[it_sum]) {
112  continue;
113  }
114 
115  // OBTAIN ALL THE FLAGS FOR THIS MODULE
116  // AND SET THE REPORT STATUS MAP
117  // NOTE AGAIN: datatiers map [DATATIER]->[value not bin!]+1 therefore
118  if (_debug > 0) {
119  std::cout << _sumnames[it_sum] << std::endl;
120  }
121  std::vector<hcaldqm::flag::Flag> flags = (_sumgen[it_sum])->endJob(ib, ig);
122  if (_debug > 0) {
123  std::cout << "********************" << std::endl;
124  std::cout << "SUMMARY" << std::endl;
125  }
126  for (uint32_t icrate = 0; icrate < _vCrates.size(); icrate++) {
127  _reportSummaryMap->setBinContent(icrate + 1, datatiers[flags[icrate]._name] + 1, (int)flags[icrate]._state);
128  if (_debug > 0) {
129  std::cout << "Crate=" << _vCrates[icrate] << std::endl;
130  std::cout << flags[icrate]._name << " " << flags[icrate]._state << std::endl;
131  }
132  }
133  }
134 }
135 
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) final
void _dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
std::map< Summary, std::string > _sumnames
HcalOfflineHarvesting(edm::ParameterSet const &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void beginRun(edm::Run const &, edm::EventSetup const &) override
MonitorElement * _reportSummaryMap
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::map< Summary, hcaldqm::DQClient * > _sumgen
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Definition: value.py:1
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::string _name
Definition: DQModule.h:42
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
std::vector< int > _vCrates
Definition: DQHarvester.h:41
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
std::string _subsystem
Definition: DQModule.h:49
std::map< Summary, bool > _summarks
std::vector< Summary > _summaryList
Definition: Run.h:45
ib
Definition: cuy.py:661
void _dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override