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 producers_by_type (process, types)
 
def replace_with (fromObj, toObj)
 

Function Documentation

def common.analyzers_by_type (   process,
  types 
)

Definition at line 13 of file common.py.

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

Definition at line 17 of file common.py.

Referenced by customizeHLTforCMSSW.customiseFor20269().

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

Definition at line 9 of file common.py.

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

Definition at line 38 of file common.py.

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

Definition at line 22 of file common.py.

22 def insert_modules_before(process, target, *modules):
23  "Add the `modules` before the `target` in any Sequence, Paths or EndPath that contains the latter."
24  for sequence in itertools.chain(
25  process._Process__sequences.itervalues(),
26  process._Process__paths.itervalues(),
27  process._Process__endpaths.itervalues()
28  ):
29  try:
30  position = sequence.index(target)
31  except ValueError:
32  continue
33  else:
34  for module in reversed(modules):
35  sequence.insert(position, module)
36 
37 
def insert_modules_before(process, target, modules)
Definition: common.py:22
def common.producers_by_type (   process,
  types 
)

Definition at line 5 of file common.py.

Referenced by customizeHLTforCMSSW.customiseFor19029(), customizeHLTforCMSSW.customiseFor20422(), and customizeHLTforCMSSW.customiseFor20429().

5 def producers_by_type(process, *types):
6  "Find all EDProducers in the Process that are instances of the given C++ type."
7  return (module for module in process._Process__producers.values() if module._TypedParameterizable__type in types)
8 
def producers_by_type(process, types)
Definition: common.py:5
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 55 of file common.py.

References harvestTrackValidationPlots.str.

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