00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 import sys, os, re, operator
00025 import optparse as opt
00026 from cmsPerfCommons import Candles, CandDesc, FileName, KeywordToCfi, CustomiseFragment, CandFname, EventContents
00027
00028
00029
00030
00031 THIS_PROG_NAME = os.path.basename(sys.argv[0])
00032 cmsDriver = 'cmsDriver.py'
00033 hypreg = re.compile('-')
00034 debug = False
00035 DEF_STEPS = ['GEN,SIM', 'DIGI']
00036 AllSteps = ["GEN,SIM", "DIGI", "L1", "DIGI2RAW", "HLT", "RAW2DIGI","RECO"]
00037 AfterPileUpSteps=[]
00038
00039
00040
00041
00042
00043 Profiler = {
00044 'TimingReport' : 'Timing_Parser',
00045 'TimingReport @@@ reuse' : 'Timing_Parser',
00046 'TimeReport' : 'Timereport_Parser',
00047 'TimeReport @@@ reuse' : 'Timereport_Parser',
00048 'SimpleMemReport' : 'SimpleMem_Parser',
00049 'EdmSize' : 'Edm_Size',
00050 'IgProfperf' : 'IgProf_perf.PERF_TICKS',
00051 'IgProfMemTotal' : 'IgProf_mem.MEM_TOTAL',
00052 'IgProfMemTotal @@@ reuse': 'IgProf_mem.MEM_TOTAL',
00053 'IgProfMemLive' : 'IgProf_mem.MEM_LIVE',
00054 'IgProfMemLive @@@ reuse' : 'IgProf_mem.MEM_LIVE',
00055 'IgProfMemAnalyse' : 'IgProf_mem.ANALYSE',
00056 'valgrind' : 'ValgrindFCE',
00057 'memcheck_valgrind' : 'Memcheck_Valgrind',
00058 'None' : 'None',
00059 }
00060
00061
00062
00063 def getFstOccur(item, list):
00064 return filter(item.__eq__,list)[0]
00065
00066 def getLstIndex(item, list):
00067 lenlist = len(list)
00068 for x in range(lenlist - 1,0,-1):
00069 if list[x] == item:
00070 return x
00071
00072 def checkSteps(steps):
00073 idx = -2
00074 lstidx = -2
00075 for step in steps:
00076 astep = step
00077 split = []
00078 if "-" in step:
00079 split = astep.split("-")
00080 astep = split[0]
00081 idx = AllSteps.index(astep)
00082 if not ( idx == -2 ):
00083 if lstidx > idx:
00084 print "ERROR: Your user defined steps are not in a valid order"
00085 sys.exit()
00086 lstidx = idx
00087 if "-" in step:
00088 lstidx = AllSteps.index(split[1])
00089
00090
00091 def getSteps(userSteps):
00092
00093
00094 gsreg = re.compile('GEN-SIM')
00095 greg = re.compile('GEN')
00096 StepsTokens = userSteps.split(",")
00097 steps = []
00098 for astep in StepsTokens:
00099
00100
00101
00102
00103 if gsreg.search(astep):
00104 astep = gsreg.sub(r"GEN,SIM", astep)
00105 elif greg.search(astep):
00106 astep = greg.sub(r"GEN,SIM", astep)
00107
00108 print astep
00109
00110
00111 steps.append(astep)
00112
00113
00114 checkSteps(steps)
00115 return steps
00116
00117 def optionparse():
00118 global _noprof
00119 explanations = map(lambda x: " " + x, Candles)
00120 explanation = ""
00121 for x in range(len(explanations)):
00122 explanation += "%-*s %s\n" % (30, explanations[x],CandDesc[x])
00123 parser = opt.OptionParser(usage=("""%s NUM_EVENTS_PER_CFG CANDLES PROFILE [--cmsdriver=cmsDriverOptions] [--usersteps=processingStepsOption]
00124
00125 Description - This program creates a configuration file for cmsRelvalreport.py that describes the order in which cmsDriver.py should be run with which candles, steps and profiling so that time spent running cmsDriver.py is minimised. Without this correct ordering we would have to re-run parts of the profiling steps.
00126
00127 Arguments:
00128 NUM_EVENTS_PER_CFG - The number of events per config file
00129
00130 CANDLES - The simulation type to perform profiling on
00131 Candles Description
00132 AllCandles Run all of the candles below
00133 %s
00134
00135 PROFILE - the type of profiling to perform (multiple codes can be used):
00136 Code Profile Type
00137 0 TimingReport
00138 1 TimeReport
00139 2 SimpleMemoryCheck
00140 3 EdmSize
00141 4 IgProfPerf
00142 5 IgProfMemTotal
00143 6 IgProfMemLive
00144 7 IgProfAnalyse
00145 8 ValgrindFCE
00146 9 ValgrindMemCheck
00147
00148 Examples:
00149 Perform Timing Report profiling for all candles and 10 events per cfg.
00150 ./%s 10 AllCandles 1
00151 Perform Timing Report, Time Report and SimpleMemoryCheck profiling for Higgs boson and 50 events.
00152 ./%s 50 \"HZZLLLL\" 012
00153 Perform IgProfPerf and IgProfMemTotal profiling for TTbar and 100 events.
00154 ./%s 100 \"TTBAR\" 45 --cmsdriver=\"--conditions FakeConditions\"
00155 Perform ValgrindFCE ValgrindMemCheck profiling for Minimum bias and 100 events. Only on gensim and digi steps.
00156 ./%s 100 \"MINBIAS\" 89 --cmsdriver=\"--conditions FakeConditions\" \"--usersteps=GEN-SIM,DIGI"""
00157 % ( THIS_PROG_NAME, explanation, THIS_PROG_NAME,THIS_PROG_NAME,THIS_PROG_NAME,THIS_PROG_NAME)))
00158
00159 devel = opt.OptionGroup(parser, "Developer Options",
00160 "Caution: use these options at your own risk."
00161 "It is believed that some of them bite.\n")
00162
00163
00164 parser.add_option(
00165 '-b',
00166 '--bypass-hlt',
00167 action="store_true",
00168 dest='bypasshlt',
00169 default=False,
00170 help='Should we bypass using the HLT root file?'
00171 )
00172
00173 parser.add_option(
00174 '-u',
00175 '--usersteps',
00176 type='string',
00177 dest='userSteps',
00178 help='Which steps to run',
00179 metavar='<STEPS>',
00180 )
00181 parser.add_option(
00182 '-c',
00183 '--cmsdriver',
00184 type='string',
00185 dest='cmsDriverOptions',
00186 help='Option for cmsDriver.py can be specified as a string to be added to all cmsDriver.py commands',
00187 metavar='<CONDITION>',
00188 )
00189
00190 devel.add_option(
00191 '-1',
00192 '--no-profile',
00193 action="store_true",
00194 dest='noprof',
00195 help='Do not perform profiling, ever',
00196
00197 )
00198
00199 devel.add_option(
00200 '-d',
00201 '--debug',
00202 action="store_true",
00203 dest='debug',
00204 help='Show debug output',
00205
00206 )
00207
00208 parser.set_defaults(debug=False,noprof=False)
00209 parser.add_option_group(devel)
00210
00211 (options, args) = parser.parse_args()
00212
00213
00214 _noprof = options.noprof
00215 debug = options.debug
00216 numofargs = len(args)
00217
00218 if ((not numofargs == 3) and (not _noprof)) or (_noprof and not (numofargs == 2)):
00219 parser.error("There are not enough arguments specified to run this program."
00220 " Please determine the correct arguments from the usage information above."
00221 " Run with --help option for more information.")
00222 sys.exit()
00223
00224 return (options, args)
00225
00226 def expandHyphens(step):
00227 newsteps = []
00228
00229 if "-" in step:
00230 hypsteps = step.split(r"-")
00231 if not (len(hypsteps) == 2):
00232 print "ERROR: Could not parse usersteps. You have too many hypens between commas"
00233 sys.exit()
00234 elif not (hypsteps[0] in AllSteps and hypsteps[1] in AllSteps):
00235 print "ERROR: One of the steps you defined is invalid"
00236 sys.exit()
00237 else:
00238 if (hypsteps[0] == hypsteps[1]):
00239 print "WARNING: You should not add a hypenated step that as the same source and destination step, ignoring"
00240 newsteps.append(hypsteps[0])
00241 else:
00242 newsteps.append(hypsteps[0])
00243 srt = AllSteps.index(hypsteps[0]) + 1
00244 for n in range(srt,len(AllSteps) - 1,1):
00245 astep = AllSteps[n]
00246 if astep == hypsteps[1]:
00247 break
00248 else:
00249 newsteps.append(astep)
00250 newsteps.append(hypsteps[1])
00251 else:
00252 if not (step in AllSteps):
00253 print "ERROR: One of the steps you defined is invalid"
00254 sys.exit()
00255 else:
00256 newsteps.append(step)
00257
00258 return newsteps
00259
00260 def setupProgramParameters(options,args):
00261 steps = []
00262 cmsDriverOptions = ""
00263 global AfterPileUpSteps
00264 NumberOfEvents = int(args[0])
00265 WhichCandles = str(args[1])
00266 ProfileCode = ""
00267 if not _noprof:
00268 ProfileCode = str(args[2])
00269
00270 if options.cmsDriverOptions:
00271
00272 cmsDriverOptions = options.cmsDriverOptions
00273 print 'Using user-specified cmsDriver.py options: ' + cmsDriverOptions
00274
00275 if options.userSteps:
00276
00277 userSteps = options.userSteps
00278 steps = getSteps(userSteps)
00279
00280 if WhichCandles.lower() == 'allcandles':
00281 Candle = Candles
00282 print 'ALL standard simulation candles will be PROCESSED:'
00283 else:
00284 Candle = [WhichCandles]
00285 print 'ONLY %s will be PROCESSED' % Candle[0]
00286
00287
00288
00289
00290 if not steps:
00291 print 'The default steps will be run:'
00292 steps = DEF_STEPS
00293 else:
00294 print "You defined your own steps to run:"
00295
00296 for astep in steps:
00297 print astep
00298
00299 return (NumberOfEvents, ProfileCode, cmsDriverOptions, steps, Candle, options.bypasshlt)
00300
00301 def init_vars():
00302
00303
00304
00305
00306
00307 try:
00308 CMSSW_BASE = os.environ['CMSSW_BASE']
00309 CMSSW_RELEASE_BASE = os.environ['CMSSW_RELEASE_BASE']
00310 CMSSW_VERSION = os.environ['CMSSW_VERSION']
00311 except KeyError:
00312 print 'Error: An environment variable either CMSSW_{BASE, RELEASE_BASE or VERSION} is not available.'
00313 print ' Please run eval `scramv1 runtime -csh` to set your environment variables'
00314 sys.exit()
00315
00316 return ( CMSSW_BASE,
00317 CMSSW_RELEASE_BASE,
00318 CMSSW_VERSION)
00319
00320 def writeReportFileHeader(CMSSW_VERSION,CMSSW_RELEASE_BASE,CMSSW_BASE):
00321
00322 SimCandlesFile = 'SimulationCandles_%s.txt' % CMSSW_VERSION
00323
00324 try:
00325 simcandles = open(SimCandlesFile, 'w')
00326 except IOError:
00327 print "Couldn't open %s to save" % SimCandlesFile
00328
00329 simcandles.write('#Candles file automatically generated by %s for %s\n'
00330 % (THIS_PROG_NAME, CMSSW_VERSION))
00331 simcandles.write("#CMSSW Base : %s\n" % CMSSW_BASE)
00332 simcandles.write("#Release Base: %s\n" % CMSSW_RELEASE_BASE)
00333 simcandles.write("#Version : %s\n\n" % CMSSW_VERSION)
00334
00335 return simcandles
00336
00337 def getProfileArray(ProfileCode):
00338
00339 Profile = []
00340
00341
00342
00343 AllowedProfile = [
00344 'TimingReport',
00345 'TimeReport',
00346 'SimpleMemReport',
00347 'EdmSize',
00348 'IgProfperf',
00349 'IgProfMemTotal',
00350 'IgProfMemLive',
00351 'IgProfMemAnalyse',
00352 'valgrind',
00353 'memcheck_valgrind',
00354 'None',
00355 ]
00356
00357 if _noprof:
00358 Profile.append(AllowedProfile[-1])
00359 else:
00360 for i in range(10):
00361 if str(i) in ProfileCode:
00362 firstCase = i == 0 and (str(1) in ProfileCode or str(2) in ProfileCode) or i == 1 and str(2) in ProfileCode
00363 secCase = i == 5 and (str(6) in ProfileCode or str(7) in ProfileCode) or i == 6 and str(7) in ProfileCode
00364
00365 if firstCase or secCase:
00366 Profile.append(AllowedProfile[i] + ' @@@ reuse')
00367 else:
00368 Profile.append(AllowedProfile[i])
00369
00370 return Profile
00371
00372 def writeStepHead(simcandles,acandle,step):
00373 simcandles.write('#%s\n' % FileName[acandle])
00374 simcandles.write('#Step %s\n' % step)
00375 print step
00376
00377
00378 def determineNewProfile(step,Profile,SavedProfile):
00379 if 'DIGI2RAW' in step:
00380 SavedProfile = Profile
00381 Profile = [ ]
00382 if 'HLT' in step:
00383 Profile = SavedProfile
00384
00385 return (Profile, SavedProfile)
00386
00387 def pythonFragment(step,cmsdriverOptions):
00388
00389
00390
00391
00392
00393
00394
00395
00396 if "--pileup" in cmsdriverOptions:
00397 return CustomiseFragment['DIGI-PILEUP']
00398 elif CustomiseFragment.has_key(step):
00399 return CustomiseFragment[step]
00400 else:
00401
00402
00403 return CustomiseFragment['DIGI']
00404
00405
00406 def setInputFile(steps,step,acandle,stepIndex,pileup=False,bypasshlt=False):
00407
00408 InputFileOption = ""
00409 if pileup and stepIndex == 0:
00410 InputFileOption = "--filein file:%s_%s" % ( FileName[acandle],"DIGI" )
00411 else:
00412 InputFileOption = "--filein file:%s_%s" % ( FileName[acandle],steps[stepIndex - 1] )
00413
00414 if pileup:
00415 pass
00416 else :
00417 if 'GEN,SIM' in step:
00418 InputFileOption = ''
00419 elif 'HLT' in steps[stepIndex - 1] and bypasshlt:
00420
00421
00422
00423
00424 InputFileOption = "--filein file:%s_%s" % ( FileName[acandle],steps[stepIndex - 2] )
00425
00426 if not InputFileOption == "" :
00427 InputFileOption += ".root "
00428
00429 return InputFileOption
00430
00431 def writeUnprofiledSteps(simcandles,CustomisePythonFragment,cmsDriverOptions,unprofiledSteps,previousOutputFile,acandle,NumberOfEvents, stepIndex, pileup,bypasshlt):
00432
00433
00434
00435
00436
00437
00438
00439 if bypasshlt and unprofiledSteps[-1]=="HLT":
00440 stepsStr = ",".join(unprofiledSteps[:-1])
00441 OutputFile = "%s_%s.root" % ( FileName[acandle],unprofiledSteps[-2])
00442 else:
00443 stepsStr = ",".join(unprofiledSteps)
00444 OutputFile = "%s_%s.root" % ( FileName[acandle],unprofiledSteps[-1])
00445 simcandles.write("\n#Run a %s step(s) that has not been selected for profiling but is needed to run the next step to be profiled\n" % (stepsStr))
00446 OutputFileOption = "--fileout=%s" % OutputFile
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458 InputFileOption = "--filein file:" + previousOutputFile
00459 if previousOutputFile =="":
00460 InputFileOption = setInputFile(AllSteps,unprofiledSteps[0],acandle,stepIndex,pileup=pileup,bypasshlt=bypasshlt)
00461
00462
00463
00464 for eventcontent in EventContents:
00465 cmsDriverOptions=re.sub(eventcontent,'FEVTDEBUGHLT',cmsDriverOptions)
00466 Command = ("%s %s -n %s --step=%s %s %s --customise=%s %s"
00467 % (cmsDriver,
00468 KeywordToCfi[acandle],
00469 NumberOfEvents,
00470 stepsStr,
00471 InputFileOption,
00472 OutputFileOption,
00473 CustomisePythonFragment,
00474 cmsDriverOptions) )
00475 simcandles.write( "%s @@@ None @@@ None\n\n" % (Command))
00476 return OutputFile
00477
00478 def writePrerequisteSteps(simcandles,steps,acandle,NumberOfEvents,cmsDriverOptions,pileup,bypasshlt):
00479 fstIdx = -1
00480 if "-" in steps[0]:
00481 fstIdx = AllSteps.index(steps[0].split("-")[0])
00482 else:
00483 fstIdx = AllSteps.index(steps[0])
00484 CustomisePythonFragment = pythonFragment("GEN,SIM",cmsDriverOptions)
00485 previousOutputFile=""
00486 OutputFile = writeUnprofiledSteps(simcandles, CustomisePythonFragment, cmsDriverOptions,AllSteps[0:fstIdx],previousOutputFile,acandle,NumberOfEvents, 0,pileup,bypasshlt)
00487 return (fstIdx, OutputFile)
00488
00489 def setOutputFileOption(acandle,endstep):
00490 return "%s_%s.root" % ( FileName[acandle],endstep)
00491
00492 def writeCommands(simcandles,
00493 Profile,
00494 acandle,
00495 steps,
00496 NumberOfEvents,
00497 cmsDriverOptions,
00498 bypasshlt,
00499 stepIndex = 0,
00500 pileup = False):
00501
00502 OutputStep = ""
00503
00504 stopIndex = len(steps)
00505 start = 0
00506
00507 userSteps = steps
00508 SavedProfile = []
00509 fstROOTfile = True
00510 fstROOTfileStr = ""
00511
00512
00513 print "Steps passed to writeCommands %s",steps
00514 if not (steps[0] == AllSteps[0]) and (steps[0].split("-")[0] != "GEN,SIM"):
00515
00516 (stepIndex, rootFileStr) = writePrerequisteSteps(simcandles,steps,acandle,NumberOfEvents,cmsDriverOptions,pileup,bypasshlt)
00517
00518
00519 if fstROOTfile:
00520 fstROOTfileStr = rootFileStr
00521 fstROOTfile = False
00522 start = -1
00523 if "-" in steps[0]:
00524 start = AllSteps.index(steps[0].split("-")[0])
00525 else:
00526 start = AllSteps.index(steps[0])
00527 lst = - 1
00528 if "-" in steps[-1]:
00529 lst = AllSteps.index(steps[-1].split("-")[1])
00530 else:
00531 lst = AllSteps.index(steps[-1])
00532 runSteps = AllSteps[start:lst]
00533 numOfSteps = (lst - start) + 1
00534 stopIndex = start + numOfSteps
00535
00536
00537 else:
00538
00539 if "-" in steps[-1]:
00540
00541 stopIndex = AllSteps.index(steps[-1].split("-")[1]) + 1
00542 else:
00543 stopIndex = AllSteps.index(steps[-1]) + 1
00544
00545 steps = AllSteps
00546
00547 unprofiledSteps = []
00548 rawreg = re.compile("^RAW2DIGI")
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610 prevPrevOutputFile = ""
00611 previousOutputFile = ""
00612
00613 for x in range(start,stopIndex,1):
00614 if stepIndex >= stopIndex:
00615 break
00616 step = steps[stepIndex]
00617
00618
00619 befStep = step
00620 aftStep = step
00621
00622 stepToWrite = step
00623
00624 CustomisePythonFragment = pythonFragment(step,cmsDriverOptions)
00625 oneShotProf = False
00626 hypsteps = []
00627
00628
00629 if step in userSteps or reduce(lambda x,y : x or y,map(lambda x: step == x.split("-")[0],userSteps)):
00630
00631
00632 hypMatch = filter(lambda x: "-" in x,filter(lambda x: step == x.split("-")[0],userSteps))
00633 if not len(hypMatch) == 0 :
00634 hypsteps = expandHyphens(hypMatch[0])
00635 stepToWrite = ",".join(hypsteps)
00636 befStep = hypsteps[0]
00637
00638 if bypasshlt and hypsteps[-1]=='HLT':
00639 aftStep = hypsteps[-2]
00640 else:
00641 aftStep = hypsteps[-1]
00642 oneShotProf = True
00643
00644 writeStepHead(simcandles,acandle,stepToWrite)
00645
00646
00647 if '--pileup' in cmsDriverOptions:
00648 outfile = stepToWrite + "_PILEUP"
00649 else:
00650 outfile = stepToWrite
00651
00652 OutputFile = setOutputFileOption(acandle,outfile)
00653 if fstROOTfile:
00654 fstROOTfileStr = OutputFile
00655 fstROOTfile = False
00656 OutputFileOption = "--fileout=" + OutputFile
00657
00658 for prof in Profile:
00659
00660
00661
00662 if 'EdmSize' in prof:
00663 EdmFile = "%s_%s.root" % (FileName[acandle],outfile)
00664
00665 if prof == Profile[0] and not os.path.exists("./" + EdmFile):
00666
00667
00668
00669
00670
00671
00672 InputFileOption = "--filein file:" + previousOutputFile
00673
00674 if rawreg.search(step) and bypasshlt and 'DIGI2RAW.root' in prevPrevOutputFile:
00675 InputFileOption = "--filein file:" + prevPrevOutputFile
00676 if previousOutputFile == "":
00677 InputFileOption = setInputFile(steps,stepToWrite,acandle,stepIndex,pileup=pileup,bypasshlt=bypasshlt)
00678 Command = ("%s %s -n %s --step=%s %s %s --customise=%s %s"
00679 % (cmsDriver,
00680 KeywordToCfi[acandle],
00681 NumberOfEvents,
00682 stepToWrite,
00683 InputFileOption,
00684 OutputFileOption,
00685 CustomisePythonFragment,
00686 cmsDriverOptions) )
00687 simcandles.write( "%s @@@ None @@@ None\n" % (Command))
00688
00689 Command = EdmFile
00690
00691 else:
00692 InputFileOption = "--filein file:" + previousOutputFile
00693 if rawreg.search(step) and bypasshlt and 'DIGI2RAW.root' in prevPrevOutputFile:
00694 InputFileOption = "--filein file:" + prevPrevOutputFile
00695
00696 if previousOutputFile == "":
00697 InputFileOption = setInputFile(steps,befStep,acandle,stepIndex,pileup,bypasshlt)
00698
00699
00700
00701 if '--pileup' in cmsDriverOptions and ( stepToWrite=='GEN,SIM' or stepToWrite=='SIM'):
00702 Command = ("%s %s -n %s --step=%s %s %s --customise=%s %s" % (
00703 cmsDriver,
00704 KeywordToCfi[acandle],
00705 NumberOfEvents,
00706 stepToWrite,
00707 InputFileOption,
00708 OutputFileOption,
00709 CustomiseFragment['GEN,SIM'],
00710 cmsDriverOptions[:cmsDriverOptions.index('--pileup')]
00711 ))
00712 else:
00713 Command = ("%s %s -n %s --step=%s %s %s --customise=%s %s" % (
00714 cmsDriver,
00715 KeywordToCfi[acandle],
00716 NumberOfEvents,
00717 stepToWrite,
00718 InputFileOption,
00719 OutputFileOption,
00720 CustomisePythonFragment,
00721 cmsDriverOptions
00722 ))
00723
00724 if _noprof:
00725 simcandles.write("%s @@@ None @@@ None\n" % Command)
00726 else:
00727 stepLabel=stepToWrite
00728 if '--pileup' in cmsDriverOptions and not "_PILEUP" in stepToWrite:
00729 stepLabel = stepToWrite+"_PILEUP"
00730 simcandles.write("%s @@@ %s @@@ %s_%s_%s\n" % (Command,
00731 Profiler[prof],
00732 FileName[acandle],
00733 stepLabel,
00734 prof))
00735
00736 if debug:
00737 print InputFileOption, step, 'GEN,SIM' in step, 'HLT' in steps[stepIndex - 1], steps
00738 print "cmsDriveroptions : " + cmsDriverOption
00739 prevPrevOutputFile = previousOutputFile
00740 previousOutputFile = OutputFile
00741 else:
00742 unprofiledSteps.append(step)
00743 isNextStepForProfile = False
00744
00745 try:
00746 isNextStepForProfile = steps[stepIndex + 1] in userSteps or reduce(lambda x,y : x or y,map(lambda z: steps[ stepIndex + 1 ] == z.split("-")[0],userSteps))
00747 except IndexError:
00748
00749 print "Error: Something is wrong we shouldn't have come this far"
00750 break
00751
00752 if isNextStepForProfile:
00753
00754 OutputFile=writeUnprofiledSteps(simcandles,CustomisePythonFragment,cmsDriverOptions,unprofiledSteps,previousOutputFile,acandle,NumberOfEvents,stepIndex,pileup,bypasshlt)
00755 unprofiledSteps = []
00756 prevPrevOutputFile = previousOutputFile
00757 previousOutputFile = OutputFile
00758
00759 if oneShotProf:
00760 stepIndex += len(hypsteps)
00761 else:
00762 stepIndex +=1
00763 return fstROOTfileStr
00764
00765 def writeCommandsToReport(simcandles,Candle,Profile,debug,NumberOfEvents,cmsDriverOptions,steps,bypasshlt):
00766
00767 OutputStep = ''
00768
00769
00770
00771
00772
00773
00774 for acandle in Candle:
00775 print '*Candle ' + acandle
00776
00777
00778
00779
00780
00781
00782 fstoutfile = writeCommands(simcandles,
00783 Profile,
00784 acandle,
00785 steps,
00786 NumberOfEvents,
00787 cmsDriverOptions,
00788 bypasshlt)
00789
00790
00791 def main(argv=sys.argv):
00792
00793
00794
00795
00796
00797 (options, args) = optionparse()
00798
00799
00800
00801
00802
00803 (NumberOfEvents, ProfileCode, cmsDriverOptions, steps, Candle, bypasshlt ) = setupProgramParameters(options,args)
00804
00805
00806
00807
00808
00809 (CMSSW_BASE, CMSSW_RELEASE_BASE, CMSSW_VERSION ) = init_vars()
00810
00811
00812
00813
00814
00815 simcandles = writeReportFileHeader(CMSSW_VERSION,CMSSW_RELEASE_BASE,CMSSW_BASE)
00816
00817
00818
00819
00820
00821 Profile = getProfileArray(ProfileCode)
00822
00823
00824
00825
00826
00827 writeCommandsToReport(simcandles,Candle,Profile,debug,NumberOfEvents,cmsDriverOptions,steps,bypasshlt)
00828
00829 simcandles.close()
00830
00831 if __name__ == "__main__":
00832 main()