10 |
|
import ROOT |
11 |
|
from array import array |
12 |
|
|
13 |
– |
|
13 |
|
#usage: ./write_systematic.py path |
14 |
|
|
16 |
– |
|
15 |
|
path=sys.argv[1] |
16 |
|
|
17 |
|
#load info |
23 |
|
for job in info: |
24 |
|
if job.type != 'DATA': |
25 |
|
print '\t - %s' %(job.name) |
28 |
– |
|
26 |
|
input = TFile.Open(job.getpath(),'read') |
27 |
|
output = TFile.Open(job.path+'/sys/'+job.prefix+job.identifier+'.root','recreate') |
28 |
|
|
40 |
|
|
41 |
|
tree = input.Get(job.tree) |
42 |
|
nEntries = tree.GetEntries() |
46 |
– |
job.addpath('/sys') |
47 |
– |
output.cd() |
48 |
– |
newtree = tree.CloneTree(0) |
49 |
– |
|
50 |
– |
|
51 |
– |
''' |
52 |
– |
input = TFile.Open(job.getpath(),'read') |
53 |
– |
Count = input.Get("Count") |
54 |
– |
CountWithPU = input.Get("CountWithPU") |
55 |
– |
CountWithPU2011B = input.Get("CountWithPU2011B") |
56 |
– |
tree = input.Get(job.tree) |
57 |
– |
nEntries = tree.GetEntries() |
43 |
|
|
44 |
|
job.addpath('/sys') |
60 |
– |
output = ROOT.TFile(job.getpath(), 'RECREATE') |
61 |
– |
newtree = tree.CloneTree(0) |
62 |
– |
''' |
45 |
|
job.SYS = ['Nominal','JER_up','JER_down','JES_up','JES_down','beff_up','beff_down','bmis_up','bmis_down'] |
46 |
+ |
|
47 |
+ |
output.cd() |
48 |
+ |
newtree = tree.CloneTree(0) |
49 |
|
|
50 |
|
hJ0 = ROOT.TLorentzVector() |
51 |
|
hJ1 = ROOT.TLorentzVector() |
171 |
|
newtree.Fill() |
172 |
|
|
173 |
|
newtree.AutoSave() |
189 |
– |
#newtree.Write() |
190 |
– |
#Count.Write() |
191 |
– |
#CountWithPU.Write() |
192 |
– |
#CountWithPU2011B.Write() |
174 |
|
output.Close() |
175 |
< |
|
175 |
> |
|
176 |
|
else: #(is data) |
177 |
|
|
178 |
< |
shutil.copy(job.getpath(),path+'/sys') |
178 |
> |
print '\t - %s' %(job.name) |
179 |
> |
input = TFile.Open(job.getpath(),'read') |
180 |
> |
output = TFile.Open(job.path+'/sys/'+job.prefix+job.identifier+'.root','recreate') |
181 |
> |
#input.cd() |
182 |
> |
obj = ROOT.TObject |
183 |
> |
for key in ROOT.gDirectory.GetListOfKeys(): |
184 |
> |
input.cd() |
185 |
> |
obj = key.ReadObj() |
186 |
> |
if obj.GetName() == job.tree: |
187 |
> |
continue |
188 |
> |
output.cd() |
189 |
> |
obj.Write(key.GetName()) |
190 |
> |
#output.cd() |
191 |
> |
tree = input.Get(job.tree) |
192 |
> |
nEntries = tree.GetEntries() |
193 |
|
job.addpath('/sys') |
194 |
+ |
output.cd() |
195 |
+ |
newtree = tree.CloneTree(0) |
196 |
+ |
#Add training Flag |
197 |
+ |
EventForTraining = array('f',[0]) |
198 |
+ |
newtree.Branch('EventForTraining',EventForTraining,'EventForTraining/F') |
199 |
+ |
for entry in range(0,nEntries): |
200 |
+ |
tree.GetEntry(entry) |
201 |
+ |
EventForTraining[0]=0 |
202 |
+ |
newtree.Fill() |
203 |
+ |
newtree.AutoSave() |
204 |
+ |
output.Close() |
205 |
+ |
|
206 |
|
|
207 |
|
#dump info |
208 |
|
infofile = open(path+'/sys'+'/samples.info','w') |