CMS 3D CMS Logo

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

Namespaces

 ReleaseScripts
 

Classes

class  TestModuleCommand
 

Functions

def _build_options
 
def convertToSingleModuleEndPaths
 
def convertToUnscheduled
 
def createTaskWithAllProducersAndFilters
 
def getHltConfiguration
 
def ignoreAllFiltersOnPath
 
def loadHltConfiguration
 
def moduleLabelsInSequences
 
def modulesInSequences
 

Variables

 __lastCallUnary
 
 _levelInTasks
 
 onTask
 
 operator
 

Function Documentation

def Utilities._build_options (   args)
private

Definition at line 6 of file Utilities.py.

Referenced by getHltConfiguration(), and loadHltConfiguration().

6 
7 def _build_options(**args):
8  options = _options.HLTProcessOptions()
9  for key, val in args.items():
10  setattr(options, key, val)
11  return options
12 
def _build_options
Definition: Utilities.py:6
def Utilities.convertToSingleModuleEndPaths (   process)
Remove the EndPaths in the Process with more than one module
and replace with new EndPaths each with only one module.

Definition at line 69 of file Utilities.py.

References mps_monitormerge.items.

Referenced by Utilities.TestModuleCommand.testConvertToSingleModuleEndPaths().

69 
71  """Remove the EndPaths in the Process with more than one module
72  and replace with new EndPaths each with only one module.
73  """
74  import FWCore.ParameterSet.Config as cms
75  toRemove =[]
76  added = []
77  for n,ep in process.endpaths_().items():
78  tsks = []
79  ep.visit(cms.TaskVisitor(tsks))
80 
81  names = ep.moduleNames()
82  if 1 == len(names):
83  continue
84  toRemove.append(n)
85  for m in names:
86  epName = m+"_endpath"
87  setattr(process,epName,cms.EndPath(getattr(process,m),*tsks))
88  added.append(epName)
89 
90  s = process.schedule_()
91  if s:
92  pathNames = [p.label_() for p in s]
93  for rName in toRemove:
94  pathNames.remove(rName)
95  for n in added:
96  pathNames.append(n)
97  newS = cms.Schedule(*[getattr(process,n) for n in pathNames])
98  if s._tasks:
99  newS.associate(*s._tasks)
100  process.setSchedule_(newS)
101 
102  for r in toRemove:
103  delattr(process,r)
104 
def convertToSingleModuleEndPaths
Definition: Utilities.py:69
def Utilities.convertToUnscheduled (   proc)

Definition at line 46 of file Utilities.py.

References print().

46 
47 def convertToUnscheduled(proc):
48  print("covertToUnscheduled is deprecated and no longer needed, and will be removed soon. Please update your configuration.")
49  return proc
50 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def convertToUnscheduled
Definition: Utilities.py:46
def Utilities.createTaskWithAllProducersAndFilters (   process)

Definition at line 62 of file Utilities.py.

Referenced by Utilities.TestModuleCommand.testCreateTaskWithAllProducersAndFilters().

62 
64  from FWCore.ParameterSet.Config import Task
65 
66  l = [ p for p in process.producers.values()]
67  l.extend( (f for f in process.filters.values()) )
68  return Task(*l)
def createTaskWithAllProducersAndFilters
Definition: Utilities.py:62
def Utilities.getHltConfiguration (   menu,
  args 
)

Definition at line 13 of file Utilities.py.

References _build_options(), and remoteMonitoring_LASER_era2018_cfg.dump.

13 
14 def getHltConfiguration(menu, **args):
15  args['menu'] = menu
16  args['fragment'] = False
17  options = _build_options(**args)
18 
19  hlt = _imp.new_module('hlt')
20  exec(_confdb.HLTProcess(options).dump(), globals(), hlt.__dict__)
21  return hlt.process
22 
def getHltConfiguration
Definition: Utilities.py:13
def _build_options
Definition: Utilities.py:6
tuple dump
OutputFilePath = cms.string('/tmp/zhokin/'), OutputFileExt = cms.string(''),.
def Utilities.ignoreAllFiltersOnPath (   path)
Given a 'Path', find all EDFilters and wrap them in 'cms.ignore'

Definition at line 2 of file Utilities.py.

References submitPVValidationJobs.__init__().

2 
3 def ignoreAllFiltersOnPath(path):
4  """Given a 'Path', find all EDFilters and wrap them in 'cms.ignore'
5  """
6  import FWCore.ParameterSet.Config as cms
7  from FWCore.ParameterSet.SequenceTypes import _MutatingSequenceVisitor, _UnarySequenceOperator
8 
9  class IgnoreFilters(object):
10  def __init__(self):
11  self.__lastCallUnary = False
12  self.onTask = False
13  def __call__(self, obj):
14  if self.onTask:
15  return obj
16  elif isinstance(obj,_UnarySequenceOperator):
17  self.__lastCallUnary = True
18  elif obj.isLeaf() and isinstance(obj, cms.EDFilter) and not self.__lastCallUnary:
19  return cms.ignore(obj)
20  else:
21  self.__lastCallUnary = False
22  return obj
23  class IgnoreFiltersVisitor(_MutatingSequenceVisitor):
24  def __init__(self):
25  self.operator = IgnoreFilters()
26  self._levelInTasks = 0
27  super(type(self),self).__init__(self.operator)
28  def enter(self,visitee):
29  if isinstance(visitee, cms.Task):
30  self._levelInTasks += 1
31  self.operator.onTask = (self._levelInTasks > 0)
32  super(IgnoreFiltersVisitor,self).enter(visitee)
33  def leave(self,visitee):
34  if self._levelInTasks > 0:
35  if isinstance(visitee, cms.Task):
36  self._levelInTasks -= 1
37  super(IgnoreFiltersVisitor,self).leave(visitee)
38 
39  mutator = IgnoreFiltersVisitor()
40  path.visit(mutator)
41  if mutator._didApply():
42  path._seq = mutator.result(path)[0]
43  path._tasks.clear()
44  path.associate(*mutator.result(path)[1])
45  return path
def ignoreAllFiltersOnPath
Definition: Utilities.py:2
def Utilities.loadHltConfiguration (   process,
  menu,
  args 
)

Definition at line 23 of file Utilities.py.

References _build_options(), and remoteMonitoring_LASER_era2018_cfg.dump.

23 
24 def loadHltConfiguration(process, menu, **args):
25  args['menu'] = menu
26  args['fragment'] = True
27  options = _build_options(**args)
28 
29  hlt = types.ModuleType('hlt')
30  exec(_confdb.HLTProcess(options).dump(), globals(), hlt.__dict__)
31  process.extend( hlt )
32 
def _build_options
Definition: Utilities.py:6
def loadHltConfiguration
Definition: Utilities.py:23
tuple dump
OutputFilePath = cms.string('/tmp/zhokin/'), OutputFileExt = cms.string(''),.
def Utilities.moduleLabelsInSequences (   sequences)

Definition at line 59 of file Utilities.py.

References modulesInSequences().

59 
60 def moduleLabelsInSequences(* sequences):
61  return [module.label_() for module in modulesInSequences(* sequences)]
def moduleLabelsInSequences
Definition: Utilities.py:59
def modulesInSequences
Definition: Utilities.py:51
def Utilities.modulesInSequences (   sequences)

Definition at line 51 of file Utilities.py.

Referenced by moduleLabelsInSequences().

51 
52 def modulesInSequences(* sequences):
53  from FWCore.ParameterSet.SequenceTypes import ModuleNodeVisitor
54  modules = []
55  for sequence in sequences:
56  sequence.visit(ModuleNodeVisitor(modules))
57  return modules
58 
def modulesInSequences
Definition: Utilities.py:51

Variable Documentation

Utilities.__lastCallUnary

Definition at line 10 of file Utilities.py.

Utilities._levelInTasks

Definition at line 25 of file Utilities.py.

Utilities.onTask

Definition at line 11 of file Utilities.py.

Utilities.operator

Definition at line 24 of file Utilities.py.

Referenced by AlcaBeamMonitorClient.AlcaBeamMonitorClient(), SiStripCalibLorentzAngle.algoBeginJob(), SiStripGainFromCalibTree.algoEndJob(), BeamConditionsMonitor.BeamConditionsMonitor(), BeamMonitorBx.BeamMonitorBx(), PFDQMEventSelector.beginJob(), DQMMessageLoggerClient.beginJob(), DQMOfflineHLTEventInfoClient.beginJob(), DQMFEDIntegrityClient.beginJob(), GenericBenchmarkAnalyzer.beginJob(), DQMLumiMonitor.beginJob(), PixelVTXMonitor.beginJob(), LaserDQM.beginJob(), PFTester.beginJob(), StripValidationPlots.beginJob(), SimplePhotonAnalyzer.beginJob(), SiPixelDQMRocLevelAnalyzer.beginJob(), DQMDaqInfo.beginJob(), TestSuite.beginJob(), FourVectorHLT.beginJob(), DQMStoreStats.beginJob(), SiStripCommissioningSource.beginRun(), SiStripDigiValid.bookHistograms(), TrackingTruthValid.bookHistograms(), SiPixelDigiValid.bookHistograms(), TrackerHitAnalyzer.bookHistograms(), TkConvValidator.bookHistograms(), SiPixelTrackingRecHitsValid.bookHistograms(), ConversionPostprocessing.ConversionPostprocessing(), SiStripCommissioningOfflineDbClient.createHistos(), CSCDCCUnpacker.CSCDCCUnpacker(), TrackerOfflineValidation::DirectoryWrapper.DirectoryWrapper(), DQMEDHarvester.DQMEDHarvester(), OuterTrackerMCHarvester.dqmEndJob(), DQMGenericClient.dqmEndRun(), DQMGlobalEDAnalyzerBase< Histograms_TICLTrackstersEdgesValidation, Args...>.DQMGlobalEDAnalyzerBase(), DTnoiseDBValidation.DTnoiseDBValidation(), DTt0DBValidation.DTt0DBValidation(), EcalBarrelMonitorDbModule.EcalBarrelMonitorDbModule(), EgHLTOfflineSummaryClient.EgHLTOfflineSummaryClient(), APVValidationPlots.endJob(), EDMtoMEConverter.endLuminosityBlockProduce(), MEtoEDMConverter.endLuminosityBlockProduce(), DQMRivetClient.endRun(), DQMGenericTnPClient.endRun(), EDMtoMEConverter.endRunProduce(), MEtoEDMConverter.endRunProduce(), ESDaqInfoTask.ESDaqInfoTask(), ESDataCertificationTask.ESDataCertificationTask(), ESDcsInfoTask.ESDcsInfoTask(), FedRawDataInputSource.FedRawDataInputSource(), FourVectorHLT.FourVectorHLT(), GenFilterEfficiencyProducer.GenFilterEfficiencyProducer(), FWEvePtr< T >.get(), GlobalHitsProdHistStripper.GlobalHitsProdHistStripper(), GlobalMuonMatchAnalyzer.GlobalMuonMatchAnalyzer(), HLTInclusiveVBFClient.HLTInclusiveVBFClient(), HLTOverallSummary.HLTOverallSummary(), HLTPrescaler.HLTPrescaler(), HLTPrescaleRecorder.HLTPrescaleRecorder(), HLTScalersClient.HLTScalersClient(), DQMFEDIntegrityClient.initialize(), DQMOfflineHLTEventInfoClient.initialize(), SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy.initializeDQMHistograms(), L1ScalersClient.L1ScalersClient(), cond::persistency::PayloadProxy< cond::persistency::KeyList >.loadPayload(), TkHistoMap.loadServices(), SiStripFedCablingBuilderFromDb.make(), MonitorElementsDb.MonitorElementsDb(), MuonTrackAnalyzer.MuonTrackAnalyzer(), MuonTrackResidualAnalyzer.MuonTrackResidualAnalyzer(), NoiseTask.NoiseTask(), funct::RootIntegrator.operator()(), EncodedTruthId.operator<(), EncodedTruthId.operator==(), PedsOnlyTask.PedsOnlyTask(), PFJetBenchmarkAnalyzer.PFJetBenchmarkAnalyzer(), PFMETBenchmarkAnalyzer.PFMETBenchmarkAnalyzer(), PFTauElecRejectionBenchmarkAnalyzer.PFTauElecRejectionBenchmarkAnalyzer(), PhotonPostprocessing.PhotonPostprocessing(), evf::FastMonitoringService.preBeginJob(), BuildTrackerMapPlugin.read(), DQMRootSource.readElements(), recoBSVTagInfoValidationAnalyzer.recoBSVTagInfoValidationAnalyzer(), RecoMuonValidator.RecoMuonValidator(), RivetAnalyzer.RivetAnalyzer(), SiStripClassToMonitorCondData.save(), SiPixelFolderOrganizer.SiPixelFolderOrganizer(), SiStripFolderOrganizer.SiStripFolderOrganizer(), SiStripGainFromCalibTree.SiStripGainFromCalibTree(), SiStripGainFromData.SiStripGainFromData(), SiStripQualityHotStripIdentifierRoot.SiStripQualityHotStripIdentifierRoot(), StatisticsFilter.StatisticsFilter(), TrackEfficiencyMonitor.TrackEfficiencyMonitor(), and TrackerOfflineValidationSummary.TrackerOfflineValidationSummary().