From 39b996be2be64ad31b97e29269e383775a1e5194 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 11 Oct 2023 11:44:34 +0200 Subject: [PATCH] Add new collection names and information of Calibration Cells to the HGCal SD Class --- .../interface/HGCalDDDConstants.h | 8 +++++ SimG4CMS/Calo/interface/HGCalSD.h | 5 ++- SimG4CMS/Calo/src/CaloSD.cc | 4 +-- SimG4CMS/Calo/src/HGCalSD.cc | 32 +++++++++++++++++++ SimG4CMS/Calo/test/python/runHGC1_cfg.py | 32 +++++++++++++++++-- .../Application/plugins/OscarMTProducer.cc | 3 ++ 6 files changed, 79 insertions(+), 5 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h index a7e070c464874..6a48e082e7131 100644 --- a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h +++ b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h @@ -40,6 +40,14 @@ class HGCalDDDConstants { std::pair assignCell(float x, float y, int lay, int subSec, bool reco) const; std::array assignCellHex(float x, float y, int zside, int lay, bool reco, bool extend, bool debug) const; std::array assignCellTrap(float x, float y, float z, int lay, bool reco) const; + std::vector calibCells(bool hd, bool full) const { + if (hd) { + return (full ? hgpar_->calibCellFullHD_ : hgpar_->calibCellPartHD_); + } else { + return (full ? hgpar_->calibCellFullLD_ : hgpar_->calibCellPartLD_); + } + } + double calibCellRad(bool hd) const { return (hd ? hgpar_->calibCellRHD_ : hgpar_->calibCellRLD_); } bool cassetteMode() const { return ((mode_ == HGCalGeometryMode::Hexagon8Cassette) || (mode_ == HGCalGeometryMode::TrapezoidCassette) || (mode_ == HGCalGeometryMode::Hexagon8CalibCell)); diff --git a/SimG4CMS/Calo/interface/HGCalSD.h b/SimG4CMS/Calo/interface/HGCalSD.h index e3fe8ffa9918f..a3ea6a839f37f 100644 --- a/SimG4CMS/Calo/interface/HGCalSD.h +++ b/SimG4CMS/Calo/interface/HGCalSD.h @@ -54,7 +54,10 @@ class HGCalSD : public CaloSD, public Observer { bool storeAllG4Hits_; bool fiducialCut_, rejectMB_, waferRot_, checkID_; int useSimWt_, verbose_; - bool dd4hep_; + bool dd4hep_, calibCells_; + double calibCellRHD_, calibCellRLD_; + std::vector calibCellFullHD_, calibCellPartHD_; + std::vector calibCellFullLD_, calibCellPartLD_; const double tan30deg_, cos30deg_; std::vector angles_; std::string missingFile_; diff --git a/SimG4CMS/Calo/src/CaloSD.cc b/SimG4CMS/Calo/src/CaloSD.cc index e81c52e82ac51..ab2d471eb7902 100644 --- a/SimG4CMS/Calo/src/CaloSD.cc +++ b/SimG4CMS/Calo/src/CaloSD.cc @@ -386,10 +386,10 @@ void CaloSD::EndOfEvent(G4HCofThisEvent*) { cleanHitCollection(); #ifdef EDM_ML_DEBUG - if (theHC == nullptr) + if (theHC[0] == nullptr) edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with no entries"; else - edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with " << theHC->entries() << " entries"; + edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with " << theHC[0]->entries() << " entries"; #endif } diff --git a/SimG4CMS/Calo/src/HGCalSD.cc b/SimG4CMS/Calo/src/HGCalSD.cc index 441b72ba9e261..adef64b0fa431 100644 --- a/SimG4CMS/Calo/src/HGCalSD.cc +++ b/SimG4CMS/Calo/src/HGCalSD.cc @@ -23,6 +23,7 @@ #include #include #include +#include //#define EDM_ML_DEBUG @@ -44,6 +45,7 @@ HGCalSD::HGCalSD(const std::string& name, levelT1_(99), levelT2_(99), useSimWt_(0), + calibCells_(false), tan30deg_(std::tan(30.0 * CLHEP::deg)), cos30deg_(std::cos(30.0 * CLHEP::deg)) { numberingScheme_.reset(nullptr); @@ -279,6 +281,36 @@ void HGCalSD::update(const BeginOfJob* job) { guardRing_ = std::make_unique(*hgcons_); guardRingPartial_ = std::make_unique(*hgcons_); } + + //Now for calibration cells + calibCellRHD_ = hgcons_->calibCellRad(true); + calibCellRLD_ = hgcons_->calibCellRad(false); + calibCellFullHD_ = hgcons_->calibCells(true, true); + calibCellPartHD_ = hgcons_->calibCells(true, false); + calibCellFullLD_ = hgcons_->calibCells(false, true); + calibCellPartLD_ = hgcons_->calibCells(false, false); + calibCells_ = ((!calibCellFullHD_.empty()) || (!calibCellPartHD_.empty())); + calibCells_ |= ((!calibCellFullLD_.empty()) || (!calibCellPartLD_.empty())); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCSim") << "HGCalSD::Calibration cells initialized with flag " << calibCells_; + edm::LogVerbatim("HGCSim") << " Radii " << calibCellRHD_ << ":" << calibCellRLD_; + std::ostringstream st1; + for (const auto& cell : calibCellFullHD_) + st1 << " " << cell; + edm::LogVerbatim("HGCSim") << calibCellFullHD_.size() << " cells for High Density full wafers: " << st1.str(); + std::ostringstream st2; + for (const auto& cell : calibCellPartHD_) + st2 << " " << cell; + edm::LogVerbatim("HGCSim") << calibCellPartHD_.size() << " cells for High Density partial wafers: " << st2.str(); + std::ostringstream st3; + for (const auto& cell : calibCellFullLD_) + st3 << " " << cell; + edm::LogVerbatim("HGCSim") << calibCellFullLD_.size() << " cells for Low Density full wafers: " << st3.str(); + std::ostringstream st4; + for (const auto& cell : calibCellPartLD_) + st4 << " " << cell; + edm::LogVerbatim("HGCSim") << calibCellPartLD_.size() << " cells for Low Density partial wafers: " << st4.str(); +#endif } else { throw cms::Exception("Unknown", "HGCalSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n"; } diff --git a/SimG4CMS/Calo/test/python/runHGC1_cfg.py b/SimG4CMS/Calo/test/python/runHGC1_cfg.py index 6b5c8dce1788e..7d9b7094484ba 100644 --- a/SimG4CMS/Calo/test/python/runHGC1_cfg.py +++ b/SimG4CMS/Calo/test/python/runHGC1_cfg.py @@ -1,13 +1,41 @@ +############################################################################### +# Way to use this: +# cmsRun ttbar.py geometry=V18 +# Options for geometry V17Shift, V18 +# +############################################################################### import FWCore.ParameterSet.Config as cms -from Configuration.Eras.Era_Phase2C11_cff import Phase2C11 +import os, sys, imp, re +import FWCore.ParameterSet.VarParsing as VarParsing + +#################################################################### +### SETUP OPTIONS +options = VarParsing.VarParsing('standard') +options.register('geometry', + "V18", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "geometry of operations: V17Shift, V18") + +### get and parse the command line arguments + +options.parseArguments() +print(options) + +#################################################################### +from Configuration.Eras.Era_Phase2C11_cff import Phase2C11 process = cms.Process("PROD",Phase2C11) + +geomFile = "Geometry.HGCalCommonData.testHGCal" + options.geometry + "Reco_cff" +print("Geometry file: ", geomFile) + process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") process.load('Configuration.StandardSequences.Generator_cff') process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi") process.load('GeneratorInterface.Core.genFilterSummary_cff') process.load('Configuration.StandardSequences.SimIdeal_cff') -process.load("Configuration.Geometry.GeometryExtended2026D49Reco_cff") +process.load(geomFile) process.load("Configuration.StandardSequences.MagneticField_cff") process.load("Configuration.EventContent.EventContent_cff") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") diff --git a/SimG4Core/Application/plugins/OscarMTProducer.cc b/SimG4Core/Application/plugins/OscarMTProducer.cc index cddddac9998ac..0d51b73a0a8df 100644 --- a/SimG4Core/Application/plugins/OscarMTProducer.cc +++ b/SimG4Core/Application/plugins/OscarMTProducer.cc @@ -159,6 +159,9 @@ OscarMTProducer::OscarMTProducer(edm::ParameterSet const& p, const OscarMTMaster produces("HGCHitsEE"); produces("HGCHitsHEfront"); produces("HGCHitsHEback"); + produces("CalibrationHGCHitsEE"); + produces("CalibrationHGCHitsHEfront"); + produces("CalibrationHGCHitsHEback"); produces("MuonDTHits"); produces("MuonCSCHits");