From bed84d283898e9d3fd4a76e068b7001e48adcc6a Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 29 May 2020 17:02:14 -0500 Subject: [PATCH 1/4] PhaseII dd4hep test --- ...gMaterialAnalyser_ForPhaseII_dd4hep_cff.py | 4 + ...gMaterialAnalyser_ForPhaseII_dd4hep_cfi.py | 45 +++++++++ ...ckingMaterialAnalyser_ForPhaseII_dd4hep.py | 93 +++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cff.py create mode 100644 SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py create mode 100755 SimTracker/TrackerMaterialAnalysis/test/trackingMaterialAnalyser_ForPhaseII_dd4hep.py diff --git a/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cff.py b/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cff.py new file mode 100644 index 0000000000000..dafa7a7ee0688 --- /dev/null +++ b/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cff.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +# Analyze and plot the tracking material +from SimTracker.TrackerMaterialAnalysis.trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi import * diff --git a/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py b/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py new file mode 100644 index 0000000000000..afabd94926f5d --- /dev/null +++ b/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py @@ -0,0 +1,45 @@ +import FWCore.ParameterSet.Config as cms + +trackingMaterialAnalyser = cms.EDAnalyzer("DD4hep_TrackingMaterialAnalyser", + MaterialAccounting = cms.InputTag("trackingMaterialProducer"), + SplitMode = cms.string("NearestLayer"), + SkipBeforeFirstDetector = cms.bool(False), + SkipAfterLastDetector = cms.bool(True), + SaveSummaryPlot = cms.bool(True), + SaveDetailedPlots = cms.bool(False), + SaveParameters = cms.bool(True), + SaveXML = cms.bool(True), + isHGCal = cms.bool(False), + isHFNose = cms.bool(False), +# to derive the following list: +# cat ../data/trackingMaterialGroups_ForPhaseII.xml | grep TrackingMaterialGroup | sed -e 's/\s*//' | cut -d ' ' -f 3 | tr '=' ' ' | cut -d ' ' -f 2 | tr -d '"' | sed -e 's/\(.*\)/"\1",/' + Groups = cms.vstring( + "TrackerRecMaterialPhase2PixelBarrelLayer1", + "TrackerRecMaterialPhase2PixelBarrelLayer2", + "TrackerRecMaterialPhase2PixelBarrelLayer3", + "TrackerRecMaterialPhase2PixelBarrelLayer4", + "TrackerRecMaterialPhase2PixelForwardDisk1", + "TrackerRecMaterialPhase2PixelForwardDisk2", + "TrackerRecMaterialPhase2PixelForwardDisk3", + "TrackerRecMaterialPhase2PixelForwardDisk4", + "TrackerRecMaterialPhase2PixelForwardDisk5", + "TrackerRecMaterialPhase2PixelForwardDisk6", + "TrackerRecMaterialPhase2PixelForwardDisk7", + "TrackerRecMaterialPhase2PixelForwardDisk8", + "TrackerRecMaterialPhase2PixelForwardDisk9", + "TrackerRecMaterialPhase2PixelForwardDisk10", + "TrackerRecMaterialPhase2PixelForwardDisk11", + "TrackerRecMaterialPhase2PixelForwardDisk12", + "TrackerRecMaterialPhase2OTBarrelLayer1", + "TrackerRecMaterialPhase2OTBarrelLayer2", + "TrackerRecMaterialPhase2OTBarrelLayer3", + "TrackerRecMaterialPhase2OTBarrelLayer4", + "TrackerRecMaterialPhase2OTBarrelLayer5", + "TrackerRecMaterialPhase2OTBarrelLayer6", + "TrackerRecMaterialPhase2OTForwardDisk1", + "TrackerRecMaterialPhase2OTForwardDisk2", + "TrackerRecMaterialPhase2OTForwardDisk3", + "TrackerRecMaterialPhase2OTForwardDisk4", + "TrackerRecMaterialPhase2OTForwardDisk5" + ) +) diff --git a/SimTracker/TrackerMaterialAnalysis/test/trackingMaterialAnalyser_ForPhaseII_dd4hep.py b/SimTracker/TrackerMaterialAnalysis/test/trackingMaterialAnalyser_ForPhaseII_dd4hep.py new file mode 100755 index 0000000000000..25297ef6f0094 --- /dev/null +++ b/SimTracker/TrackerMaterialAnalysis/test/trackingMaterialAnalyser_ForPhaseII_dd4hep.py @@ -0,0 +1,93 @@ +#! /usr/bin/env cmsRun + +import FWCore.ParameterSet.Config as cms + +process = cms.Process("MaterialAnalyser") + +readGeometryFromDB = False + +# Configuration and Conditions +# We cannot read the geometry from the DB, since we have to inject out custom-made +# material-budget grouping into the DDD of the detector. So we need to read the +# geometry using the XMLIdealGeometryRecord. +if readGeometryFromDB: +# Global Tag and geometry via it + process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff") + from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag + process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') +else: + process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff') + +process.load('FWCore.MessageService.MessageLogger_cfi') + +# Add our custom detector grouping to DDD +process.XMLIdealGeometryESSource.geomXMLFiles.extend(['SimTracker/TrackerMaterialAnalysis/data/trackingMaterialGroups_ForPhaseII.xml']) + +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath( + 'DetectorDescription/DDCMS/data/cms-geometry-2021.xml' + ), + appendToDataLabel = cms.string('CMS') +) + +process.DDSpecParRegistryESProducer = cms.ESProducer( + "DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('CMS') +) + +process.DDCompactViewESProducer = cms.ESProducer( + "DDCompactViewESProducer", + appendToDataLabel = cms.string('CMS') +) + +# Analyze and plot the tracking material +process.load("SimTracker.TrackerMaterialAnalysis.trackingMaterialAnalyser_ForPhaseII_dd4hep_cff") +process.trackingMaterialAnalyser.SplitMode = "NearestLayer" +process.trackingMaterialAnalyser.SaveParameters = True +process.trackingMaterialAnalyser.SaveXML = True +process.trackingMaterialAnalyser.SaveDetailedPlots = False + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('file:material.root') +) + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + + +process.path = cms.Path(process.trackingMaterialAnalyser) + + +def customizeMessageLogger(process): + ### Easy customisation of MessageLogger ### + # 1. Extend MessageLogger to monitor all modules: the * means any + # label for all defined python modules + process.MessageLogger.debugModules.extend(['*']) + # 2. Define destination and its default logging properties + destination = 'debugTrackingMaterialAnalyzer' + how_to_debug = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), + DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + ) + # 3. Attach destination and its logging properties to the main process + process.MessageLogger.destinations.extend([destination]) + process.MessageLogger._Parameterizable__addParameter(destination, how_to_debug) + # 4. Define and extend the categories we would like to monitor + log_debug_categories = ['TrackingMaterialAnalyser', 'MaterialAccountingGroup'] + process.MessageLogger.categories.extend(log_debug_categories) + + # 5. Extend the configuration of the configured destination so that it + # will trace all messages coming from the list of specified + # categories. + unlimit_debug = cms.untracked.PSet(limit = cms.untracked.int32(-1)) + for val in log_debug_categories: + process.MessageLogger.debugTrackingMaterialAnalyzer._Parameterizable__addParameter(val, unlimit_debug) + + return process + + +#process = customizeMessageLogger(process) + + From 6430959d170798e8bb1730a990126abeadbdc8ad Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Mon, 1 Jun 2020 11:44:03 -0500 Subject: [PATCH 2/4] Additional DDDetector tag --- .../plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc | 3 ++- .../plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.h | 1 + .../python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py | 1 + ...alyser_ForPhaseII_dd4hep.py => TrackingMaterialAnalyser.py} | 0 4 files changed, 4 insertions(+), 1 deletion(-) rename SimTracker/TrackerMaterialAnalysis/test/{trackingMaterialAnalyser_ForPhaseII_dd4hep.py => TrackingMaterialAnalyser.py} (100%) diff --git a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc index ae195c488b33a..a4b5ae855873c 100644 --- a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc +++ b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc @@ -41,6 +41,7 @@ DD4hep_TrackingMaterialAnalyser::DD4hep_TrackingMaterialAnalyser(const edm::Para << "Invalid SplitMode \"" << splitmode << "\". Acceptable values are \"NearestLayer\", \"InnerLayer\", \"OuterLayer\"."; } + m_tag = iPSet.getParameter("DDDetector"); m_skipAfterLastDetector = iPSet.getParameter("SkipAfterLastDetector"); m_skipBeforeFirstDetector = iPSet.getParameter("SkipBeforeFirstDetector"); m_saveSummaryPlot = iPSet.getParameter("SaveSummaryPlot"); @@ -149,7 +150,7 @@ void DD4hep_TrackingMaterialAnalyser::endJob(void) { void DD4hep_TrackingMaterialAnalyser::analyze(const edm::Event& event, const edm::EventSetup& setup) { using namespace edm; ESTransientHandle hDDD; - setup.get().get(hDDD); + setup.get().get(m_tag,hDDD); m_groups.reserve(m_groupNames.size()); // Initialize m_groups iff it has size equal to zero, so that we are diff --git a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.h b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.h index 05b11e842d988..3789ed39c43e1 100644 --- a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.h +++ b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.h @@ -33,6 +33,7 @@ class DD4hep_TrackingMaterialAnalyser : public edm::one::EDAnalyzer<> { void saveLayerPlots(); edm::EDGetTokenT > m_materialToken; + edm::ESInputTag m_tag; SplitMode m_splitMode; bool m_skipAfterLastDetector; bool m_skipBeforeFirstDetector; diff --git a/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py b/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py index afabd94926f5d..c4ebc814ec63a 100644 --- a/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py +++ b/SimTracker/TrackerMaterialAnalysis/python/trackingMaterialAnalyser_ForPhaseII_dd4hep_cfi.py @@ -3,6 +3,7 @@ trackingMaterialAnalyser = cms.EDAnalyzer("DD4hep_TrackingMaterialAnalyser", MaterialAccounting = cms.InputTag("trackingMaterialProducer"), SplitMode = cms.string("NearestLayer"), + DDDetector = cms.ESInputTag("","CMS"), SkipBeforeFirstDetector = cms.bool(False), SkipAfterLastDetector = cms.bool(True), SaveSummaryPlot = cms.bool(True), diff --git a/SimTracker/TrackerMaterialAnalysis/test/trackingMaterialAnalyser_ForPhaseII_dd4hep.py b/SimTracker/TrackerMaterialAnalysis/test/TrackingMaterialAnalyser.py similarity index 100% rename from SimTracker/TrackerMaterialAnalysis/test/trackingMaterialAnalyser_ForPhaseII_dd4hep.py rename to SimTracker/TrackerMaterialAnalysis/test/TrackingMaterialAnalyser.py From 9b27a44b33b447fdb85c3b20624d59a6f70834d3 Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 5 Jun 2020 10:23:43 -0500 Subject: [PATCH 3/4] Fix DDProducer --- .../data/dd4hep_trackingMaterialGroups.xml | 7 ++ .../test/TrackingMaterialAnalyser.py | 80 ++++--------------- .../test/listIds_dd4hep.py | 3 +- 3 files changed, 25 insertions(+), 65 deletions(-) diff --git a/SimTracker/TrackerMaterialAnalysis/data/dd4hep_trackingMaterialGroups.xml b/SimTracker/TrackerMaterialAnalysis/data/dd4hep_trackingMaterialGroups.xml index bf4c137f19d3d..ce982c585b23a 100644 --- a/SimTracker/TrackerMaterialAnalysis/data/dd4hep_trackingMaterialGroups.xml +++ b/SimTracker/TrackerMaterialAnalysis/data/dd4hep_trackingMaterialGroups.xml @@ -1,5 +1,12 @@ + + + + + + + diff --git a/SimTracker/TrackerMaterialAnalysis/test/TrackingMaterialAnalyser.py b/SimTracker/TrackerMaterialAnalysis/test/TrackingMaterialAnalyser.py index 25297ef6f0094..fc9bf5230ae8e 100755 --- a/SimTracker/TrackerMaterialAnalysis/test/TrackingMaterialAnalyser.py +++ b/SimTracker/TrackerMaterialAnalysis/test/TrackingMaterialAnalyser.py @@ -4,40 +4,26 @@ process = cms.Process("MaterialAnalyser") -readGeometryFromDB = False - -# Configuration and Conditions -# We cannot read the geometry from the DB, since we have to inject out custom-made -# material-budget grouping into the DDD of the detector. So we need to read the -# geometry using the XMLIdealGeometryRecord. -if readGeometryFromDB: -# Global Tag and geometry via it - process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff") - from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag - process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') -else: - process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff') - -process.load('FWCore.MessageService.MessageLogger_cfi') - -# Add our custom detector grouping to DDD -process.XMLIdealGeometryESSource.geomXMLFiles.extend(['SimTracker/TrackerMaterialAnalysis/data/trackingMaterialGroups_ForPhaseII.xml']) - -process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", - confGeomXMLFiles = cms.FileInPath( - 'DetectorDescription/DDCMS/data/cms-geometry-2021.xml' - ), +process.DDDetectorESProducer = cms.ESSource( + "DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('SimTracker/TrackerMaterialAnalysis/data/dd4hep_trackingMaterialGroups.xml'), appendToDataLabel = cms.string('CMS') ) -process.DDSpecParRegistryESProducer = cms.ESProducer( - "DDSpecParRegistryESProducer", - appendToDataLabel = cms.string('CMS') -) +from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff import * +from SLHCUpgradeSimulations.Geometry.fakeConditions_phase2TkT14_cff import * +from Geometry.EcalCommonData.ecalSimulationParameters_cff import * +from Geometry.HcalCommonData.hcalDDDSimConstants_cff import * +from Geometry.HGCalCommonData.hgcalParametersInitialization_cfi import * +from Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi import * +from Geometry.MuonNumbering.muonGeometryConstants_cff import * +from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cff import * + +process.load('FWCore.MessageService.MessageLogger_cfi') process.DDCompactViewESProducer = cms.ESProducer( - "DDCompactViewESProducer", - appendToDataLabel = cms.string('CMS') + "DDCompactViewESProducer", + appendToDataLabel = cms.string('CMS') ) # Analyze and plot the tracking material @@ -51,43 +37,11 @@ fileNames = cms.untracked.vstring('file:material.root') ) - process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) - +process.MessageLogger.destinations.extend(["LogTrackingMaterialAnalysis"]) +process.MessageLogger.categories.append("TrackingMaterialAnalysis") process.path = cms.Path(process.trackingMaterialAnalyser) - -def customizeMessageLogger(process): - ### Easy customisation of MessageLogger ### - # 1. Extend MessageLogger to monitor all modules: the * means any - # label for all defined python modules - process.MessageLogger.debugModules.extend(['*']) - # 2. Define destination and its default logging properties - destination = 'debugTrackingMaterialAnalyzer' - how_to_debug = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), - DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), - default = cms.untracked.PSet(limit = cms.untracked.int32(0)), - ) - # 3. Attach destination and its logging properties to the main process - process.MessageLogger.destinations.extend([destination]) - process.MessageLogger._Parameterizable__addParameter(destination, how_to_debug) - # 4. Define and extend the categories we would like to monitor - log_debug_categories = ['TrackingMaterialAnalyser', 'MaterialAccountingGroup'] - process.MessageLogger.categories.extend(log_debug_categories) - - # 5. Extend the configuration of the configured destination so that it - # will trace all messages coming from the list of specified - # categories. - unlimit_debug = cms.untracked.PSet(limit = cms.untracked.int32(-1)) - for val in log_debug_categories: - process.MessageLogger.debugTrackingMaterialAnalyzer._Parameterizable__addParameter(val, unlimit_debug) - - return process - - -#process = customizeMessageLogger(process) - - diff --git a/SimTracker/TrackerMaterialAnalysis/test/listIds_dd4hep.py b/SimTracker/TrackerMaterialAnalysis/test/listIds_dd4hep.py index 33b0f3362ac54..b419a331aeb7d 100755 --- a/SimTracker/TrackerMaterialAnalysis/test/listIds_dd4hep.py +++ b/SimTracker/TrackerMaterialAnalysis/test/listIds_dd4hep.py @@ -27,8 +27,7 @@ process.DDSpecParRegistryESProducer = cms.ESProducer( - "DDSpecParRegistryESProducer", - appendToDataLabel = cms.string('CMS') + "DDSpecParRegistryESProducer" ) process.DDCompactViewESProducer = cms.ESProducer( From 2144981f0c92c20cf04394c2fc55b97a644c5e40 Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 5 Jun 2020 11:14:25 -0500 Subject: [PATCH 4/4] scram b code-format --- .../plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc index a4b5ae855873c..e149a828cb1f3 100644 --- a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc +++ b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_TrackingMaterialAnalyser.cc @@ -150,7 +150,7 @@ void DD4hep_TrackingMaterialAnalyser::endJob(void) { void DD4hep_TrackingMaterialAnalyser::analyze(const edm::Event& event, const edm::EventSetup& setup) { using namespace edm; ESTransientHandle hDDD; - setup.get().get(m_tag,hDDD); + setup.get().get(m_tag, hDDD); m_groups.reserve(m_groupNames.size()); // Initialize m_groups iff it has size equal to zero, so that we are