CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
cmsDriverOptions Namespace Reference

Functions

def adaptOptions
 
def checkOptions
 
def OptionsFromCommand
 
def OptionsFromCommandLine
 
def OptionsFromItems
 

Function Documentation

def cmsDriverOptions.adaptOptions ( )

Definition at line 17 of file cmsDriverOptions.py.

17 
18 def adaptOptions():
19  return
def cmsDriverOptions.checkOptions ( )

Definition at line 14 of file cmsDriverOptions.py.

14 
15 def checkOptions():
16  return
def cmsDriverOptions.OptionsFromCommand (   command)

Definition at line 20 of file cmsDriverOptions.py.

Referenced by MatrixToProcess.MatrixToProcess.load().

20 
21 def OptionsFromCommand(command):
22  items=command.split()
23  if items[0] != 'cmsDriver.py':
24  return None
25  items.append('--evt_type')
26  items.append(items[1])
27  options=OptionsFromItems(items[2:])
28  options.arguments = command
29  return options
def cmsDriverOptions.OptionsFromCommandLine ( )

Definition at line 30 of file cmsDriverOptions.py.

References OptionsFromItems().

Referenced by cmsDriver.run().

30 
32  import sys
33  options=OptionsFromItems(sys.argv[1:])
34  # memorize the command line arguments
35  options.arguments = reduce(lambda x, y: x+' '+y, sys.argv[1:])
36  return options
def cmsDriverOptions.OptionsFromItems (   items)

Definition at line 37 of file cmsDriverOptions.py.

References join(), and python.rootplot.root2matplotlib.replace().

Referenced by OptionsFromCommand(), and OptionsFromCommandLine().

37 
38 def OptionsFromItems(items):
39  import sys
40  from Configuration.Applications.Options import parser,threeValued
41  #three valued options
42  for (index,item) in enumerate(items):
43  for (opt,value) in threeValued:
44  if (str(item) in opt) and (index==len(items)-1 or items[index+1].startswith('-')):
45  items.insert(index+1,value)
46 
47  (options,args) = parser.parse_args(items)
48 
49  if not options.conditions or options.conditions=="help":
50  from Configuration.AlCa import autoCond
51  possible=""
52  for k in autoCond.autoCond:
53  possible+="\nauto:"+k+" -> "+autoCond.autoCond[k]
54  raise Exception("the --conditions option is mandatory. Possibilities are: "+possible)
55 
56 
57  #################################
58  # Check parameters for validity #
59  #################################
60 
61  # check in case of ALCAOUTPUT case for alca splitting
62  if options.triggerResultsProcess == None and "ALCAOUTPUT" in options.step:
63  print "ERROR: If ALCA splitting is requested, the name of the process in which the alca producers ran needs to be specified. E.g. via --triggerResultsProcess RECO"
64  sys.exit(1)
65 
66  if not options.evt_type:
67  options.evt_type=sys.argv[1]
68 
69  #now adjust the given parameters before passing it to the ConfigBuilder
70 
71  #trail a "/" to dirin and dirout
72  if options.dirin!='' and (not options.dirin.endswith('/')): options.dirin+='/'
73  if options.dirout!='' and (not options.dirout.endswith('/')): options.dirout+='/'
74 
75  # Build the IO files if necessary.
76  # The default form of the files is:
77  # <type>_<energy>_<step>.root
78  prec_step = {"NONE":"",
79  "FILTER":"",
80  "ALL":"",
81  "LHE":"",
82  "GEN":"",
83  "reGEN":"",
84  "SIM":"GEN",
85  "reSIM":"SIM",
86  "DIGI":"SIM",
87  "DIGIPREMIX":"SIM",
88  "DIGIPREMIX_S2":"SIM",
89  "reDIGI":"DIGI",
90  "L1REPACK":"RAW",
91  "HLT":"RAW",
92  "RECO":"DIGI",
93  "ALCA":"RECO",
94  "ANA":"RECO",
95  "SKIM":"RECO",
96  "DIGI2RAW":"DIGI",
97  "RAW2DIGI":"DIGI2RAW",
98  "RAW2RECO":"DIGI2RAW",
99  "DATAMIX":"DIGI",
100  "DIGI2RAW":"DATAMIX",
101  "HARVESTING":"RECO",
102  "ALCAHARVEST":"RECO",
103  "PAT":"RECO"}
104 
105  trimmedEvtType=options.evt_type.split('/')[-1]
106 
107  #get the list of steps, without their options
108  options.trimmedStep=[]
109  for s in options.step.split(','):
110  step=s.split(':')[0]
111  options.trimmedStep.append(step)
112  first_step=options.trimmedStep[0]
113 
114  #replace step aliases
115  # this does not affect options.trimmedStep which still contains 'NONE'
116  stepsAliases={
117  'NONE':'',
118  'ALL':'GEN,SIM,DIGI,L1,DIGI2RAW,HLT:GRun,RAW2DIGI,RECO,POSTRECO,VALIDATION,DQM',
119  'DATA_CHAIN':'RAW2DIGI,RECO,POSTRECO,DQM'
120  }
121  if options.step in stepsAliases:
122  options.step=stepsAliases[options.step]
123 
124  options.step = options.step.replace("SIM_CHAIN","GEN,SIM,DIGI,L1,DIGI2RAW")
125 
126  # add on the end of job sequence...
127  addEndJob = True
128  if ("FASTSIM" in options.step and not "VALIDATION" in options.step) or "HARVESTING" in options.step or "ALCAHARVEST" in options.step or "ALCAOUTPUT" in options.step or options.step == "":
129  addEndJob = False
130  if ("SKIM" in options.step and not "RECO" in options.step):
131  addEndJob = False
132  if ("ENDJOB" in options.step):
133  addEndJob = False
134  if ('DQMIO' in options.datatier):
135  addEndJob = False
136  if addEndJob:
137  options.step=options.step+',ENDJOB'
138 
139 
140  #determine the type of file on input
141  if options.filetype==defaultOptions.filetype:
142  if options.filein.lower().endswith(".lhe") or options.filein.lower().endswith(".lhef") or options.filein.startswith("lhe:"):
143  options.filetype="LHE"
144  elif options.filein.startswith("mcdb:"):
145  print "This is a deprecated way of selecting lhe files from article number. Please use lhe:article argument to --filein"
146  options.filein=options.filein.replace('mcdb:','lhe:')
147  options.filetype="LHE"
148  else:
149  options.filetype="EDM"
150 
151  filesuffix = {"LHE": "lhe", "EDM": "root", "MCDB": "", "DQM":"root"}[options.filetype]
152 
153  if options.filein=="" and not (first_step in ("ALL","GEN","LHE","SIM_CHAIN")):
154  options.dirin="file:"+options.dirin.replace('file:','')
155  options.filein=trimmedEvtType+"_"+prec_step[first_step]+"."+filesuffix
156 
157 
158  # Prepare the canonical file name for output / config file etc
159  # (EventType_STEP1_STEP2_..._PU)
160  standardFileName = ""
161  standardFileName = trimmedEvtType+"_"+"_".join(options.trimmedStep)
162  standardFileName = standardFileName.replace(",","_").replace(".","_")
163  if options.pileup != "NoPileUp":
164  standardFileName += "_PU"
165 
166 
167  # if no output file name given, set it to default
168  if options.fileout=="" and not first_step in ("HARVESTING", "ALCAHARVEST"):
169  options.fileout = standardFileName+".root"
170 
171  # Prepare the name of the config file
172  if not options.python_filename:
173  options.python_filename = standardFileName+'.py'
174 
175  print options.step
176 
177 
178  # Setting name of process
179  # if not set explicitly it needs some thinking
180  if not options.name:
181  if 'reSIM' in options.trimmedStep:
182  options.name = 'RESIM'
183  elif 'reDIGI' in options.trimmedStep:
184  options.name = 'REDIGI'
185  elif 'HLT' in options.trimmedStep:
186  options.name = 'HLT'
187  elif 'RECO' in options.trimmedStep:
188  options.name = 'RECO'
189  elif options.trimmedStep == ['NONE'] and options.filetype in ('LHE', 'MCDB'):
190  options.name = 'LHE'
191  elif len(options.trimmedStep)==0:
192  options.name = 'PROCESS'
193  else:
194  options.name = options.trimmedStep[-1]
195 
196  # check to be sure that people run the harvesting as a separate step
197  isHarvesting = False
198  isOther = False
199 
200  if "HARVESTING" in options.trimmedStep and len(options.trimmedStep) > 1:
201  raise Exception("The Harvesting step must be run alone")
202 
203  # if not specified by user try to guess whether MC or DATA
204  if not options.isData and not options.isMC:
205  if 'SIM' in options.trimmedStep:
206  options.isMC=True
207  if 'CFWRITER' in options.trimmedStep:
208  options.isMC=True
209  if 'DIGI' in options.trimmedStep:
210  options.isMC=True
211  if 'DIGI2RAW' in options.trimmedStep:
212  options.isMC=True
213  if (not (options.eventcontent == None)) and 'SIM' in options.eventcontent:
214  options.isMC=True
215  if 'SIM' in options.datatier:
216  options.isMC=True
217  if options.isMC:
218  print 'We have determined that this is simulation (if not, rerun cmsDriver.py with --data)'
219  else:
220  print 'We have determined that this is real data (if not, rerun cmsDriver.py with --mc)'
221 
222  if options.profile:
223  if options.profile and options.prefix:
224  raise Exception("--profile and --prefix are incompatible")
225  profilerType = 'pp'
226  profileOpts = options.profile.split(':')
227  if len(profileOpts):
228  profilerType = profileOpts[0].replace("=", " ")
229 
230  if profilerType == "pp":
231  options.profileTypeLabel = "performance"
232  elif profilerType == "mp":
233  options.profileTypeLabel = "memory"
234  elif profilerType.startswith("fp "):
235  options.profileTypeLabel = profilerType.replace("fp ", "")
236  else:
237  raise Exception("Not a valid profiler type %s. Alternatives are pp, mp, fp=<function>."%(profilerType))
238 
239  options.prefix = "igprof -t cmsRun -%s" % profilerType
240 
241  # If an "era" argument was supplied make sure it is one of the valid possibilities
242  if options.era :
243  from Configuration.StandardSequences.Eras import eras
244  from FWCore.ParameterSet.Config import Modifier, ModifierChain
245  # Split the string by commas to check individual eras
246  requestedEras = options.era.split(",")
247  # Check that the entry is a valid era
248  for eraName in requestedEras :
249  if not hasattr( eras, eraName ) : # Not valid, so print a helpful message
250  validOptions="" # Create a stringified list of valid options to print to the user
251  for key in eras.__dict__ :
252  if eras.internalUseEras.count(getattr(eras,key)) > 0 : continue # Don't tell the user about things they should leave alone
253  if isinstance( eras.__dict__[key], Modifier ) or isinstance( eras.__dict__[key], ModifierChain ) :
254  if validOptions!="" : validOptions+=", "
255  validOptions+="'"+key+"'"
256  raise Exception( "'%s' is not a valid option for '--era'. Valid options are %s." % (eraName, validOptions) )
257  # Warn the user if they are explicitly setting an era that should be
258  # set automatically by the ConfigBuilder.
259  for eraName in requestedEras : # Same loop, but had to make sure all the names existed first
260  if eras.internalUseEras.count(getattr(eras,eraName)) > 0 :
261  print "WARNING: You have explicitly set '"+eraName+"' with the '--era' command. That is usually reserved for internal use only."
262  # If the "--fast" option was supplied automatically enable the fastSim era
263  if options.fast :
264  if options.era:
265  options.era+=",fastSim"
266  else :
267  options.era="fastSim"
268 
269 
270  return options
271 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18