Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:09

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