Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:24

0001 #!/usr/bin/env python
0002 #from G.Benelli and Arun Mittal
0003 # 2016 November 17
0004 #Quick script to split a large sqlite file (holding all of our Noise payloads (Run1+Run2) into a set of smaller ones.
0005 import subprocess
0006 IOVs=[]
0007 for line in subprocess.Popen("conddb --noLimit --db Linear.db list EcalLinearCorrections_from2011_offline",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines():
0008   if "EcalTimeDependentCorrections" in line:
0009 #    IOVs.append(line.split()[0])             #   for run based IOVs
0010     IOVs.append((line.split()[2].strip(')')).strip('('))             #   for timestamp based IOVs
0011 print(IOVs)
0012 print("There are %s IOVs!"%len(IOVs))
0013 #Prepare the conddb_import commands template:
0014 #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"
0015 
0016 #Let's assemble the commands now!
0017 #Let's pick IOVs every 200:
0018 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))]
0019 
0020 RelevantIOVs.append((RelevantIOVs[-1][2],IOVs[-1],IOVs[-1]))
0021 
0022 print(RelevantIOVs)
0023 for i,splitIOVs in enumerate(RelevantIOVs):
0024   begin=splitIOVs[0]
0025   end=splitIOVs[1]
0026   upperLimit=splitIOVs[1]
0027   print(i,begin,end,upperLimit)
0028   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)
0029   print(command)
0030 
0031   #Now if we want to execute it inside Python uncomment the following two lines:
0032   STDOUT=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
0033   print(STDOUT)