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_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.

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.

Referenced by customizeHLTforCMSSW.customiseFor18559().

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_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 
38 # logic from Modifier.toModify from FWCore/ParameterSet/python/Config.py
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.customiseFor17771(), customizeHLTforCMSSW.customiseFor17792(), customizeHLTforCMSSW.customiseFor17794(), customizeHLTforCMSSW.customiseFor18330(), and customizeHLTforCMSSW.customiseFor18429().

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 39 of file common.py.

References harvestTrackValidationPlots.str.

39 def replace_with(fromObj, toObj):
40  """Replace one object with a different one of the same type.
41 
42  This function replaces the contents of `fromObj` object with those of `toObj`,
43  so all references ot it remain valid.
44  """
45 
46  if type(toObj) != type(fromObj):
47  raise TypeError('replaceWith requires both arguments to be the same type')
48 
49  if isinstance(toObj, cms._ModuleSequenceType):
50  fromObj._seq = toObj._seq
51 
52  elif isinstance(toObj, cms._Parameterizable):
53  # delete the old items, in case `toObj` is not a complete superset of `fromObj`
54  for p in fromObj.parameterNames_():
55  delattr(fromObj, p)
56  for p in toObj.parameterNames_():
57  setattr(fromObj, p, getattr(toObj, p))
58  if isinstance(toObj, cms._TypedParameterizable):
59  fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
60 
61  else:
62  raise TypeError('replaceWith does not work with "%s" objects' % str(type(fromObj)))
63 
64 
def replace_with(fromObj, toObj)
Definition: common.py:39