Skip to content

Commit

Permalink
Merge pull request #40227 from bsunanda/Run-sim137
Browse files Browse the repository at this point in the history
Run-sim137 Correct the code in the analysis code of Simulation
  • Loading branch information
cmsbuild committed Dec 5, 2022
2 parents 40e0d38 + 62c890d commit 777fa29
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
33 changes: 22 additions & 11 deletions SimG4CMS/Calo/plugins/CaloSimHitStudy.cc
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
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

0 comments on commit 777fa29

Please sign in to comment.