![]() |
|
|||
File indexing completed on 2023-03-17 10:48:00
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 from __future__ import print_function 0006 import subprocess 0007 #Input IOVs: 0008 #Reference for the use of subprocess Popen to execute a command: 0009 #subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read() 0010 #Let's prepare a container for the list of IOVs: 0011 IOVs=[] 0012 #for line in subprocess.Popen("conddb --db dump_one_shot_v1.5_447_256581_258507.db list EcalLaserAPDPNRatios_201510078_256581_258507 --limit 1000",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines(): 0013 #for line in subprocess.Popen("conddb --noLimit --db dump_one_shot_v1.5_447_232134_256483.db list EcalLaserAPDPNRatios_20151007_232134_256483",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines(): 0014 #for line in subprocess.Popen("conddb --noLimit --db offline2016.db list EcalLaserAPDPNRatios_offline2016",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines(): 0015 #for line in subprocess.Popen("conddb --noLimit --db dump_one_shot_v1.5_447_274208_279557.db list EcalLaserAPDPNRatios_offline_corr2016_274208_279557",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines(): 0016 #for line in subprocess.Popen("conddb --noLimit --db dump_one_shot_v1.5_447_267160_279557_v1_cut0.55.db list EcalLaserAPDPNRatios_offline_corr2016_267160_279557",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines(): 0017 #for line in subprocess.Popen("conddb --noLimit --db EcalPedestals_tree.db list EcalPedestals_laser_2016",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines(): 0018 for line in subprocess.Popen("conddb --noLimit --db EcalPedestals_timestamp.db list EcalPedestals_timestamp",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.readlines(): 0019 if "EcalCondObjectContainer" in line: 0020 # IOVs.append(line.split()[0]) # for run based IOVs 0021 IOVs.append((line.split()[2].strip(')')).strip('(')) # for timestamp based IOVs 0022 print(IOVs) 0023 print("There are %s IOVs!"%len(IOVs)) 0024 #Prepare the conddb_import commands template: 0025 #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" 0026 0027 #Let's assemble the commands now! 0028 #Let's pick IOVs every 5: 0029 #RelevantIOVs=[(IOV,IOVs[IOVs.index(IOV)+4],IOVs[IOVs.index(IOV)+5]) for IOV in IOVs if IOVs.index(IOV)==0 or ((IOVs.index(IOV)+1)%5==0 and (IOVs.index(IOV)+5)<len(IOVs))] 0030 #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))] 0031 #AZ: every 100 0032 RelevantIOVs=[(IOV,IOVs[IOVs.index(IOV)+49],IOVs[IOVs.index(IOV)+50]) for IOV in IOVs if IOVs.index(IOV)==0 or ((IOVs.index(IOV))%50==0 and (IOVs.index(IOV)+50)<len(IOVs))] 0033 0034 RelevantIOVs.append((RelevantIOVs[-1][2],IOVs[-1],IOVs[-1])) 0035 0036 print(RelevantIOVs) 0037 for i,splitIOVs in enumerate(RelevantIOVs): 0038 begin=splitIOVs[0] 0039 end=splitIOVs[1] 0040 upperLimit=splitIOVs[1] 0041 print(i,begin,end,upperLimit) 0042 # command = "conddb_import -f sqlite:EcalPedestals_tree.db -c sqlite:EcalPedestals_tree_"+str(begin)+"_"+str(end)+".db -i EcalPedestals_laser_2016 -t EcalPedestals_laser_2016 -b "+str(begin)+" -e "+str(end) 0043 command = "conddb_import -f sqlite:EcalPedestals_timestamp.db -c sqlite:EcalPedestals_timestamp_"+str(begin)+"_"+str(end)+".db -i EcalPedestals_timestamp -t EcalPedestals_timestamp -b "+str(begin)+" -e "+str(end) 0044 print(command) 0045 0046 #Now if we want to execute it inside Python uncomment the following two lines: 0047 STDOUT=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read() 0048 print(STDOUT)
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |
![]() ![]() |