42 float iphi_max = NphiMax + 0.5;
43 int iphi_bins = (
int)(iphi_max - iphi_min);
53 int iEtaMax = (iEtaHBMax > iEtaHEMax ? iEtaHBMax : iEtaHEMax);
54 iEtaMax = (iEtaMax > iEtaHFMax ? iEtaMax : iEtaHFMax);
55 iEtaMax = (iEtaMax > iEtaHOMax ? iEtaMax : iEtaHOMax);
91 for (
unsigned int i = 0;
i <
types.size(); ++
i) {
93 sprintf(name,
"HcalHitEta%s", divisions[i].
first.c_str());
94 sprintf(title,
"Hit energy as a function of eta tower index in %s", divisions[i].
second.c_str());
97 sprintf(name,
"HcalHitTimeAEta%s", divisions[i].
first.c_str());
98 sprintf(title,
"Hit time as a function of eta tower index in %s", divisions[i].
second.c_str());
101 sprintf(name,
"HcalHitE25%s", divisions[i].
first.c_str());
102 sprintf(title,
"Energy in time window 0 to 25 for a tower in %s", divisions[i].
second.c_str());
104 ib.
book2D(name, title, limit.
bins, limit.
low, limit.
high, iphi_bins, iphi_min, iphi_max));
106 sprintf(name,
"HcalHitE50%s", divisions[i].
first.c_str());
107 sprintf(title,
"Energy in time window 0 to 50 for a tower in %s", divisions[i].
second.c_str());
109 ib.
book2D(name, title, limit.
bins, limit.
low, limit.
high, iphi_bins, iphi_min, iphi_max));
111 sprintf(name,
"HcalHitE100%s", divisions[i].
first.c_str());
112 sprintf(title,
"Energy in time window 0 to 100 for a tower in %s", divisions[i].
second.c_str());
114 ib.
book2D(name, title, limit.
bins, limit.
low, limit.
high, iphi_bins, iphi_min, iphi_max));
116 sprintf(name,
"HcalHitE250%s", divisions[i].
first.c_str());
117 sprintf(title,
"Energy in time window 0 to 250 for a tower in %s", divisions[i].
second.c_str());
119 ib.
book2D(name, title, limit.
bins, limit.
low, limit.
high, iphi_bins, iphi_min, iphi_max));
122 sprintf(name,
"Energy_HB");
124 sprintf(name,
"Energy_HE");
126 sprintf(name,
"Energy_HO");
128 sprintf(name,
"Energy_HF");
131 sprintf(name,
"Time_HB");
133 sprintf(name,
"Time_HE");
135 sprintf(name,
"Time_HO");
137 sprintf(name,
"Time_HF");
140 sprintf(name,
"Time_Enweighted_HB");
142 sprintf(name,
"Time_Enweighted_HE");
144 sprintf(name,
"Time_Enweighted_HO");
146 sprintf(name,
"Time_Enweighted_HF");
154 std::vector<PCaloHit> caloHits;
157 bool getHits =
false;
162 edm::LogVerbatim(
"HitsValidationHcal") <<
"HitsValidationHcal.: Input flags Hits " << getHits;
165 caloHits.insert(caloHits.end(), hitsHcal->begin(), hitsHcal->end());
170 for (
unsigned int i = 0;
i < caloHits.size(); ++
i) {
171 unsigned int id_ = caloHits[
i].id();
173 caloHits[
i].setID(hid.
rawId());
180 edm::LogVerbatim(
"HitsValidationHcal") <<
"HitsValidationHcal: Hit buffer " << caloHits.size();
187 int nHit = hits.size();
188 double entotHB = 0, entotHE = 0, entotHF = 0, entotHO = 0;
189 double timetotHB = 0, timetotHE = 0, timetotHF = 0, timetotHO = 0;
190 int nHB = 0, nHE = 0, nHO = 0, nHF = 0;
192 std::map<std::pair<HcalDetId, unsigned int>,
energysum> map_try;
194 std::map<std::pair<HcalDetId, unsigned int>,
energysum>::iterator itr;
196 for (
int i = 0;
i < nHit;
i++) {
197 double energy = hits[
i].energy();
198 double time = hits[
i].time();
200 int itime = (
int)(time);
201 int subdet =
id.subdet();
202 int depth =
id.depth();
204 unsigned int dep = hits[
i].depth();
206 std::pair<int, int>
types =
histId(subdet, eta, depth, dep);
211 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
215 }
else if (subdet == static_cast<int>(
HcalOuter)) {
219 }
else if (subdet == static_cast<int>(
HcalForward)) {
225 std::pair<HcalDetId, unsigned int> id0(
id, dep);
227 if (map_try.count(id0) != 0)
228 ensum = map_try[id0];
240 map_try[id0] = ensum;
244 <<
"Hit[" <<
i <<
"] ID " <<
std::dec <<
" " <<
id <<
std::dec <<
" Det " <<
id.det() <<
" Sub " << subdet
245 <<
" depth " << depth <<
" depthX " << dep <<
" Eta " << eta <<
" Phi " <<
id.iphi() <<
" E " << energy
246 <<
" time " << time <<
" type " << types.first <<
" " << types.second;
249 double etax = eta - 0.5;
252 if (types.first >= 0) {
256 if (types.second >= 0) {
277 for (itr = map_try.begin(); itr != map_try.end(); ++itr) {
280 std::pair<int, int>
types =
histId((
int)(
id.subdet()),
id.
ieta(),
id.
depth(), (*itr).first.second);
283 double etax = eta - 0.5;
284 double phix = phi - 0.5;
285 if (types.first >= 0) {
291 if (types.second >= 0) {
300 <<
" energy of tower =" << (*itr).first.first <<
" in time 25ns is == " << (*itr).second.e25
301 <<
" in time 25-50ns == " << (*itr).second.e50 <<
" in time 50-100ns == " << (*itr).second.e100
302 <<
" in time 100-250 ns == " << (*itr).second.e250;
309 std::pair<int, int>
range;
319 bins = range.second - range.first;
334 bins = range.second - range.first;
349 <<
" range.first:" << range.first <<
" and second:" << range.second;
350 edm::LogVerbatim(
"HitsValidationHcal") <<
"bins: " << bins <<
" low:" << low <<
" high:" <<
high;
357 for (
unsigned int k = 0;
k <
types.size(); ++
k) {
359 if (subdet == (
int)(
types[
k].subdet) && depth ==
types[
k].depth1 && eta *
types[
k].
z > 0 &&
360 dep == (
unsigned int)(
types[
k].depth2)) {
365 if (subdet == (
int)(
types[
k].subdet) && depth ==
types[
k].depth1 && eta *
types[
k].
z > 0) {
370 if (subdet == (
int)(
types[
k].subdet) && depth ==
types[
k].depth1) {
378 for (
unsigned int k = 0;
k <
types.size(); ++
k) {
384 return std::pair<int, int>(
id1,
id2);
392 std::vector<std::pair<std::string, std::string>> divisions;
393 std::pair<std::string, std::string>
names;
394 char name1[40],
name2[40];
398 snprintf(name1, 40,
"HC%d",
depth);
399 snprintf(name2, 40,
"HCAL depth%d",
depth + 1);
402 divisions.push_back(names);
403 types.push_back(type);
407 snprintf(name1, 40,
"HB%d",
depth);
408 snprintf(name2, 40,
"HB depth%d",
depth + 1);
411 divisions.push_back(names);
412 types.push_back(type);
416 snprintf(name1, 40,
"HE%d+z",
depth);
417 snprintf(name2, 40,
"HE +z depth%d",
depth + 1);
420 divisions.push_back(names);
421 types.push_back(type);
422 snprintf(name1, 40,
"HE%d-z",
depth);
423 snprintf(name2, 40,
"HE -z depth%d",
depth + 1);
426 divisions.push_back(names);
427 types.push_back(type);
432 snprintf(name1, 40,
"HO%d", depth);
433 snprintf(name2, 40,
"HO depth%d", depth);
436 divisions.push_back(names);
437 types.push_back(type);
441 std::string hfty2[4] = {
"Absorber",
"Window",
"Bundle",
"Jungle"};
442 int dept0[4] = {0, 1, 2, 3};
443 for (
int k = 0;
k < 4; ++
k) {
445 snprintf(name1, 40,
"HF%s%d+z", hfty1[
k].c_str(),
depth);
446 snprintf(name2, 40,
"HF (%s) +z depth%d", hfty2[
k].c_str(),
depth + 1);
449 divisions.push_back(names);
450 types.push_back(type);
451 snprintf(name1, 40,
"HF%s%d-z", hfty1[k].c_str(),
depth);
452 snprintf(name2, 40,
"HF (%s) -z depth%d", hfty2[k].c_str(),
depth + 1);
455 divisions.push_back(names);
456 types.push_back(type);
467 desc.
add<
bool>(
"Verbose",
false);
468 desc.
add<
bool>(
"TestNumber",
false);
SimHitsValidationHcal(const edm::ParameterSet &ps)
MonitorElement * meEnergy_HF
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
T getParameter(std::string const &) const
EventNumber_t event() const
const HcalDDDRecConstants * hcons
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setCurrentFolder(std::string const &fullpath)
MonitorElement * metime_enweighted_HO
constexpr uint32_t rawId() const
get the raw id
MonitorElement * metime_HE
void analyze(const edm::Event &e, const edm::EventSetup &c) override
const std::string names[nVars_]
MonitorElement * metime_enweighted_HB
std::vector< MonitorElement * > meHcalEnergyl25_
U second(std::pair< T, U > const &p)
MonitorElement * meEnergy_HB
MonitorElement * metime_HO
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< MonitorElement * > meHcalEnergyl100_
MonitorElement * metime_enweighted_HF
ParameterDescriptionBase * add(U const &iLabel, T const &value)
MonitorElement * metime_enweighted_HE
std::vector< MonitorElement * > meHcalEnergyl250_
std::vector< MonitorElement * > meHcalHitEta_
int getMaxDepth(const int &type) const
MonitorElement * meEnergy_HE
std::vector< MonitorElement * > meHcalEnergyl50_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::vector< MonitorElement * > meHcalHitTimeEta_
std::pair< int, int > histId(int subdet, int eta, int depth, unsigned int dep)
DetId relabel(const uint32_t testId) const
std::pair< int, int > getEtaRange(const int &i) const
MonitorElement * metime_HB
MonitorElement * meEnergy_HO
etaRange getLimits(idType)
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
~SimHitsValidationHcal() override
int getNPhi(const int &type) const
std::vector< std::pair< std::string, std::string > > getHistogramTypes()
MonitorElement * metime_HF
void analyzeHits(std::vector< PCaloHit > &)