CMS 3D CMS Logo

Namespaces | Classes | Functions | Variables
Utilities Namespace Reference

Namespaces

 ReleaseScripts
 

Classes

class  TestModuleCommand
 

Functions

def _build_options (args)
 
def cleanUnscheduled (proc)
 
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
 
 onTask
 
 operator
 

Function Documentation

def Utilities._build_options (   args)
private

Definition at line 7 of file Utilities.py.

Referenced by getHltConfiguration(), and loadHltConfiguration().

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

Definition at line 78 of file Utilities.py.

References cmsPerfStripChart.dict, and list().

Referenced by convertToUnscheduled().

78 def cleanUnscheduled(proc):
79  import FWCore.ParameterSet.Config as cms
80 
81  pathsAndEndPaths = dict(proc.paths)
82  pathsAndEndPaths.update( dict(proc.endpaths) )
83 
84  #have to get them now since switching them after the
85  # paths have been changed gives null labels
86  if proc.schedule:
87  pathNamesInScheduled = [p.label_() for p in proc.schedule]
88  else:
89  pathNamesInScheduled = False
90 
91  def getUnqualifiedName(name):
92  if name[0] in set(['!','-']):
93  return name[1:]
94  return name
95 
96  def getQualifiedModule(name,proc):
97  unqual_name = getUnqualifiedName(name)
98  p=getattr(proc,unqual_name)
99  if unqual_name != name:
100  if name[0] == '!':
101  p = ~p
102  elif name[0] == '-':
103  p = cms.ignore(p)
104  return p
105 
106  # Loop over paths
107  # On each path we move EDProducers and EDFilters that
108  # are ignored to Tasks
109  producerList = list()
110  import six
111  for pName, originalPath in six.iteritems(pathsAndEndPaths):
112  producerList[:] = []
113  qualified_names = []
114  v = cms.DecoratedNodeNamePlusVisitor(qualified_names)
115  originalPath.visit(v)
116  remaining =[]
117 
118  for n in qualified_names:
119  unqual_name = getUnqualifiedName(n)
120  mod = getattr(proc,unqual_name)
121 
122  #remove EDProducer's and EDFilter's which are set to ignore
123  if not (isinstance(mod, cms.EDProducer) or
124  (n[0] =='-' and isinstance(mod, cms.EDFilter)) ):
125  remaining.append(n)
126  else:
127  producerList.append(mod)
128 
129  taskList = []
130  if v.leavesOnTasks():
131  taskList.append(cms.Task(*(v.leavesOnTasks())))
132  if (producerList):
133  taskList.append(cms.Task(*producerList))
134 
135  if remaining:
136  p = getQualifiedModule(remaining[0],proc)
137  for m in remaining[1:]:
138  p+=getQualifiedModule(m,proc)
139  setattr(proc,pName,type(getattr(proc,pName))(p))
140  else:
141  setattr(proc,pName,type(getattr(proc,pName))())
142 
143  newPath = getattr(proc,pName)
144  if (taskList):
145  newPath.associate(*taskList)
146 
147  # If there is a schedule then it needs to point at
148  # the new Path objects
149  if proc.schedule:
150  listOfTasks = list(proc.schedule._tasks)
151  proc.schedule = cms.Schedule([getattr(proc,p) for p in pathNamesInScheduled])
152  proc.schedule.associate(*listOfTasks)
153  return proc
154 
155 
def cleanUnscheduled(proc)
Definition: Utilities.py:78
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
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 175 of file Utilities.py.

Referenced by Utilities.TestModuleCommand.testConvertToSingleModuleEndPaths().

176  """Remove the EndPaths in the Process with more than one module
177  and replace with new EndPaths each with only one module.
178  """
179  import FWCore.ParameterSet.Config as cms
180  import six
181  toRemove =[]
182  added = []
183  for n,ep in six.iteritems(process.endpaths_()):
184  tsks = []
185  ep.visit(cms.TaskVisitor(tsks))
186 
187  names = ep.moduleNames()
188  if 1 == len(names):
189  continue
190  toRemove.append(n)
191  for m in names:
192  epName = m+"_endpath"
193  setattr(process,epName,cms.EndPath(getattr(process,m),*tsks))
194  added.append(epName)
195 
196  s = process.schedule_()
197  if s:
198  pathNames = [p.label_() for p in s]
199  for rName in toRemove:
200  pathNames.remove(rName)
201  for n in added:
202  pathNames.append(n)
203  newS = cms.Schedule(*[getattr(process,n) for n in pathNames])
204  if s._tasks:
205  newS.associate(*s._tasks)
206  process.setSchedule_(newS)
207 
208  for r in toRemove:
209  delattr(process,r)
210 
211 
def convertToSingleModuleEndPaths(process)
Definition: Utilities.py:175
def Utilities.convertToUnscheduled (   proc)

Definition at line 46 of file Utilities.py.

References cleanUnscheduled().

Referenced by Utilities.TestModuleCommand.testNoSchedule(), and Utilities.TestModuleCommand.testWithSchedule().

47  import FWCore.ParameterSet.Config as cms
48  """Given a 'Process', convert the python configuration from scheduled execution to unscheduled. This is done by
49  1. Pulling EDProducers off Path and EndPath Sequences and putting them on an associated Task.
50  2. Pulling EDFilters whose filter results are ignored off Path and EndPath Sequences and putting
51  them on an associated Task.
52  3. Fixing up the Schedule if needed
53  """
54  # Warning: It is not always possible to convert a configuration
55  # where EDProducers are all run on Paths to an unscheduled
56  # configuration by modifying only the python configuration.
57  # There is more than one kind of pathological condition
58  # that can cause this conversion to produce a configuration
59  # that gives different results than the original configuration
60  # when run under cmsRun. One should view the converted configuration
61  # as a thing which needs to be validated. It is possible for there
62  # to be pathologies that cannot be resolved by modifying only the
63  # python configuration and may require redesign inside the C++ code
64  # of the modules and redesign of the logic. For example,
65  # an EDAnalyzer might try to get a product and check if the
66  # returned handle isValid. Then it could behave differently
67  # depending on whether or not the product was present.
68  # The behavior when the product is not present could
69  # be meaningful and important. In the unscheduled case,
70  # the EDProducer will always run and the product could
71  # always be there.
72 
73  proc.resolve()
74 
75  proc=cleanUnscheduled(proc)
76  return proc
77 
def cleanUnscheduled(proc)
Definition: Utilities.py:78
def convertToUnscheduled(proc)
Definition: Utilities.py:46
def Utilities.createTaskWithAllProducersAndFilters (   process)

Definition at line 167 of file Utilities.py.

Referenced by Utilities.TestModuleCommand.testCreateTaskWithAllProducersAndFilters().

168  from FWCore.ParameterSet.Config import Task
169  import six
170 
171  l = [ p for p in six.itervalues(process.producers)]
172  l.extend( (f for f in six.itervalues(process.filters)) )
173  return Task(*l)
174 
def createTaskWithAllProducersAndFilters(process)
Definition: Utilities.py:167
def Utilities.getHltConfiguration (   menu,
  args 
)

Definition at line 14 of file Utilities.py.

References _build_options(), and FrontierConditions_GlobalTag_cff.dump.

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 
23 
def _build_options(args)
Definition: Utilities.py:7
def getHltConfiguration(menu, args)
Definition: Utilities.py:14
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 resolutioncreator_cfi.object.

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 ignoreAllFiltersOnPath(path)
Definition: Utilities.py:2
def Utilities.loadHltConfiguration (   process,
  menu,
  args 
)

Definition at line 24 of file Utilities.py.

References _build_options(), and FrontierConditions_GlobalTag_cff.dump.

24 def loadHltConfiguration(process, menu, **args):
25  args['menu'] = menu
26  args['fragment'] = True
27  options = _build_options(**args)
28 
29  hlt = _imp.new_module('hlt')
30  exec(_confdb.HLTProcess(options).dump(), globals(), hlt.__dict__)
31  process.extend( hlt )
32 
33 
def _build_options(args)
Definition: Utilities.py:7
def loadHltConfiguration(process, menu, args)
Definition: Utilities.py:24
def Utilities.moduleLabelsInSequences (   sequences)

Definition at line 164 of file Utilities.py.

References modulesInSequences().

164 def moduleLabelsInSequences(* sequences):
165  return [module.label() for module in modulesInSequences(* sequences)]
166 
def moduleLabelsInSequences(sequences)
Definition: Utilities.py:164
def modulesInSequences(sequences)
Definition: Utilities.py:156
def Utilities.modulesInSequences (   sequences)

Definition at line 156 of file Utilities.py.

Referenced by moduleLabelsInSequences().

156 def modulesInSequences(* sequences):
157  from FWCore.ParameterSet.SequenceTypes import ModuleNodeVisitor
158  modules = []
159  for sequence in sequences:
160  sequence.visit(ModuleNodeVisitor(modules))
161  return modules
162 
163 
def modulesInSequences(sequences)
Definition: Utilities.py:156

Variable Documentation

Utilities.__lastCallUnary
private

Definition at line 10 of file Utilities.py.

Utilities._levelInTasks
private

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(), edm::debugging_allocator< T >.allocate(), DetIdSelectorTest.analyze(), BeamMonitorBx.BeamMonitorBx(), PFDQMEventSelector.beginJob(), GenericBenchmarkAnalyzer.beginJob(), DQMMessageLoggerClient.beginJob(), PFTester.beginJob(), DQMSourceExample.beginJob(), DQMFEDIntegrityClient.beginJob(), LaserDQM.beginJob(), DQMOfflineHLTEventInfoClient.beginJob(), DQMLumiMonitor.beginJob(), PixelVTXMonitor.beginJob(), DQMClientExample.beginJob(), SimplePhotonAnalyzer.beginJob(), APVValidationPlots.beginJob(), StripValidationPlots.beginJob(), TestSuite.beginJob(), SiPixelDQMRocLevelAnalyzer.beginJob(), DQMDaqInfo.beginJob(), FourVectorHLT.beginJob(), MEtoEDMConverter.beginJob(), MuonAlignment.beginJob(), DQMStoreStats.beginJob(), ESIntegrityTask.beginLuminosityBlock(), SiStripLAProfileBooker.beginRun(), SiStripCommissioningSource.beginRun(), SiStripDigiValid.bookHistograms(), TrackingTruthValid.bookHistograms(), SiPixelDigiValid.bookHistograms(), TrackerHitAnalyzer.bookHistograms(), TkConvValidator.bookHistograms(), SiPixelTrackingRecHitsValid.bookHistograms(), SiStripCondObjBuilderFromDb.buildAnalysisRelatedObjects(), ConversionPostprocessing.ConversionPostprocessing(), ConverterTester.ConverterTester(), SiStripCommissioningOfflineDbClient.createHistos(), CSCDCCUnpacker.CSCDCCUnpacker(), edm::debugging_allocator< T >.deallocate(), TrackerOfflineValidation::DirectoryWrapper.DirectoryWrapper(), OuterTrackerMCHarvester.dqmEndJob(), DQMGenericClient.dqmEndJob(), DQMFileReader.DQMFileReader(), DTnoiseDBValidation.DTnoiseDBValidation(), DTt0DBValidation.DTt0DBValidation(), EcalBarrelMonitorDbModule.EcalBarrelMonitorDbModule(), EcalBarrelSimHitsValidation.EcalBarrelSimHitsValidation(), EcalEndcapSimHitsValidation.EcalEndcapSimHitsValidation(), EcalPreshowerSimHitsValidation.EcalPreshowerSimHitsValidation(), EcalSimHitsValidation.EcalSimHitsValidation(), EgHLTOfflineSummaryClient.EgHLTOfflineSummaryClient(), DQMEDHarvester.endJob(), HarvestingAnalyzer.endJob(), DQMEDHarvester.endLuminosityBlock(), EDMtoMEConverter.endLuminosityBlockProduce(), MEtoEDMConverter.endLuminosityBlockProduce(), DQMRivetClient.endRun(), DQMGenericTnPClient.endRun(), ESIntegrityTask.endRun(), SiStripClassToMonitorCondData.endRun(), SiStripMonitorCondData.endRun(), OccupancyPlots.endRun(), EDMtoMEConverter.endRunProduce(), MEtoEDMConverter.endRunProduce(), ESDaqInfoTask.ESDaqInfoTask(), ESDataCertificationTask.ESDataCertificationTask(), ESDcsInfoTask.ESDcsInfoTask(), FedRawDataInputSource.FedRawDataInputSource(), SiStripQualityDQM.fillGrandSummaryMEs(), FourVectorHLT.FourVectorHLT(), GenFilterEfficiencyProducer.GenFilterEfficiencyProducer(), FWEvePtr< T >.get(), SiStripCablingDQM.getActiveDetIds(), ValidHitPairFilter.getCloseDets(), ClusterShapeTrackFilter.getGlobalPoss(), GlobalHitsProdHistStripper.GlobalHitsProdHistStripper(), GlobalMuonMatchAnalyzer.GlobalMuonMatchAnalyzer(), HLTInclusiveVBFClient.HLTInclusiveVBFClient(), HLTOverallSummary.HLTOverallSummary(), HLTPrescaler.HLTPrescaler(), HLTPrescaleRecorder.HLTPrescaleRecorder(), HLTScalersClient.HLTScalersClient(), DQMSourceExample.initialize(), DQMFEDIntegrityClient.initialize(), DQMOfflineHLTEventInfoClient.initialize(), DQMClientExample.initialize(), SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy.initializeDQMHistograms(), L1ScalersClient.L1ScalersClient(), cond::persistency::PayloadProxy< cond::persistency::KeyList >.loadPayload(), TkHistoMap.loadServices(), SiStripFedCablingBuilderFromDb.make(), MEtoMEComparitor.MEtoMEComparitor(), MonitorElementsDb.MonitorElementsDb(), MuonTrackAnalyzer.MuonTrackAnalyzer(), MuonTrackResidualAnalyzer.MuonTrackResidualAnalyzer(), NoiseTask.NoiseTask(), PVSelector.operator()(), RunLumiSelector.operator()(), PVObjectSelector.operator()(), ElectronVPlusJetsIDSelectionFunctor.operator()(), PFElectronSelector.operator()(), PFMuonSelector.operator()(), funct::RootIntegrator.operator()(), PFJetIDSelectionFunctor.operator()(), MuonVPlusJetsIDSelectionFunctor.operator()(), JetIDSelectionFunctor.operator()(), SimpleCutBasedElectronIDSelectionFunctor.operator()(), de_rank< T >.operator()(), Indexed< T >.operator+(), EncodedTruthId.operator<(), EncodedTruthId.operator==(), PedsOnlyTask.PedsOnlyTask(), PFJetBenchmarkAnalyzer.PFJetBenchmarkAnalyzer(), PFMETBenchmarkAnalyzer.PFMETBenchmarkAnalyzer(), PFTauElecRejectionBenchmarkAnalyzer.PFTauElecRejectionBenchmarkAnalyzer(), PhotonPostprocessing.PhotonPostprocessing(), evf::FastMonitoringService.preBeginJob(), TkDetMapESProducer.produce(), SiStripBadModuleFedErrESSource.produce(), BuildTrackerMapPlugin.read(), recoBSVTagInfoValidationAnalyzer.recoBSVTagInfoValidationAnalyzer(), RecoMuonValidator.RecoMuonValidator(), SiStripCondObjBuilderFromDb.retrieveNumberAPVPairs(), RivetAnalyzer.RivetAnalyzer(), WPlusJetsEventSelector.scaleJets(), SiStripCondObjBuilderFromDb.setValuesApvLatency(), SiPixelFolderOrganizer.SiPixelFolderOrganizer(), SiStripCorrelateBadStripAndNoise.SiStripCorrelateBadStripAndNoise(), SiStripCorrelateNoise.SiStripCorrelateNoise(), SiStripFolderOrganizer.SiStripFolderOrganizer(), SiStripGainFromCalibTree.SiStripGainFromCalibTree(), SiStripGainFromData.SiStripGainFromData(), SiStripPlotGain.SiStripPlotGain(), SiStripQualityHotStripIdentifierRoot.SiStripQualityHotStripIdentifierRoot(), StatisticsFilter.StatisticsFilter(), TrackEfficiencyMonitor.TrackEfficiencyMonitor(), TrackerOfflineValidationSummary.TrackerOfflineValidationSummary(), TSCBLBuilderWithPropagator.TSCBLBuilderWithPropagator(), Clusterizer1D< reco::Track >.~Clusterizer1D(), DivisiveClusterizer1D< T >.~DivisiveClusterizer1D(), pixeltemp::DivisiveClusterizer1D< T >.~DivisiveClusterizer1D(), TSCBLBuilderWithPropagator.~TSCBLBuilderWithPropagator(), and TSCPBuilderNoMaterial.~TSCPBuilderNoMaterial().