1 |
|
#!/usr/bin/env python |
2 |
|
from __future__ import print_function |
3 |
|
import sys |
4 |
< |
import os |
4 |
> |
import os,subprocess |
5 |
|
import ROOT |
6 |
|
from array import array |
7 |
|
from math import sqrt |
12 |
|
from optparse import OptionParser |
13 |
|
import pickle |
14 |
|
|
15 |
+ |
|
16 |
|
#CONFIGURE |
17 |
|
ROOT.gROOT.SetBatch(True) |
18 |
|
print('hello') |
88 |
|
#eval |
89 |
|
|
90 |
|
samples = info.get_samples(namelist) |
91 |
+ |
print(samples) |
92 |
+ |
tmpDir = os.environ["TMPDIR"] |
93 |
|
for job in samples: |
94 |
|
#get trees: |
95 |
|
print(INpath+'/'+job.prefix+job.identifier+'.root') |
96 |
|
input = ROOT.TFile.Open(INpath+'/'+job.prefix+job.identifier+'.root','read') |
97 |
|
print(OUTpath+'/'+job.prefix+job.identifier+'.root') |
98 |
< |
outfile = ROOT.TFile.Open(OUTpath+'/'+job.prefix+job.identifier+'.root','recreate') |
98 |
> |
outfile = ROOT.TFile.Open(tmpDir+'/'+job.prefix+job.identifier+'.root','recreate') |
99 |
|
input.cd() |
100 |
|
obj = ROOT.TObject |
101 |
|
for key in ROOT.gDirectory.GetListOfKeys(): |
127 |
|
newtree.Branch(theMVAs[i].MVAname,mvaVals[i],'nominal:JER_up:JER_down:JES_up:JES_down:beff_up:beff_down:bmis_up:bmis_down:beff1_up:beff1_down/F') |
128 |
|
MVA_formulas_Nominal = [] |
129 |
|
print('\n--> ' + job.name +':') |
127 |
– |
#progbar setup |
128 |
– |
if nEntries >= longe: |
129 |
– |
step=long(nEntries/longe) |
130 |
– |
long=longe |
131 |
– |
else: |
132 |
– |
long=nEntries |
133 |
– |
step = 1 |
134 |
– |
bar=progbar(long) |
130 |
|
#Fill event by event: |
131 |
|
for entry in range(0,nEntries): |
137 |
– |
if entry % step == 0: |
138 |
– |
bar.move() |
139 |
– |
#load entry |
132 |
|
tree.GetEntry(entry) |
133 |
|
|
134 |
|
for i in range(0,len(theMVAs)): |
137 |
|
newtree.Fill() |
138 |
|
newtree.AutoSave() |
139 |
|
outfile.Close() |
140 |
+ |
targetStorage = OUTpath.replace('gsidcap://t3se01.psi.ch:22128/','srm://t3se01.psi.ch:8443/srm/managerv2?SFN=')+'/'+job.prefix+job.identifier+'.root' |
141 |
+ |
command = 'lcg-del -b -D srmv2 -l %s' %(targetStorage) |
142 |
+ |
print(command) |
143 |
+ |
subprocess.call([command], shell=True) |
144 |
+ |
command = 'lcg-cp -b -D srmv2 file:///%s %s' %(tmpDir+'/'+job.prefix+job.identifier+'.root',targetStorage) |
145 |
+ |
print(command) |
146 |
+ |
subprocess.call([command], shell=True) |
147 |
|
|
148 |
|
print('\n') |