Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run-sim137 Correct the code in the analysis code of Simulation #40227

Merged
merged 2 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions SimG4CMS/Calo/plugins/CaloSimHitStudy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
#include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"

#include <TH1F.h>
Expand Down Expand Up @@ -406,6 +407,22 @@ void CaloSimHitStudy::analyzeHits(std::vector<PCaloHit>& hits, int indx) {
id |= 0x20000;
else if (dep == 2)
id |= 0x40000;
} else if (indx == 3) {
if (testNumber_) {
int subdet(0), ieta(0), iphi(0), z(0), lay(0), depth(0);
HcalTestNumbering::unpackHcalIndex(id, subdet, z, depth, ieta, iphi, lay);
HcalDDDRecConstants::HcalID hid1 =
hcalGeom_->topology().dddConstants()->getHCID(subdet, ieta, iphi, lay, depth);
int zside = 2 * z - 1;
HcalDetId hid2(static_cast<HcalSubdetector>(hid1.subdet), (zside * hid1.eta), hid1.phi, hid1.depth);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HitStudy") << "From SIM step subdet:z:depth:eta:phi:lay " << subdet << ":" << z << ":"
<< depth << ":" << ieta << ":" << iphi << ":" << lay
<< " After getHCID subdet:zside:eta:phi:depth " << hid1.subdet << ":" << zside
<< ":" << hid1.eta << ":" << hid1.phi << ":" << hid1.depth << " ID " << hid2;
#endif
id = hid2.rawId();
}
}
std::map<unsigned int, double>::const_iterator it = hitMap.find(id);
if (it == hitMap.end()) {
Expand Down Expand Up @@ -444,23 +461,17 @@ void CaloSimHitStudy::analyzeHits(std::vector<PCaloHit>& hits, int indx) {
etotG[idx] += edep;
}
} else {
int subdet(0);
if (testNumber_) {
int ieta(0), phi(0), z(0), lay(0), depth(0);
HcalTestNumbering::unpackHcalIndex(id, subdet, z, depth, ieta, phi, lay);
} else {
subdet = HcalDetId(id).subdet();
}
if (subdet == static_cast<int>(HcalBarrel)) {
HcalSubdetector subdet = HcalDetId(id).subdet();
if (subdet == HcalSubdetector::HcalBarrel) {
idx = indx + 2;
nHB++;
} else if (subdet == static_cast<int>(HcalEndcap)) {
} else if (subdet == HcalSubdetector::HcalEndcap) {
idx = indx + 3;
nHE++;
} else if (subdet == static_cast<int>(HcalOuter)) {
} else if (subdet == HcalSubdetector::HcalOuter) {
idx = indx + 4;
nHO++;
} else if (subdet == static_cast<int>(HcalForward)) {
} else if (subdet == HcalSubdetector::HcalForward) {
idx = indx + 5;
nHF++;
}
Expand Down
8 changes: 4 additions & 4 deletions SimG4CMS/Calo/src/HCalSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,12 @@ bool HCalSD::filterHit(CaloG4Hit* aHit, double time) {
uint32_t HCalSD::setDetUnitId(int det, const G4ThreeVector& pos, int depth, int lay = 1) {
uint32_t id = 0;
if (det == 0) {
#ifdef printDebug
double eta = std::abs(pos.eta());
#endif
if (std::abs(pos.z()) > maxZ_) {
det = 5;
#ifdef printDebug
double eta = std::abs(pos.eta());
if (eta < 2.868)
++detNull_[2];
#endif
Expand All @@ -598,11 +600,9 @@ uint32_t HCalSD::setDetUnitId(int det, const G4ThreeVector& pos, int depth, int
++detNull_[det - 3];
#endif
}
#ifdef EDM_ML_DEBUG
#ifdef printDEBUG
edm::LogVerbatim("HcalSim") << "Position " << pos.perp() << ":" << std::abs(pos.z()) << " Limits "
<< !(hcalConstants_->isHE()) << ":" << maxZ_ << " det " << det;
#endif
#ifdef printDebug
} else {
++detNull_[3];
#endif
Expand Down