test
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 18 of file cmsDriverOptions.py.

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

Definition at line 15 of file cmsDriverOptions.py.

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

Definition at line 21 of file cmsDriverOptions.py.

Referenced by MatrixToProcess.MatrixToProcess.load().

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

Definition at line 31 of file cmsDriverOptions.py.

References OptionsFromItems().

Referenced by cmsDriver.run().

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

Definition at line 38 of file cmsDriverOptions.py.

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

Referenced by OptionsFromCommand(), and OptionsFromCommandLine().

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