Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:49

0001 #include "RecoJets/FFTJetAlgorithms/interface/adjustForPileup.h"
0002 
0003 namespace fftjetcms {
0004   math::XYZTLorentzVector adjustForPileup(const math::XYZTLorentzVector& jet,
0005                                           const math::XYZTLorentzVector& pileup,
0006                                           const bool subtractPileupAs4Vec) {
0007     const double pt = jet.Pt();
0008     if (pt > 0.0) {
0009       const double pileupPt = pileup.Pt();
0010       const double ptFactor = (pt - pileupPt) / pt;
0011       if (ptFactor <= 0.0)
0012         return math::XYZTLorentzVector();
0013       else if (subtractPileupAs4Vec) {
0014         const math::XYZTLorentzVector subtracted(jet - pileup);
0015         const double e = subtracted.E();
0016         if (e <= 0.0)
0017           return math::XYZTLorentzVector();
0018         else {
0019           // Avoid negative jet masses
0020           const double px = subtracted.Px();
0021           const double py = subtracted.Py();
0022           const double pz = subtracted.Pz();
0023           if (e * e < px * px + py * py + pz * pz)
0024             // It is not clear what is the best thing to do here.
0025             // For now, revert to Pt scaling.
0026             return jet * ptFactor;
0027           else
0028             return subtracted;
0029         }
0030       } else
0031         return jet * ptFactor;
0032     } else
0033       return jet;
0034   }
0035 }  // namespace fftjetcms