CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDigisClient.cc
Go to the documentation of this file.
2 // -*- C++ -*-
3 //
4 // Package: HcalDigisClient
5 // Class: HcalDigisClient
6 //
14 //
15 // Original Author: Ali Fahim,22 R-013,+41227672649,
16 // Created: Wed Mar 23 22:54:28 CET 2011
17 //
18 //
19 
20 
21 // system include files
22 
24  outputFile_ = iConfig.getUntrackedParameter<std::string > ("outputFile", "HcalDigisClient.root");
25  dirName_ = iConfig.getParameter<std::string > ("DQMDirName");
26  msm_ = new std::map<std::string, MonitorElement*>();
27 
28 
29 }
30 
31 
33 
34  std::string strtmp;
35  HistLim ietaLim(82, -41., 41.);
36 
37  for (int depth = 1; depth <= 4; depth++) {
38  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth" + str(depth) + "_" + subdetopt;
39  book1D(ib,strtmp, ietaLim);
40  }
41 
42 }
43 
46  std::vector<MonitorElement*> hcalMEs;
47  // Since out folders are fixed to three, we can just go over these three folders
48  // i.e., CaloTowersV/CaloTowersTask, HcalRecHitsV/HcalRecHitTask, NoiseRatesV/NoiseRatesTask.
49  std::vector<std::string> fullPathHLTFolders = ig.getSubdirs();
50  for (unsigned int i = 0; i < fullPathHLTFolders.size(); i++) {
51  ig.setCurrentFolder(fullPathHLTFolders[i]);
52  std::vector<std::string> fullSubPathHLTFolders = ig.getSubdirs();
53  for (unsigned int j = 0; j < fullSubPathHLTFolders.size(); j++) {
54  if (strcmp(fullSubPathHLTFolders[j].c_str(), "HcalDigisV/HcalDigiTask") == 0) {
55  hcalMEs = ig.getContents(fullSubPathHLTFolders[j]);
56  if (!HcalDigisEndjob(hcalMEs, "HB"))
57  edm::LogError("HcalDigisClient") << "Error in HcalDigisEndjob! HB";
58  if (!HcalDigisEndjob(hcalMEs, "HE"))
59  edm::LogError("HcalDigisClient") << "Error in HcalDigisEndjob! HE";
60  if (!HcalDigisEndjob(hcalMEs, "HO"))
61  edm::LogError("HcalDigisClient") << "Error in HcalDigisEndjob! HO";
62  if (!HcalDigisEndjob(hcalMEs, "HF"))
63  edm::LogError("HcalDigisClient") << "Error in HcalDigisEndjob! HF"; }
64  }
65  }
66 }
67 
68 int HcalDigisClient::HcalDigisEndjob(const std::vector<MonitorElement*> &hcalMEs, std::string subdet_) {
69 
70  using namespace std;
71  string strtmp;
72 
73 
74  MonitorElement * nevtot(0);
75  MonitorElement * ieta_iphi_occupancy_map1(0);
76  MonitorElement * ieta_iphi_occupancy_map2(0);
77  MonitorElement * ieta_iphi_occupancy_map3(0);
78  MonitorElement * ieta_iphi_occupancy_map4(0);
79 
80 
81  std::cout << " Number of histos " << hcalMEs.size() << std::endl;
82 
83  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
84  if (hcalMEs[ih]->getName() == "nevtot") nevtot = hcalMEs[ih];
85 
86  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth1_" + subdet_;
87  if (hcalMEs[ih]->getName() == strtmp) ieta_iphi_occupancy_map1 = hcalMEs[ih];
88  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth2_" + subdet_;
89  if (hcalMEs[ih]->getName() == strtmp) ieta_iphi_occupancy_map2 = hcalMEs[ih];
90  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth3_" + subdet_;
91  if (hcalMEs[ih]->getName() == strtmp) ieta_iphi_occupancy_map3 = hcalMEs[ih];
92  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth4_" + subdet_;
93  if (hcalMEs[ih]->getName() == strtmp) ieta_iphi_occupancy_map4 = hcalMEs[ih];
94 
95  }//
96 
97  if (nevtot == 0 ||
98  ieta_iphi_occupancy_map1 == 0 ||
99  ieta_iphi_occupancy_map2 == 0 ||
100  ieta_iphi_occupancy_map3 == 0 ||
101  ieta_iphi_occupancy_map4 == 0
102  ) {
103  edm::LogError("HcalDigisClient") << "No nevtot or maps histo found...";
104  return 0;
105  }
106 
107  int ev = nevtot->getEntries();
108  if(ev <= 0) {
109  edm::LogError("HcalDigisClient") << "normalization factor <= 0!";
110  return 0;
111  }
112 
113  float fev = (float) nevtot->getEntries();
114 
115  int nx = ieta_iphi_occupancy_map1->getNbinsX();
116  int ny = ieta_iphi_occupancy_map1->getNbinsY();
117  float sumphi_1, sumphi_2, sumphi_3, sumphi_4;
118  float phi_factor;
119  float cnorm;
120 
121  for (int i = 1; i <= nx; i++) {
122  sumphi_1 = 0.;
123  sumphi_2 = 0.;
124  sumphi_3 = 0.;
125  sumphi_4 = 0.;
126 
127  for (int j = 1; j <= ny; j++) {
128 
129  // occupancies
130 
131  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth1_" + subdet_;
132  cnorm = ieta_iphi_occupancy_map1->getBinContent(i, j) / fev;
133  ieta_iphi_occupancy_map1->setBinContent(i, j, cnorm);
134  sumphi_1 += ieta_iphi_occupancy_map1->getBinContent(i, j);
135 
136  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth2_" + subdet_;
137  cnorm = ieta_iphi_occupancy_map2->getBinContent(i, j) / fev;
138  ieta_iphi_occupancy_map2->setBinContent(i, j, cnorm);
139  sumphi_2 += ieta_iphi_occupancy_map2->getBinContent(i, j);
140 
141  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth3_" + subdet_;
142  cnorm = ieta_iphi_occupancy_map3->getBinContent(i, j) / fev;
143  ieta_iphi_occupancy_map3->setBinContent(i, j, cnorm);
144  sumphi_3 += ieta_iphi_occupancy_map3->getBinContent(i, j);
145 
146  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth4_" + subdet_;
147  cnorm = ieta_iphi_occupancy_map4->getBinContent(i, j) / fev;
148  ieta_iphi_occupancy_map4->setBinContent(i, j, cnorm);
149  sumphi_4 += ieta_iphi_occupancy_map4->getBinContent(i, j);
150 
151  }
152 
153  int ieta = i - 42; // -41 -1, 0 40
154  if (ieta >= 0) ieta += 1; // -41 -1, 1 41 - to make it detector-like
155 
156  if (ieta >= -20 && ieta <= 20) {
157  phi_factor = 72.;
158  } else {
159  if (ieta >= 40 || ieta <= -40)
160  phi_factor = 18.;
161  else
162  phi_factor = 36.;
163  }
164 
165  if (ieta >= 0) ieta -= 1; // -41 -1, 0 40 - to bring back to strtmp num !!!
166  double deta = double(ieta);
167 
168  // occupancies vs ieta
169  cnorm = sumphi_1 / phi_factor;
170  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth1_" + subdet_;
171  fill1D(strtmp, deta, cnorm);
172 
173  cnorm = sumphi_2 / phi_factor;
174  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth2_" + subdet_;
175  fill1D(strtmp, deta, cnorm);
176 
177  cnorm = sumphi_3 / phi_factor;
178  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth3_" + subdet_;
179  fill1D(strtmp, deta, cnorm);
180 
181  cnorm = sumphi_4 / phi_factor;
182  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth4_" + subdet_;
183  fill1D(strtmp, deta, cnorm);
184 
185  } // end of i-loop
186 
187  return 1;
188 }
189 
191  if (!msm_->count(name)) return NULL;
192  else return msm_->find(name)->second;
193 }
194 
196  std::stringstream out;
197  out << x;
198  return out.str();
199 }
200 
201 double HcalDigisClient::integralMETH2D(MonitorElement* ME, int i0, int i1, int j0, int j1) {
202  double sum(0);
203  for (int i = i0; i <= i1; i++) {
204  for (int j = j0; j <= j1; j++) {
205  sum += ME->getBinContent(i, j);
206  }
207  }
208 
209  return sum;
210 }
211 
213  int nx = ME->getNbinsX();
214  int ny = ME->getNbinsY();
215 
216  double content(0);
217  for (int i = 1; i <= nx; i++) {
218  for (int j = 1; j <= ny; j++) {
219  content = ME->getBinContent(i, j);
220  content *= s;
221  ME->setBinContent(i, j, content);
222  }
223  }
224 }
225 
226 //define this as a plug-in
228 
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::string dirName_
void scaleMETH2D(MonitorElement *ME, double s)
virtual void runClient(DQMStore::IBooker &ib, DQMStore::IGetter &ig)
#define NULL
Definition: scimark2.h:8
bool ev
int HcalDigisEndjob(const std::vector< MonitorElement * > &hcalMEs, std::string subdet_)
double getEntries(void) const
get # of entries
HcalDigisClient(const edm::ParameterSet &)
int getNbinsY(void) const
get # of bins in Y-axis
std::string outputFile_
Definition: ME.h:11
void fill1D(std::string name, double X, double weight=1)
MonitorElement * monitor(std::string name)
int j
Definition: DBlmapReader.cc:9
std::string str(int x)
void booking(DQMStore::IBooker &ib, std::string subdetopt)
tuple out
Definition: dbtoconf.py:99
void book1D(DQMStore::IBooker &ib, std::string name, int n, double min, double max)
std::map< std::string, MonitorElement * > * msm_
double integralMETH2D(MonitorElement *ME, int i0, int i1, int j0, int j1)
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:306
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:330
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:121