CMS 3D CMS Logo

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

Functions

def adaptOptions
 
def checkModifier
 
def checkOptions
 
def OptionsFromCommand
 
def OptionsFromCommandLine
 
def OptionsFromItems
 

Function Documentation

def cmsDriverOptions.adaptOptions ( )

Definition at line 22 of file cmsDriverOptions.py.

22 
23 def adaptOptions():
24  return
def cmsDriverOptions.checkModifier (   era)

Definition at line 15 of file cmsDriverOptions.py.

Referenced by OptionsFromItems().

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

Definition at line 19 of file cmsDriverOptions.py.

19 
20 def checkOptions():
21  return
def cmsDriverOptions.OptionsFromCommand (   command)

Definition at line 25 of file cmsDriverOptions.py.

Referenced by MatrixToProcess.MatrixToProcess.load().

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

Definition at line 35 of file cmsDriverOptions.py.

References OptionsFromItems().

Referenced by cmsDriver.run().

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

Definition at line 42 of file cmsDriverOptions.py.

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

Referenced by OptionsFromCommand(), and OptionsFromCommandLine().

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