18 |
|
from printcolor import printc |
19 |
|
|
20 |
|
#CONFIGURE |
21 |
< |
|
21 |
> |
print 'hello' |
22 |
|
#load config |
23 |
|
#os.mkdir(path+'/sys') |
24 |
< |
argv = sys.argv[5:] |
24 |
> |
argv = sys.argv |
25 |
|
parser = OptionParser() |
26 |
+ |
parser.add_option("-U", "--update", dest="update", default=0, |
27 |
+ |
help="update infofile") |
28 |
+ |
parser.add_option("-D", "--discr", dest="discr", default="", |
29 |
+ |
help="discriminators to be added") |
30 |
+ |
#parser.add_option("-I", "--inpath", dest="inpath", default="", |
31 |
+ |
# help="path to samples") |
32 |
+ |
#parser.add_option("-O", "--outpath", dest="outpath", default="", |
33 |
+ |
# help="path where to store output samples") |
34 |
+ |
parser.add_option("-S", "--samples", dest="names", default="", |
35 |
+ |
help="samples you want to run on") |
36 |
|
parser.add_option("-C", "--config", dest="config", default=[], action="append", |
37 |
< |
help="configuration defining the plots to make") |
37 |
> |
help="configuration file") |
38 |
|
(opts, args) = parser.parse_args(argv) |
39 |
< |
if opts.config ==[]: |
39 |
> |
if opts.config =="": |
40 |
|
opts.config = "config" |
31 |
– |
print opts.config |
41 |
|
config = BetterConfigParser() |
42 |
+ |
#config.read('./config7TeV_ZZ') |
43 |
|
config.read(opts.config) |
44 |
|
anaTag = config.get("Analysis","tag") |
45 |
|
|
46 |
|
#get locations: |
47 |
|
Wdir=config.get('Directories','Wdir') |
48 |
< |
|
49 |
< |
MVAdir=config.get('Directories','MVAdir') |
48 |
> |
MVASubdir=config.get('Directories','MVAdir') |
49 |
> |
samplesinfo=config.get('Directories','samplesinfo') |
50 |
|
|
51 |
|
#systematics |
52 |
|
systematics=config.get('systematics','systematics') |
61 |
|
###################### |
62 |
|
#Evaluate multi: Must Have same treeVars!!! |
63 |
|
|
64 |
< |
Apath=sys.argv[1] |
65 |
< |
infofile = open(Apath+'/samples.info','r') |
64 |
> |
#OUTpath=opts.outpath |
65 |
> |
#INpath=opts.inpath |
66 |
> |
INpath = config.get('Directories','MVAin') |
67 |
> |
OUTpath = config.get('Directories','MVAout') |
68 |
> |
|
69 |
> |
infofile = open(samplesinfo,'r') |
70 |
|
info = pickle.load(infofile) |
71 |
|
infofile.close() |
72 |
< |
arglist=sys.argv[2] #RTight_blavla,bsbsb |
72 |
> |
arglist=opts.discr #RTight_blavla,bsbsb |
73 |
|
|
74 |
< |
namelistIN=sys.argv[3] |
74 |
> |
namelistIN=opts.names |
75 |
|
namelist=namelistIN.split(',') |
76 |
|
|
77 |
< |
doinfo=bool(int(sys.argv[4])) |
77 |
> |
doinfo=bool(int(opts.update)) |
78 |
|
|
79 |
|
MVAlist=arglist.split(',') |
80 |
+ |
MVAdir=config.get('Directories','vhbbpath') |
81 |
|
|
82 |
|
#CONFIG |
83 |
|
#factory |
91 |
|
#MVAinfofiles=[] |
92 |
|
MVAinfos=[] |
93 |
|
for MVAname in MVAlist: |
94 |
< |
MVAinfofile = open(Wdir+'/weights/'+factoryname+'_'+MVAname+'.info','r') |
94 |
> |
MVAinfofile = open(MVAdir+'/data/'+factoryname+'_'+MVAname+'.info','r') |
95 |
|
MVAinfos.append(pickle.load(MVAinfofile)) |
96 |
|
MVAinfofile.close() |
97 |
|
|
130 |
|
# reader.AddSpectator(spectators[i],MVA_spectator_buffer[i]) |
131 |
|
#Load raeder |
132 |
|
for i in range(0,len(readers)): |
133 |
< |
readers[i].BookMVA(MVAinfos[i].MVAname,MVAinfos[i].getweightfile()) |
133 |
> |
readers[i].BookMVA(MVAinfos[i].MVAname,MVAdir+'/data/'+MVAinfos[i].getweightfile()) |
134 |
|
#--> Now the MVA is booked |
135 |
|
|
136 |
|
#Apply samples |
137 |
< |
infofile = open(Apath+'/samples.info','r') |
137 |
> |
infofile = open(samplesinfo,'r') |
138 |
|
Ainfo = pickle.load(infofile) |
139 |
|
infofile.close() |
140 |
|
|
143 |
|
if eval(job.active): |
144 |
|
if job.name in namelist: |
145 |
|
#get trees: |
146 |
< |
input = TFile.Open(job.getpath(),'read') |
147 |
< |
outfile = TFile.Open(job.path+'/'+MVAdir+job.prefix+job.identifier+'.root','recreate') |
146 |
> |
print INpath+'/'+job.prefix+job.identifier+'.root' |
147 |
> |
input = TFile.Open(INpath+'/'+job.prefix+job.identifier+'.root','read') |
148 |
> |
print OUTpath+'/'+job.prefix+job.identifier+'.root' |
149 |
> |
outfile = TFile.Open(OUTpath+'/'+job.prefix+job.identifier+'.root','recreate') |
150 |
|
input.cd() |
151 |
|
obj = ROOT.TObject |
152 |
|
for key in ROOT.gDirectory.GetListOfKeys(): |
162 |
|
nEntries = tree.GetEntries() |
163 |
|
outfile.cd() |
164 |
|
newtree = tree.CloneTree(0) |
165 |
+ |
#input.Close() |
166 |
|
|
167 |
|
#MCs: |
168 |
|
if job.type != 'DATA': |
181 |
|
MVAbranches=[] |
182 |
|
MVAbranches4=[] |
183 |
|
for i in range(0,len(readers)): |
184 |
< |
MVAbranches.append(array('f',[0]*9)) |
185 |
< |
MVAbranches4.append(array('f',[0]*9)) |
186 |
< |
newtree.Branch(MVAinfos[i].MVAname,MVAbranches[i],'nominal:JER_up:JER_down:JES_up:JES_down:beff_up:beff_down:bmis_up:bmis_down/F') |
187 |
< |
newtree.Branch(MVAinfos[i].MVAname+'_4',MVAbranches4[i],'nominal:JER_up:JER_down:JES_up:JES_down:beff_up:beff_down:bmis_up:bmis_down/F') |
184 |
> |
MVAbranches.append(array('f',[0]*11)) |
185 |
> |
MVAbranches4.append(array('f',[0]*11)) |
186 |
> |
newtree.Branch(MVAinfos[i].MVAname,MVAbranches[i],'nominal:JER_up:JER_down:JES_up:JES_down:beff_up:beff_down:bmis_up:bmis_down:beff1_up:beff1_down/F') |
187 |
> |
newtree.Branch(MVAinfos[i].MVAname+'_4',MVAbranches4[i],'nominal:JER_up:JER_down:JES_up:JES_down:beff_up:beff_down:bmis_up:bmis_down:beff1_up:beff1_down/F') |
188 |
|
print '\n--> ' + job.name +':' |
189 |
|
#progbar setup |
190 |
|
if nEntries >= longe: |
263 |
|
for MVAinfo in MVAinfos: |
264 |
|
job.addcomment('Added MVA %s'%MVAinfo.MVAname) |
265 |
|
job.addpath(MVAdir) |
266 |
< |
infofile = open(Apath+MVAdir+'/samples.info','w') |
266 |
> |
infofile = open(samplesinfo,'w') |
267 |
|
pickle.dump(Ainfo,infofile) |
268 |
|
infofile.close() |
269 |
|
|