CMS 3D CMS Logo

Functions
cmsDriverOptions Namespace Reference

Functions

def adaptOptions ()
 
def checkModifier (era)
 
def checkOptions ()
 
def OptionsFromCommand (command)
 
def OptionsFromCommandLine ()
 
def OptionsFromItems (items)
 

Function Documentation

def cmsDriverOptions.adaptOptions ( )

Definition at line 22 of file cmsDriverOptions.py.

23  return
24 
def cmsDriverOptions.checkModifier (   era)

Definition at line 15 of file cmsDriverOptions.py.

Referenced by OptionsFromItems().

15 def checkModifier(era):
16  from FWCore.ParameterSet.Config import Modifier, ModifierChain
17  return isinstance( era, Modifier ) or isinstance( era, ModifierChain )
18 
def cmsDriverOptions.checkOptions ( )

Definition at line 19 of file cmsDriverOptions.py.

20  return
21 
def cmsDriverOptions.OptionsFromCommand (   command)

Definition at line 25 of file cmsDriverOptions.py.

Referenced by MatrixToProcess.MatrixToProcess.load().

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

Definition at line 35 of file cmsDriverOptions.py.

References OptionsFromItems().

Referenced by cmsDriver.run().

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

Definition at line 42 of file cmsDriverOptions.py.

References checkModifier(), join(), edm.print(), python.rootplot.root2matplotlib.replace(), and str.

Referenced by OptionsFromCommand(), and OptionsFromCommandLine().

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