CMS 3D CMS Logo

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