CMS 3D CMS Logo

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