CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
Modules.SwitchProducer Class Reference
Inheritance diagram for Modules.SwitchProducer:
Modules.EDProducer Modules._Module Mixins._ConfigureComponent Mixins._TypedParameterizable Mixins._Labelable SequenceTypes._SequenceLeaf Mixins._Parameterizable SequenceTypes._Sequenceable Config.SwitchProducerTest Config.SwitchProducerTest2 Modules.SwitchProducerPickleable Modules.SwitchProducerTest

Public Member Functions

def __init__ (self, caseFunctionDict, kargs)
 
def __setattr__
 
def appendToProcessDescLists_
 
def caseLabel_
 
def clone (self, params)
 
def directDependencies (self)
 
def dumpPython
 
def insertInto
 
def moduleLabel_
 
def modulesForConditionalTask_ (self)
 
def nameInProcessDesc_
 
def setLabel
 
- Public Member Functions inherited from Modules.EDProducer
def __init__ (self, type_, arg, kargs)
 
- Public Member Functions inherited from Modules._Module
def __init__ (self, type_, arg, kargs)
 
def insertInto
 
def setPrerequisites (self, libs)
 
- Public Member Functions inherited from Mixins._TypedParameterizable
def __init__ (self, type_, arg, kargs)
 
def appendToProcessDescList_
 
def clone (self, args, params)
 
def copy (self)
 
def directDependencies (self)
 
def dumpConfig
 
def dumpPython
 
def dumpPythonAttributes
 
def insertInto
 
def moduleLabel_
 
def nameInProcessDesc_
 
def type_ (self)
 
- Public Member Functions inherited from Mixins._Parameterizable
def __delattr__
 
def __init__ (self, arg, kargs)
 
def __repr__ (self)
 
def __setattr__
 
def dumpPython
 
def getParameter (self, params)
 
def hasParameter (self, params)
 
def insertContentsInto (self, parameterSet)
 
def isFrozen (self)
 
def isModified (self)
 
def parameterNames_ (self)
 
def parameters_ (self)
 
def setIsFrozen (self)
 
def update_ (self, d)
 
- Public Member Functions inherited from Mixins._Labelable
def __str__ (self)
 
def dumpSequenceConfig (self)
 
def dumpSequencePython
 
def hasLabel_ (self)
 
def label (self)
 
def label_ (self)
 
def setLabel
 
- Public Member Functions inherited from SequenceTypes._SequenceLeaf
def __init__ (self)
 
def isLeaf (self)
 
- Public Member Functions inherited from SequenceTypes._Sequenceable
def __add__ (self, rhs)
 
def __init__ (self)
 
def __invert__ (self)
 
def __mul__ (self, rhs)
 
def isLeaf (self)
 
def isOperation (self)
 
def resolve
 
def visitNode (self, visitor)
 

Static Public Member Functions

def getCpu ()
 

Private Member Functions

def __addParameter
 
def __setParameters (self, parameters)
 
def _chooseCase (self, accelerators)
 
def _clonesequence (self, lookuptable)
 
def _errorstr (self)
 
def _getProducer (self, accelerators)
 
def _placeImpl
 

Static Private Member Functions

def __typeIsValid (typ)
 

Private Attributes

 _caseFunctionDict
 
 _isModified
 

Detailed Description

This purpose class is to provide a switch of EDProducers for a single module/product label.

The decision is done at the time when the python configuration is
translated to C++. This class is generic, and intended to be
inherited for concrete switches. Example:

class SwitchProducerFoo(SwitchProducer):
    def __init__(self, **kargs):
        super(SwitchProducerFoo,self).__init__(
            dict(case1 = case1Func, case2 = case2Func),
            **kargs
        )

foo = SwitchProducerFoo(
    case1 = EDProducer("Producer1"),
    case2 = EDProducer("Producer2")
)

Here case1Func and case2Func are functions that return a (bool,
int) tuple, where the bool tells whether that case is enabled or
not, and the int tells the priority of that case. The case with
the highest priority among those that are enabled will get chosen.

The end result is that the product(s) labeled as "foo" will be
produced with one of the producers. It would be good if their
output product types and instance names would be the same (or very
close).

Definition at line 220 of file Modules.py.

Constructor & Destructor Documentation

◆ __init__()

def Modules.SwitchProducer.__init__ (   self,
  caseFunctionDict,
  kargs 
)

Definition at line 249 of file Modules.py.

249  def __init__(self, caseFunctionDict, **kargs):
250  super(SwitchProducer,self).__init__(None)
251  self._caseFunctionDict = copy.copy(caseFunctionDict)
252  self.__setParameters(kargs)
253  self._isModified = False
254 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ __addParameter()

def Modules.SwitchProducer.__addParameter (   self,
  name 
)
private

Definition at line 288 of file Modules.py.

References Modules.SwitchProducer.__typeIsValid(), Modules.SwitchProducer._caseFunctionDict, Mixins._ParameterTypeBase._isModified, Mixins._SimpleParameterTypeBase._isModified, Mixins._Parameterizable._isModified, mps_setup.append, Modules.SwitchProducer.caseLabel_(), Mixins._ParameterTypeBase.dumpPython(), Mixins.UsingBlock.dumpPython(), Mixins._Parameterizable.dumpPython(), Config.Process.dumpPython(), Config.SubProcess.dumpPython(), Config.ProcessAccelerator.dumpPython(), Mixins._Labelable.hasLabel_(), join(), relativeConstraints.keys, MagneticFieldMapESProducer.label_, TrackerInteractionGeometryESProducer.label_, CTPPSPixelDAQMappingAnalyzer.label_, TestCUDAProducerCPU.label_, TestCUDAProducerGPU.label_, TestCUDAProducerGPUFirst.label_, SiPhase2OuterTrackerLorentzAngleReader.label_, TestCUDAAnalyzerGPU.label_, SiPhase2BadStripChannelReader.label_, mkfit::ReducedTrack.label_, TestCUDAProducerGPUtoCPU.label_, SiStripLorentzAngleReader.label_, edm::eventsetup::ComponentDescription.label_, TestCUDAProducerGPUEW.label_, pat::TriggerFilter.label_, XMLIdealMagneticFieldGeometryESProducer.label_, ESDigiToRaw.label_, PythiaFilterHT.label_, WriteCTPPSTotemDAQMappingMask.label_, TestCUDAProducerGPUEWTask.label_, WriteCTPPSPixelAnalysisMask.label_, VertexCompositeCandidateCollectionSelector.label_, RetrieveCTPPSBeamParameters.label_, WriteCTPPSPixelDAQMapping.label_, CTPPSPixelRawToDigi.label_, HistoProviderDQM.label_, SiStripDelayESProducer::TokenSign.label_, VertexMonitor.label_, edm::ConsumesInfo.label_, PythiaMomDauFilter.label_, RandomEngineState.label_, StripSubClusterShapeFilterBase.label_, edm::test::ProcessBlock.label_, SiPixelStatusManager.label_, edm::SecSourceAnalyzer.label_, edm::InputTag.label_, TPGCheck.label_, SiPixelStatusHarvester.label_, DDDetectorESProducer.label_, reco::Centrality.label_, edm::test::Run.label_, PPSPixelDigiAnalyzer.label_, edm::test::LuminosityBlock.label_, pat::TauJetCorrFactors.label_, edm::test::Event.label_, EffPurFromHistos2D.label_, EcalTrigPrimAnalyzer.label_, edm::DataMixingSiStripWorker.label_, edm::DataMixingSiPixelWorker.label_, StallStatistics.label_, edm::DataMixingPileupCopy.label_, SiPixelCalibDigiProducer.label_, EffPurFromHistos.label_, edm::DataMixingSiStripRawWorker.label_, edm::HiMixingWorkerBase.label_, SingleTopTChannelLepton_miniAOD::MonitorEnsemble.label_, TopSingleLepton_miniAOD::MonitorEnsemble.label_, npstat::UniformAxis.label_, edm::messagedrop::StringProducerWithPhase.label_, PileupJetIdAlgo::AlgoGBRForestsAndConstants.label_, edm::DataMixingEMWorker.label_, fwlite::ObjectCountSelector< Collection >.label_, edm::DataMixingHcalWorker.label_, pat::JetCorrFactors.label_, edm::DataMixingHcalDigiWorkerProd.label_, pat::JetCorrFactorsProducer.label_, edm::ParameterDescriptionBase.label_, TopSingleLepton::MonitorEnsemble.label_, edm::DataMixingMuonWorker.label_, pat::helper::AnyNumberAssociationAdaptor.label_, npstat::NUHistoAxis.label_, SingleTopTChannelLepton::MonitorEnsemble.label_, edm::DataMixingEMDigiWorker.label_, TopDiLeptonOffline::MonitorEnsemble.label_, edm::DataMixingHcalDigiWorker.label_, HLTObjectsMonitor.label_, npstat::GridAxis.label_, SummaryGenerator.label_, npstat::HistoAxis.label_, edm::GenericConsumer.label_, templateHelper::SiPixelTitles_Display< PayloadType, StoreType, TransientType >.label_, edm::service::RandomNumberGeneratorService::LabelAndEngine.label_, ALPAKA_ACCELERATOR_NAMESPACE::ProducerBaseAdaptor< TProducer, Tr >.label_, edm::MixingWorker< T >.label_, edm::DataMixingModule.label_, AlignPCLThresholdPlotHelper::AlignPCLThresholds_DisplayBase< PayloadType >.label_, templateHelper::SiPixelHeaderTable< PayloadType, StoreType, TransientType >.label_, mkfit::TrackBase.label_, gainCalibHelper::SiPixelGainCalibrationValues< myType, PayloadType >.label_, templateHelper::SiPixelIDs< PayloadType, myType >.label_, AlignPCLThresholdPlotHelper::AlignPCLThresholds_CompareBase< PayloadType, nIOVs, ntags >.label_, templateHelper::SiPixelFullPixelIDMap< PayloadType, StoreType, TransientType >.label_, SiPixelQualityBadFractionMap.label_, gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >.label_, Mixins._Labelable.label_(), SiPixelQualityBadFractionComparisonBase< nIOVs, ntags >.label_, fwlite::Scanner< Collection >.label_, gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >.label_, SiPixelDynamicInefficiencyFullPixelMap< theFactor >.label_, templateHelper::SiPixelTemplateHeaderInfo< PayloadType, StoreType, TransientType, myType, myParam >.label_, gainCalibHelper::SiPixelGainCalibrationCorrelations< PayloadType >.label_, SiPixelDynamicInefficiencyPUPixelMaps.label_, SiPixelLorentzAngleFullPixelMap.label_, gainCalibHelper::SiPixelGainCalibrationValuesByPart< myType, PayloadType >.label_, SiPixelDynamicInefficiencyPUParametrization.label_, PixelAlignmentComparisonMapBase< coord, ntags, nIOVs >.label_, SiPixelLorentzAngleFullMapCompareBase< nIOVs, ntags >.label_, gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >.label_, SiPixelDynamicInefficiencyPUParamComparisonBase< nIOVs, ntags >.label_, gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >.label_, gainCalibHelper::SiPixelGainCalibrationMap< myType, PayloadType, myDetType >.label_, and gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >.label_.

288  def __addParameter(self, name:str, value):
289  if not self.__typeIsValid(value):
290  raise TypeError(name+" does not already exist, so it can only be set to a cms.EDProducer or cms.EDAlias")
291  if name not in self._caseFunctionDict:
292  raise ValueError("Case '%s' is not allowed (allowed ones are %s)" % (name, ",".join(self._caseFunctionDict.keys())))
293  if name in self.__dict__:
294  message = "Duplicate insert of member " + name
295  message += "\nThe original parameters are:\n"
296  message += self.dumpPython() + '\n'
297  raise ValueError(message)
298  self.__dict__[name]=value
299  if self.hasLabel_():
300  value.setLabel(self.caseLabel_(self.label_(), name))
301  self._Parameterizable__parameterNames.append(name)
302  self._isModified = True
303 
static std::string join(char **cmd)
Definition: RemoteFile.cc:21

◆ __setattr__()

def Modules.SwitchProducer.__setattr__ (   self,
  name 
)

Definition at line 308 of file Modules.py.

References Mixins._Parameterizable.__addParameter(), Modules.SwitchProducer.__typeIsValid(), Mixins._ParameterTypeBase._isModified, Mixins._SimpleParameterTypeBase._isModified, Mixins._Parameterizable._isModified, Modules.SwitchProducer.caseLabel_(), Mixins._ParameterTypeBase.dumpPython(), Mixins.UsingBlock.dumpPython(), Mixins._Parameterizable.dumpPython(), Config.Process.dumpPython(), Config.SubProcess.dumpPython(), Config.ProcessAccelerator.dumpPython(), Mixins._Labelable.hasLabel_(), Mixins._ParameterTypeBase.isFrozen(), Mixins._Parameterizable.isFrozen(), MagneticFieldMapESProducer.label_, TrackerInteractionGeometryESProducer.label_, CTPPSPixelDAQMappingAnalyzer.label_, TestCUDAProducerCPU.label_, TestCUDAProducerGPU.label_, TestCUDAProducerGPUFirst.label_, SiPhase2OuterTrackerLorentzAngleReader.label_, TestCUDAAnalyzerGPU.label_, SiPhase2BadStripChannelReader.label_, mkfit::ReducedTrack.label_, TestCUDAProducerGPUtoCPU.label_, SiStripLorentzAngleReader.label_, edm::eventsetup::ComponentDescription.label_, TestCUDAProducerGPUEW.label_, pat::TriggerFilter.label_, XMLIdealMagneticFieldGeometryESProducer.label_, ESDigiToRaw.label_, PythiaFilterHT.label_, TestCUDAProducerGPUEWTask.label_, WriteCTPPSTotemDAQMappingMask.label_, WriteCTPPSPixelAnalysisMask.label_, VertexCompositeCandidateCollectionSelector.label_, RetrieveCTPPSBeamParameters.label_, WriteCTPPSPixelDAQMapping.label_, CTPPSPixelRawToDigi.label_, HistoProviderDQM.label_, VertexMonitor.label_, SiStripDelayESProducer::TokenSign.label_, edm::ConsumesInfo.label_, PythiaMomDauFilter.label_, RandomEngineState.label_, StripSubClusterShapeFilterBase.label_, edm::test::ProcessBlock.label_, SiPixelStatusManager.label_, edm::SecSourceAnalyzer.label_, edm::InputTag.label_, SiPixelStatusHarvester.label_, TPGCheck.label_, DDDetectorESProducer.label_, reco::Centrality.label_, edm::test::Run.label_, PPSPixelDigiAnalyzer.label_, edm::test::LuminosityBlock.label_, pat::TauJetCorrFactors.label_, edm::test::Event.label_, EffPurFromHistos2D.label_, EcalTrigPrimAnalyzer.label_, edm::DataMixingSiStripWorker.label_, edm::DataMixingSiPixelWorker.label_, StallStatistics.label_, edm::DataMixingPileupCopy.label_, SiPixelCalibDigiProducer.label_, EffPurFromHistos.label_, edm::DataMixingSiStripRawWorker.label_, TopSingleLepton_miniAOD::MonitorEnsemble.label_, SingleTopTChannelLepton_miniAOD::MonitorEnsemble.label_, edm::HiMixingWorkerBase.label_, npstat::UniformAxis.label_, edm::messagedrop::StringProducerWithPhase.label_, PileupJetIdAlgo::AlgoGBRForestsAndConstants.label_, edm::DataMixingEMWorker.label_, fwlite::ObjectCountSelector< Collection >.label_, edm::DataMixingHcalWorker.label_, pat::JetCorrFactors.label_, edm::DataMixingHcalDigiWorkerProd.label_, pat::JetCorrFactorsProducer.label_, edm::ParameterDescriptionBase.label_, TopSingleLepton::MonitorEnsemble.label_, edm::DataMixingMuonWorker.label_, npstat::NUHistoAxis.label_, pat::helper::AnyNumberAssociationAdaptor.label_, SingleTopTChannelLepton::MonitorEnsemble.label_, edm::DataMixingEMDigiWorker.label_, TopDiLeptonOffline::MonitorEnsemble.label_, edm::DataMixingHcalDigiWorker.label_, HLTObjectsMonitor.label_, npstat::GridAxis.label_, SummaryGenerator.label_, npstat::HistoAxis.label_, edm::GenericConsumer.label_, templateHelper::SiPixelTitles_Display< PayloadType, StoreType, TransientType >.label_, edm::service::RandomNumberGeneratorService::LabelAndEngine.label_, ALPAKA_ACCELERATOR_NAMESPACE::ProducerBaseAdaptor< TProducer, Tr >.label_, edm::MixingWorker< T >.label_, edm::DataMixingModule.label_, AlignPCLThresholdPlotHelper::AlignPCLThresholds_DisplayBase< PayloadType >.label_, templateHelper::SiPixelHeaderTable< PayloadType, StoreType, TransientType >.label_, mkfit::TrackBase.label_, gainCalibHelper::SiPixelGainCalibrationValues< myType, PayloadType >.label_, templateHelper::SiPixelIDs< PayloadType, myType >.label_, AlignPCLThresholdPlotHelper::AlignPCLThresholds_CompareBase< PayloadType, nIOVs, ntags >.label_, templateHelper::SiPixelFullPixelIDMap< PayloadType, StoreType, TransientType >.label_, SiPixelQualityBadFractionMap.label_, gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >.label_, Mixins._Labelable.label_(), SiPixelQualityBadFractionComparisonBase< nIOVs, ntags >.label_, fwlite::Scanner< Collection >.label_, gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >.label_, SiPixelDynamicInefficiencyFullPixelMap< theFactor >.label_, templateHelper::SiPixelTemplateHeaderInfo< PayloadType, StoreType, TransientType, myType, myParam >.label_, SiPixelDynamicInefficiencyPUPixelMaps.label_, gainCalibHelper::SiPixelGainCalibrationCorrelations< PayloadType >.label_, SiPixelLorentzAngleFullPixelMap.label_, gainCalibHelper::SiPixelGainCalibrationValuesByPart< myType, PayloadType >.label_, SiPixelDynamicInefficiencyPUParametrization.label_, PixelAlignmentComparisonMapBase< coord, ntags, nIOVs >.label_, SiPixelLorentzAngleFullMapCompareBase< nIOVs, ntags >.label_, gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >.label_, SiPixelDynamicInefficiencyPUParamComparisonBase< nIOVs, ntags >.label_, gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >.label_, gainCalibHelper::SiPixelGainCalibrationMap< myType, PayloadType, myDetType >.label_, and gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >.label_.

Referenced by GenObject.GenObject.setValue().

308  def __setattr__(self, name:str, value):
309  # Following snippet copied and customized from
310  # _Parameterizable in order to support Modifier.toModify
311  #
312  #since labels are not supposed to have underscores at the beginning
313  # I will assume that if we have such then we are setting an internal variable
314  if self.isFrozen() and not (name in ["_Labelable__label","_isFrozen"] or name.startswith('_')):
315  message = "Object already added to a process. It is read only now\n"
316  message += " %s = %s" %(name, value)
317  message += "\nThe original parameters are:\n"
318  message += self.dumpPython() + '\n'
319  raise ValueError(message)
320  # underscored names bypass checking for _ParameterTypeBase
321  if name[0]=='_':
322  super(SwitchProducer, self).__setattr__(name,value)
323  elif not name in self.__dict__:
324  self.__addParameter(name, value)
325  self._isModified = True
326  else:
327  if not self.__typeIsValid(value):
328  raise TypeError(name+" can only be set to a cms.EDProducer or cms.EDAlias")
329  # We should always receive an cms.EDProducer
330  self.__dict__[name] = value
331  if self.hasLabel_():
332  value.setLabel(self.caseLabel_(self.label_(), name))
333  self._isModified = True
334 

◆ __setParameters()

def Modules.SwitchProducer.__setParameters (   self,
  parameters 
)
private

Definition at line 304 of file Modules.py.

References Mixins._Parameterizable.__addParameter().

304  def __setParameters(self, parameters):
305  for name, value in parameters.items():
306  self.__addParameter(name, value)
307 

◆ __typeIsValid()

def Modules.SwitchProducer.__typeIsValid (   typ,
  bool 
)
staticprivate

Definition at line 285 of file Modules.py.

Referenced by Modules.SwitchProducer.__addParameter(), and Modules.SwitchProducer.__setattr__().

285  def __typeIsValid(typ) -> bool:
286  return (isinstance(typ, EDProducer) and not isinstance(typ, SwitchProducer)) or isinstance(typ, EDAlias)
287 

◆ _chooseCase()

def Modules.SwitchProducer._chooseCase (   self,
  accelerators 
)
private
Returns the name of the chosen case.

Definition at line 268 of file Modules.py.

References Modules.SwitchProducer._caseFunctionDict, Mixins._Parameterizable.parameterNames_(), and str.

Referenced by Modules.SwitchProducer._getProducer(), and Modules.SwitchProducer.insertInto().

268  def _chooseCase(self, accelerators):
269  """Returns the name of the chosen case."""
270  cases = self.parameterNames_()
271  bestCase = None
272  for case in cases:
273  (enabled, priority) = self._caseFunctionDict[case](accelerators)
274  if enabled and (bestCase is None or bestCase[0] < priority):
275  bestCase = (priority, case)
276  if bestCase is None:
277  raise RuntimeError("All cases '%s' were disabled" % (str(cases)))
278  return bestCase[1]
279 
#define str(s)

◆ _clonesequence()

def Modules.SwitchProducer._clonesequence (   self,
  lookuptable 
)
private

Definition at line 428 of file Modules.py.

References Modules._Module._errorstr(), and EcalPhiSymFlatTableProducers_cfi.id.

428  def _clonesequence(self, lookuptable):
429  try:
430  return lookuptable[id(self)]
431  except:
432  raise ModuleCloneError(self._errorstr())

◆ _errorstr()

def Modules.SwitchProducer._errorstr (   self)
private

Definition at line 433 of file Modules.py.

433  def _errorstr(self):
434  return "SwitchProducer"
435 
436 

◆ _getProducer()

def Modules.SwitchProducer._getProducer (   self,
  accelerators 
)
private
Returns the EDroducer of the chosen case

Definition at line 280 of file Modules.py.

References Modules.SwitchProducer._chooseCase().

280  def _getProducer(self, accelerators):
281  """Returns the EDroducer of the chosen case"""
282  return self.__dict__[self._chooseCase(accelerators)]
283 

◆ _placeImpl()

def Modules.SwitchProducer._placeImpl (   self,
  name 
)
private

Definition at line 413 of file Modules.py.

Referenced by SequenceTypes._ModuleSequenceType._place(), and Mixins._TypedParameterizable._place().

413  def _placeImpl(self,name:str,proc):
414  proc._placeSwitchProducer(name,self)
415 # for case in self.parameterNames_():
416 # caseLabel = self.caseLabel_(name, case)
417 # caseObj = self.__dict__[case]
418 #
419 # if isinstance(caseObj, EDAlias):
420 # # EDAliases end up in @all_aliases automatically
421 # proc._placeAlias(caseLabel, caseObj)
422 # else:
423 # # Note that these don't end up in @all_modules
424 # # automatically because they're not part of any
425 # # Task/Sequence/Path
426 # proc._placeProducer(caseLabel, caseObj)
427 

◆ appendToProcessDescLists_()

def Modules.SwitchProducer.appendToProcessDescLists_ (   self,
  modules,
  aliases,
  myname 
)

Definition at line 391 of file Modules.py.

References Modules.SwitchProducer.caseLabel_(), and Mixins._Parameterizable.parameterNames_().

391  def appendToProcessDescLists_(self, modules, aliases, myname:str):
392  # This way we can insert the chosen EDProducer to @all_modules
393  # so that we get easily a worker for it
394  modules.append(myname)
395  for case in self.parameterNames_():
396  if isinstance(self.__dict__[case], EDAlias):
397  aliases.append(self.caseLabel_(myname, case))
398  else:
399  modules.append(self.caseLabel_(myname, case))
400 

◆ caseLabel_()

def Modules.SwitchProducer.caseLabel_ (   self,
  name 
)

◆ clone()

def Modules.SwitchProducer.clone (   self,
  params 
)

Definition at line 335 of file Modules.py.

References Mixins._Parameterizable.parameterNames_(), and Mixins.saveOrigin().

335  def clone(self, **params):
336  returnValue = SwitchProducer.__new__(type(self))
337 
338  # Need special treatment as cms.EDProducer is not a valid parameter type (except in this case)
339  myparams = dict()
340  for name, value in params.items():
341  if value is None:
342  continue
343  elif isinstance(value, dict):
344  myparams[name] = self.__dict__[name].clone(**value)
345  else: # value is an EDProducer
346  myparams[name] = value.clone()
347 
348  # Add the ones that were not customized
349  for name in self.parameterNames_():
350  if name not in params:
351  myparams[name] = self.__dict__[name].clone()
352  returnValue.__init__(**myparams)
353  returnValue._isModified = False
354  returnValue._isFrozen = False
355  saveOrigin(returnValue, 1)
356  return returnValue
357 
def saveOrigin(obj, level)
Definition: Mixins.py:723
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135

◆ directDependencies()

def Modules.SwitchProducer.directDependencies (   self)

Definition at line 373 of file Modules.py.

373  def directDependencies(self):
374  # XXX FIXME handle SwitchProducer dependencies
375  return []
376 

◆ dumpPython()

def Modules.SwitchProducer.dumpPython (   self,
  options 
)

Definition at line 358 of file Modules.py.

References __class__< T >.__class__(), Mixins._Parameterizable.parameterNames_(), and RooUtil::StringUtil.rstrip().

Referenced by Types._AllowedParameterTypes.__init__().

358  def dumpPython(self, options:PrintOptions=PrintOptions()) -> str:
359  # Note that if anyone uses the generic SwitchProducer instead
360  # of a derived-one, the information on the functions for the
361  # producer decision is lost
362  specialImportRegistry.registerUse(self)
363  result = "%s(" % self.__class__.__name__ # not including cms. since the deriving classes are not in cms "namespace"
364  options.indent()
365  for resource in sorted(self.parameterNames_()):
366  result += "\n" + options.indentation() + resource + " = " + getattr(self, resource).dumpPython(options).rstrip() + ","
367  if result[-1] == ",":
368  result = result.rstrip(",")
369  options.unindent()
370  result += "\n)\n"
371  return result
372 
void rstrip(TString &in, TString separator="#")
Definition: stringutil.cc:9
def dumpPython(process, name)

◆ getCpu()

def Modules.SwitchProducer.getCpu ( )
static
Returns a function that returns the priority for a CPU "computing device". Intended to be used by deriving classes.

Definition at line 264 of file Modules.py.

264  def getCpu():
265  """Returns a function that returns the priority for a CPU "computing device". Intended to be used by deriving classes."""
266  return _switch_cpu
267 

◆ insertInto()

def Modules.SwitchProducer.insertInto (   self,
  parameterSet,
  myname 
)

Definition at line 401 of file Modules.py.

References Modules.SwitchProducer._chooseCase(), Modules.SwitchProducer.caseLabel_(), edm::ModuleProcessName.moduleLabel_, FWJobMetadataManager::Data.moduleLabel_, PFMatchedCandidateRefExtractor.moduleLabel_, edm::ModuleLabelMatch.moduleLabel_, HPSPFTauProducer.moduleLabel_, GBRForestWriter.moduleLabel_, edm::BranchKey.moduleLabel_, MuonMETcorrInputProducer.moduleLabel_, SysShiftMETcorrInputProducer.moduleLabel_, ShiftedJetProducerByMatchedObjectT< T >.moduleLabel_, Type0PFMETcorrInputProducer.moduleLabel_, NoPileUpPFMEtProducer.moduleLabel_, PFCandMETcorrInputProducer.moduleLabel_, ShiftedPFCandidateProducerForPFMVAMEt.moduleLabel_, PFchsMETcorrInputProducer.moduleLabel_, ShiftedParticleProducer.moduleLabel_, MultShiftMETcorrInputProducer.moduleLabel_, edm::ESTagGetter::Info.moduleLabel_, ShiftedPFCandidateProducerForPFNoPUMEt.moduleLabel_, MultShiftMETcorrDBInputProducer.moduleLabel_, TauDiscriminantCutMultiplexerT< TauType, TauTypeRef, ParentClass >.moduleLabel_, RecoTauGenericJetRegionProducer< JetType, CandType >.moduleLabel_, GenericBoostedTauSeedsProducer< JetType, CandType >.moduleLabel_, TauDiscriminationAgainstElectronDeadECAL< TauType, TauDiscriminator >.moduleLabel_, SubjetFilterAlgorithm.moduleLabel_, edm::ESConsumesInfoEntry.moduleLabel_, pat::TauJetCorrFactorsProducer.moduleLabel_, TauDiscriminationAgainstElectronMVA6< TauType, TauDiscriminator, ElectronType >.moduleLabel_, PFRecoTauChargedHadronProducer.moduleLabel_, JetIdSelector< T >.moduleLabel_, edm::ModuleDescription.moduleLabel_, edm::ProductSelectorRules::Rule.moduleLabel_, MinMETProducerT< T >.moduleLabel_, ObjectViewMatcher< T1, T2 >.moduleLabel_, TauTagValidation.moduleLabel_, PFRecoTauDiscriminationAgainstMuon2.moduleLabel_, ObjectViewCleaner< T >.moduleLabel_, PFRecoTauDiscriminationAgainstMuon2Container.moduleLabel_, PFRecoTauDiscriminationAgainstMuonSimple.moduleLabel_, ShiftedParticleProducerT< T >.moduleLabel_, PFRecoTauDiscriminationAgainstMuonMVA.moduleLabel_, HLTMuonMatchAndPlot.moduleLabel_, ProductBranch.moduleLabel_, TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >.moduleLabel_, PFRecoTauDiscriminationByIsolationMVA2.moduleLabel_, edm::test::TestProcessorConfig::ProduceEntry.moduleLabel_, ALPAKA_ACCELERATOR_NAMESPACE::ESProducer.moduleLabel_, reco::tau::PFRecoTauDiscriminationByMVAIsolationRun2.moduleLabel_, reco::tau::PATTauDiscriminationByMVAIsolationRun2.moduleLabel_, VirtualJetProducer.moduleLabel_, ShiftedJetProducerT< T, Textractor >.moduleLabel_, CaloJetMETcorrInputProducerT< T, Textractor >.moduleLabel_, PFRecoTauDiscriminationByIsolation.moduleLabel_, edm::PoolOutputModule.moduleLabel_, edm::BranchDescription.moduleLabel_, JetCleanerForType1METT< T, Textractor >.moduleLabel_, PFRecoTauDiscriminationByIsolationContainer.moduleLabel_, edm::ProductResolverIndexHelper::Item.moduleLabel_, Mixins._TypedParameterizable.moduleLabel_(), Mixins._TypedParameterizable.nameInProcessDesc_(), Config.SubProcess.nameInProcessDesc_(), and Mixins._Parameterizable.parameterNames_().

401  def insertInto(self, parameterSet, myname:str, accelerators):
402  for case in self.parameterNames_():
403  producer = self.__dict__[case]
404  producer.insertInto(parameterSet, self.caseLabel_(myname, case))
405  newpset = parameterSet.newPSet()
406  newpset.addString(True, "@module_label", self.moduleLabel_(myname))
407  newpset.addString(True, "@module_type", "SwitchProducer")
408  newpset.addString(True, "@module_edm_type", "EDProducer")
409  newpset.addVString(True, "@all_cases", [self.caseLabel_(myname, p) for p in self.parameterNames_()])
410  newpset.addString(False, "@chosen_case", self.caseLabel_(myname, self._chooseCase(accelerators)))
411  parameterSet.addPSet(True, self.nameInProcessDesc_(myname), newpset)
412 

◆ moduleLabel_()

def Modules.SwitchProducer.moduleLabel_ (   self,
  myname 
)

Definition at line 379 of file Modules.py.

Referenced by ExternalGeneratorFilter.ExternalGeneratorFilter.insertInto().

379  def moduleLabel_(self, myname:str):
380  return myname

◆ modulesForConditionalTask_()

def Modules.SwitchProducer.modulesForConditionalTask_ (   self)

Definition at line 383 of file Modules.py.

References Mixins._Parameterizable.parameterNames_().

383  def modulesForConditionalTask_(self):
384  # Need the contained modules (not EDAliases) for ConditionalTask
385  ret = []
386  for case in self.parameterNames_():
387  caseobj = self.__dict__[case]
388  if not isinstance(caseobj, EDAlias):
389  ret.append(caseobj)
390  return ret

◆ nameInProcessDesc_()

def Modules.SwitchProducer.nameInProcessDesc_ (   self,
  myname 
)

Definition at line 377 of file Modules.py.

Referenced by Types.EDAlias.appendToProcessDescList_(), ExternalGeneratorFilter.ExternalGeneratorFilter.insertInto(), and Types.EDAlias.insertInto().

377  def nameInProcessDesc_(self, myname:str):
378  return myname

◆ setLabel()

def Modules.SwitchProducer.setLabel (   self,
  label 
)

Definition at line 255 of file Modules.py.

References Modules.SwitchProducer.caseLabel_(), and Mixins._Parameterizable.parameterNames_().

255  def setLabel(self, label:str):
256  super().setLabel(label)
257  # SwitchProducer owns the contained modules, and therefore
258  # need to set / unset the label for them explicitly here
259  for case in self.parameterNames_():
260  producer = self.__dict__[case]
261  producer.setLabel(self.caseLabel_(label, case) if label is not None else None)
262 

Member Data Documentation

◆ _caseFunctionDict

Modules.SwitchProducer._caseFunctionDict
private

◆ _isModified

Modules.SwitchProducer._isModified
private

Definition at line 253 of file Modules.py.