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 
25  outputFile_ = iConfig.getUntrackedParameter<std::string > ("outputFile", "HcalDigisClient.root");
26  dirName_ = iConfig.getParameter<std::string > ("DQMDirName");
27  if (!dbe_) edm::LogError("HcalDigisClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
28  msm_ = new std::map<std::string, MonitorElement*>();
29  //if (iConfig.getUntrackedParameter<bool>("DQMStore", false)) if (dbe_) dbe_->setVerbose(0);
30 
31  // std::cout << "dirName: " << dirName_ << std::endl;
32  //dbe_->setCurrentFolder(dirName_);
33  dbe_->setCurrentFolder("HcalDigisV/HcalDigiTask");
34 
35  booking("HB");
36  booking("HE");
37  booking("HO");
38  booking("HF");
39 }
40 
42  using namespace edm;
43 
44 
45 }
46 
48 
49  std::string strtmp;
50  HistLim ietaLim(82, -41., 41.);
51 
52  for (int depth = 1; depth <= 4; depth++) {
53  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth" + str(depth) + "_" + subdetopt;
54  book1D(strtmp, ietaLim);
55  }
56 
57 }
58 
60  if (!dbe_) return; //we dont have the DQMStore so we cant do anything
62  std::vector<MonitorElement*> hcalMEs;
63  // Since out folders are fixed to three, we can just go over these three folders
64  // i.e., CaloTowersV/CaloTowersTask, HcalRecHitsV/HcalRecHitTask, NoiseRatesV/NoiseRatesTask.
65  std::vector<std::string> fullPathHLTFolders = dbe_->getSubdirs();
66  for (unsigned int i = 0; i < fullPathHLTFolders.size(); i++) {
67  dbe_->setCurrentFolder(fullPathHLTFolders[i]);
68  std::vector<std::string> fullSubPathHLTFolders = dbe_->getSubdirs();
69  for (unsigned int j = 0; j < fullSubPathHLTFolders.size(); j++) {
70  if (strcmp(fullSubPathHLTFolders[j].c_str(), "HcalDigisV/HcalDigiTask") == 0) {
71  hcalMEs = dbe_->getContents(fullSubPathHLTFolders[j]);
72  if (!HcalDigisEndjob(hcalMEs, "HB"))
73  edm::LogError("HcalDigisClient") << "Error in HcalDigisEndjob! HB";
74  if (!HcalDigisEndjob(hcalMEs, "HE"))
75  edm::LogError("HcalDigisClient") << "Error in HcalDigisEndjob! HE";
76  if (!HcalDigisEndjob(hcalMEs, "HO"))
77  edm::LogError("HcalDigisClient") << "Error in HcalDigisEndjob! HO";
78  if (!HcalDigisEndjob(hcalMEs, "HF"))
79  edm::LogError("HcalDigisClient") << "Error in HcalDigisEndjob! HF"; }
80  }
81  }
82 }
83 
84 int HcalDigisClient::HcalDigisEndjob(const std::vector<MonitorElement*> &hcalMEs, std::string subdet_) {
85 
86  using namespace std;
87  string strtmp;
88 
89 
90  MonitorElement * nevtot(0);
91  MonitorElement * ieta_iphi_occupancy_map1(0);
92  MonitorElement * ieta_iphi_occupancy_map2(0);
93  MonitorElement * ieta_iphi_occupancy_map3(0);
94  MonitorElement * ieta_iphi_occupancy_map4(0);
95 
96 
97  std::cout << " Number of histos " << hcalMEs.size() << std::endl;
98 
99  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
100  if (hcalMEs[ih]->getName() == "nevtot") nevtot = hcalMEs[ih];
101 
102  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth1_" + subdet_;
103  if (hcalMEs[ih]->getName() == strtmp) ieta_iphi_occupancy_map1 = hcalMEs[ih];
104  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth2_" + subdet_;
105  if (hcalMEs[ih]->getName() == strtmp) ieta_iphi_occupancy_map2 = hcalMEs[ih];
106  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth3_" + subdet_;
107  if (hcalMEs[ih]->getName() == strtmp) ieta_iphi_occupancy_map3 = hcalMEs[ih];
108  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth4_" + subdet_;
109  if (hcalMEs[ih]->getName() == strtmp) ieta_iphi_occupancy_map4 = hcalMEs[ih];
110 
111  }//
112 
113  if (nevtot == 0 ||
114  ieta_iphi_occupancy_map1 == 0 ||
115  ieta_iphi_occupancy_map2 == 0 ||
116  ieta_iphi_occupancy_map3 == 0 ||
117  ieta_iphi_occupancy_map4 == 0
118  ) {
119  edm::LogError("HcalDigisClient") << "No nevtot or maps histo found...";
120  return 0;
121  }
122 
123  int ev = nevtot->getEntries();
124  if(ev <= 0) {
125  edm::LogError("HcalDigisClient") << "normalization factor <= 0!";
126  return 0;
127  }
128 
129  float fev = (float) nevtot->getEntries();
130 
131  int nx = ieta_iphi_occupancy_map1->getNbinsX();
132  int ny = ieta_iphi_occupancy_map1->getNbinsY();
133  float sumphi_1, sumphi_2, sumphi_3, sumphi_4;
134  float phi_factor;
135  float cnorm;
136 
137  for (int i = 1; i <= nx; i++) {
138  sumphi_1 = 0.;
139  sumphi_2 = 0.;
140  sumphi_3 = 0.;
141  sumphi_4 = 0.;
142 
143  for (int j = 1; j <= ny; j++) {
144 
145  // occupancies
146 
147  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth1_" + subdet_;
148  cnorm = ieta_iphi_occupancy_map1->getBinContent(i, j) / fev;
149  ieta_iphi_occupancy_map1->setBinContent(i, j, cnorm);
150  sumphi_1 += ieta_iphi_occupancy_map1->getBinContent(i, j);
151 
152  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth2_" + subdet_;
153  cnorm = ieta_iphi_occupancy_map2->getBinContent(i, j) / fev;
154  ieta_iphi_occupancy_map2->setBinContent(i, j, cnorm);
155  sumphi_2 += ieta_iphi_occupancy_map2->getBinContent(i, j);
156 
157  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth3_" + subdet_;
158  cnorm = ieta_iphi_occupancy_map3->getBinContent(i, j) / fev;
159  ieta_iphi_occupancy_map3->setBinContent(i, j, cnorm);
160  sumphi_3 += ieta_iphi_occupancy_map3->getBinContent(i, j);
161 
162  strtmp = "HcalDigiTask_ieta_iphi_occupancy_map_depth4_" + subdet_;
163  cnorm = ieta_iphi_occupancy_map4->getBinContent(i, j) / fev;
164  ieta_iphi_occupancy_map4->setBinContent(i, j, cnorm);
165  sumphi_4 += ieta_iphi_occupancy_map4->getBinContent(i, j);
166 
167  }
168 
169  int ieta = i - 42; // -41 -1, 0 40
170  if (ieta >= 0) ieta += 1; // -41 -1, 1 41 - to make it detector-like
171 
172  if (ieta >= -20 && ieta <= 20) {
173  phi_factor = 72.;
174  } else {
175  if (ieta >= 40 || ieta <= -40)
176  phi_factor = 18.;
177  else
178  phi_factor = 36.;
179  }
180 
181  if (ieta >= 0) ieta -= 1; // -41 -1, 0 40 - to bring back to strtmp num !!!
182  double deta = double(ieta);
183 
184  // occupancies vs ieta
185  cnorm = sumphi_1 / phi_factor;
186  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth1_" + subdet_;
187  fill1D(strtmp, deta, cnorm);
188 
189  cnorm = sumphi_2 / phi_factor;
190  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth2_" + subdet_;
191  fill1D(strtmp, deta, cnorm);
192 
193  cnorm = sumphi_3 / phi_factor;
194  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth3_" + subdet_;
195  fill1D(strtmp, deta, cnorm);
196 
197  cnorm = sumphi_4 / phi_factor;
198  strtmp = "HcalDigiTask_occupancy_vs_ieta_depth4_" + subdet_;
199  fill1D(strtmp, deta, cnorm);
200 
201  } // end of i-loop
202 
203  return 1;
204 }
205 
207  if (!msm_->count(name)) return NULL;
208  else return msm_->find(name)->second;
209 }
210 
212  std::stringstream out;
213  out << x;
214  return out.str();
215 }
216 
217 double HcalDigisClient::integralMETH2D(MonitorElement* ME, int i0, int i1, int j0, int j1) {
218  double sum(0);
219  for (int i = i0; i <= i1; i++) {
220  for (int j = j0; j <= j1; j++) {
221  sum += ME->getBinContent(i, j);
222  }
223  }
224 
225  return sum;
226 }
227 
229  int nx = ME->getNbinsX();
230  int ny = ME->getNbinsY();
231 
232  double content(0);
233  for (int i = 1; i <= nx; i++) {
234  for (int j = 1; j <= ny; j++) {
235  content = ME->getBinContent(i, j);
236  content *= s;
237  ME->setBinContent(i, j, content);
238  }
239  }
240 }
241 
242 //define this as a plug-in
244 
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)
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1644
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::string dirName_
void scaleMETH2D(MonitorElement *ME, double s)
#define NULL
Definition: scimark2.h:8
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)
int iEvent
Definition: GenABIO.cc:230
void booking(std::string subdetopt)
void book1D(std::string name, int n, double min, double max)
MonitorElement * monitor(std::string name)
int j
Definition: DBlmapReader.cc:9
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1722
std::string str(int x)
tuple out
Definition: dbtoconf.py:99
std::map< std::string, MonitorElement * > * msm_
double integralMETH2D(MonitorElement *ME, int i0, int i1, int j0, int j1)
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
virtual void runClient()
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655