CMS 3D CMS Logo

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