00038 :
00039 import sys
00040 from Configuration.Applications.Options import parser,threeValued
00041
00042 for (index,item) in enumerate(items):
00043 for (opt,value) in threeValued:
00044 if (str(item) in opt) and (index==len(items)-1 or items[index+1].startswith('-')):
00045 items.insert(index+1,value)
00046
00047 (options,args) = parser.parse_args(items)
00048
00049 if not options.conditions or options.conditions=="help":
00050 from Configuration.AlCa import autoCond
00051 possible=""
00052 for k in autoCond.autoCond:
00053 possible+="\nauto:"+k+" -> "+autoCond.autoCond[k]
00054 raise Exception("the --conditions option is mandatory. Possibilities are: "+possible)
00055
00056
00057
00058
00059
00060
00061
00062 if options.triggerResultsProcess == None and "ALCAOUTPUT" in options.step:
00063 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"
00064 sys.exit(1)
00065
00066 if not options.evt_type:
00067 options.evt_type=sys.argv[1]
00068
00069
00070
00071
00072 if options.dirin!='' and (not options.dirin.endswith('/')): options.dirin+='/'
00073 if options.dirout!='' and (not options.dirout.endswith('/')): options.dirout+='/'
00074
00075
00076
00077
00078 prec_step = {"NONE":"",
00079 "FILTER":"",
00080 "ALL":"",
00081 "LHE":"",
00082 "GEN":"",
00083 "reGEN":"",
00084 "SIM":"GEN",
00085 "reSIM":"SIM",
00086 "DIGI":"SIM",
00087 "reDIGI":"DIGI",
00088 "L1REPACK":"RAW",
00089 "HLT":"RAW",
00090 "RECO":"DIGI",
00091 "ALCA":"RECO",
00092 "ANA":"RECO",
00093 "SKIM":"RECO",
00094 "DIGI2RAW":"DIGI",
00095 "RAW2DIGI":"DIGI2RAW",
00096 "RAW2RECO":"DIGI2RAW",
00097 "DATAMIX":"DIGI",
00098 "DIGI2RAW":"DATAMIX",
00099 "HARVESTING":"RECO",
00100 "ALCAHARVEST":"RECO"}
00101
00102 trimmedEvtType=options.evt_type.split('/')[-1]
00103
00104
00105 options.trimmedStep=[]
00106 for s in options.step.split(','):
00107 step=s.split(':')[0]
00108 options.trimmedStep.append(step)
00109 first_step=options.trimmedStep[0]
00110
00111
00112
00113 stepsAliases={
00114 'NONE':'',
00115 'ALL':'GEN,SIM,DIGI,L1,DIGI2RAW,HLT:GRun,RAW2DIGI,RECO,POSTRECO,VALIDATION,DQM',
00116 'DATA_CHAIN':'RAW2DIGI,RECO,POSTRECO,DQM'
00117 }
00118 if options.step in stepsAliases:
00119 options.step=stepsAliases[options.step]
00120
00121 options.step = options.step.replace("SIM_CHAIN","GEN,SIM,DIGI,L1,DIGI2RAW")
00122
00123
00124 addEndJob = True
00125 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 == "":
00126 addEndJob = False
00127 if ("SKIM" in options.step and not "RECO" in options.step):
00128 addEndJob = False
00129 if ("ENDJOB" in options.step):
00130 addEndJob = False
00131 if ('DQMROOT' in options.datatier):
00132 addEndJob = False
00133 if addEndJob:
00134 options.step=options.step+',ENDJOB'
00135
00136
00137
00138 if options.filetype==defaultOptions.filetype:
00139 if options.filein.lower().endswith(".lhe") or options.filein.lower().endswith(".lhef") or options.filein.startswith("lhe:"):
00140 options.filetype="LHE"
00141 elif options.filein.startswith("mcdb:"):
00142 print "This is a deprecated way of selecting lhe files from article number. Please use lhe:article argument to --filein"
00143 options.filein=options.filein.replace('mcdb:','lhe:')
00144 options.filetype="LHE"
00145 else:
00146 options.filetype="EDM"
00147
00148 filesuffix = {"LHE": "lhe", "EDM": "root", "MCDB": "", "DQM":"root"}[options.filetype]
00149
00150 if options.filein=="" and not (first_step in ("ALL","GEN","LHE","SIM_CHAIN")):
00151 options.dirin="file:"+options.dirin.replace('file:','')
00152 options.filein=trimmedEvtType+"_"+prec_step[first_step]+"."+filesuffix
00153
00154
00155
00156
00157 standardFileName = ""
00158 standardFileName = trimmedEvtType+"_"+"_".join(options.trimmedStep)
00159 standardFileName = standardFileName.replace(",","_").replace(".","_")
00160 if options.pileup != "NoPileUp":
00161 standardFileName += "_PU"
00162
00163
00164
00165 if options.fileout=="" and not first_step in ("HARVESTING", "ALCAHARVEST"):
00166 options.fileout = standardFileName+".root"
00167
00168
00169 if not options.python_filename:
00170 options.python_filename = standardFileName+'.py'
00171
00172 print options.step
00173
00174
00175
00176
00177 if not options.name:
00178 if 'reSIM' in options.trimmedStep:
00179 options.name = 'RESIM'
00180 elif 'reDIGI' in options.trimmedStep:
00181 options.name = 'REDIGI'
00182 elif 'HLT' in options.trimmedStep:
00183 options.name = 'HLT'
00184 elif 'RECO' in options.trimmedStep:
00185 options.name = 'RECO'
00186 elif options.trimmedStep == ['NONE'] and options.filetype in ('LHE', 'MCDB'):
00187 options.name = 'LHE'
00188 elif len(options.trimmedStep)==0:
00189 options.name = 'PROCESS'
00190 else:
00191 options.name = options.trimmedStep[-1]
00192
00193
00194 isHarvesting = False
00195 isOther = False
00196
00197 if "HARVESTING" in options.trimmedStep and len(options.trimmedStep) > 1:
00198 raise Exception("The Harvesting step must be run alone")
00199
00200
00201 if not options.isData and not options.isMC:
00202 if 'SIM' in options.trimmedStep:
00203 options.isMC=True
00204 if 'CFWRITER' in options.trimmedStep:
00205 options.isMC=True
00206 if 'DIGI' in options.trimmedStep:
00207 options.isMC=True
00208 if (not (options.eventcontent == None)) and 'SIM' in options.eventcontent:
00209 options.isMC=True
00210 if 'SIM' in options.datatier:
00211 options.isMC=True
00212 if options.isMC:
00213 print 'We have determined that this is simulation (if not, rerun cmsDriver.py with --data)'
00214 else:
00215 print 'We have determined that this is real data (if not, rerun cmsDriver.py with --mc)'
00216
00217 if options.profile:
00218 if options.profile and options.prefix:
00219 raise Exception("--profile and --prefix are incompatible")
00220 profilerType = 'pp'
00221 profileOpts = options.profile.split(':')
00222 if len(profileOpts):
00223 profilerType = profileOpts[0].replace("=", " ")
00224
00225 if profilerType == "pp":
00226 options.profileTypeLabel = "performance"
00227 elif profilerType == "mp":
00228 options.profileTypeLabel = "memory"
00229 elif profilerType.startswith("fp "):
00230 options.profileTypeLabel = profilerType.replace("fp ", "")
00231 else:
00232 raise Exception("Not a valid profiler type %s. Alternatives are pp, mp, fp=<function>."%(profilerType))
00233
00234 options.prefix = "igprof -t cmsRun -%s" % profilerType
00235
00236 return options
00237