Skip to content

Instantly share code, notes, and snippets.

@aminnj
Last active September 17, 2019 18:42
Show Gist options
  • Save aminnj/c06bede0f8693ea0ffd612e269be4013 to your computer and use it in GitHub Desktop.
Save aminnj/c06bede0f8693ea0ffd612e269be4013 to your computer and use it in GitHub Desktop.
Dump a subset of a cmssw pset recursively
from pset_rawsim_onlyhlt import process
def recurse_coll(item,already_dumped=[]):
if hasattr(item,"_seq"):
print("process.{} = {}\n".format(item.label(),item.dumpPython()))
for thing in item._seq._collection:
for x in recurse_coll(thing): yield x
if hasattr(item,"_Parameterizable__parameterNames"):
if not item.label() in already_dumped:
print("process.{} = {}\n".format(item.label(),item.dumpPython()))
for thing in item.parameters_().items():
for x in recurse_coll(thing): yield x
already_dumped.append(item.label())
if type(item) in [tuple]:
pk,pv = item
if pv.configTypeName() == "InputTag":
label = pv.value().split(":",1)[0]
if hasattr(process,label):
for x in recurse_coll(getattr(process,label)): yield x
else:
yield pk,pv
maincoll = process.ScoutingCaloMuonOutput
_ = list(recurse_coll(maincoll))
@aminnj
Copy link
Author

aminnj commented Sep 17, 2019

Also run edmConfigDump on the pset and copy in the lines like

import FWCore.ParameterSet.Config as cms
process = cms.Process("HLT")

to the beginning of the output of the gist script output. Also make sure the sequence is defined at the bottom (move if necessary). Then you should be able to use edmConfigToHTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment