diff --git a/Geometry/HcalTowerAlgo/test/HcalCellCount.cc b/Geometry/HcalTowerAlgo/test/HcalCellCount.cc new file mode 100644 index 0000000000000..8ccffd52a291e --- /dev/null +++ b/Geometry/HcalTowerAlgo/test/HcalCellCount.cc @@ -0,0 +1,100 @@ +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/EcalDetId/interface/EcalSubdetector.h" +#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" +#include +#include + +class HcalCellCount : public edm::one::EDAnalyzer<> { +public: + explicit HcalCellCount(const edm::ParameterSet&); + ~HcalCellCount(void) override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + void beginJob() override {} + void analyze(edm::Event const&, edm::EventSetup const&) override; + void endJob() override {} + +private: + const int verbose_; + edm::ESGetToken tok_geom_; +}; + +HcalCellCount::HcalCellCount(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter("Verbosity")) { + tok_geom_ = esConsumes(); +} + +void HcalCellCount::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("Verbosity", 0); + descriptions.add("hcalCellCount", desc); +} + +void HcalCellCount::analyze(edm::Event const& /*iEvent*/, const edm::EventSetup& iSetup) { + const CaloGeometry* geo = &iSetup.getData(tok_geom_); + + // ECAL + const CaloSubdetectorGeometry* bGeom = geo->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + if (bGeom != nullptr) + edm::LogVerbatim("HCalGeom") << "Valid ID for EcalBarrel: " + << bGeom->getValidDetIds(DetId::Ecal, EcalBarrel).size(); + else + edm::LogVerbatim("HCalGeom") << "EB Geometry does not exist"; + const CaloSubdetectorGeometry* eGeom = geo->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); + if (eGeom != nullptr) + edm::LogVerbatim("HCalGeom") << "Valid ID for EcalEndcap: " + << eGeom->getValidDetIds(DetId::Ecal, EcalEndcap).size(); + else + edm::LogVerbatim("HCalGeom") << "EE Geometry does not exist"; + const CaloSubdetectorGeometry* sGeom = geo->getSubdetectorGeometry(DetId::Ecal, EcalPreshower); + if (sGeom != nullptr) + edm::LogVerbatim("HCalGeom") << "Valid ID for EcalPreshower: " + << sGeom->getValidDetIds(DetId::Ecal, EcalPreshower).size(); + else + edm::LogVerbatim("HCalGeom") << "ES Geometry does not exist"; + const CaloSubdetectorGeometry* tGeom = geo->getSubdetectorGeometry(DetId::Ecal, EcalTriggerTower); + if (tGeom != nullptr) + edm::LogVerbatim("HCalGeom") << "Valid ID for EcalTriggerTower: " + << tGeom->getValidDetIds(DetId::Ecal, EcalTriggerTower).size(); + else + edm::LogVerbatim("HCalGeom") << "EcalTriggerTower Geometry does not exist"; + + //HCAL + const CaloSubdetectorGeometry* gHB = geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel); + if (gHB != nullptr) { + edm::LogVerbatim("HCalGeom") << "Valid ID for HcalBarrel: " << gHB->getValidDetIds(DetId::Hcal, HcalBarrel).size(); + edm::LogVerbatim("HCalGeom") << "Valid ID for HcalEndcap: " << gHB->getValidDetIds(DetId::Hcal, HcalEndcap).size(); + edm::LogVerbatim("HCalGeom") << "Valid ID for HcalOuter: " << gHB->getValidDetIds(DetId::Hcal, HcalOuter).size(); + edm::LogVerbatim("HCalGeom") << "Valid ID for HcalForward: " + << gHB->getValidDetIds(DetId::Hcal, HcalForward).size(); + edm::LogVerbatim("HCalGeom") << "Valid ID for HcalTriggerTower: " + << gHB->getValidDetIds(DetId::Hcal, HcalTriggerTower).size(); + } else { + edm::LogVerbatim("HCalGeom") << "HCAL Geometry does not exist"; + } + + //HGCAL + const CaloSubdetectorGeometry* gHGEE = geo->getSubdetectorGeometry(DetId::HGCalEE, 0); + if (gHGEE != nullptr) + edm::LogVerbatim("HCalGeom") << "Valid ID for HGCalEE: " << gHGEE->getValidDetIds(DetId::HGCalEE, 0).size(); + else + edm::LogVerbatim("HCalGeom") << "HGCaLEE Geometry does not exist"; + const CaloSubdetectorGeometry* gHGHSi = geo->getSubdetectorGeometry(DetId::HGCalHSi, 0); + if (gHGHSi != nullptr) + edm::LogVerbatim("HCalGeom") << "Valid ID for HGCalHSi: " << gHGHSi->getValidDetIds(DetId::HGCalHSi, 0).size(); + else + edm::LogVerbatim("HCalGeom") << "HGCaLHSi Geometry does not exist"; + const CaloSubdetectorGeometry* gHGHSc = geo->getSubdetectorGeometry(DetId::HGCalHSc, 0); + if (gHGHSc != nullptr) + edm::LogVerbatim("HCalGeom") << "Valid ID for HGCalHSc: " << gHGHSc->getValidDetIds(DetId::HGCalHSc, 0).size(); + else + edm::LogVerbatim("HCalGeom") << "HGCaLHSc Geometry does not exist"; +} + +DEFINE_FWK_MODULE(HcalCellCount); diff --git a/Geometry/HcalTowerAlgo/test/python/runHcalCellCountRun3_cfg.py b/Geometry/HcalTowerAlgo/test/python/runHcalCellCountRun3_cfg.py new file mode 100644 index 0000000000000..689790396b19e --- /dev/null +++ b/Geometry/HcalTowerAlgo/test/python/runHcalCellCountRun3_cfg.py @@ -0,0 +1,147 @@ +############################################################################### +# Way to use this: +# cmsRun runHcalCellCountRun3_cfg.py geometry=2021 +# +# Options for geometry 2016, 2016dev, 2017, 2018, 2021, 2023, 2024 +# +############################################################################### +import FWCore.ParameterSet.Config as cms +import os, sys, importlib, re +import FWCore.ParameterSet.VarParsing as VarParsing + +#################################################################### +### SETUP OPTIONS +options = VarParsing.VarParsing('standard') +options.register('geometry', + "2024", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "geometry of operations: 2016, 2016dev, 2017, 2018, 2021, 2023, 2024") +### get and parse the command line arguments +options.parseArguments() + +print(options) + +#################################################################### +# Use the options + +geomName = "Configuration.Geometry.GeometryExtended" + options.geometry + "Reco_cff" + +if (options.geometry == "2016"): + from Configuration.Eras.Era_Run2_2016_cff import Run2_2016 + process = cms.Process('G4PrintGeometry',Run2_2016) +elif (options.geometry == "2016dev"): + from Configuration.Eras.Era_Run2_2016_cff import Run2_2016 + process = cms.Process('G4PrintGeometry',Run2_2016) +elif (options.geometry == "2017"): + from Configuration.Eras.Era_Run2_2017_cff import Run2_2017 + process = cms.Process('G4PrintGeometry',Run2_2017) +elif (options.geometry == "2018"): + from Configuration.Eras.Era_Run2_2018_cff import Run2_2018 + process = cms.Process('G4PrintGeometry',Run2_2018) +else: + from Configuration.Eras.Era_Run3_DDD_cff import Run3_DDD + process = cms.Process('G4PrintGeometry',Run3_DDD) + +print("Geom file Name: ", geomName) + +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load(geomName) +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('Geometry.HcalTowerAlgo.hcalCellCount_cfi') + +process.MessageLogger.G4cout=dict() + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +if hasattr(process,'MessageLogger'): + process.MessageLogger.HCalGeom=dict() + + +process.source = cms.Source("EmptySource") + +process.generator = cms.EDProducer("FlatRandomPtGunProducer", + PGunParameters = cms.PSet( + PartID = cms.vint32(13), + MinEta = cms.double(-2.5), + MaxEta = cms.double(2.5), + MinPhi = cms.double(-3.14159265359), + MaxPhi = cms.double(3.14159265359), + MinPt = cms.double(9.99), + MaxPt = cms.double(10.01) + ), + AddAntiParticle = cms.bool(False), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1) +) + +process.options = cms.untracked.PSet( + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + TryToContinue = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + holdsReferencesToDeleteEarly = cms.untracked.VPSet(), + makeTriggerResults = cms.obsolete.untracked.bool, + modulesToCallForTryToContinue = cms.untracked.vstring(), + modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +process.ProductionFilterSequence = cms.Sequence(process.generator) +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2024_realistic', '') + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.analysis_step = cms.EndPath(process.hcalCellCount) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step, + process.genfiltersummary_step, + process.simulation_step, + process.analysis_step, + process.endjob_step) + +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.ProductionFilterSequence) + +process.g4SimHits.UseMagneticField = False +process.g4SimHits.Physics.DefaultCutValue = 10. + diff --git a/Geometry/HcalTowerAlgo/test/python/runHcalCellCountRun4_cfg.py b/Geometry/HcalTowerAlgo/test/python/runHcalCellCountRun4_cfg.py new file mode 100644 index 0000000000000..2c7c7083e85c2 --- /dev/null +++ b/Geometry/HcalTowerAlgo/test/python/runHcalCellCountRun4_cfg.py @@ -0,0 +1,144 @@ +############################################################################### +# Way to use this: +# cmsRun runHcalCellCountRun4_cfg.py geometry=D110 +# +# Options for geometry D95, D96, D98, D99, D100, D101, D102, D103, D104, +# D105, D106, D107, D108, D109, D110, D111, D112, D113, +# D114, D115, D116 +# +############################################################################### +import FWCore.ParameterSet.Config as cms +import os, sys, importlib, re +import FWCore.ParameterSet.VarParsing as VarParsing + +#################################################################### +### SETUP OPTIONS +options = VarParsing.VarParsing('standard') +options.register('geometry', + "D110", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "geometry of operations: D95, D96, D98, D99, D100, D101, D102, D103, D104, D105, D106, D107, D108, D109, D110, D111, D112, D113, D114, D115, D116") +### get and parse the command line arguments +options.parseArguments() + +print(options) + +#################################################################### +# Use the options + +geomFile = "Configuration.Geometry.GeometryExtendedRun4" + options.geometry + "Reco_cff" +geomName = "Run4" + options.geometry + +print("Geometry Name: ", geomName) +print("Geom file Name: ", geomFile) + +import Configuration.Geometry.defaultPhase2ConditionsEra_cff as _settings +GLOBAL_TAG, ERA = _settings.get_era_and_conditions(geomName) + +print("Global Tag Name: ", GLOBAL_TAG) +print("Era Name: ", ERA) + + +process = cms.Process('HcalCellCount',ERA) + +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load(geomFile) +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedRealisticHLLHC_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('Geometry.HcalTowerAlgo.hcalCellCount_cfi') + +process.MessageLogger.G4cout=dict() + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +if hasattr(process,'MessageLogger'): + process.MessageLogger.HCalGeom=dict() + + +process.source = cms.Source("EmptySource") + +process.generator = cms.EDProducer("FlatRandomPtGunProducer", + PGunParameters = cms.PSet( + PartID = cms.vint32(13), + MinEta = cms.double(-2.5), + MaxEta = cms.double(2.5), + MinPhi = cms.double(-3.14159265359), + MaxPhi = cms.double(3.14159265359), + MinPt = cms.double(9.99), + MaxPt = cms.double(10.01) + ), + AddAntiParticle = cms.bool(False), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1) +) + +process.options = cms.untracked.PSet( + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + TryToContinue = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + holdsReferencesToDeleteEarly = cms.untracked.VPSet(), + makeTriggerResults = cms.obsolete.untracked.bool, + modulesToCallForTryToContinue = cms.untracked.vstring(), + modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +process.ProductionFilterSequence = cms.Sequence(process.generator) +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, GLOBAL_TAG, '') + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.analysis_step = cms.EndPath(process.hcalCellCount) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step, + process.genfiltersummary_step, + process.simulation_step, + process.analysis_step, + process.endjob_step) + +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.ProductionFilterSequence) + +process.g4SimHits.UseMagneticField = False +process.g4SimHits.Physics.DefaultCutValue = 10. +