CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Utils.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 _Utils_
4 
5 Module containing some utility tools
6 
7 """
8 
9 def stepALCAPRODUCER(skims):
10  """
11  _stepALCAPRODUCER_
12 
13  Creates and returns the configuration string for the ALCAPRODUCER step
14  starting from the list of AlcaReco path to be run.
15 
16  """
17 
18  step = ''
19  if len(skims) >0:
20  step = ',ALCAPRODUCER:'+('+'.join(skims))
21  return step
22 
23 
24 def stepSKIMPRODUCER(PhysicsSkims):
25  """
26  _stepSKIMPRODUCER_
27 
28  Creates and returns the configuration string for the SKIM step
29  starting from the list of skims to be run.
30 
31  """
32 
33  step = ''
34  if len(PhysicsSkims) >0 :
35  step = ',SKIM:'+('+'.join(PhysicsSkims))
36  return step
37 
38 def addMonitoring(process):
39  """
40  _addMonitoring_
41 
42  Add the monitoring services to the process provided
43  in order to write out performance summaries to the framework job report
44  """
45  import FWCore.ParameterSet.Config as cms
46 
47  process.SimpleMemoryCheck = cms.Service("SimpleMemoryCheck",
48  jobReportOutputOnly = cms.untracked.bool(True)
49  )
50  process.Timing = cms.Service("Timing",
51  summaryOnly = cms.untracked.bool(True)
52  )
53 
54  return process
55 
56 
57 def validateProcess(process):
58  """
59  _validateProcess_
60 
61  Check attributes of process are appropriate for production
62  This method returns nothing but will throw a RuntimeError for any issues it finds
63  likely to cause problems in the production system
64 
65  """
66 
67  schedule=process.schedule_()
68  paths=process.paths_()
69  endpaths=process.endpaths_()
70 
71  # check output mods are in paths and have appropriate settings
72  for outputModName in process.outputModules_().keys():
73  outputMod = getattr(process, outputModName)
74  if not hasattr(outputMod, 'dataset'):
75  msg = "Process contains output module without dataset PSET: %s \n" % outputModName
76  msg += " You need to add this PSET to this module to set dataTier and filterName\n"
77  raise RuntimeError, msg
78  ds=getattr(outputMod,'dataset')
79  if not hasattr(ds, "dataTier"):
80  msg = "Process contains output module without dataTier parameter: %s \n" % outputModName
81  msg += " You need to add an untracked parameter to the dataset PSET of this module to set dataTier\n"
82  raise RuntimeError, msg
83 
84  # check module in path or whatever (not sure of exact syntax for endpath)
85  omRun=False
86 
87  if schedule==None:
88  for path in paths:
89  if outputModName in getattr(process,path).moduleNames():
90  omRun=True
91  for path in endpaths:
92  if outputModName in getattr(process,path).moduleNames():
93  omRun=True
94  else:
95  for path in schedule:
96  if outputModName in path.moduleNames():
97  omRun=True
98  if omRun==False:
99  msg = "Output Module %s not in endPath" % outputModName
100  raise RuntimeError, msg
101 
102 
103 def dqmIOSource(args):
104  import FWCore.ParameterSet.Config as cms
105  if args.get('newDQMIO', False):
106  return cms.Source("DQMRootSource",
107  fileNames = cms.untracked(cms.vstring())
108  )
109  else:
110  return cms.Source("PoolSource",
111  fileNames = cms.untracked(cms.vstring())
112  )
113 
114 def harvestingMode(process, datasetName, args,rANDl=True):
115  import FWCore.ParameterSet.Config as cms
116  if rANDl and (not args.get('newDQMIO', False)):
117  process.source.processingMode = cms.untracked.string('RunsAndLumis')
118  process.dqmSaver.workflow = datasetName
119  process.dqmSaver.saveByLumiSection = 1
120  if args.has_key('referenceFile') and args.get('referenceFile', ''):
121  process.DQMStore.referenceFileName = cms.untracked.string(args['referenceFile'])
122 
123 def dictIO(options,args):
124  if args.has_key('outputs'):
125  options.outputDefinition = args['outputs'].__str__()
126  else:
127  writeTiers = args.get('writeTiers', [])
128  options.eventcontent = ','.join(writeTiers)
129  options.datatier = ','.join(writeTiers)
130 
131 def dqmSeq(args,default):
132  if 'dqmSeq' in args and len(args['dqmSeq'])!=0:
133  return ':'+('+'.join(args['dqmSeq']))
134  else:
135  return default
136 
137 def gtNameAndConnect(globalTag, args):
138  if args.has_key('globalTagConnect') and args['globalTagConnect'] != '':
139  return globalTag + ','+args['globalTagConnect']
140  # we override here the default in the release which uses the FrontierProd servlet not suited for Tier0 activity
141  return globalTag +',frontier://PromptProd/CMS_CONDITIONS'
def dqmSeq
Definition: Utils.py:131
def stepALCAPRODUCER
Definition: Utils.py:9
def addMonitoring
Definition: Utils.py:38
def validateProcess
Definition: Utils.py:57
def stepSKIMPRODUCER
Definition: Utils.py:24
def gtNameAndConnect
Definition: Utils.py:137
def dqmIOSource
Definition: Utils.py:103
def dictIO
Definition: Utils.py:123
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def harvestingMode
Definition: Utils.py:114