CMS 3D CMS Logo

HGCGeometryClient.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 
17 
19 
20 public:
21  explicit HGCalGeometryClient(const edm::ParameterSet& );
22  ~HGCalGeometryClient() 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 
35  subDirectory_ = iConfig.getParameter<std::string>("DirectoryName");
36 }
37 
39 
41  ig.setCurrentFolder("/");
42 #ifdef EDM_ML_DEBUG
43  edm::LogVerbatim("HGCalValid") << "HGCalGeometry :: runClient";
44 #endif
45  std::vector<MonitorElement*> hgcalMEs;
46  std::vector<std::string> fullDirPath = ig.getSubdirs();
47 
48  for (unsigned int i=0; i<fullDirPath.size(); i++) {
49 #ifdef EDM_ML_DEBUG
50  edm::LogVerbatim("HGCalValid") << "HGCalGeometry::fullPath: "
51  << fullDirPath.at(i);
52 #endif
53  ig.setCurrentFolder(fullDirPath.at(i));
54  std::vector<std::string> fullSubDirPath = ig.getSubdirs();
55 
56  for (unsigned int j=0; j<fullSubDirPath.size(); j++) {
57 #ifdef EDM_ML_DEBUG
58  edm::LogVerbatim("HGCalValid") << "HGCalGeometry:: fullSubPath: "
59  << fullSubDirPath.at(j);
60 #endif
61  if (strcmp(fullSubDirPath.at(j).c_str(), subDirectory_.c_str()) == 0) {
62  hgcalMEs = ig.getContents(fullSubDirPath.at(j));
63 #ifdef EDM_ML_DEBUG
64  edm::LogVerbatim("HGCalValid") << "HGCalGeometry:: hgcalMES size : "
65  << hgcalMEs.size();
66 #endif
67  if (!geometryEndjob(hgcalMEs))
68  edm::LogWarning("HGCalValid") << "\nError in GeometryEndjob!";
69  }
70  }
71  }
72 }
73 
74 int HGCalGeometryClient::geometryEndjob(const std::vector<MonitorElement*>& hgcalMEs) {
75  std::string dets[3] = {"hee", "hef", "heb"};
76  std::string hist1[4] = {"TotEdepStep","dX","dY","dZ"};
77  std::string hist2[10]= {"LayerVsEnStep","XG4VsId","YG4VsId","ZG4VsId","dxVsX",
78  "dyVsY","dzVsZ","dxVsLayer","dyVsLayer","dzVsLayer"};
79  std::vector<MonitorElement*> hist1_;
80  std::vector<MonitorElement*> hist2_;
81 
82  //Normalize the histograms
83  for (unsigned int idet=0; idet<3; ++idet) {
84  char name[100];
85  for (unsigned int kh=0; kh<4; ++kh) {
86  sprintf(name, "%s%s", dets[idet].c_str(), hist1[kh].c_str());
87  for (unsigned int ih=0; ih<hgcalMEs.size(); ih++) {
88  if (strcmp(hgcalMEs[ih]->getName().c_str(), name) == 0) {
89  hist1_.push_back(hgcalMEs[ih]);
90  double nevent = hist1_.back()->getEntries();
91  int nbinsx = hist1_.back()->getNbinsX();
92  for (int i=1; i<= nbinsx; ++i) {
93  double binValue = hist1_.back()->getBinContent(i)/nevent;
94  hist1_.back()->setBinContent(i,binValue);
95  }
96  }
97  }
98  }
99  for (unsigned int kh=0; kh<10; ++kh) {
100  sprintf(name, "%s%s", dets[idet].c_str(), hist2[kh].c_str());
101  for (unsigned int ih=0; ih<hgcalMEs.size(); ih++) {
102  if (strcmp(hgcalMEs[ih]->getName().c_str(), name) == 0) {
103  hist2_.push_back(hgcalMEs[ih]);
104  double nevent = hist2_.back()->getEntries();
105  int nbinsx = hist2_.back()->getNbinsX();
106  int nbinsy = hist2_.back()->getNbinsY();
107  for (int i=1; i<= nbinsx; ++i) {
108  for (int j=1; j<= nbinsy; ++j) {
109  double binValue = hist2_.back()->getBinContent(i,j)/nevent;
110  hist2_.back()->setBinContent(i,j,binValue);
111  }
112  }
113  }
114  }
115  }
116  }
117 
118  return 1;
119 }
120 
122 
T getParameter(std::string const &) const
void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig) override
int geometryEndjob(const std::vector< MonitorElement * > &hcalMEs)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:361
int nevent
Definition: AMPTWrapper.h:74
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HGCalGeometryClient(const edm::ParameterSet &)
std::vector< MonitorElement * > getContents(Args &&...args)
Definition: DQMStore.h:192
TString getName(TString structure, int layer, TString geometry)
Definition: DMRtrends.cc:167
~HGCalGeometryClient() override
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
std::vector< std::string > getSubdirs()
Definition: DQMStore.cc:325
Definition: Run.h:45
ib
Definition: cuy.py:662