-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_PresortedTrees.py
35 lines (32 loc) · 1.23 KB
/
create_PresortedTrees.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
from Definitions import *
import ROOT
import os
import stat
import glob
cwd=os.getcwd()
def create_script(cmsswpath,samplesname,rootfile):
print samplename
script='#!/bin/bash\n'
script+='export VO_CMS_SW_DIR=/cvmfs/cms.cern.ch\n'
script+='source $VO_CMS_SW_DIR/cmsset_default.sh\n'
script+='cd '+cmsswpath+'src\neval `scram runtime -sh`\n'
script+='python '+cwd+'/presortTree.py '+OutputDirectoryForPresortedTrees+"/"+samplename+'.root'+' '+rootfile
if not os.path.exists("scripts_sort"):
os.makedirs("scripts_sort")
filename='scripts_sort/'+samplename+'.sh'
f=open(filename,'w')
f.write(script)
f.close()
st = os.stat(filename)
os.chmod(filename, st.st_mode | stat.S_IEXEC)
rootfiles=glob.glob(InputDirectoryForPresortedTrees+'*.root')
samplenames=[samplename.replace(InputDirectoryForPresortedTrees,"").replace(".root","") for samplename in rootfiles]
#print rootfiles
#print samplenames
print samplenames
raw_input()
for rootfile,samplename in zip(rootfiles,samplenames):
print samplename,rootfile
if not os.path.exists(OutputDirectoryForMEMDatabase+"/"+samplename):
os.makedirs(OutputDirectoryForMEMDatabase+"/"+samplename)
create_script(cmsswpath,samplename,rootfile)