forked from mstamenk/hhh-analysis-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare_inclusive_samples.py
56 lines (34 loc) · 1.54 KB
/
prepare_inclusive_samples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Script to filter output from NanoAOD-tools into inclusive_resolved and inclusive_boosted
import os, ROOT
import glob
ROOT.gROOT.SetBatch(ROOT.kTRUE)
ROOT.ROOT.EnableImplicitMT()
version = 'v26'
year = '2018'
path = '/isilon/data/users/mstamenk/eos-triple-h/samples-%s-%s-nanoaod'%(version,year)
output = '/isilon/data/users/mstamenk/eos-triple-h/%s/mva-inputs-%s/'%(version,year)
inclusive_resolved = 'inclusive_resolved'
inclusive_boosted = 'inclusive_boosted'
cut_resolved = 'nsmalljets >= 6 && nprobejets == 0'
cut_boosted = 'nprobejets > 0'
if not os.path.isdir(output + '/' + inclusive_resolved):
print("Creating %s"%(output + '/' + inclusive_resolved))
os.makedirs(output + '/' + inclusive_resolved)
if not os.path.isdir(output + '/' + inclusive_boosted):
print("Creating %s"%(output + '/' + inclusive_boosted))
os.makedirs(output + '/' + inclusive_boosted)
files = glob.glob(path + '/' + '*.root')
for f_in in files:
f_name = os.path.basename(f_in)
print(f_name)
df = ROOT.RDataFrame('Events',f_in)
df_resolved = df.Filter(cut_resolved)
df_boosted = df.Filter(cut_boosted)
print("Running on %s"%f_in)
print("Doing resolved")
if not os.path.isfile( output + '/' + inclusive_resolved + '/' + f_name):
df_resolved.Snapshot('Events', output + '/' + inclusive_resolved + '/' + f_name)
print("Doing boosted")
if not os.path.isfile( output + '/' + inclusive_boosted + '/' + f_name):
df_boosted.Snapshot('Events', output + '/' + inclusive_boosted + '/' + f_name)
print("All done!")