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