CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
common Namespace Reference

Functions

def analyzers_by_type
 
def esproducers_by_type
 
def filters_by_type
 
def insert_modules_after
 
def insert_modules_before
 
def modules_by_type
 
def producers_by_type
 
def replace_with
 

Function Documentation

def common.analyzers_by_type (   process,
  types 
)

Definition at line 17 of file common.py.

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

Definition at line 21 of file common.py.

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

Definition at line 13 of file common.py.

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

Definition at line 50 of file common.py.

Referenced by customizeHLTforPatatrack.customiseCommon().

50 
51 def insert_modules_after(process, target, *modules):
52  "Add the `modules` after the `target` in any Sequence, Paths or EndPath that contains the latter."
53  for sequence in itertools.chain(
54  process._Process__sequences.values(),
55  process._Process__paths.values(),
56  process._Process__endpaths.values()
57  ):
58  try:
59  position = sequence.index(target)
60  except ValueError:
61  continue
62  else:
63  for module in reversed(modules):
64  sequence.insert(position+1, module)
65 
66 
# logic from Modifier.toModify from FWCore/ParameterSet/python/Config.py
def insert_modules_after
Definition: common.py:50
def common.insert_modules_before (   process,
  target,
  modules 
)

Definition at line 34 of file common.py.

34 
35 def insert_modules_before(process, target, *modules):
36  "Add the `modules` before the `target` in any Sequence, Paths or EndPath that contains the latter."
37  for sequence in itertools.chain(
38  process._Process__sequences.values(),
39  process._Process__paths.values(),
40  process._Process__endpaths.values()
41  ):
42  try:
43  position = sequence.index(target)
44  except ValueError:
45  continue
46  else:
47  for module in reversed(modules):
48  sequence.insert(position, module)
49 
def insert_modules_before
Definition: common.py:34
def common.modules_by_type (   process,
  types 
)

Definition at line 25 of file common.py.

25 
26 def modules_by_type(process, *types):
27  "Find all modiles or other components in the Process that are instances of the given C++ type."
28  switches = (module for module in (getattr(switchproducer, case) \
29  for switchproducer in process._Process__switchproducers.values() \
30  for case in switchproducer.parameterNames_()))
31  return (module for module in itertools.chain(process.__dict__.values(), switches) \
32  if hasattr(module, '_TypedParameterizable__type') and module._TypedParameterizable__type in types)
33 
def modules_by_type
Definition: common.py:25
def common.producers_by_type (   process,
  types 
)

Definition at line 4 of file common.py.

Referenced by customizeHLTforCMSSW.customiseHCALFor2018Input(), customizeHLTforCMSSW.customisePixelGainForRun2Input(), customizeHLTforCMSSW.customisePixelL1ClusterThresholdForRun2Input(), and customizePixelTracksForTriplets.customizePixelTracksForTriplets().

4 
5 def producers_by_type(process, *types):
6  "Find all EDProducers in the Process that are instances of the given C++ type."
7  switches = (module for module in (getattr(switchproducer, case) \
8  for switchproducer in process._Process__switchproducers.values() \
9  for case in switchproducer.parameterNames_()) \
10  if isinstance(module, cms.EDProducer))
11  return (module for module in itertools.chain(process._Process__producers.values(), switches) \
12  if module._TypedParameterizable__type in types)
def producers_by_type
Definition: common.py:4
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 67 of file common.py.

References str.

Referenced by customizeHLTforPatatrack.customiseCommon().

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