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