2 import FWCore.ParameterSet.Config
as cms
5 "Find all EDProducers in the Process that are instances of the given C++ type." 6 switches = (module
for module
in (getattr(switchproducer, case) \
7 for switchproducer
in process._Process__switchproducers.values() \
8 for case
in switchproducer.parameterNames_()) \
9 if isinstance(module, cms.EDProducer))
10 return (module
for module
in itertools.chain(process._Process__producers.values(), switches) \
11 if module._TypedParameterizable__type
in types)
14 "Find all EDFilters in the Process that are instances of the given C++ type." 15 return (filter
for filter
in process._Process__filters.values()
if filter._TypedParameterizable__type
in types)
18 "Find all EDAnalyzers in the Process that are instances of the given C++ type." 19 return (analyzer
for analyzer
in process._Process__analyzers.values()
if analyzer._TypedParameterizable__type
in types)
22 "Find all ESProducers in the Process that are instances of the given C++ type." 23 return (module
for module
in process._Process__esproducers.values()
if module._TypedParameterizable__type
in types)
26 "Find all modiles or other components in the Process that are instances of the given C++ type." 27 switches = (module
for module
in (getattr(switchproducer, case) \
28 for switchproducer
in process._Process__switchproducers.values() \
29 for case
in switchproducer.parameterNames_()))
30 return (module
for module
in itertools.chain(process.__dict__.values(), switches) \
31 if hasattr(module,
'_TypedParameterizable__type')
and module._TypedParameterizable__type
in types)
35 "Add the `modules` before the `target` in any Sequence, Paths or EndPath that contains the latter." 36 for sequence
in itertools.chain(
37 process._Process__sequences.values(),
38 process._Process__paths.values(),
39 process._Process__endpaths.values()
42 position = sequence.index(target)
46 for module
in reversed(modules):
47 sequence.insert(position, module)
51 "Add the `modules` after the `target` in any Sequence, Paths or EndPath that contains the latter." 52 for sequence
in itertools.chain(
53 process._Process__sequences.values(),
54 process._Process__paths.values(),
55 process._Process__endpaths.values()
58 position = sequence.index(target)
62 for module
in reversed(modules):
63 sequence.insert(position+1, module)
68 """Replace one object with a different one of the same type. 70 This function replaces the contents of `fromObj` object with those of `toObj`, 71 so all references ot it remain valid. 74 if not isinstance(toObj, type(fromObj)):
75 raise TypeError(
'replaceWith requires both arguments to be the same type')
77 if isinstance(toObj, cms._ModuleSequenceType):
78 fromObj._seq = toObj._seq
80 elif isinstance(toObj, cms._Parameterizable):
82 for p
in fromObj.parameterNames_():
84 for p
in toObj.parameterNames_():
85 setattr(fromObj, p, getattr(toObj, p))
86 if isinstance(toObj, cms._TypedParameterizable):
87 fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
90 raise TypeError(
'replaceWith does not work with "%s" objects' %
str(type(fromObj)))
95 columns = len(process.PrescaleService.lvl1Labels.value())
96 prescales = cms.vuint32([prescale] * columns)
98 for pset
in process.PrescaleService.prescaleTable:
99 if pset.pathName.value() == path:
100 pset.prescales = prescales
103 process.PrescaleService.prescaleTable.append(cms.PSet(
104 pathName = cms.string(path),
105 prescales = prescales
def replace_with(fromObj, toObj)
def filters_by_type(process, types)
def insert_modules_before(process, target, modules)
def modules_by_type(process, types)
def set_prescale(process, path, prescale)
def producers_by_type(process, types)
def insert_modules_after(process, target, modules)
def analyzers_by_type(process, types)
def esproducers_by_type(process, types)