1 | #! /usr/bin/env python
|
---|
2 | import sys,os,subprocess
|
---|
3 |
|
---|
4 | def usage():
|
---|
5 | print ' - Usage: ./getmaps.py benchmark_point cross section'
|
---|
6 | print ' - Example: ./getmaps.py T2tt_650_50.txt -1'
|
---|
7 | print ' - Only the last run of a given analysis is taken'
|
---|
8 | print ' - If a negative cross section is given, a cross section of'
|
---|
9 | print ' 0.001 fb is used and no information on the best region is'
|
---|
10 | print ' displayed in the output'
|
---|
11 |
|
---|
12 | def GetAnalysisNumber(name):
|
---|
13 | rpos = name.rfind('_')
|
---|
14 | nr= int(name[rpos+1:])
|
---|
15 | aname=name[:rpos]
|
---|
16 | if nr>Numbers[aname]:
|
---|
17 | Numbers[aname]=nr
|
---|
18 |
|
---|
19 | # at least one argument, check if asking for help
|
---|
20 | if len(sys.argv) < 3 or (sys.argv[1] == "-h" or sys.argv[1] == "--help"):
|
---|
21 | usage()
|
---|
22 | sys.exit()
|
---|
23 |
|
---|
24 | # xsection information
|
---|
25 | if float(sys.argv[2]) < 0:
|
---|
26 | xsec = 0.001
|
---|
27 | else:
|
---|
28 | xsec = float(sys.argv[2])
|
---|
29 |
|
---|
30 | # get the list of the relevant analysis
|
---|
31 | analysispath = os.getcwd()+'/Output/'+sys.argv[1]
|
---|
32 | dirlist=[dirnames[0] for dirnames in os.walk(analysispath)]
|
---|
33 | dirlist = [ dir for dir in dirlist if not('Cutflows' in dir or 'Histograms' in dir or dir==analysispath)]
|
---|
34 | dirlist = [ dir.replace(analysispath,'') for dir in dirlist]
|
---|
35 | dirlist = [ dir.replace('/','',1) for dir in dirlist if dir[0]=='/']
|
---|
36 | anames = [ dir[:dir.rfind('_')] for dir in dirlist]
|
---|
37 | anames = list(set(anames))
|
---|
38 | Numbers = dict([analysis,-1] for analysis in anames)
|
---|
39 | for dir in dirlist:
|
---|
40 | GetAnalysisNumber(dir)
|
---|
41 | for analysis in anames:
|
---|
42 | TheCommand = './exclusion_CLs.py '+analysis+' '+sys.argv[1]+' ' +str(Numbers[analysis])+' ' + str(xsec)
|
---|
43 | try:
|
---|
44 | result=subprocess.Popen([TheCommand],shell=True,stdout=subprocess.PIPE,cwd=os.getcwd())
|
---|
45 | except:
|
---|
46 | print 'ERROR: impossible to execute the command: ' + TheCommand+'\n'
|
---|
47 | sys.exit()
|
---|
48 | ok, err = result.communicate()
|
---|
49 | if not ok:
|
---|
50 | print "ERROR with the extraction of the efficiencies. Check the ", analysis, "analysis...\n"
|
---|
51 |
|
---|