CMS 3D CMS Logo

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