CMS 3D CMS Logo

HGCalRecHitsClient.cc
Go to the documentation of this file.
7 
10 
16 
18 
19  verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
20  nameDetector_ = iConfig.getParameter<std::string>("DetectorName");
21 }
22 
24 
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(true);
36  }
37 }
38 
40  runClient_(ib, ig);
41 }
42 
44 
45  ig.setCurrentFolder("/");
46  if (verbosity_>0) edm::LogInfo("HGCalValidation") << "\nrunClient";
47  std::vector<MonitorElement*> hgcalMEs;
48  std::vector<std::string> fullDirPath = ig.getSubdirs();
49 
50  for (unsigned int i=0; i<fullDirPath.size(); i++) {
51  if (verbosity_>0)
52  edm::LogInfo("HGCalValidation") << "\nfullPath: " << fullDirPath.at(i);
53  ig.setCurrentFolder(fullDirPath.at(i));
54  std::vector<std::string> fullSubDirPath = ig.getSubdirs();
55 
56  for (unsigned int j=0; j<fullSubDirPath.size(); j++) {
57  if (verbosity_>1)
58  edm::LogInfo("HGCalValidation") << "fullSubPath: " << fullSubDirPath.at(j);
59  std::string nameDirectory = "HGCalRecHitsV/"+nameDetector_;
60  if (strcmp(fullSubDirPath.at(j).c_str(), nameDirectory.c_str()) == 0) {
61  hgcalMEs = ig.getContents(fullSubDirPath.at(j));
62  if (verbosity_>1)
63  edm::LogInfo("HGCalValidation") << "hgcalMES size : " << hgcalMEs.size();
64  if (!recHitsEndjob(hgcalMEs))
65  edm::LogWarning("HGCalValidation") << "\nError in RecHitsEndjob!";
66  }
67  }
68 
69  }
70 }
71 
72 int HGCalRecHitsClient::recHitsEndjob(const std::vector<MonitorElement*>& hgcalMEs) {
73  std::vector<MonitorElement*> energy_;
74  std::vector<MonitorElement*> EtaPhi_Plus_;
75  std::vector<MonitorElement*> EtaPhi_Minus_;
76  std::vector<MonitorElement*> HitOccupancy_Plus_;
77  std::vector<MonitorElement*> HitOccupancy_Minus_;
78  std::vector<MonitorElement*> MeanHitOccupancy_Plus_;
79  std::vector<MonitorElement*> MeanHitOccupancy_Minus_;
80 
81  std::ostringstream name;
82  double nevent;
83  int nbinsx, nbinsy;
84 
85  for (unsigned int ilayer = 0; ilayer < layers_; ilayer++ ){
86  name.str(""); name << "energy_layer_" << ilayer;
87  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
88  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
89  energy_.push_back(hgcalMEs[ih]);
90  }
91  }
92 
93  //normalization
94  nevent = energy_.at(ilayer)->getEntries();
95  nbinsx = energy_.at(ilayer)->getNbinsX();
96  for(int i=1; i <= nbinsx; i++) {
97  double binValue = energy_.at(ilayer)->getBinContent(i)/nevent;
98  energy_.at(ilayer)->setBinContent(i,binValue);
99  }
100 
101  //EtaPhi 2d plots
102  name.str(""); name << "EtaPhi_Plus_" << "layer_" << ilayer;
103  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
104  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
105  EtaPhi_Plus_.push_back(hgcalMEs[ih]);
106  }
107  }
108 
109  name.str(""); name << "EtaPhi_Minus_" << "layer_" << ilayer;
110  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
111  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
112  EtaPhi_Minus_.push_back(hgcalMEs[ih]);
113  }
114  }
115 
116  //normalization EtaPhi
117  nevent = EtaPhi_Plus_.at(ilayer)->getEntries();
118  nbinsx = EtaPhi_Plus_.at(ilayer)->getNbinsX();
119  nbinsy = EtaPhi_Plus_.at(ilayer)->getNbinsY();
120  for(int i=1; i<= nbinsx; ++i) {
121  for(int j=1; j<= nbinsy; ++j) {
122  double binValue = EtaPhi_Plus_.at(ilayer)->getBinContent(i, j)/nevent;
123  EtaPhi_Plus_.at(ilayer)->setBinContent(i, j, binValue);
124  }
125  }
126 
127  nevent = EtaPhi_Minus_.at(ilayer)->getEntries();
128  nbinsx = EtaPhi_Minus_.at(ilayer)->getNbinsX();
129  nbinsy = EtaPhi_Plus_.at(ilayer)->getNbinsY();
130  for(int i=1; i<= nbinsx; ++i) {
131  for(int j=1; j<= nbinsy; ++j) {
132  double binValue = EtaPhi_Minus_.at(ilayer)->getBinContent(i, j)/nevent;
133  EtaPhi_Minus_.at(ilayer)->setBinContent(i, j, binValue);
134  }
135  }
136 
137  //HitOccupancy
138  name.str(""); name << "HitOccupancy_Plus_layer_" << ilayer;
139  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
140  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
141  HitOccupancy_Plus_.push_back(hgcalMEs[ih]);
142  }
143  }
144 
145  name.str(""); name << "HitOccupancy_Minus_layer_" << ilayer;
146  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
147  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
148  HitOccupancy_Minus_.push_back(hgcalMEs[ih]);
149  }
150  }
151 
152  //normalization of hit occupancy histos
153  nevent = HitOccupancy_Plus_.at(ilayer)->getEntries();
154  nbinsx = HitOccupancy_Plus_.at(ilayer)->getNbinsX();
155  for(int i=1; i<= nbinsx; ++i) {
156  double binValue = HitOccupancy_Plus_.at(ilayer)->getBinContent(i)/nevent;
157  HitOccupancy_Plus_.at(ilayer)->setBinContent(i, binValue);
158  }
159 
160  nevent = HitOccupancy_Minus_.at(ilayer)->getEntries();
161  nbinsx = HitOccupancy_Minus_.at(ilayer)->getNbinsX();
162  for(int i=1; i<= nbinsx; ++i) {
163  double binValue = HitOccupancy_Minus_.at(ilayer)->getBinContent(i)/nevent;
164  HitOccupancy_Minus_.at(ilayer)->setBinContent(i, binValue);
165  }
166 
167  }//loop over layers
168 
169  name.str(""); name << "SUMOfRecHitOccupancy_Plus";
170  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
171  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
172  MeanHitOccupancy_Plus_.push_back(hgcalMEs[ih]);
173  unsigned int indx = MeanHitOccupancy_Plus_.size()-1;
174  for (int ilayer=0; ilayer < (int)layers_; ++ilayer) {
175  double meanVal = HitOccupancy_Plus_.at(ilayer)->getMean();
176  MeanHitOccupancy_Plus_[indx]->setBinContent(ilayer+1, meanVal);
177  }
178  break;
179  }
180  }
181 
182  name.str(""); name << "SUMOfRecHitOccupancy_Plus";
183  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
184  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
185  MeanHitOccupancy_Minus_.push_back(hgcalMEs[ih]);
186  unsigned indx = MeanHitOccupancy_Minus_.size()-1;
187  for (int ilayer=0; ilayer < (int)layers_; ++ilayer) {
188  double meanVal = HitOccupancy_Minus_.at(ilayer)->getMean();
189  MeanHitOccupancy_Minus_[indx]->setBinContent(ilayer+1, meanVal);
190  }
191  break;
192  }
193  }
194 
195  return 1;
196 }
197 
199 
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 recHitsEndjob(const std::vector< MonitorElement * > &hcalMEs)
void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig)
#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
HGCalRecHitsClient(const edm::ParameterSet &)
int j
Definition: DBlmapReader.cc:9
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
const T & get() const
Definition: EventSetup.h:56
virtual void runClient_(DQMStore::IBooker &ib, DQMStore::IGetter &ig)
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:323
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:347
Definition: Run.h:42
ib
Definition: cuy.py:660