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

Run3-sim136 Extend the testing of wrong cell assignments in HCAL #40035

Merged
merged 2 commits into from Nov 11, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions SimG4CMS/Calo/interface/HCalSD.h
Expand Up @@ -57,6 +57,8 @@ class HCalSD : public CaloSD, public Observer<const BeginOfJob*> {
void update(const BeginOfJob*) override;
void initRun() override;
bool filterHit(CaloG4Hit*, double) override;
void initEvent(const BeginOfEvent*) override;
void endEvent() override;

private:
void fillLogVolumeVector(const std::string&, const std::vector<std::string>&, std::vector<const G4LogicalVolume*>&);
Expand Down Expand Up @@ -120,6 +122,7 @@ class HCalSD : public CaloSD, public Observer<const BeginOfJob*> {
std::vector<const G4LogicalVolume*> hfLV, fibreLV, pmtLV, fibre1LV, fibre2LV;
std::map<uint32_t, double> layerWeights;
TH1F *hit_[9], *time_[9], *dist_[9], *hzvem, *hzvhad;
std::vector<int> detNull_;
};

#endif // HCalSD_h
32 changes: 32 additions & 0 deletions SimG4CMS/Calo/src/HCalSD.cc
Expand Up @@ -34,6 +34,7 @@

//#define EDM_ML_DEBUG
//#define plotDebug
//#define printDebug

#ifdef plotDebug
#include <TH1F.h>
Expand Down Expand Up @@ -579,18 +580,34 @@ uint32_t HCalSD::setDetUnitId(int det, const G4ThreeVector& pos, int depth, int
if (det == 0) {
if (std::abs(pos.z()) > maxZ_) {
det = 5;
#ifdef printDebug
double eta = std::abs(pos.eta());
if (eta < 2.868)
++detNull_[2];
#endif
} else if (!(hcalConstants_->isHE())) {
det = 3;
#ifdef printDebug
++detNull_[0];
#endif
} else {
double minR = minRoff_ + slopeHE_ * std::abs(pos.z());
double maxR = maxRoff_ + slopeHE_ * std::abs(pos.z());
det = ((pos.perp() > minR) && (pos.perp() < maxR)) ? 4 : 3;
#ifdef printDebug
++detNull_[det - 3];
#endif
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HcalSim") << "Position " << pos.perp() << ":" << std::abs(pos.z()) << " Limits "
<< !(hcalConstants_->isHE()) << ":" << maxZ_ << " det " << det;
#endif
#ifdef printDebug
} else {
++detNull_[3];
#endif
}

if (numberingFromDDD.get()) {
//get the ID's as eta, phi, depth, ... indices
HcalNumberingFromDDD::HcalID tmp =
Expand Down Expand Up @@ -1064,3 +1081,18 @@ void HCalSD::modifyDepth(HcalNumberingFromDDD::HcalID& id) {
id.depth = (depth_ == 0) ? 1 : 2;
}
}

void HCalSD::initEvent(const BeginOfEvent*) {
#ifdef printDebug
detNull_ = {0, 0, 0, 0};
#endif
}

void HCalSD::endEvent() {
#ifdef printDebug
int sum = detNull_[0] + detNull_[1] + detNull_[2];
if (sum > 0)
edm::LogVerbatim("HcalSim") << "NullDets " << detNull_[0] << " " << detNull_[1] << " " << detNull_[2] << " "
<< detNull_[3] << " " << (static_cast<float>(sum) / (sum + detNull_[3]));
#endif
}
9 changes: 7 additions & 2 deletions SimG4CMS/Calo/test/python/minbias.py
@@ -1,7 +1,7 @@
###############################################################################
# Way to use this:
# cmsRun minbias.py geometry=2016
# Options for geometry 2016, 2017, 2018, 2021, legacy
# Options for geometry 2016, 2017, 2018, 2021, 2026, legacy
#
###############################################################################
import FWCore.ParameterSet.Config as cms
Expand All @@ -15,7 +15,7 @@
"2021",
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"geometry of operations: 2016, 2017, 2018, 2021")
"geometry of operations: 2016, 2017, 2018, 2021, 2026, legacy")

### get and parse the command line arguments

Expand Down Expand Up @@ -48,6 +48,11 @@
process = cms.Process('Sim',Run3_DDD)
geomFile = "Configuration.Geometry.GeometryExtended" + options.geometry + "Reco_cff"
globalTag = "auto:phase1_2022_realistic"
elif (options.geometry == "2026"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('Sim',Phase2C11M9)
geomFile = "Configuration.Geometry.GeometryExtended" + options.geometry + "D88Reco_cff"
globalTag = "auto:phase2_realistic"
else:
process = cms.Process('Sim')
geomFile = "Configuration.Geometry.GeometryExtendedReco_cff"
Expand Down
10 changes: 8 additions & 2 deletions SimG4CMS/Calo/test/python/ttbar.py
@@ -1,7 +1,7 @@
###############################################################################
# Way to use this:
# cmsRun ttbar.py geometry=2016
# Options for geometry 2016, 2017, 2018, 2021, legacy
# Options for geometry 2016, 2017, 2018, 2021, 2026, legacy
#
###############################################################################
import FWCore.ParameterSet.Config as cms
Expand All @@ -15,7 +15,7 @@
"2021",
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"geometry of operations: 2016, 2017, 2018, 2021")
"geometry of operations: 2016, 2017, 2018, 2021, 2026, legacy")

### get and parse the command line arguments

Expand Down Expand Up @@ -48,6 +48,11 @@
process = cms.Process('Sim',Run3_DDD)
geomFile = "Configuration.Geometry.GeometryExtended" + options.geometry + "Reco_cff"
globalTag = "auto:phase1_2022_realistic"
elif (options.geometry == "2026"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('Sim',Phase2C11M9)
geomFile = "Configuration.Geometry.GeometryExtended" + options.geometry + "D88Reco_cff"
globalTag = "auto:phase2_realistic"
else:
process = cms.Process('Sim')
geomFile = "Configuration.Geometry.GeometryExtendedReco_cff"
Expand Down Expand Up @@ -82,6 +87,7 @@
if 'MessageLogger' in process.__dict__:
process.MessageLogger.G4cerr=dict()
process.MessageLogger.HitStudy=dict()
process.MessageLogger.HcalSim=dict()

process.Timing = cms.Service("Timing")

Expand Down