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

◆ adaptOptions()

def cmsDriverOptions.adaptOptions ( )

Definition at line 21 of file cmsDriverOptions.py.

21 def adaptOptions():
22  return
23 

◆ checkModifier()

def cmsDriverOptions.checkModifier (   era)

Definition at line 14 of file cmsDriverOptions.py.

Referenced by OptionsFromItems().

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

◆ checkOptions()

def cmsDriverOptions.checkOptions ( )

Definition at line 18 of file cmsDriverOptions.py.

18 def checkOptions():
19  return
20 

◆ OptionsFromCommand()

def cmsDriverOptions.OptionsFromCommand (   command)

Definition at line 24 of file cmsDriverOptions.py.

Referenced by MatrixToProcess.MatrixToProcess.load().

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

◆ OptionsFromCommandLine()

def cmsDriverOptions.OptionsFromCommandLine ( )

Definition at line 34 of file cmsDriverOptions.py.

References OptionsFromItems().

Referenced by cmsDriver.run().

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

◆ OptionsFromItems()

def cmsDriverOptions.OptionsFromItems (   items)

Definition at line 41 of file cmsDriverOptions.py.

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

Referenced by OptionsFromCommandLine().

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