File indexing completed on 2024-11-27 03:17:45
0001 import ROOT
0002 import sys
0003
0004 from DataFormats.FWLite import Events, Handle
0005
0006 ROOT.gROOT.SetBatch()
0007
0008 def compare_bx_vector(xs, ys):
0009 x_total_size = xs.getLastBX() - xs.getFirstBX() + 1
0010 y_total_size = ys.getLastBX() - ys.getLastBX() + 1
0011
0012 if x_total_size != y_total_size:
0013 print("> BX count mismatch:", x_total_size, "vs", y_total_size)
0014 print(">", xs.getFirstBX(), ",", ys.getFirstBX())
0015 print(">", xs.getLastBX(), ",", ys.getLastBX())
0016 return
0017
0018 for bx in range(xs.getFirstBX(), xs.getLastBX() + 1):
0019 x_size = xs.size(bx)
0020 y_size = ys.size(bx)
0021
0022 if x_size != y_size:
0023 print(">> BX size mismatch:", x_size, "vs", y_size, "@", bx)
0024
0025 for i in range(x_size):
0026 x = xs.at(bx, i)
0027 for m in range(y_size):
0028 y = ys.at(bx, m)
0029
0030 if x.getType() == y.getType():
0031 print(">>> Pt :", x.hwPt(), "vs", y.hwPt())
0032 print(">>> eta :", x.hwPhi(), "vs", y.hwPhi())
0033 print(">>> overflow :", (x.hwQual()&0x1), "vs", (y.hwQual()&0x1))
0034 print(">>> type :", x.getType(), "vs", y.getType())
0035
0036 if x.hwPt() != y.hwPt(): print(">>> Pt mismatch", x.hwPt(), "vs", y.hwPt())
0037 if x.hwPhi() != y.hwPhi(): print(">>> Phi mismatch", x.hwPhi(), "vs", y.hwPhi())
0038 if (x.hwQual()&0x1) != (y.hwQual()&0x1): print(">>> Qual mismatch",(x.hwQual()&0x1), "vs", (y.hwQual()&0x1))
0039 if x.getType() != y.getType(): print(">>> Type mismatch", x.hwPt(), "vs", y.hwPt())
0040 yield x,y
0041
0042
0043
0044 events = Events(sys.argv[1])
0045
0046 spares_in = Handle('BXVector<l1t::CaloSpare>')
0047 spares_out = Handle('BXVector<l1t::CaloSpare>')
0048
0049 egammas_in = Handle('BXVector<l1t::EGamma>')
0050 egammas_out = Handle('BXVector<l1t::EGamma>')
0051
0052 etsums_in = Handle('BXVector<l1t::EtSum>')
0053 etsums_out = Handle('BXVector<l1t::EtSum>')
0054
0055 jets_in = Handle('BXVector<l1t::Jet>')
0056 jets_out = Handle('BXVector<l1t::Jet>')
0057
0058 taus_in = Handle('BXVector<l1t::Tau>')
0059 taus_out = Handle('BXVector<l1t::Tau>')
0060
0061
0062 in_label = ("caloStage1FinalDigis", "")
0063 tau_label = ("caloStage1FinalDigis", "isoTaus")
0064 out_label = "l1tRawToDigi"
0065
0066 in_ring_label = ("caloStage1FinalDigis", "HFRingSums")
0067 out_ring_label = ("l1tRawToDigi", "HFRingSums")
0068
0069 in_bit_label = ("caloStage1FinalDigis", "HFBitCounts")
0070 out_bit_label = ("l1tRawToDigi", "HFBitCounts")
0071
0072 for event in events:
0073 print("< New event")
0074 event.getByLabel(in_ring_label, spares_in)
0075 event.getByLabel(in_label, egammas_in)
0076 event.getByLabel(in_label, etsums_in)
0077 event.getByLabel(in_label, jets_in)
0078 event.getByLabel(tau_label, taus_in)
0079
0080 event.getByLabel(out_ring_label, spares_out)
0081 event.getByLabel(out_label, egammas_out)
0082 event.getByLabel(out_label, etsums_out)
0083 event.getByLabel(out_label, jets_out)
0084 event.getByLabel(out_label, taus_out)
0085
0086 print("Checking etsums")
0087 for a, b in compare_bx_vector(etsums_in.product(), etsums_out.product()):
0088 if a.getType() != b.getType():
0089 print(">>> Type different:", a.getType(), "vs", b.getType())