18 |
|
from printcolor import printc |
19 |
|
|
20 |
|
#CONFIGURE |
21 |
< |
|
21 |
> |
print 'hello' |
22 |
|
#load config |
23 |
|
#os.mkdir(path+'/sys') |
24 |
|
argv = sys.argv |
27 |
|
help="update infofile") |
28 |
|
parser.add_option("-D", "--discr", dest="discr", default="", |
29 |
|
help="discriminators to be added") |
30 |
< |
parser.add_option("-P", "--path", dest="path", default="", |
31 |
< |
help="path to samples") |
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", |
39 |
|
if opts.config =="": |
40 |
|
opts.config = "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 |
|
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=opts.path |
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=opts.discr #RTight_blavla,bsbsb |
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(Apath+'/'+job.getpath(),'read') |
147 |
< |
outfile = TFile.Open(Apath+'/'+MVASubdir+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 |
|
|