CMS 3D CMS Logo

HGCalHitClient.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <unistd.h>
3 #include <iostream>
4 #include <fstream>
5 #include <vector>
6 
16 
17 //#define EDM_ML_DEBUG
18 
20 public:
21  explicit HGCalHitClient(const edm::ParameterSet&);
22  ~HGCalHitClient() override;
23 
24  void beginRun(const edm::Run& run, const edm::EventSetup& c) override {}
25  void dqmEndJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) override;
26 
27 private:
29 
30  int geometryEndjob(const std::vector<MonitorElement*>& hcalMEs);
31 };
32 
34  subDirectory_ = iConfig.getParameter<std::string>("DirectoryName");
35 }
36 
38 
40  ig.setCurrentFolder("/");
41 #ifdef EDM_ML_DEBUG
42  edm::LogVerbatim("HGCalValid") << "HGCalHitValidation :: runClient";
43 #endif
44  std::vector<MonitorElement*> hgcalMEs;
45  std::vector<std::string> fullDirPath = ig.getSubdirs();
46 
47  for (unsigned int i = 0; i < fullDirPath.size(); i++) {
48 #ifdef EDM_ML_DEBUG
49  edm::LogVerbatim("HGCalValid") << "HGCalHitValidation::fullPath: " << fullDirPath.at(i);
50 #endif
51  ig.setCurrentFolder(fullDirPath.at(i));
52  std::vector<std::string> fullSubDirPath = ig.getSubdirs();
53 
54  for (unsigned int j = 0; j < fullSubDirPath.size(); j++) {
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("HGCalValid") << "HGCalHitValidation:: fullSubPath: " << fullSubDirPath.at(j);
57 #endif
58  if (strcmp(fullSubDirPath.at(j).c_str(), subDirectory_.c_str()) == 0) {
59  hgcalMEs = ig.getContents(fullSubDirPath.at(j));
60 #ifdef EDM_ML_DEBUG
61  edm::LogVerbatim("HGCalValid") << "HGCalHitValidation:: hgcalMES size : " << hgcalMEs.size();
62 #endif
63  if (!geometryEndjob(hgcalMEs))
64  edm::LogWarning("HGCalValid") << "\nError in HGcalHitEndjob!";
65  }
66  }
67  }
68 }
69 
70 int HGCalHitClient::geometryEndjob(const std::vector<MonitorElement*>& hgcalMEs) {
71  std::string dets[3] = {"hee", "hef", "heb"};
72  std::string hist1[2] = {"EnRec", "EnSim"};
73  std::string hist2[7] = {"dzVsZ", "dyVsY", "dxVsX", "RecVsSimZ", "RecVsSimY", "RecVsSimX", "EnSimRec"};
74 
75  std::vector<MonitorElement*> hist1_;
76  std::vector<MonitorElement*> hist2_;
77 
78  //Normalize the histograms
79  for (unsigned int idet = 0; idet < 3; ++idet) {
80  char name[100];
81  for (unsigned int kh = 0; kh < 2; ++kh) {
82  sprintf(name, "%s%s", dets[idet].c_str(), hist1[kh].c_str());
83  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
84  if (strcmp(hgcalMEs[ih]->getName().c_str(), name) == 0) {
85  hist1_.push_back(hgcalMEs[ih]);
86  double nevent = hist1_.back()->getEntries();
87  int nbinsx = hist1_.back()->getNbinsX();
88  for (int i = 1; i <= nbinsx; ++i) {
89  double binValue = hist1_.back()->getBinContent(i) / nevent;
90  hist1_.back()->setBinContent(i, binValue);
91  }
92  }
93  }
94  }
95  for (unsigned int kh = 0; kh < 7; ++kh) {
96  sprintf(name, "%s%s", dets[idet].c_str(), hist2[kh].c_str());
97  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
98  if (strcmp(hgcalMEs[ih]->getName().c_str(), name) == 0) {
99  hist2_.push_back(hgcalMEs[ih]);
100  double nevent = hist2_.back()->getEntries();
101  int nbinsx = hist2_.back()->getNbinsX();
102  int nbinsy = hist2_.back()->getNbinsY();
103  for (int i = 1; i <= nbinsx; ++i) {
104  for (int j = 1; j <= nbinsy; ++j) {
105  double binValue = hist2_.back()->getBinContent(i, j) / nevent;
106  hist2_.back()->setBinContent(i, j, binValue);
107  }
108  }
109  }
110  }
111  }
112  }
113 
114  return 1;
115 }
116 
118 
DQMEDHarvester.h
nevent
int nevent
Definition: AMPTWrapper.h:84
Handle.h
HGCalHitClient::geometryEndjob
int geometryEndjob(const std::vector< MonitorElement * > &hcalMEs)
Definition: HGCalHitClient.cc:70
mps_fire.i
i
Definition: mps_fire.py:355
dqm::implementation::IGetter::getContents
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
MessageLogger.h
edm::Run
Definition: Run.h:45
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dqm::implementation::IGetter::getSubdirs
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:678
HGCalHitClient::~HGCalHitClient
~HGCalHitClient() override
Definition: HGCalHitClient.cc:37
MakerMacros.h
dqm::legacy::DQMStore::IBooker
dqm::implementation::IBooker IBooker
Definition: DQMStore.h:729
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
getName
TString getName(TString structure, int layer, TString geometry)
Definition: DMRtrends.cc:235
Run.h
HGCalHitClient::dqmEndJob
void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig) override
Definition: HGCalHitClient.cc:39
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
HGCalHitClient::HGCalHitClient
HGCalHitClient(const edm::ParameterSet &)
Definition: HGCalHitClient.cc:33
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
HGCalHitClient::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
Definition: HGCalHitClient.cc:24
edm::LogVerbatim
Definition: MessageLogger.h:297
cuy.ib
ib
Definition: cuy.py:662
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
HGCalHitClient::subDirectory_
std::string subDirectory_
Definition: HGCalHitClient.cc:28
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
DQMEDHarvester
Definition: DQMEDHarvester.py:1
writedatasetfile.run
run
Definition: writedatasetfile.py:27
dqm::implementation::IGetter
Definition: DQMStore.h:484
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
HGCalHitClient
Definition: HGCalHitClient.cc:19
dqm::implementation::IBooker
Definition: DQMStore.h:43
ParameterSet.h
dqm::legacy::DQMStore::IGetter
dqm::implementation::IGetter IGetter
Definition: DQMStore.h:730
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66