CMS 3D CMS Logo

Functions
common Namespace Reference

Functions

def analyzers_by_type (process, *types)
 
def esproducers_by_type (process, *types)
 
def filters_by_type (process, *types)
 
def insert_modules_after (process, target, *modules)
 
def insert_modules_before (process, target, *modules)
 
def modules_by_type (process, *types)
 
def producers_by_type (process, *types)
 
def replace_with (fromObj, toObj)
 

Function Documentation

◆ analyzers_by_type()

def common.analyzers_by_type (   process,
types 
)

Definition at line 14 of file common.py.

14 def analyzers_by_type(process, *types):
15  "Find all EDAnalyzers in the Process that are instances of the given C++ type."
16  return (analyzer for analyzer in process._Process__analyzers.values() if analyzer._TypedParameterizable__type in types)
17 

◆ esproducers_by_type()

def common.esproducers_by_type (   process,
types 
)

Definition at line 18 of file common.py.

18 def esproducers_by_type(process, *types):
19  "Find all ESProducers in the Process that are instances of the given C++ type."
20  return (module for module in process._Process__esproducers.values() if module._TypedParameterizable__type in types)
21 

◆ filters_by_type()

def common.filters_by_type (   process,
types 
)

Definition at line 10 of file common.py.

10 def filters_by_type(process, *types):
11  "Find all EDFilters in the Process that are instances of the given C++ type."
12  return (filter for filter in process._Process__filters.values() if filter._TypedParameterizable__type in types)
13 

◆ insert_modules_after()

def common.insert_modules_after (   process,
  target,
modules 
)

Definition at line 43 of file common.py.

43 def insert_modules_after(process, target, *modules):
44  "Add the `modules` after the `target` in any Sequence, Paths or EndPath that contains the latter."
45  for sequence in itertools.chain(
46  six.itervalues(process._Process__sequences),
47  six.itervalues(process._Process__paths),
48  six.itervalues(process._Process__endpaths)
49  ):
50  try:
51  position = sequence.index(target)
52  except ValueError:
53  continue
54  else:
55  for module in reversed(modules):
56  sequence.insert(position+1, module)
57 
58 
59 # logic from Modifier.toModify from FWCore/ParameterSet/python/Config.py

◆ insert_modules_before()

def common.insert_modules_before (   process,
  target,
modules 
)

Definition at line 27 of file common.py.

27 def insert_modules_before(process, target, *modules):
28  "Add the `modules` before the `target` in any Sequence, Paths or EndPath that contains the latter."
29  for sequence in itertools.chain(
30  six.itervalues(process._Process__sequences),
31  six.itervalues(process._Process__paths),
32  six.itervalues(process._Process__endpaths)
33  ):
34  try:
35  position = sequence.index(target)
36  except ValueError:
37  continue
38  else:
39  for module in reversed(modules):
40  sequence.insert(position, module)
41 
42 

◆ modules_by_type()

def common.modules_by_type (   process,
types 
)

Definition at line 22 of file common.py.

22 def modules_by_type(process, *types):
23  "Find all modiles or other components in the Process that are instances of the given C++ type."
24  return (module for module in process.__dict__.values() if hasattr(module, '_TypedParameterizable__type') and module._TypedParameterizable__type in types)
25 
26 

◆ producers_by_type()

def common.producers_by_type (   process,
types 
)

Definition at line 6 of file common.py.

6 def producers_by_type(process, *types):
7  "Find all EDProducers in the Process that are instances of the given C++ type."
8  return (module for module in process._Process__producers.values() if module._TypedParameterizable__type in types)
9 

Referenced by customizeHLTforCMSSW.customisePixelGainForRun2Input(), customizeHLTforCMSSW.synchronizeHCALHLTofflineRun2(), and customizeHLTforCMSSW.synchronizeHCALHLTofflineRun3on2018data().

◆ replace_with()

def common.replace_with (   fromObj,
  toObj 
)
Replace one object with a different one of the same type.

This function replaces the contents of `fromObj` object with those of `toObj`,
so all references ot it remain valid.

Definition at line 60 of file common.py.

60 def replace_with(fromObj, toObj):
61  """Replace one object with a different one of the same type.
62 
63  This function replaces the contents of `fromObj` object with those of `toObj`,
64  so all references ot it remain valid.
65  """
66 
67  if not isinstance(toObj, type(fromObj)):
68  raise TypeError('replaceWith requires both arguments to be the same type')
69 
70  if isinstance(toObj, cms._ModuleSequenceType):
71  fromObj._seq = toObj._seq
72 
73  elif isinstance(toObj, cms._Parameterizable):
74  # delete the old items, in case `toObj` is not a complete superset of `fromObj`
75  for p in fromObj.parameterNames_():
76  delattr(fromObj, p)
77  for p in toObj.parameterNames_():
78  setattr(fromObj, p, getattr(toObj, p))
79  if isinstance(toObj, cms._TypedParameterizable):
80  fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
81 
82  else:
83  raise TypeError('replaceWith does not work with "%s" objects' % str(type(fromObj)))
84 

References str.

common.replace_with
def replace_with(fromObj, toObj)
Definition: common.py:60
str
#define str(s)
Definition: TestProcessor.cc:51
common.esproducers_by_type
def esproducers_by_type(process, *types)
Definition: common.py:18
common.modules_by_type
def modules_by_type(process, *types)
Definition: common.py:22
common.analyzers_by_type
def analyzers_by_type(process, *types)
Definition: common.py:14
common.insert_modules_after
def insert_modules_after(process, target, *modules)
Definition: common.py:43
common.filters_by_type
def filters_by_type(process, *types)
Definition: common.py:10
common.producers_by_type
def producers_by_type(process, *types)
Definition: common.py:6
common.insert_modules_before
def insert_modules_before(process, target, *modules)
Definition: common.py:27