302 parser = argparse.ArgumentParser()
303 parser.add_argument(
"-d",
"--dir")
304 parser.add_argument(
"-t",
"--tmp")
305 parser.add_argument(
"-n",
"--npars",default=3)
306 parser.add_argument(
"-r",
"--ref")
307 parser.add_argument(
"-b",
"--batch",action=
'store_true')
308 parser.add_argument(
"-ns",
"--nosubmit", action=
'store_true')
309 parser.add_argument(
"-rc",
"--redo-configs", action=
'store_true')
310 parser.add_argument(
"-ntm",
"--ntestsmatrices",default=100)
311 parser.add_argument(
"-ntc",
"--ntestscomparisons",default=100)
312 parser.add_argument(
"--matrixStage",action=
'store_true')
313 parser.add_argument(
"--comparisonStage",action=
'store_true')
314 parser.add_argument(
"--investigateComb",default=
"",type=str)
315 parser.add_argument(
"--investigateSplits",default=
"",type=str)
316 args = parser.parse_args()
319 shareDir = os.getcwd()+
"/../../share/"+args.dir
320 nominalFile = shareDir+
"/"+args.ref
321 templateFile = shareDir+
"/"+args.tmp
323 if "/" in templateFile :
324 for item
in templateFile.split(
"/")[:-1] :
325 newFilesDir = newFilesDir+
"/"+item
329 print "sharedir",shareDir
330 print "nominal",nominalFile
331 print "template",templateFile
332 print "new configs will go in",newFilesDir
333 print "using",nPars,
"parameters, not counting eta intercalibration non-closure."
340 if args.redo_configs
and not args.investigateSplits :
341 start_time = time.time()
344 print(
"--- %s seconds ---" % (time.time() - start_time))
345 for comb
in fullCombList :
351 nConfigs = len([os.path.join(newFilesDir, f)
for f
in os.listdir(newFilesDir)
if "index" in f])
354 outRootDir = os.getcwd()+
"/NPRootFiles/"
355 outRootFormat = outRootDir+
"matrices_{0}.root"
356 if args.matrixStage
and not args.investigateSplits :
362 useval =
int(args.ntestsmatrices)
363 indicesToUse = random.sample(
xrange(0,nConfigs), useval)
364 for index
in indicesToUse :
367 config = templateFile.replace(
"template",
"index{0}".
format(index))
371 outRootName = outRootFormat.format(index)
373 outPlotName = os.getcwd()+
"/NPPlots/matrices_{0}.pdf".
format(index)
380 if args.comparisonStage
and not args.investigateSplits :
385 rootFiles = [os.path.join(outRootDir, f)
for f
in os.listdir(outRootDir)
if "matrices" in f]
386 indicesAvailable = []
387 for file
in rootFiles :
388 index = re.findall(
r'\d+', file.split(
"/")[-1].
split(
"_")[-1])
389 indicesAvailable.append(eval(index[0]))
394 if args.investigateComb :
395 goodComb = tuple([eval(item)
for item
in args.investigateComb.split(
",")])
397 for index
in range(4) :
398 for new
in random.sample(indicesAvailable,
max(1,
int(
float(args.ntestscomparisons)/4.0))) :
399 if not new
in goodComb :
400 newComb =
list(goodComb)
402 newList.append(tuple(newComb))
403 pool = tuple(newList)
409 random.shuffle(indicesAvailable)
410 if len(indicesAvailable) > 15 :
411 indicesAvailable = indicesAvailable[:15]
419 for indices
in random.sample(pool,
min(len(pool),args.ntestscomparisons)) :
420 print "Testing combination",indices
422 outFileName = os.getcwd()+
"/NPPlots/SR-4D-{0}-{1}-{2}-{3}.png".
format(indices[0],indices[1],indices[2],indices[3])
424 runComparisonCommands(outFileName,
"NONE",outRootFormat.format(indices[0]),outRootFormat.format(indices[1],outRootFormat.format(indices[2])),outRootFormat.format(indices[2]),outRootFormat.format(indices[3]),
"{0}-{1}-{2}-{3}".
format(indices[0],indices[1],indices[2],indices[3]),args.batch)
428 if args.investigateSplits :
430 configIndices = tuple([eval(item)
for item
in args.investigateSplits.split(
",")])
432 splitconfigs = [templateFile.replace(
"template",
"index{0}".
format(index))
for index
in configIndices[1:]]
435 for configindex, config
in zip(configIndices[1:],splitconfigs) :
439 for index
in range(newIndices) :
440 outRootName = (outRootFormat.format(configindex)).
replace(
".root",
"_splitV{0}.root".
format(index))
441 newconfig = config.replace(
".config",
"_splitV{0}.config".
format(index))
442 newconfig = newconfig.replace(
"generateConfigs",
"splitsConfigs")
443 newIterables.append(
"{0}_splitV{1}".
format(configindex,index))
447 iterables.append(newIterables)
450 isdone =
not subprocess.check_output(
"qstat",shell=
True)
453 isdone =
not subprocess.check_output(
"qstat",shell=
True)
456 pool = tuple(product([configIndices[0]],iterables[0],iterables[1],iterables[2]))
458 for indices
in random.sample(pool,
min(len(pool),args.ntestscomparisons)) :
459 print "Testing combination",indices
461 outFileName = os.getcwd()+
"/NPPlots/SR-4D-{0}-{1}-{2}-{3}.png".
format(indices[0],indices[1],indices[2],indices[3])
463 runComparisonCommands(outFileName,
"NONE",outRootFormat.format(indices[0]),outRootFormat.format(indices[1],outRootFormat.format(indices[2])),outRootFormat.format(indices[2]),outRootFormat.format(indices[3]),
"{0}-{1}-{2}-{3}".
format(indices[0],indices[1],indices[2],indices[3]),args.batch)