CMS 3D CMS Logo

HGCalDigiClient.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <vector>
4 #include <unistd.h>
5 
14 
21 
23 private:
26  int layers_;
27 
28 public:
29  explicit HGCalDigiClient(const edm::ParameterSet &);
30  ~HGCalDigiClient() override {}
31 
32  void beginRun(const edm::Run &run, const edm::EventSetup &c) override;
33  void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig) override;
35  int digisEndjob(const std::vector<MonitorElement *> &hcalMEs);
36 };
37 
39  : nameDetector_(iConfig.getParameter<std::string>("DetectorName")),
40  verbosity_(iConfig.getUntrackedParameter<int>("Verbosity", 0)) {}
41 
43  if (nameDetector_ == "HCal") {
45  iSetup.get<HcalRecNumberingRecord>().get(pHRNDC);
46  const HcalDDDRecConstants *hcons = &(*pHRNDC);
47  layers_ = hcons->getMaxDepth(1);
48  } else {
50  iSetup.get<IdealGeometryRecord>().get(nameDetector_, pHGDC);
51  const HGCalDDDConstants &hgcons_ = (*pHGDC);
52  layers_ = hgcons_.layers(true);
53  }
54 }
55 
57 
59  ig.setCurrentFolder("/");
60  if (verbosity_)
61  edm::LogVerbatim("HGCalValidation") << "\nrunClient";
62  std::vector<MonitorElement *> hgcalMEs;
63  std::vector<std::string> fullDirPath = ig.getSubdirs();
64 
65  for (unsigned int i = 0; i < fullDirPath.size(); i++) {
66  if (verbosity_)
67  edm::LogVerbatim("HGCalValidation") << "\nfullPath: " << fullDirPath.at(i);
68  ig.setCurrentFolder(fullDirPath.at(i));
69  std::vector<std::string> fullSubDirPath = ig.getSubdirs();
70 
71  for (unsigned int j = 0; j < fullSubDirPath.size(); j++) {
72  if (verbosity_)
73  edm::LogVerbatim("HGCalValidation") << "fullSubPath: " << fullSubDirPath.at(j);
74  std::string nameDirectory = "HGCAL/HGCalDigisV/" + nameDetector_;
75  if (strcmp(fullSubDirPath.at(j).c_str(), nameDirectory.c_str()) == 0) {
76  hgcalMEs = ig.getContents(fullSubDirPath.at(j));
77  if (verbosity_)
78  edm::LogVerbatim("HGCalValidation") << "hgcalMES size : " << hgcalMEs.size();
79  if (!digisEndjob(hgcalMEs))
80  edm::LogVerbatim("HGCalValidation") << "\nError in DigisEndjob!";
81  }
82  }
83  }
84 }
85 
86 int HGCalDigiClient::digisEndjob(const std::vector<MonitorElement *> &hgcalMEs) {
87  std::vector<MonitorElement *> charge_;
88  std::vector<MonitorElement *> DigiOccupancy_XY_;
89  std::vector<MonitorElement *> ADC_;
90  std::vector<MonitorElement *> DigiOccupancy_Plus_;
91  std::vector<MonitorElement *> DigiOccupancy_Minus_;
92  std::vector<MonitorElement *> MeanDigiOccupancy_Plus_;
93  std::vector<MonitorElement *> MeanDigiOccupancy_Minus_;
94  std::ostringstream name;
95  double nevent;
96  int nbinsx, nbinsy;
97 
98  for (int ilayer = 0; ilayer < layers_; ilayer++) {
99  //charge
100  name.str("");
101  name << "charge_layer_" << ilayer;
102  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
103  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0)
104  charge_.push_back(hgcalMEs[ih]);
105  }
106  //normalization
107  nevent = charge_.at(ilayer)->getEntries();
108  nbinsx = charge_.at(ilayer)->getNbinsX();
109  for (int i = 1; i <= nbinsx; i++) {
110  double binValue = charge_.at(ilayer)->getBinContent(i) / nevent;
111  charge_.at(ilayer)->setBinContent(i, binValue);
112  }
113 
114  //XY 2d plots
115  name.str("");
116  name << "DigiOccupancy_XY_"
117  << "layer_" << ilayer;
118  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
119  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0)
120  DigiOccupancy_XY_.push_back(hgcalMEs[ih]);
121  }
122 
123  //normalization of XY 2d
124  nevent = DigiOccupancy_XY_.at(ilayer)->getEntries();
125  nbinsx = DigiOccupancy_XY_.at(ilayer)->getNbinsX();
126  nbinsy = DigiOccupancy_XY_.at(ilayer)->getNbinsY();
127  for (int i = 1; i <= nbinsx; ++i) {
128  for (int j = 1; j <= nbinsy; ++j) {
129  double binValue = DigiOccupancy_XY_.at(ilayer)->getBinContent(i, j) / nevent;
130  DigiOccupancy_XY_.at(ilayer)->setBinContent(i, j, binValue);
131  }
132  }
133 
134  //ADC
135  name.str("");
136  name << "ADC_layer_" << ilayer;
137  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
138  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0)
139  ADC_.push_back(hgcalMEs[ih]);
140  }
141 
142  //normalization of ADC Histos
143  nevent = ADC_.at(ilayer)->getEntries();
144  nbinsx = ADC_.at(ilayer)->getNbinsX();
145  for (int i = 1; i <= nbinsx; ++i) {
146  double binValue = ADC_.at(ilayer)->getBinContent(i) / nevent;
147  ADC_.at(ilayer)->setBinContent(i, binValue);
148  }
149 
150  //Digi Occupancy
151  name.str("");
152  name << "DigiOccupancy_Plus_layer_" << ilayer;
153  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
154  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0) {
155  DigiOccupancy_Plus_.push_back(hgcalMEs[ih]);
156  }
157  }
158 
159  name.str("");
160  name << "DigiOccupancy_Minus_layer_" << ilayer;
161  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
162  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0) {
163  DigiOccupancy_Minus_.push_back(hgcalMEs[ih]);
164  }
165  }
166 
167  //normalization of Digi Occupancy histos
168  nevent = DigiOccupancy_Plus_.at(ilayer)->getEntries();
169  nbinsx = DigiOccupancy_Plus_.at(ilayer)->getNbinsX();
170  for (int i = 1; i <= nbinsx; ++i) {
171  double binValue = DigiOccupancy_Plus_.at(ilayer)->getBinContent(i) / nevent;
172  DigiOccupancy_Plus_.at(ilayer)->setBinContent(i, binValue);
173  }
174 
175  nevent = DigiOccupancy_Minus_.at(ilayer)->getEntries();
176  nbinsx = DigiOccupancy_Minus_.at(ilayer)->getNbinsX();
177  for (int i = 1; i <= nbinsx; ++i) {
178  double binValue = DigiOccupancy_Minus_.at(ilayer)->getBinContent(i) / nevent;
179  DigiOccupancy_Minus_.at(ilayer)->setBinContent(i, binValue);
180  }
181 
182  } //loop over layers
183 
184  name.str("");
185  name << "SUMOfDigiOccupancy_Plus";
186  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
187  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0) {
188  MeanDigiOccupancy_Plus_.push_back(hgcalMEs[ih]);
189  unsigned indx = MeanDigiOccupancy_Plus_.size() - 1;
190  for (int ilayer = 0; ilayer < (int)layers_; ++ilayer) {
191  double meanVal = DigiOccupancy_Plus_.at(ilayer)->getMean();
192  MeanDigiOccupancy_Plus_[indx]->setBinContent(ilayer + 1, meanVal);
193  }
194  break;
195  }
196  }
197 
198  name.str("");
199  name << "SUMOfDigiOccupancy_Plus";
200  for (unsigned int ih = 0; ih < hgcalMEs.size(); ih++) {
201  if (strcmp(hgcalMEs[ih]->getName().c_str(), name.str().c_str()) == 0) {
202  MeanDigiOccupancy_Minus_.push_back(hgcalMEs[ih]);
203  unsigned indx = MeanDigiOccupancy_Minus_.size() - 1;
204  for (int ilayer = 0; ilayer < (int)layers_; ++ilayer) {
205  double meanVal = DigiOccupancy_Minus_.at(ilayer)->getMean();
206  MeanDigiOccupancy_Minus_[indx]->setBinContent(ilayer + 1, meanVal);
207  }
208  break;
209  }
210  }
211  return 1;
212 }
213 
215 
ConfigurationDescriptions.h
DQMEDHarvester.h
nevent
int nevent
Definition: AMPTWrapper.h:84
HGCalDigiClient::nameDetector_
std::string nameDetector_
Definition: HGCalDigiClient.cc:24
HGCalDigiClient::layers_
int layers_
Definition: HGCalDigiClient.cc:26
mps_fire.i
i
Definition: mps_fire.py:428
HGCalDigiClient::digisEndjob
int digisEndjob(const std::vector< MonitorElement * > &hcalMEs)
Definition: HGCalDigiClient.cc:86
dqm::implementation::IGetter::getContents
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
ESTransientHandle.h
MessageLogger.h
edm::Run
Definition: Run.h:45
HGCalDigiClient::runClient_
void runClient_(DQMStore::IBooker &ib, DQMStore::IGetter &ig)
Definition: HGCalDigiClient.cc:58
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dqm::implementation::IGetter::getSubdirs
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:678
HcalRecNumberingRecord.h
HGCalDDDConstants
Definition: HGCalDDDConstants.h:27
HGCalDigiClient::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
Definition: HGCalDigiClient.cc:42
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
getName
TString getName(TString structure, int layer, TString geometry)
Definition: DMRtrends.cc:235
Run.h
edm::ESHandle
Definition: DTSurvey.h:22
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
HGCalDigiClient::verbosity_
int verbosity_
Definition: HGCalDigiClient.cc:25
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalDigiClient
Definition: HGCalDigiClient.cc:22
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HGCalDigiClient::dqmEndJob
void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig) override
Definition: HGCalDigiClient.cc:56
HGCalDDDConstants::layers
unsigned int layers(bool reco) const
Definition: HGCalDDDConstants.cc:561
createfilelist.int
int
Definition: createfilelist.py:10
cuy.ib
ib
Definition: cuy.py:662
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
HGCalDigiClient::HGCalDigiClient
HGCalDigiClient(const edm::ParameterSet &)
Definition: HGCalDigiClient.cc:38
get
#define get
DQMEDHarvester
Definition: DQMEDHarvester.py:1
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dqm::implementation::IGetter
Definition: DQMStore.h:484
HcalDDDRecConstants.h
HGCalDigiClient::~HGCalDigiClient
~HGCalDigiClient() override
Definition: HGCalDigiClient.cc:30
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
HcalDDDRecConstants::getMaxDepth
int getMaxDepth(const int &type) const
Definition: HcalDDDRecConstants.h:88
HcalDDDRecConstants
Definition: HcalDDDRecConstants.h:23
HGCalDDDConstants.h
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25