16 edm::LogInfo(
"HitsValidationHcal") <<
"Module Label: " <<
g4Label_ <<
" Hits: " << hcalHits_ <<
" TestNumbering " 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);
85 edm::LogInfo(
"HitsValidationHcal") <<
"Booking the Histograms";
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::LogInfo(
"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());
175 edm::LogInfo(
"HitsValidationHcal") <<
"Hit[" <<
i <<
"] " << hid;
180 edm::LogInfo(
"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];
230 ensum.
e250 += energy;
232 ensum.
e100 += energy;
240 map_try[id0] = ensum;
244 <<
id.det() <<
" Sub " << subdet <<
" depth " << depth <<
" depthX " << dep
245 <<
" Eta " << eta <<
" Phi " <<
id.iphi() <<
" E " << energy <<
" time " << time
246 <<
" 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) {
299 edm::LogInfo(
"HitsValidationHcal") <<
" energy of tower =" << (*itr).first.first
300 <<
" in time 25ns is == " << (*itr).second.e25
301 <<
" in time 25-50ns == " << (*itr).second.e50
302 <<
" in time 50-100ns == " << (*itr).second.e100
303 <<
" in time 100-250 ns == " << (*itr).second.e250;
310 std::pair<int, int> range;
320 bins = range.second - range.first;
335 bins = range.second - range.first;
350 <<
" range.first:" << range.first <<
" and second:" << range.second;
351 edm::LogInfo(
"HitsValidationHcal") <<
"bins: " << bins <<
" low:" << low <<
" high:" << high;
358 for (
unsigned int k = 0;
k <
types.size(); ++
k) {
360 if (subdet == (
int)(
types[
k].subdet) && depth ==
types[
k].depth1 && eta *
types[
k].
z > 0 &&
361 dep == (
unsigned int)(
types[
k].depth2)) {
366 if (subdet == (
int)(
types[
k].subdet) && depth ==
types[
k].depth1 && eta *
types[
k].
z > 0) {
371 if (subdet == (
int)(
types[
k].subdet) && depth ==
types[
k].depth1) {
379 for (
unsigned int k = 0;
k <
types.size(); ++
k) {
385 return std::pair<int, int>(
id1,
id2);
393 std::vector<std::pair<std::string, std::string>> divisions;
394 std::pair<std::string, std::string>
names;
395 char name1[40], name2[40];
399 snprintf(name1, 40,
"HC%d",
depth);
400 snprintf(name2, 40,
"HCAL depth%d",
depth + 1);
403 divisions.push_back(names);
404 types.push_back(type);
408 snprintf(name1, 40,
"HB%d",
depth);
409 snprintf(name2, 40,
"HB depth%d",
depth + 1);
412 divisions.push_back(names);
413 types.push_back(type);
417 snprintf(name1, 40,
"HE%d+z",
depth);
418 snprintf(name2, 40,
"HE +z depth%d",
depth + 1);
421 divisions.push_back(names);
422 types.push_back(type);
423 snprintf(name1, 40,
"HE%d-z",
depth);
424 snprintf(name2, 40,
"HE -z depth%d",
depth + 1);
427 divisions.push_back(names);
428 types.push_back(type);
433 snprintf(name1, 40,
"HO%d", depth);
434 snprintf(name2, 40,
"HO depth%d", depth);
437 divisions.push_back(names);
438 types.push_back(type);
442 std::string hfty2[4] = {
"Absorber",
"Window",
"Bundle",
"Jungle"};
443 int dept0[4] = {0, 1, 2, 3};
444 for (
int k = 0;
k < 4; ++
k) {
446 snprintf(name1, 40,
"HF%s%d+z", hfty1[
k].c_str(),
depth);
447 snprintf(name2, 40,
"HF (%s) +z depth%d", hfty2[
k].c_str(),
depth + 1);
450 divisions.push_back(names);
451 types.push_back(type);
452 snprintf(name1, 40,
"HF%s%d-z", hfty1[k].c_str(),
depth);
453 snprintf(name2, 40,
"HF (%s) -z depth%d", hfty2[k].c_str(),
depth + 1);
456 divisions.push_back(names);
457 types.push_back(type);
468 desc.
add<
bool>(
"Verbose",
false);
469 desc.
add<
bool>(
"TestNumber",
false);
SimHitsValidationHcal(const edm::ParameterSet &ps)
MonitorElement * meEnergy_HF
T getParameter(std::string const &) const
EventNumber_t event() const
const HcalDDDRecConstants * hcons
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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_]
std::pair< int, int > getEtaRange(const int &i) const
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)
void setCurrentFolder(std::string const &fullpath)
MonitorElement * book1D(Args &&...args)
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_
MonitorElement * book2D(Args &&...args)
int getMaxDepth(const int &type) const
MonitorElement * meEnergy_HE
std::vector< MonitorElement * > meHcalEnergyl50_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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
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 > &)