CMS 3D CMS Logo

HcalSimHitsClient.cc
Go to the documentation of this file.
3 
8 
10 
12  : dirName_(iConfig.getParameter<std::string>("DQMDirName")),
13  verbose_(iConfig.getUntrackedParameter<bool>("Verbosity", false)),
15 
17  const auto &pHRNDC = c.getData(tok_HRNDC_);
18  hcons = &pHRNDC;
23 
24  edm::LogVerbatim("HitsValidationHcal") << " Maximum Depths HB:" << maxDepthHB_ << " HE:" << maxDepthHE_
25  << " HO:" << maxDepthHO_ << " HF:" << maxDepthHF_;
26 }
27 
29 
32 
33  if (verbose_)
34  edm::LogVerbatim("HitsValidationHcal") << "runClient";
35 
36  std::vector<MonitorElement *> hcalMEs;
37 
38  std::vector<std::string> fullPathHLTFolders = ig.getSubdirs();
39  for (unsigned int i = 0; i < fullPathHLTFolders.size(); i++) {
40  if (verbose_)
41  edm::LogVerbatim("HitsValidationHcal") << "fullPath: " << fullPathHLTFolders[i];
42  ig.setCurrentFolder(fullPathHLTFolders[i]);
43 
44  std::vector<std::string> fullSubPathHLTFolders = ig.getSubdirs();
45  for (unsigned int j = 0; j < fullSubPathHLTFolders.size(); j++) {
46  if (verbose_)
47  edm::LogVerbatim("HitsValidationHcal") << "fullSub: " << fullSubPathHLTFolders[j];
48 
49  if (strcmp(fullSubPathHLTFolders[j].c_str(), "HcalHitsV/SimHitsValidationHcal") == 0) {
50  hcalMEs = ig.getContents(fullSubPathHLTFolders[j]);
51  if (verbose_)
52  edm::LogVerbatim("HitsValidationHcal") << "hltMES size : " << hcalMEs.size();
53  if (!SimHitsEndjob(hcalMEs))
54  edm::LogWarning("HitsValidationHcal") << "Error in SimhitEndjob!";
55  }
56  }
57  }
58 }
59 
60 // called after entering the directory
61 // hcalMEs are within that directory
62 int HcalSimHitsClient::SimHitsEndjob(const std::vector<MonitorElement *> &hcalMEs) {
63  std::vector<std::string> divisions = getHistogramTypes();
64  MonitorElement *Occupancy_map[nTime][divisions.size()];
65  MonitorElement *Energy[nType1], *Time_weighteden[nType1];
66  MonitorElement *HitEnergyvsieta[divisions.size()], *HitTimevsieta[divisions.size()];
67 
68  std::string time[nTime] = {"25", "50", "100", "250"};
69  std::string detdivision[nType1] = {"HB", "HE", "HF", "HO"};
70  char name[40], name1[40], name2[40], name3[40], name4[40];
71 
72  for (int k = 0; k < nType1; k++) {
73  Energy[k] = nullptr;
74  Time_weighteden[k] = nullptr;
75  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
76  sprintf(name1, "Energy_%s", detdivision[k].c_str());
77  sprintf(name2, "Time_Enweighted_%s", detdivision[k].c_str());
78  if (strcmp(hcalMEs[ih]->getName().c_str(), name1) == 0) {
79  Energy[k] = hcalMEs[ih];
80  }
81  if (strcmp(hcalMEs[ih]->getName().c_str(), name2) == 0) {
82  Time_weighteden[k] = hcalMEs[ih];
83  }
84  }
85  }
86 
87  for (int i = 0; i < nTime; i++) {
88  for (unsigned int j = 0; j < divisions.size(); j++) {
89  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
90  sprintf(name, "HcalHitE%s%s", time[i].c_str(), divisions[j].c_str());
91  if (strcmp(hcalMEs[ih]->getName().c_str(), name) == 0) {
92  Occupancy_map[i][j] = hcalMEs[ih];
93  }
94  }
95  }
96  }
97 
98  for (unsigned int k = 0; k < divisions.size(); k++) {
99  HitEnergyvsieta[k] = nullptr;
100  HitTimevsieta[k] = nullptr;
101  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
102  sprintf(name3, "HcalHitEta%s", divisions[k].c_str());
103  sprintf(name4, "HcalHitTimeAEta%s", divisions[k].c_str());
104  if (strcmp(hcalMEs[ih]->getName().c_str(), name3) == 0) {
105  HitEnergyvsieta[k] = hcalMEs[ih];
106  }
107  if (strcmp(hcalMEs[ih]->getName().c_str(), name4) == 0) {
108  HitTimevsieta[k] = hcalMEs[ih];
109  }
110  }
111  }
112 
113  // mean energy
114 
115  double nevent = Energy[0]->getEntries();
116  if (verbose_)
117  edm::LogVerbatim("HitsValidationHcal") << "nevent : " << nevent;
118 
119  float cont[nTime][divisions.size()];
120  float en[nType1], tme[nType1];
121  float hitenergy[divisions.size()], hittime[divisions.size()];
122  float fev = float(nevent);
123 
124  for (int dettype = 0; dettype < nType1; dettype++) {
125  int nx1 = Energy[dettype]->getNbinsX();
126  for (int i = 0; i <= nx1; i++) {
127  en[dettype] = Energy[dettype]->getBinContent(i) / fev;
128  Energy[dettype]->setBinContent(i, en[dettype]);
129  }
130  int nx2 = Time_weighteden[dettype]->getNbinsX();
131  for (int i = 0; i <= nx2; i++) {
132  tme[dettype] = Time_weighteden[dettype]->getBinContent(i) / fev;
133  Time_weighteden[dettype]->setBinContent(i, tme[dettype]);
134  }
135  }
136 
137  for (unsigned int dettype = 0; dettype < divisions.size(); dettype++) {
138  int nx1 = HitEnergyvsieta[dettype]->getNbinsX();
139  for (int i = 0; i <= nx1; i++) {
140  hitenergy[dettype] = HitEnergyvsieta[dettype]->getBinContent(i) / fev;
141  HitEnergyvsieta[dettype]->setBinContent(i, hitenergy[dettype]);
142  }
143  int nx2 = HitTimevsieta[dettype]->getNbinsX();
144  for (int i = 0; i <= nx2; i++) {
145  hittime[dettype] = HitTimevsieta[dettype]->getBinContent(i) / fev;
146  HitTimevsieta[dettype]->setBinContent(i, hittime[dettype]);
147  }
148  }
149 
150  for (int itime = 0; itime < nTime; itime++) {
151  for (unsigned int det = 0; det < divisions.size(); det++) {
152  int ny = Occupancy_map[itime][det]->getNbinsY();
153  int nx = Occupancy_map[itime][det]->getNbinsX();
154  for (int i = 1; i < nx + 1; i++) {
155  for (int j = 1; j < ny + 1; j++) {
156  cont[itime][det] = Occupancy_map[itime][det]->getBinContent(i, j) / fev;
157  Occupancy_map[itime][det]->setBinContent(i, j, cont[itime][det]);
158  }
159  }
160  }
161  }
162 
163  return 1;
164 }
165 
166 std::vector<std::string> HcalSimHitsClient::getHistogramTypes() {
168  if (verbose_)
169  edm::LogVerbatim("HitsValidationHcal") << "Max depth 1st step:: " << maxDepth;
171  if (verbose_)
172  edm::LogVerbatim("HitsValidationHcal") << "Max depth 2nd step:: " << maxDepth;
174  if (verbose_)
175  edm::LogVerbatim("HitsValidationHcal") << "Max depth 3rd step:: " << maxDepth;
176  std::vector<std::string> divisions;
177  char name1[20];
178 
179  // first overall Hcal
180  for (int depth = 0; depth < maxDepth; ++depth) {
181  sprintf(name1, "HC%d", depth);
182  divisions.push_back(std::string(name1));
183  }
184  // HB
185  for (int depth = 0; depth < maxDepthHB_; ++depth) {
186  sprintf(name1, "HB%d", depth);
187  divisions.push_back(std::string(name1));
188  }
189  // HE
190  for (int depth = 0; depth < maxDepthHE_; ++depth) {
191  sprintf(name1, "HE%d+z", depth);
192  divisions.push_back(std::string(name1));
193  sprintf(name1, "HE%d-z", depth);
194  divisions.push_back(std::string(name1));
195  }
196  // HO
197  {
198  int depth = maxDepthHO_;
199  sprintf(name1, "HO%d", depth);
200  divisions.push_back(std::string(name1));
201  }
202  // HF (first absorber, then different types of abnormal hits)
203  std::string hfty1[4] = {"A", "W", "B", "J"};
204  for (int k = 0; k < 4; ++k) {
205  for (int depth = 0; depth < maxDepthHF_; ++depth) {
206  sprintf(name1, "HF%s%d+z", hfty1[k].c_str(), depth);
207  divisions.push_back(std::string(name1));
208  sprintf(name1, "HF%s%d-z", hfty1[k].c_str(), depth);
209  divisions.push_back(std::string(name1));
210  }
211  }
212  return divisions;
213 }
214 
Log< level::Info, true > LogVerbatim
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void beginRun(edm::Run const &run, edm::EventSetup const &c) override
int SimHitsEndjob(const std::vector< MonitorElement *> &hcalMEs)
static const int nType1
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
const edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_HRNDC_
std::vector< std::string > getHistogramTypes()
int nevent
Definition: AMPTWrapper.h:84
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
const HcalDDDRecConstants * hcons
Transition
Definition: Transition.h:12
const std::string dirName_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual void runClient_(DQMStore::IBooker &, DQMStore::IGetter &)
int getMaxDepth(const int &type) const
virtual int getNbinsY() const
get # of bins in Y-axis
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
static const int nTime
HLT enums.
HcalSimHitsClient(const edm::ParameterSet &)
std::string getName(const G4String &)
Definition: ForwardName.cc:3
virtual int getNbinsX() const
get # of bins in X-axis
Log< level::Warning, false > LogWarning
cont
load Luminosity info ##
Definition: generateEDF.py:620
Definition: Run.h:45
ib
Definition: cuy.py:661
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:625
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:739