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 (command)
 
def OptionsFromCommandLine ()
 
def OptionsFromItems (items)
 

Function Documentation

def cmsDriverOptions.adaptOptions ( )

Definition at line 18 of file cmsDriverOptions.py.

19  return
20 
def cmsDriverOptions.checkOptions ( )

Definition at line 15 of file cmsDriverOptions.py.

16  return
17 
def cmsDriverOptions.OptionsFromCommand (   command)

Definition at line 21 of file cmsDriverOptions.py.

Referenced by MatrixToProcess.MatrixToProcess.load().

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
30 
def OptionsFromItems(items)
def OptionsFromCommand(command)
def cmsDriverOptions.OptionsFromCommandLine ( )

Definition at line 31 of file cmsDriverOptions.py.

References OptionsFromItems().

Referenced by cmsDriver.run().

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
37 
def OptionsFromItems(items)
def cmsDriverOptions.OptionsFromItems (   items)

Definition at line 38 of file cmsDriverOptions.py.

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

Referenced by OptionsFromCommand(), and OptionsFromCommandLine().

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+" -> "+str(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  "NANO":"PAT",
105  "PATGEN":"GEN"}
106 
107  trimmedEvtType=options.evt_type.split('/')[-1]
108 
109  #get the list of steps, without their options
110  options.trimmedStep=[]
111  for s in options.step.split(','):
112  step=s.split(':')[0]
113  options.trimmedStep.append(step)
114  first_step=options.trimmedStep[0]
115 
116  #replace step aliases
117  # this does not affect options.trimmedStep which still contains 'NONE'
118  stepsAliases={
119  'NONE':'',
120  'ALL':'GEN,SIM,DIGI,L1,DIGI2RAW,HLT:GRun,RAW2DIGI,RECO,POSTRECO,VALIDATION,DQM',
121  'DATA_CHAIN':'RAW2DIGI,RECO,POSTRECO,DQM'
122  }
123  if options.step in stepsAliases:
124  options.step=stepsAliases[options.step]
125 
126  options.step = options.step.replace("SIM_CHAIN","GEN,SIM,DIGI,L1,DIGI2RAW")
127 
128  # add on the end of job sequence...
129  addEndJob = True
130  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 == "":
131  addEndJob = False
132  if ("SKIM" in options.step and not "RECO" in options.step):
133  addEndJob = False
134  if ("ENDJOB" in options.step):
135  addEndJob = False
136  if ('DQMIO' in options.datatier):
137  addEndJob = False
138  if addEndJob:
139  options.step=options.step+',ENDJOB'
140 
141 
142  #determine the type of file on input
143  if options.filetype==defaultOptions.filetype:
144  if options.filein.lower().endswith(".lhe") or options.filein.lower().endswith(".lhef") or options.filein.startswith("lhe:"):
145  options.filetype="LHE"
146  elif options.filein.startswith("mcdb:"):
147  print "This is a deprecated way of selecting lhe files from article number. Please use lhe:article argument to --filein"
148  options.filein=options.filein.replace('mcdb:','lhe:')
149  options.filetype="LHE"
150  else:
151  options.filetype="EDM"
152 
153  filesuffix = {"LHE": "lhe", "EDM": "root", "MCDB": "", "DQM":"root"}[options.filetype]
154 
155  if options.filein=="" and not (first_step in ("ALL","GEN","LHE","SIM_CHAIN")):
156  options.dirin="file:"+options.dirin.replace('file:','')
157  options.filein=trimmedEvtType+"_"+prec_step[first_step]+"."+filesuffix
158 
159 
160  # Prepare the canonical file name for output / config file etc
161  # (EventType_STEP1_STEP2_..._PU)
162  standardFileName = ""
163  standardFileName = trimmedEvtType+"_"+"_".join(options.trimmedStep)
164  standardFileName = standardFileName.replace(",","_").replace(".","_")
165  if options.pileup != "NoPileUp":
166  standardFileName += "_PU"
167 
168 
169  # if no output file name given, set it to default
170  if options.fileout=="" and not first_step in ("HARVESTING", "ALCAHARVEST"):
171  options.fileout = standardFileName+".root"
172 
173  # Prepare the name of the config file
174  if not options.python_filename:
175  options.python_filename = standardFileName+'.py'
176 
177  print options.step
178 
179 
180  # Setting name of process
181  # if not set explicitly it needs some thinking
182  if not options.name:
183  if 'reSIM' in options.trimmedStep:
184  options.name = 'RESIM'
185  elif 'reDIGI' in options.trimmedStep:
186  options.name = 'REDIGI'
187  elif 'HLT' in options.trimmedStep:
188  options.name = 'HLT'
189  elif 'RECO' in options.trimmedStep:
190  options.name = 'RECO'
191  elif options.trimmedStep == ['NONE'] and options.filetype in ('LHE', 'MCDB'):
192  options.name = 'LHE'
193  elif len(options.trimmedStep)==0:
194  options.name = 'PROCESS'
195  else:
196  options.name = options.trimmedStep[-1]
197 
198  # check to be sure that people run the harvesting as a separate step
199  isHarvesting = False
200  isOther = False
201 
202  if "HARVESTING" in options.trimmedStep and len(options.trimmedStep) > 1:
203  raise Exception("The Harvesting step must be run alone")
204 
205  # if not specified by user try to guess whether MC or DATA
206  if not options.isData and not options.isMC:
207  if 'SIM' in options.trimmedStep:
208  options.isMC=True
209  if 'CFWRITER' in options.trimmedStep:
210  options.isMC=True
211  if 'DIGI' in options.trimmedStep:
212  options.isMC=True
213  if 'DIGI2RAW' in options.trimmedStep:
214  options.isMC=True
215  if (not (options.eventcontent == None)) and 'SIM' in options.eventcontent:
216  options.isMC=True
217  if 'SIM' in options.datatier:
218  options.isMC=True
219  if options.isMC:
220  print 'We have determined that this is simulation (if not, rerun cmsDriver.py with --data)'
221  else:
222  print 'We have determined that this is real data (if not, rerun cmsDriver.py with --mc)'
223 
224  if options.profile:
225  if options.profile and options.prefix:
226  raise Exception("--profile and --prefix are incompatible")
227  profilerType = 'pp'
228  profileOpts = options.profile.split(':')
229  if len(profileOpts):
230  profilerType = profileOpts[0].replace("=", " ")
231 
232  if profilerType == "pp":
233  options.profileTypeLabel = "performance"
234  elif profilerType == "mp":
235  options.profileTypeLabel = "memory"
236  elif profilerType.startswith("fp "):
237  options.profileTypeLabel = profilerType.replace("fp ", "")
238  else:
239  raise Exception("Not a valid profiler type %s. Alternatives are pp, mp, fp=<function>."%(profilerType))
240 
241  options.prefix = "igprof -t cmsRun -%s" % profilerType
242 
243  # If an "era" argument was supplied make sure it is one of the valid possibilities
244  if options.era :
245  from Configuration.StandardSequences.Eras import eras
246  from FWCore.ParameterSet.Config import Modifier, ModifierChain
247  # Split the string by commas to check individual eras
248  requestedEras = options.era.split(",")
249  # Check that the entry is a valid era
250  for eraName in requestedEras :
251  if not hasattr( eras, eraName ) : # Not valid, so print a helpful message
252  validOptions="" # Create a stringified list of valid options to print to the user
253  for key in eras.__dict__ :
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  # If the "--fast" option was supplied automatically enable the fastSim era
259  if options.fast :
260  if options.era:
261  options.era+=",fastSim"
262  else :
263  options.era="fastSim"
264 
265  # options incompatible with fastsim
266  if options.fast and not options.scenario == "pp":
267  raise Exception("ERROR: the --option fast is only compatible with the default scenario (--scenario=pp)")
268  if options.fast and 'HLT' in options.trimmedStep:
269  raise Exception("ERROR: the --option fast is incompatible with HLT (HLT is no longer available in FastSim)")
270 
271  return options
272 
273 
def OptionsFromItems(items)
def replace(string, replacements)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18