CMS 3D CMS Logo

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