mjj = (ak7Reco[0] + ak7Reco[1]).M()
                mjet = (ak7Reco[0].M() + ak7Reco[1].M()) * 0.5

                deltaPhi = abs(ak7Reco[0].DeltaPhi( ak7Reco[1] ))
                deltaY = abs(ak7Reco[0].Rapidity() - ak7Reco[1].Rapidity())
                ptAvgGen = (ak7GenMatched[0].Perp() + ak7GenMatched[1].Perp()) * 0.5
                mjjGen = (ak7GenMatched[0] + ak7GenMatched[1]).M()
                mjetGen = (ak7GenMatched[0].M() + ak7GenMatched[1].M()) * 0.5

                mjetGroomOverMjet = 1.0
                mjetGroomGenOverMjet = 1.0

                if ak7RecoMatched is not None and ak7RecoMatched[0] is not None and ak7RecoMatched[1] is not None :
                    mjetRecoMatched = (ak7RecoMatched[0].M() + ak7RecoMatched[1].M()) * 0.5
                    mjetGroomOverMjet = mjet / mjetRecoMatched
                    mjetUngroomGenMatched0 = findJetInColl( ak7GenMatched[0], ak7Gens[0] )
                    mjetUngroomGenMatched1 = findJetInColl( ak7GenMatched[1], ak7Gens[0] )
                    if mjetUngroomGenMatched0[0] is not None and mjetUngroomGenMatched1[0] is not None :
                        mjetUngroomedGen = ( mjetUngroomGenMatched0[0].M() + mjetUngroomGenMatched1[0].M() ) * 0.5
                        mjetGenGroomOverMjet = mjetGen / mjetUngroomedGen

                responsePtBin = findBin( ptAvg, ptBins )
                if responsePtBin is None :
                    continue

                response = responses[responsePtBin][igroom]
                response.Fill( mjet, mjetGen, weight )

                etaMax = ak7Reco[0].Rapidity()
                if abs(ak7Reco[0].Rapidity()) < abs(ak7Reco[1].Rapidity()) :
                    etaMax = abs(ak7Reco[1].Rapidity())
                theAK7RecoJet = None
                theAK7GenJet = None
                theAK7UngroomedJet = None
                theAK7MatchedGenJet = None
                theAK7GenMatchedRecoJet = None 

                if len(ak7Reco) > ijet :
                    theAK7RecoJet = ak7Reco[ijet]                                           # the reco jet
                if len(ak7Gen) > ijet :
                    theAK7GenJet = ak7Gen[ijet]                                             # the gen jet
                if len(ak7RecoMatched) > ijet :
                    theAK7UngroomedJet = ak7RecoMatched[ijet]                               # ungroomed jet matched to the the reco jet
                if len(ak7GenMatched) > ijet :
                    theAK7MatchedGenJet = ak7GenMatched[ijet]                               # gen jet matched to the reco jet            
                if len( ak7Reco ) > ijet :
                    theAK7GenMatchedRecoJet = findJetInColl( theAK7GenJet, ak7Reco ) # reco jet matched to the gen jet


                # check to see that the the two reco jets match the the two gen jets.
                # If not, it's a miss (gen, no reco), or a fake (reco, no gen)
                isMiss = False
                isFake = False

                # Here's the ptJet, and mjet to use. Depending on whether this is
                # a miss, a fake, or a match, these mean slightly different things.
                ptJet = None
                mjet = None
                responsePtBin = None

                # First check miss: values set to gen-only
                if theAK7GenMatchedRecoJet is None and theAK7GenJet is not None :