From d90bb98b5fd77f42a3fe1cf860fb4f502eaf97c9 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 10 Nov 2022 03:05:26 +0100 Subject: [PATCH 1/2] Extend the testing of wrong cell assinments in HCAL --- SimG4CMS/Calo/interface/HCalSD.h | 3 +++ SimG4CMS/Calo/src/HCalSD.cc | 33 +++++++++++++++++++++++++++- SimG4CMS/Calo/test/python/minbias.py | 9 ++++++-- SimG4CMS/Calo/test/python/ttbar.py | 10 +++++++-- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/SimG4CMS/Calo/interface/HCalSD.h b/SimG4CMS/Calo/interface/HCalSD.h index 1fefbcbb26c72..778a9f37dfd46 100644 --- a/SimG4CMS/Calo/interface/HCalSD.h +++ b/SimG4CMS/Calo/interface/HCalSD.h @@ -57,6 +57,8 @@ class HCalSD : public CaloSD, public Observer { 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::vector&); @@ -120,6 +122,7 @@ class HCalSD : public CaloSD, public Observer { std::vector hfLV, fibreLV, pmtLV, fibre1LV, fibre2LV; std::map layerWeights; TH1F *hit_[9], *time_[9], *dist_[9], *hzvem, *hzvhad; + std::vector detNull_; }; #endif // HCalSD_h diff --git a/SimG4CMS/Calo/src/HCalSD.cc b/SimG4CMS/Calo/src/HCalSD.cc index aff0d17fa2032..d33379c52007a 100644 --- a/SimG4CMS/Calo/src/HCalSD.cc +++ b/SimG4CMS/Calo/src/HCalSD.cc @@ -34,6 +34,7 @@ //#define EDM_ML_DEBUG //#define plotDebug +//#define printDebug #ifdef plotDebug #include @@ -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 = @@ -1064,3 +1081,17 @@ 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(sum) / (sum + detNull_[3])); +#endif +} diff --git a/SimG4CMS/Calo/test/python/minbias.py b/SimG4CMS/Calo/test/python/minbias.py index 897d0226ea4e7..ed2e52b03f8a5 100644 --- a/SimG4CMS/Calo/test/python/minbias.py +++ b/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 @@ -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 @@ -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" diff --git a/SimG4CMS/Calo/test/python/ttbar.py b/SimG4CMS/Calo/test/python/ttbar.py index e9911023635e4..247f179266c46 100644 --- a/SimG4CMS/Calo/test/python/ttbar.py +++ b/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 @@ -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 @@ -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" @@ -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") From f6ccd86f5f27ba6a3a3409c863f3d7915995a591 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 10 Nov 2022 03:20:24 +0100 Subject: [PATCH 2/2] Code check --- SimG4CMS/Calo/src/HCalSD.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SimG4CMS/Calo/src/HCalSD.cc b/SimG4CMS/Calo/src/HCalSD.cc index d33379c52007a..74dcba967dcf6 100644 --- a/SimG4CMS/Calo/src/HCalSD.cc +++ b/SimG4CMS/Calo/src/HCalSD.cc @@ -583,7 +583,7 @@ uint32_t HCalSD::setDetUnitId(int det, const G4ThreeVector& pos, int depth, int #ifdef printDebug double eta = std::abs(pos.eta()); if (eta < 2.868) - ++detNull_[2]; + ++detNull_[2]; #endif } else if (!(hcalConstants_->isHE())) { det = 3; @@ -603,11 +603,11 @@ uint32_t HCalSD::setDetUnitId(int det, const G4ThreeVector& pos, int depth, int << !(hcalConstants_->isHE()) << ":" << maxZ_ << " det " << det; #endif #ifdef printDebug - } else { - ++detNull_[3]; + } else { + ++detNull_[3]; #endif - } - + } + if (numberingFromDDD.get()) { //get the ID's as eta, phi, depth, ... indices HcalNumberingFromDDD::HcalID tmp = @@ -1092,6 +1092,7 @@ 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(sum) / (sum + detNull_[3])); + edm::LogVerbatim("HcalSim") << "NullDets " << detNull_[0] << " " << detNull_[1] << " " << detNull_[2] << " " + << detNull_[3] << " " << (static_cast(sum) / (sum + detNull_[3])); #endif }