CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCalSimHitsClient.cc
Go to the documentation of this file.
9 
16 
18  nameDetector_ = iConfig.getParameter<std::string>("DetectorName");
19  verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
20 }
21 
23 
25 
26  if (nameDetector_ == "HCal") {
28  iSetup.get<HcalRecNumberingRecord>().get( pHRNDC );
29  const HcalDDDRecConstants *hcons = &(*pHRNDC);
30  layers_ = hcons->getMaxDepth(1);
31  } else {
33  iSetup.get<IdealGeometryRecord>().get(nameDetector_, pHGDC);
34  const HGCalDDDConstants & hgcons = (*pHGDC);
35  layers_ = hgcons.layers(false);
36  }
37  if (verbosity_>0)
38  edm::LogInfo("HGCalValidation") << "Initialize HGCalSimHitsClient for "
39  << nameDetector_ << " : " << layers_;
40 }
41 
43  runClient_(ib, ig);
44 }
45 
47 
48  ig.setCurrentFolder("/");
49  if (verbosity_>0) edm::LogInfo("HGCalValidation") << "\nrunClient";
50  std::vector<MonitorElement*> hgcalMEs;
51  std::vector<std::string> fullDirPath = ig.getSubdirs();
52 
53  for (unsigned int i=0; i<fullDirPath.size(); i++) {
54  if (verbosity_>0)
55  edm::LogInfo("HGCalValidation") << "\nfullPath: " << fullDirPath.at(i);
56  ig.setCurrentFolder(fullDirPath.at(i));
57  std::vector<std::string> fullSubDirPath = ig.getSubdirs();
58 
59  for (unsigned int j=0; j<fullSubDirPath.size(); j++) {
60  if (verbosity_>0)
61  edm::LogInfo("HGCalValidation") << "fullSubPath: " << fullSubDirPath.at(j);
62  std::string nameDirectory = "HGCalSimHitsV/"+nameDetector_;
63 
64  if (strcmp(fullSubDirPath.at(j).c_str(), nameDirectory.c_str()) == 0) {
65  hgcalMEs = ig.getContents(fullSubDirPath.at(j));
66  if (verbosity_>0)
67  edm::LogInfo("HGCalValidation") << "hgcalMES size : " << hgcalMEs.size();
68  if (!simHitsEndjob(hgcalMEs))
69  edm::LogWarning("HGCalValidation") << "\nError in SimhitsEndjob!";
70  }
71  }
72  }
73 }
74 
75 int HGCalSimHitsClient::simHitsEndjob(const std::vector<MonitorElement*>& hgcalMEs) {
76 
77  std::vector<MonitorElement*> energy_[6];
78  std::vector<MonitorElement*> EtaPhi_Plus_;
79  std::vector<MonitorElement*> EtaPhi_Minus_;
80  std::vector<MonitorElement*> HitOccupancy_Plus_[4];
81  std::vector<MonitorElement*> HitOccupancy_Minus_[4];
82  std::vector<MonitorElement*> MeanHitOccupancy_Plus_;
83  std::vector<MonitorElement*> MeanHitOccupancy_Minus_;
84 
85  std::ostringstream name;
86  double nevent;
87  int nbinsx, nbinsy;
88  for (unsigned int ilayer = 0; ilayer < layers_; ilayer++ ){
89  for (int itimeslice = 0; itimeslice < 6 ; itimeslice++ ) {
90  //Energy
91  name.str(""); name << "energy_time_" << itimeslice << "_layer_" << ilayer;
92  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
93  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
94  energy_[itimeslice].push_back(hgcalMEs[ih]);
95  }
96  }
97  //normalization
98  nevent = energy_[itimeslice].at(ilayer)->getEntries();
99  nbinsx = energy_[itimeslice].at(ilayer)->getNbinsX();
100  for(int i=1; i <= nbinsx; i++) {
101  double binValue = energy_[itimeslice].at(ilayer)->getBinContent(i)/nevent;
102  energy_[itimeslice].at(ilayer)->setBinContent(i,binValue);
103  }
104  }
105 
106  //EtaPhi 2d plots
107  name.str(""); name << "EtaPhi_Plus_" << "layer_" << ilayer;
108  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
109  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
110  EtaPhi_Plus_.push_back(hgcalMEs[ih]);
111  }
112  }
113 
114  name.str(""); name << "EtaPhi_Minus_" << "layer_" << ilayer;
115  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
116  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
117  EtaPhi_Minus_.push_back(hgcalMEs[ih]);
118  }
119  }
120  //normalization EtaPhi
121  nevent = EtaPhi_Plus_.at(ilayer)->getEntries();
122  nbinsx = EtaPhi_Plus_.at(ilayer)->getNbinsX();
123  nbinsy = EtaPhi_Plus_.at(ilayer)->getNbinsY();
124  for(int i=1; i<= nbinsx; ++i) {
125  for(int j=1; j<= nbinsy; ++j) {
126  double binValue = EtaPhi_Plus_.at(ilayer)->getBinContent(i, j)/nevent;
127  EtaPhi_Plus_.at(ilayer)->setBinContent(i, j, binValue);
128  }
129  }
130 
131  nevent = EtaPhi_Minus_.at(ilayer)->getEntries();
132  nbinsx = EtaPhi_Minus_.at(ilayer)->getNbinsX();
133  nbinsy = EtaPhi_Plus_.at(ilayer)->getNbinsY();
134  for(int i=1; i<= nbinsx; ++i) {
135  for(int j=1; j<= nbinsy; ++j) {
136  double binValue = EtaPhi_Minus_.at(ilayer)->getBinContent(i, j)/nevent;
137  EtaPhi_Minus_.at(ilayer)->setBinContent(i, j, binValue);
138  }
139  }
140 
141  //HitOccupancy
142  for(int indx=0; indx<4; ++indx){
143  name.str(""); name << "HitOccupancy_Plus"<< indx << "_layer_" << ilayer;
144  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
145  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
146  HitOccupancy_Plus_[indx].push_back(hgcalMEs[ih]);
147  }
148  }
149 
150  name.str(""); name << "HitOccupancy_Minus"<< indx << "_layer_" << ilayer;
151  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
152  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
153  HitOccupancy_Minus_[indx].push_back(hgcalMEs[ih]);
154  }
155  }
156  }
157  for(int indx=0; indx<4; ++indx){
158  nevent = HitOccupancy_Plus_[indx].at(ilayer)->getEntries();
159  nbinsx = HitOccupancy_Plus_[indx].at(ilayer)->getNbinsX();
160  for(int i=1; i<= nbinsx; ++i) {
161  double binValue = HitOccupancy_Plus_[indx].at(ilayer)->getBinContent(i)/nevent;
162  HitOccupancy_Plus_[indx].at(ilayer)->setBinContent(i, binValue);
163  }
164 
165  nevent = HitOccupancy_Minus_[indx].at(ilayer)->getEntries();
166  nbinsx = HitOccupancy_Minus_[indx].at(ilayer)->getNbinsX();
167  for(int i=1; i<= nbinsx; ++i) {
168  double binValue = HitOccupancy_Minus_[indx].at(ilayer)->getBinContent(i)/nevent;
169  HitOccupancy_Minus_[indx].at(ilayer)->setBinContent(i, binValue);
170  }
171 
172  }
173 
174  }//loop over layers
175 
176  for(int indx=0; indx<4; ++indx) {
177  name.str(""); name << "MeanHitOccupancy_Plus"<< indx ;
178  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
179  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
180  MeanHitOccupancy_Plus_.push_back(hgcalMEs[ih]);
181  unsigned int ind = MeanHitOccupancy_Plus_.size()-1;
182  for(int ilayer=0; ilayer < (int)layers_; ++ilayer) {
183  double meanVal = HitOccupancy_Plus_[indx].at(ilayer)->getMean();
184  MeanHitOccupancy_Plus_[ind]->setBinContent(ilayer+1, meanVal);
185  }
186  break;
187  }
188  }
189 
190  name.str(""); name << "MeanHitOccupancy_Minus"<< indx ;
191  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
192  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
193  MeanHitOccupancy_Minus_.push_back(hgcalMEs[ih]);
194  unsigned int ind = MeanHitOccupancy_Minus_.size()-1;
195  for(int ilayer=0; ilayer < (int)layers_; ++ilayer) {
196  double meanVal = HitOccupancy_Minus_[indx].at(ilayer)->getMean();
197  MeanHitOccupancy_Minus_[ind]->setBinContent(ilayer+1, meanVal);
198  }
199  break;
200  }
201  }
202  }
203 
204  return 1;
205 }
206 
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
int ib
Definition: cuy.py:660
virtual void runClient_(DQMStore::IBooker &ib, DQMStore::IGetter &ig)
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int nevent
Definition: AMPTWrapper.h:74
int getMaxDepth(const int type) const
unsigned int layers(bool reco) const
int j
Definition: DBlmapReader.cc:9
HGCalSimHitsClient(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:56
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:322
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:346
int simHitsEndjob(const std::vector< MonitorElement * > &hcalMEs)
void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig)
Definition: Run.h:43