CMS 3D CMS Logo

HcalSimHitsClient.cc
Go to the documentation of this file.
3 
9 
12 
14  dirName_ = iConfig.getParameter<std::string>("DQMDirName");
15  verbose_ = iConfig.getUntrackedParameter<bool>("Verbosity", false);
16 }
17 
19 
22  c.get<HcalRecNumberingRecord>().get(pHRNDC);
23  hcons = &(*pHRNDC);
28 
29  edm::LogInfo("HitsValidationHcal") << " Maximum Depths HB:" << maxDepthHB_ << " HE:" << maxDepthHE_
30  << " HO:" << maxDepthHO_ << " HF:" << maxDepthHF_;
31 }
32 
34 
37 
38  if (verbose_)
39  edm::LogInfo("HitsValidationHcal") << "runClient";
40 
41  std::vector<MonitorElement *> hcalMEs;
42 
43  std::vector<std::string> fullPathHLTFolders = ig.getSubdirs();
44  for (unsigned int i = 0; i < fullPathHLTFolders.size(); i++) {
45  if (verbose_)
46  edm::LogInfo("HitsValidationHcal") << "fullPath: " << fullPathHLTFolders[i];
47  ig.setCurrentFolder(fullPathHLTFolders[i]);
48 
49  std::vector<std::string> fullSubPathHLTFolders = ig.getSubdirs();
50  for (unsigned int j = 0; j < fullSubPathHLTFolders.size(); j++) {
51  if (verbose_)
52  edm::LogInfo("HitsValidationHcal") << "fullSub: " << fullSubPathHLTFolders[j];
53 
54  if (strcmp(fullSubPathHLTFolders[j].c_str(), "HcalHitsV/SimHitsValidationHcal") == 0) {
55  hcalMEs = ig.getContents(fullSubPathHLTFolders[j]);
56  if (verbose_)
57  edm::LogInfo("HitsValidationHcal") << "hltMES size : " << hcalMEs.size();
58  if (!SimHitsEndjob(hcalMEs))
59  edm::LogWarning("HitsValidationHcal") << "Error in SimhitEndjob!";
60  }
61  }
62  }
63 }
64 
65 // called after entering the directory
66 // hcalMEs are within that directory
67 int HcalSimHitsClient::SimHitsEndjob(const std::vector<MonitorElement *> &hcalMEs) {
68  std::vector<std::string> divisions = getHistogramTypes();
69  MonitorElement *Occupancy_map[nTime][divisions.size()];
70  MonitorElement *Energy[nType1], *Time_weighteden[nType1];
71  MonitorElement *HitEnergyvsieta[divisions.size()], *HitTimevsieta[divisions.size()];
72 
73  std::string time[nTime] = {"25", "50", "100", "250"};
74  std::string detdivision[nType1] = {"HB", "HE", "HF", "HO"};
75  char name[40], name1[40], name2[40], name3[40], name4[40];
76 
77  for (int k = 0; k < nType1; k++) {
78  Energy[k] = nullptr;
79  Time_weighteden[k] = nullptr;
80  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
81  sprintf(name1, "Energy_%s", detdivision[k].c_str());
82  sprintf(name2, "Time_Enweighted_%s", detdivision[k].c_str());
83  if (strcmp(hcalMEs[ih]->getName().c_str(), name1) == 0) {
84  Energy[k] = hcalMEs[ih];
85  }
86  if (strcmp(hcalMEs[ih]->getName().c_str(), name2) == 0) {
87  Time_weighteden[k] = hcalMEs[ih];
88  }
89  }
90  }
91 
92  for (int i = 0; i < nTime; i++) {
93  for (unsigned int j = 0; j < divisions.size(); j++) {
94  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
95  sprintf(name, "HcalHitE%s%s", time[i].c_str(), divisions[j].c_str());
96  if (strcmp(hcalMEs[ih]->getName().c_str(), name) == 0) {
97  Occupancy_map[i][j] = hcalMEs[ih];
98  }
99  }
100  }
101  }
102 
103  for (unsigned int k = 0; k < divisions.size(); k++) {
104  HitEnergyvsieta[k] = nullptr;
105  HitTimevsieta[k] = nullptr;
106  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
107  sprintf(name3, "HcalHitEta%s", divisions[k].c_str());
108  sprintf(name4, "HcalHitTimeAEta%s", divisions[k].c_str());
109  if (strcmp(hcalMEs[ih]->getName().c_str(), name3) == 0) {
110  HitEnergyvsieta[k] = hcalMEs[ih];
111  }
112  if (strcmp(hcalMEs[ih]->getName().c_str(), name4) == 0) {
113  HitTimevsieta[k] = hcalMEs[ih];
114  }
115  }
116  }
117 
118  // mean energy
119 
120  double nevent = Energy[0]->getEntries();
121  if (verbose_)
122  edm::LogInfo("HitsValidationHcal") << "nevent : " << nevent;
123 
124  float cont[nTime][divisions.size()];
125  float en[nType1], tme[nType1];
126  float hitenergy[divisions.size()], hittime[divisions.size()];
127  float fev = float(nevent);
128 
129  for (int dettype = 0; dettype < nType1; dettype++) {
130  int nx1 = Energy[dettype]->getNbinsX();
131  for (int i = 0; i <= nx1; i++) {
132  en[dettype] = Energy[dettype]->getBinContent(i) / fev;
133  Energy[dettype]->setBinContent(i, en[dettype]);
134  }
135  int nx2 = Time_weighteden[dettype]->getNbinsX();
136  for (int i = 0; i <= nx2; i++) {
137  tme[dettype] = Time_weighteden[dettype]->getBinContent(i) / fev;
138  Time_weighteden[dettype]->setBinContent(i, tme[dettype]);
139  }
140  }
141 
142  for (unsigned int dettype = 0; dettype < divisions.size(); dettype++) {
143  int nx1 = HitEnergyvsieta[dettype]->getNbinsX();
144  for (int i = 0; i <= nx1; i++) {
145  hitenergy[dettype] = HitEnergyvsieta[dettype]->getBinContent(i) / fev;
146  HitEnergyvsieta[dettype]->setBinContent(i, hitenergy[dettype]);
147  }
148  int nx2 = HitTimevsieta[dettype]->getNbinsX();
149  for (int i = 0; i <= nx2; i++) {
150  hittime[dettype] = HitTimevsieta[dettype]->getBinContent(i) / fev;
151  HitTimevsieta[dettype]->setBinContent(i, hittime[dettype]);
152  }
153  }
154 
155  for (int itime = 0; itime < nTime; itime++) {
156  for (unsigned int det = 0; det < divisions.size(); det++) {
157  int ny = Occupancy_map[itime][det]->getNbinsY();
158  int nx = Occupancy_map[itime][det]->getNbinsX();
159  for (int i = 1; i < nx + 1; i++) {
160  for (int j = 1; j < ny + 1; j++) {
161  cont[itime][det] = Occupancy_map[itime][det]->getBinContent(i, j) / fev;
162  Occupancy_map[itime][det]->setBinContent(i, j, cont[itime][det]);
163  }
164  }
165  }
166  }
167 
168  return 1;
169 }
170 
171 std::vector<std::string> HcalSimHitsClient::getHistogramTypes() {
173  if (verbose_)
174  edm::LogInfo("HitsValidationHcal") << "Max depth 1st step:: " << maxDepth;
176  if (verbose_)
177  edm::LogInfo("HitsValidationHcal") << "Max depth 2nd step:: " << maxDepth;
179  if (verbose_)
180  edm::LogInfo("HitsValidationHcal") << "Max depth 3rd step:: " << maxDepth;
181  std::vector<std::string> divisions;
182  char name1[20];
183 
184  // first overall Hcal
185  for (int depth = 0; depth < maxDepth; ++depth) {
186  sprintf(name1, "HC%d", depth);
187  divisions.push_back(std::string(name1));
188  }
189  // HB
190  for (int depth = 0; depth < maxDepthHB_; ++depth) {
191  sprintf(name1, "HB%d", depth);
192  divisions.push_back(std::string(name1));
193  }
194  // HE
195  for (int depth = 0; depth < maxDepthHE_; ++depth) {
196  sprintf(name1, "HE%d+z", depth);
197  divisions.push_back(std::string(name1));
198  sprintf(name1, "HE%d-z", depth);
199  divisions.push_back(std::string(name1));
200  }
201  // HO
202  {
203  int depth = maxDepthHO_;
204  sprintf(name1, "HO%d", depth);
205  divisions.push_back(std::string(name1));
206  }
207  // HF (first absorber, then different types of abnormal hits)
208  std::string hfty1[4] = {"A", "W", "B", "J"};
209  for (int k = 0; k < 4; ++k) {
210  for (int depth = 0; depth < maxDepthHF_; ++depth) {
211  sprintf(name1, "HF%s%d+z", hfty1[k].c_str(), depth);
212  divisions.push_back(std::string(name1));
213  sprintf(name1, "HF%s%d-z", hfty1[k].c_str(), depth);
214  divisions.push_back(std::string(name1));
215  }
216  }
217  return divisions;
218 }
219 
nevent
int nevent
Definition: AMPTWrapper.h:84
mps_fire.i
i
Definition: mps_fire.py:355
HcalSimHitsClient.h
dqm::implementation::IGetter::getContents
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
EcalCondDBWriter_cfi.Energy
Energy
Definition: EcalCondDBWriter_cfi.py:152
ESHandle.h
edm::Run
Definition: Run.h:45
edm::LogInfo
Definition: MessageLogger.h:254
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
generateEDF.cont
cont
load Luminosity info ##
Definition: generateEDF.py:629
DQMStore.h
dqm::implementation::IGetter::getSubdirs
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:678
HcalRecNumberingRecord.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HcalSimHitsClient::nType1
static const int nType1
Definition: HcalSimHitsClient.h:41
HcalSimHitsClient::getHistogramTypes
std::vector< std::string > getHistogramTypes()
Definition: HcalSimHitsClient.cc:171
HcalSimHitsClient
Definition: HcalSimHitsClient.h:33
HLT_2018_cff.maxDepth
maxDepth
Definition: HLT_2018_cff.py:7356
HcalSimHitsClient::dirName_
std::string dirName_
Definition: HcalSimHitsClient.h:38
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalSimHitsClient::maxDepthHO_
int maxDepthHO_
Definition: HcalSimHitsClient.h:43
HcalSimHitsClient::SimHitsEndjob
int SimHitsEndjob(const std::vector< MonitorElement * > &hcalMEs)
Definition: HcalSimHitsClient.cc:67
Service.h
getName
TString getName(TString structure, int layer, TString geometry)
Definition: DMRtrends.cc:235
HcalSimHitsClient::~HcalSimHitsClient
~HcalSimHitsClient() override
Definition: HcalSimHitsClient.cc:18
Run.h
edm::ESHandle
Definition: DTSurvey.h:22
dqmdumpme.k
k
Definition: dqmdumpme.py:60
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
HcalSimHitsClient::runClient_
virtual void runClient_(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: HcalSimHitsClient.cc:35
edm::ParameterSet
Definition: ParameterSet.h:36
dqm::impl::MonitorElement::getNbinsY
virtual int getNbinsY() const
get # of bins in Y-axis
Definition: MonitorElement.cc:580
HcalSimHitsClient::maxDepthHB_
int maxDepthHB_
Definition: HcalSimHitsClient.h:43
Event.h
HcalSimHitsClient::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: HcalSimHitsClient.cc:33
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HcalSimHitsClient::nTime
static const int nTime
Definition: HcalSimHitsClient.h:40
HcalSimHitsClient::maxDepthHE_
int maxDepthHE_
Definition: HcalSimHitsClient.h:43
HcalSimHitsClient::hcons
const HcalDDDRecConstants * hcons
Definition: HcalSimHitsClient.h:42
cuy.ib
ib
Definition: cuy.py:662
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
writedatasetfile.run
run
Definition: writedatasetfile.py:27
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
HcalSimHitsClient::verbose_
bool verbose_
Definition: HcalSimHitsClient.h:39
HcalDDDRecConstants::getMaxDepth
int getMaxDepth(const int &type) const
Definition: HcalDDDRecConstants.h:88
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ntuplemaker.time
time
Definition: ntuplemaker.py:310
HcalSimHitsClient::maxDepthHF_
int maxDepthHF_
Definition: HcalSimHitsClient.h:43
hfnoseParametersInitialization_cfi.name2
name2
Definition: hfnoseParametersInitialization_cfi.py:8
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
HcalSimHitsClient::HcalSimHitsClient
HcalSimHitsClient(const edm::ParameterSet &)
Definition: HcalSimHitsClient.cc:13
HcalSimHitsClient::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &c) override
Definition: HcalSimHitsClient.cc:20