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

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

Definition at line 14 of file cmsDriverOptions.py.

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

Definition at line 20 of file cmsDriverOptions.py.

Referenced by MatrixToProcess.MatrixToProcess.load().

20 
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
def cmsDriverOptions.OptionsFromCommandLine ( )

Definition at line 30 of file cmsDriverOptions.py.

References OptionsFromItems().

Referenced by cmsDriver.run().

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

Definition at line 37 of file cmsDriverOptions.py.

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

Referenced by OptionsFromCommand(), and OptionsFromCommandLine().

37 
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+" -> "+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  "reDIGI":"DIGI",
89  "L1REPACK":"RAW",
90  "HLT":"RAW",
91  "RECO":"DIGI",
92  "ALCA":"RECO",
93  "ANA":"RECO",
94  "SKIM":"RECO",
95  "DIGI2RAW":"DIGI",
96  "RAW2DIGI":"DIGI2RAW",
97  "RAW2RECO":"DIGI2RAW",
98  "DATAMIX":"DIGI",
99  "DIGI2RAW":"DATAMIX",
100  "HARVESTING":"RECO",
101  "ALCAHARVEST":"RECO"}
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 ('DQMROOT' 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 'SIM' in options.trimmedStep:
204  options.isMC=True
205  if 'CFWRITER' in options.trimmedStep:
206  options.isMC=True
207  if 'DIGI' in options.trimmedStep:
208  options.isMC=True
209  if 'DIGI2RAW' in options.trimmedStep:
210  options.isMC=True
211  if (not (options.eventcontent == None)) and 'SIM' in options.eventcontent:
212  options.isMC=True
213  if 'SIM' in options.datatier:
214  options.isMC=True
215  if options.isMC:
216  print 'We have determined that this is simulation (if not, rerun cmsDriver.py with --data)'
217  else:
218  print 'We have determined that this is real data (if not, rerun cmsDriver.py with --mc)'
219 
220  if options.profile:
221  if options.profile and options.prefix:
222  raise Exception("--profile and --prefix are incompatible")
223  profilerType = 'pp'
224  profileOpts = options.profile.split(':')
225  if len(profileOpts):
226  profilerType = profileOpts[0].replace("=", " ")
227 
228  if profilerType == "pp":
229  options.profileTypeLabel = "performance"
230  elif profilerType == "mp":
231  options.profileTypeLabel = "memory"
232  elif profilerType.startswith("fp "):
233  options.profileTypeLabel = profilerType.replace("fp ", "")
234  else:
235  raise Exception("Not a valid profiler type %s. Alternatives are pp, mp, fp=<function>."%(profilerType))
236 
237  options.prefix = "igprof -t cmsRun -%s" % profilerType
238 
239  return options
240 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18