File indexing completed on 2024-04-06 12:20:53
0001 import ROOT
0002
0003 f=ROOT.TFile("gainLUTs.root")
0004 f.cd()
0005
0006 fout=ROOT.TFile("packedGainLUTs.root","RECREATE")
0007 def pack(f,fout,station,code):
0008 fout.cd()
0009 newH=ROOT.TH1D("gain_{code}_{station}".format(station=station,code=code),"h",2*1024,0,2*1024)
0010 for N,i in enumerate([0,4]):
0011 h=f.Get("G_{code}_{station}_{i}".format(station=station,code=code,i=i))
0012 for j in range(1,h.GetNbinsX()+1):
0013 newH.SetBinContent(N*1024+j,h.GetBinContent(j))
0014 newH.Write()
0015
0016
0017 def pack2(f,fout,station,code):
0018 fout.cd()
0019 for q1 in ['H', 'L']:
0020 for q2 in ['H', 'L']:
0021 newH=ROOT.TH1D("gain2_{code}_{station}_{q1}{q2}".format(station=station,code=code,q1=q1,q2=q2),"h",4*512,0,4*512)
0022 for N,i in enumerate([0,1,4,5]):
0023 h=f.Get("G2_{code}_{station}_{i}_{q1}{q2}".format(station=station,code=code,i=i,q1=q1,q2=q2))
0024 for j in range(1,h.GetNbinsX()+1):
0025 newH.SetBinContent(N*512+j,h.GetBinContent(j))
0026 newH.Write()
0027
0028
0029 def packV(f,fout,code):
0030 fout.cd()
0031 newH=ROOT.TH1D("gain_{code}_0".format(code=code),"h",2*1024,0,2*1024)
0032 for N,i in enumerate([0,1]):
0033 h=f.Get("G_{code}_0_{i}".format(code=code,i=i))
0034 for j in range(1,h.GetNbinsX()+1):
0035 newH.SetBinContent(N*1024+j,h.GetBinContent(j))
0036 newH.Write()
0037
0038 pack(f,fout,3,8)
0039 pack(f,fout,2,8)
0040 pack(f,fout,2,12)
0041 pack(f,fout,2,4)
0042 pack(f,fout,2,4)
0043 pack(f,fout,1,14)
0044 pack(f,fout,1,12)
0045 pack(f,fout,1,10)
0046 pack(f,fout,1,6)
0047
0048
0049 pack2(f,fout,3,8)
0050 pack2(f,fout,2,8)
0051 pack2(f,fout,2,4)
0052 pack2(f,fout,1,8)
0053 pack2(f,fout,1,4)
0054 pack2(f,fout,1,2)
0055
0056 packV(f,fout,3)
0057 packV(f,fout,5)
0058 packV(f,fout,6)
0059 packV(f,fout,7)
0060 packV(f,fout,9)
0061 packV(f,fout,10)
0062 packV(f,fout,11)
0063 packV(f,fout,12)
0064 packV(f,fout,13)
0065 packV(f,fout,14)
0066 packV(f,fout,15)
0067
0068 fout.Close()
0069 f.Close()