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  virtual ~HGCalGeometryClient();
23 
24  virtual void beginRun(const edm::Run& run, const edm::EventSetup& c) {}
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::LogInfo("HGCalValid") << "HGCalGeometry :: runClient" << std::endl;
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::LogInfo("HGCalValid") << "HGCalGeometry::fullPath: "
51  << fullDirPath.at(i) << std::endl;
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::LogInfo("HGCalValid") << "HGCalGeometry:: fullSubPath: "
59  << fullSubDirPath.at(j) << std::endl;
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::LogInfo("HGCalValid") << "HGCalGeometry:: hgcalMES size : "
65  << hgcalMEs.size() << std::endl;
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 
std::vector< MonitorElement * > getContents(Args &&...args)
Definition: DQMStore.h:197
T getParameter(std::string const &) const
int geometryEndjob(const std::vector< MonitorElement * > &hcalMEs)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int nevent
Definition: AMPTWrapper.h:74
void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig)
HGCalGeometryClient(const edm::ParameterSet &)
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:323
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:347
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
Definition: Run.h:43
ib
Definition: cuy.py:660