CMS 3D CMS Logo

SplitLinear.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #from G.Benelli and Arun Mittal
3 # 2016 November 17
4 #Quick script to split a large sqlite file (holding all of our Noise payloads (Run1+Run2) into a set of smaller ones.
5 import subprocess
6 IOVs=[]
7 for line in subprocess.Popen("conddb --noLimit --db Linear.db list EcalLinearCorrections_from2011_offline",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines():
8  if "EcalTimeDependentCorrections" in line:
9 # IOVs.append(line.split()[0]) # for run based IOVs
10  IOVs.append((line.split()[2].strip(')')).strip('(')) # for timestamp based IOVs
11 print IOVs
12 print "There are %s IOVs!"%len(IOVs)
13 #Prepare the conddb_import commands template:
14 #CommandTemplate="conddb_import -f sqlite:SiStripNoise_GR10_v3_offline.db -c sqlite:SiStripNoise_GR10_v3_offline_%s_%s.db -i SiStripNoise_GR10_v4_offline -t SiStripNoise_GR10_v4_offline -b %s -e %s"
15 
16 #Let's assemble the commands now!
17 #Let's pick IOVs every 200:
18 RelevantIOVs=[(IOV,IOVs[IOVs.index(IOV)+199],IOVs[IOVs.index(IOV)+200]) for IOV in IOVs if IOVs.index(IOV)==0 or ((IOVs.index(IOV))%200==0 and (IOVs.index(IOV)+200)<len(IOVs))]
19 
20 RelevantIOVs.append((RelevantIOVs[-1][2],IOVs[-1],IOVs[-1]))
21 
22 print RelevantIOVs
23 for i,splitIOVs in enumerate(RelevantIOVs):
24  begin=splitIOVs[0]
25  end=splitIOVs[1]
26  upperLimit=splitIOVs[1]
27  print i,begin,end,upperLimit
28  command = "conddb_import -f sqlite:Linear.db -c sqlite:Linear_"+str(begin)+"_"+str(end)+".db -i EcalLinearCorrections_from2011_offline -t EcalLinearCorrections_from2011_offline -b "+str(begin)+" -e "+str(end)
29  print command
30 
31  #Now if we want to execute it inside Python uncomment the following two lines:
32  STDOUT=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
33  print STDOUT
#define str(s)