CMS 3D CMS Logo

HGCalDigiClient.cc
Go to the documentation of this file.
6 
14 
16 
17  nameDetector_ = iConfig.getParameter<std::string>("DetectorName");
18  verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
19 }
20 
22 
23 void HGCalDigiClient::beginRun(const edm::Run& run, const edm::EventSetup& iSetup) {
24 
25  if (nameDetector_ == "HCal") {
27  iSetup.get<HcalRecNumberingRecord>().get( pHRNDC );
28  const HcalDDDRecConstants *hcons = &(*pHRNDC);
29  layers_ = hcons->getMaxDepth(1);
30  } else {
32  iSetup.get<IdealGeometryRecord>().get(nameDetector_, pHGDC);
33  const HGCalDDDConstants & hgcons_ = (*pHGDC);
34  layers_ = hgcons_.layers(true);
35  }
36 }
37 
39  runClient_(ib, ig);
40 }
41 
43 
44  ig.setCurrentFolder("/");
45  if (verbosity_) edm::LogInfo("HGCalValidation") << "\nrunClient";
46  std::vector<MonitorElement*> hgcalMEs;
47  std::vector<std::string> fullDirPath = ig.getSubdirs();
48 
49  for (unsigned int i=0; i<fullDirPath.size(); i++) {
50  if (verbosity_)
51  edm::LogInfo("HGCalValidation") << "\nfullPath: " << fullDirPath.at(i);
52  ig.setCurrentFolder(fullDirPath.at(i));
53  std::vector<std::string> fullSubDirPath = ig.getSubdirs();
54 
55  for (unsigned int j=0; j<fullSubDirPath.size(); j++) {
56  if (verbosity_)
57  edm::LogInfo("HGCalValidation") << "fullSubPath: " << fullSubDirPath.at(j);
58  std::string nameDirectory = "HGCalDigiV/"+nameDetector_;
59  if (strcmp(fullSubDirPath.at(j).c_str(), nameDirectory.c_str()) == 0) {
60  hgcalMEs = ig.getContents(fullSubDirPath.at(j));
61  if (verbosity_)
62  edm::LogInfo("HGCalValidation") << "hgcalMES size : " << hgcalMEs.size();
63  if (!digisEndjob(hgcalMEs))
64  edm::LogInfo("HGCalValidation") << "\nError in DigisEndjob!";
65  }
66  }
67 
68  }
69 }
70 
71 int HGCalDigiClient::digisEndjob(const std::vector<MonitorElement*>& hgcalMEs) {
72 
73  std::vector<MonitorElement*> charge_;
74  std::vector<MonitorElement*> DigiOccupancy_XY_;
75  std::vector<MonitorElement*> ADC_;
76  std::vector<MonitorElement*> DigiOccupancy_Plus_;
77  std::vector<MonitorElement*> DigiOccupancy_Minus_;
78  std::vector<MonitorElement*> MeanDigiOccupancy_Plus_;
79  std::vector<MonitorElement*> MeanDigiOccupancy_Minus_;
80  std::ostringstream name;
81  double nevent;
82  int nbinsx, nbinsy;
83 
84  for (int ilayer = 0; ilayer < layers_; ilayer++ ){
85  //charge
86  name.str(""); name << "charge_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  charge_.push_back(hgcalMEs[ih]);
90  }
91  //normalization
92  nevent = charge_.at(ilayer)->getEntries();
93  nbinsx = charge_.at(ilayer)->getNbinsX();
94  for(int i=1; i <= nbinsx; i++) {
95  double binValue = charge_.at(ilayer)->getBinContent(i)/nevent;
96  charge_.at(ilayer)->setBinContent(i,binValue);
97  }
98 
99  //XY 2d plots
100  name.str(""); name << "DigiOccupancy_XY_" << "layer_" << ilayer;
101  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
102  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0)
103  DigiOccupancy_XY_.push_back(hgcalMEs[ih]);
104  }
105 
106  //normalization of XY 2d
107  nevent = DigiOccupancy_XY_.at(ilayer)->getEntries();
108  nbinsx = DigiOccupancy_XY_.at(ilayer)->getNbinsX();
109  nbinsy = DigiOccupancy_XY_.at(ilayer)->getNbinsY();
110  for(int i=1; i<= nbinsx; ++i) {
111  for(int j=1; j<= nbinsy; ++j) {
112  double binValue = DigiOccupancy_XY_.at(ilayer)->getBinContent(i, j)/nevent;
113  DigiOccupancy_XY_.at(ilayer)->setBinContent(i, j, binValue);
114  }
115  }
116 
117  //ADC
118  name.str(""); name << "ADC_layer_" << ilayer;
119  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
120  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0)
121  ADC_.push_back(hgcalMEs[ih]);
122  }
123 
124  //normalization of ADC Histos
125  nevent = ADC_.at(ilayer)->getEntries();
126  nbinsx = ADC_.at(ilayer)->getNbinsX();
127  for(int i=1; i<= nbinsx; ++i) {
128  double binValue = ADC_.at(ilayer)->getBinContent(i)/nevent;
129  ADC_.at(ilayer)->setBinContent(i, binValue);
130  }
131 
132  //Digi Occupancy
133  name.str(""); name << "DigiOccupancy_Plus_layer_" << ilayer;
134  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
135  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
136  DigiOccupancy_Plus_.push_back(hgcalMEs[ih]);
137  }
138  }
139 
140  name.str(""); name << "DigiOccupancy_Minus_layer_" << ilayer;
141  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
142  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
143  DigiOccupancy_Minus_.push_back(hgcalMEs[ih]);
144  }
145  }
146 
147  //normalization of Digi Occupancy histos
148  nevent = DigiOccupancy_Plus_.at(ilayer)->getEntries();
149  nbinsx = DigiOccupancy_Plus_.at(ilayer)->getNbinsX();
150  for(int i=1; i<= nbinsx; ++i) {
151  double binValue = DigiOccupancy_Plus_.at(ilayer)->getBinContent(i)/nevent;
152  DigiOccupancy_Plus_.at(ilayer)->setBinContent(i, binValue);
153  }
154 
155  nevent = DigiOccupancy_Minus_.at(ilayer)->getEntries();
156  nbinsx = DigiOccupancy_Minus_.at(ilayer)->getNbinsX();
157  for(int i=1; i<= nbinsx; ++i) {
158  double binValue = DigiOccupancy_Minus_.at(ilayer)->getBinContent(i)/nevent;
159  DigiOccupancy_Minus_.at(ilayer)->setBinContent(i, binValue);
160  }
161 
162  }//loop over layers
163 
164  name.str(""); name << "SUMOfDigiOccupancy_Plus";
165  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
166  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0) {
167  MeanDigiOccupancy_Plus_.push_back(hgcalMEs[ih]);
168  unsigned indx = MeanDigiOccupancy_Plus_.size()-1;
169  for(int ilayer=0; ilayer < (int)layers_; ++ilayer) {
170  double meanVal = DigiOccupancy_Plus_.at(ilayer)->getMean();
171  MeanDigiOccupancy_Plus_[indx]->setBinContent(ilayer+1, meanVal);
172  }
173  break;
174  }
175  }
176 
177  name.str(""); name << "SUMOfDigiOccupancy_Plus";
178  for(unsigned int ih=0; ih<hgcalMEs.size(); ih++){
179  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0){
180  MeanDigiOccupancy_Minus_.push_back(hgcalMEs[ih]);
181  unsigned indx = MeanDigiOccupancy_Minus_.size()-1;
182  for(int ilayer=0; ilayer < (int)layers_; ++ilayer) {
183  double meanVal = DigiOccupancy_Minus_.at(ilayer)->getMean();
184  MeanDigiOccupancy_Minus_[indx]->setBinContent(ilayer+1, meanVal);
185  }
186  break;
187  }
188  }
189  return 1;
190 }
191 
193 
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 digisEndjob(const std::vector< MonitorElement * > &hcalMEs)
virtual ~HGCalDigiClient()
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int nevent
Definition: AMPTWrapper.h:74
unsigned int layers(bool reco) const
void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig)
HGCalDigiClient(const edm::ParameterSet &)
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
int getMaxDepth(const int &type) const
const T & get() const
Definition: EventSetup.h:55
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
std::string nameDetector_
Definition: Run.h:42
ib
Definition: cuy.py:660