CMS 3D CMS Logo

Namespaces | Classes | Functions | Variables
Utilities Namespace Reference

Namespaces

 ReleaseScripts
 

Classes

class  TestModuleCommand
 

Functions

def _build_options (args)
 
def convertToSingleModuleEndPaths (process)
 
def convertToUnscheduled (proc)
 
def createTaskWithAllProducersAndFilters (process)
 
def getHltConfiguration (menu, args)
 
def ignoreAllFiltersOnPath (path)
 
def loadHltConfiguration (process, menu, args)
 
def moduleLabelsInSequences (sequences)
 
def modulesInSequences (sequences)
 

Variables

 __lastCallUnary
 
 _levelInTasks
 
 loadHltConfiguration
 
 onTask
 
 operator
 

Function Documentation

◆ _build_options()

def Utilities._build_options (   args)
private

Definition at line 6 of file Utilities.py.

Referenced by getHltConfiguration(), and loadHltConfiguration().

6 def _build_options(**args):
7  options = _options.HLTProcessOptions()
8  for key, val in args.items():
9  setattr(options, key, val)
10  return options
11 
12 
def _build_options(args)
Definition: Utilities.py:6

◆ convertToSingleModuleEndPaths()

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().

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

◆ convertToUnscheduled()

def Utilities.convertToUnscheduled (   proc)

Definition at line 46 of file Utilities.py.

References print().

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

◆ createTaskWithAllProducersAndFilters()

def Utilities.createTaskWithAllProducersAndFilters (   process)

Definition at line 62 of file Utilities.py.

Referenced by Utilities.TestModuleCommand.testCreateTaskWithAllProducersAndFilters().

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

◆ getHltConfiguration()

def Utilities.getHltConfiguration (   menu,
  args 
)

Definition at line 13 of file Utilities.py.

References _build_options(), and GCP_Ntuples_cfg.dump.

13 def getHltConfiguration(menu, **args):
14  args['menu'] = menu
15  args['fragment'] = False
16  options = _build_options(**args)
17 
18  try:
19  foo = {'process': None}
20  exec(_confdb.HLTProcess(options).dump(), globals(), foo)
21  process = foo['process']
22  except:
23  raise Exception(f'query to ConfDB failed (output is not a valid python file)\n args={args}')
24 
25  if not isinstance(process, cms.Process):
26  raise Exception(f'query to ConfDB did not return a valid HLT menu (cms.Process not found)\n args={args}')
27 
28  return process
29 
30 
def _build_options(args)
Definition: Utilities.py:6
def getHltConfiguration(menu, args)
Definition: Utilities.py:13

◆ ignoreAllFiltersOnPath()

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__(), and resolutioncreator_cfi.object.

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

◆ loadHltConfiguration()

def Utilities.loadHltConfiguration (   process,
  menu,
  args 
)

Definition at line 31 of file Utilities.py.

References _build_options(), GCP_Ntuples_cfg.dump, and loadHltConfiguration.

31 def loadHltConfiguration(process, menu, **args):
32  args['menu'] = menu
33  args['fragment'] = True
34  options = _build_options(**args)
35 
36  try:
37  hlt = {'fragment': None}
38  exec(_confdb.HLTProcess(options).dump(), globals(), hlt)
39  process2 = hlt['fragment']
40  except:
41  raise Exception(f'query to ConfDB failed (output is not a valid python file)\n args={args}')
42 
43  if not isinstance(process2, cms.Process):
44  raise Exception(f'query to ConfDB did not return a valid HLT menu (cms.Process not found)\n args={args}')
45 
46  process.extend( process2 )
47 
48  return process
49 
50 
def _build_options(args)
Definition: Utilities.py:6
def loadHltConfiguration(process, menu, args)
Definition: Utilities.py:31

◆ moduleLabelsInSequences()

def Utilities.moduleLabelsInSequences (   sequences)

Definition at line 59 of file Utilities.py.

References modulesInSequences().

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

◆ modulesInSequences()

def Utilities.modulesInSequences (   sequences)

Definition at line 51 of file Utilities.py.

Referenced by moduleLabelsInSequences().

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

Variable Documentation

◆ __lastCallUnary

Utilities.__lastCallUnary
private

Definition at line 10 of file Utilities.py.

◆ _levelInTasks

Utilities._levelInTasks
private

Definition at line 25 of file Utilities.py.

◆ loadHltConfiguration

Utilities.loadHltConfiguration

Definition at line 52 of file Utilities.py.

Referenced by loadHltConfiguration().

◆ onTask

Utilities.onTask

Definition at line 11 of file Utilities.py.

◆ operator

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(), DQMFEDIntegrityClient.beginJob(), DQMOfflineHLTEventInfoClient.beginJob(), GenericBenchmarkAnalyzer.beginJob(), LaserDQM.beginJob(), DQMLumiMonitor.beginJob(), PFTester.beginJob(), StripValidationPlots.beginJob(), SiPixelDQMRocLevelAnalyzer.beginJob(), TestSuite.beginJob(), DQMDaqInfo.beginJob(), FourVectorHLT.beginJob(), DQMStoreStats.beginJob(), SiStripLAProfileBooker.beginRun(), SiStripCommissioningSource.beginRun(), SiStripDigiValid.bookHistograms(), TrackingTruthValid.bookHistograms(), SiPixelDigiValid.bookHistograms(), TrackerHitAnalyzer.bookHistograms(), TkConvValidator.bookHistograms(), SiPixelTrackingRecHitsValid.bookHistograms(), ConversionPostprocessing.ConversionPostprocessing(), SiStripCommissioningOfflineDbClient.createHistos(), CSCDCCUnpacker.CSCDCCUnpacker(), DAQSource.DAQSource(), TrackerOfflineValidation::DirectoryWrapper.DirectoryWrapper(), DQMEDHarvester.DQMEDHarvester(), Phase2OTHarvestTrackingParticles.dqmEndJob(), OuterTrackerMCHarvester.dqmEndJob(), DQMGenericClient.dqmEndRun(), HLTGenValClient.dqmEndRun(), DQMGlobalEDAnalyzerBase< dtsegment2dsl::Histograms, Args... >.DQMGlobalEDAnalyzerBase(), DTnoiseDBValidation.DTnoiseDBValidation(), DTt0DBValidation.DTt0DBValidation(), EcalBarrelMonitorDbModule.EcalBarrelMonitorDbModule(), EgHLTOfflineSummaryClient.EgHLTOfflineSummaryClient(), APVValidationPlots.endJob(), SiStripApvGainInspector.endJob(), EDMtoMEConverter.endLuminosityBlockProduce(), MEtoEDMConverter.endLuminosityBlockProduce(), DQMRivetClient.endRun(), DQMGenericTnPClient.endRun(), EDMtoMEConverter.endRunProduce(), MEtoEDMConverter.endRunProduce(), ESDaqInfoTask.ESDaqInfoTask(), ESDataCertificationTask.ESDataCertificationTask(), ESDcsInfoTask.ESDcsInfoTask(), FedRawDataInputSource.FedRawDataInputSource(), SiStripQualityDQM.fillGrandSummaryMEs(), FourVectorHLT.FourVectorHLT(), GenFilterEfficiencyProducer.GenFilterEfficiencyProducer(), FWEvePtr< T >.get(), SiStripCablingDQM.getActiveDetIds(), 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(), RecoDisplacedMuonValidator.RecoDisplacedMuonValidator(), RecoMuonValidator.RecoMuonValidator(), SiStripClassToMonitorCondData.save(), SiPixelFolderOrganizer.SiPixelFolderOrganizer(), SiStripFolderOrganizer.SiStripFolderOrganizer(), SiStripGainFromCalibTree.SiStripGainFromCalibTree(), SiStripGainFromData.SiStripGainFromData(), StatisticsFilter.StatisticsFilter(), TrackEfficiencyMonitor.TrackEfficiencyMonitor(), and TrackerOfflineValidationSummary.TrackerOfflineValidationSummary().