Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:26

0001 #ifndef PhysicsTools_Heppy_IsolationComputer_h
0002 #define PhysicsTools_Heppy_IsolationComputer_h
0003 
0004 #include <vector>
0005 #include "DataFormats/PatCandidates/interface/PackedCandidate.h"
0006 
0007 namespace heppy {
0008   class IsolationComputer {
0009   public:
0010     /// Create the calculator; optionally specify a cone for computing deltaBeta weights
0011     IsolationComputer(float weightCone = -1) : weightCone_(weightCone) {}
0012 
0013     /// Self-veto policy
0014     enum SelfVetoPolicy { selfVetoNone = 0, selfVetoAll = 1, selfVetoFirst = 2 };
0015     /// Initialize with the list of packed candidates (note: clears also all vetos)
0016     void setPackedCandidates(const std::vector<pat::PackedCandidate> &all,
0017                              int fromPV_thresh = 1,
0018                              float dz_thresh = 9999.,
0019                              float dxy_thresh = 9999.,
0020                              bool also_leptons = false);
0021 
0022     /// veto footprint from this candidate, for the isolation of all candidates and also for calculation of neutral weights (if used)
0023     void addVetos(const reco::Candidate &cand);
0024 
0025     /// clear all vetos
0026     void clearVetos();
0027 
0028     /// Isolation from charged from the PV
0029     float chargedAbsIso(const reco::Candidate &cand,
0030                         float dR,
0031                         float innerR = 0,
0032                         float threshold = 0,
0033                         SelfVetoPolicy selfVeto = selfVetoAll) const;
0034 
0035     /// Isolation from charged from PU
0036     float puAbsIso(const reco::Candidate &cand,
0037                    float dR,
0038                    float innerR = 0,
0039                    float threshold = 0,
0040                    SelfVetoPolicy selfVeto = selfVetoAll) const;
0041 
0042     /// Isolation from all neutrals (uncorrected)
0043     float neutralAbsIsoRaw(const reco::Candidate &cand,
0044                            float dR,
0045                            float innerR = 0,
0046                            float threshold = 0,
0047                            SelfVetoPolicy selfVeto = selfVetoAll) const;
0048 
0049     /// Isolation from neutral hadrons (uncorrected)
0050     float neutralHadAbsIsoRaw(const reco::Candidate &cand,
0051                               float dR,
0052                               float innerR = 0,
0053                               float threshold = 0,
0054                               SelfVetoPolicy selfVeto = selfVetoAll) const;
0055 
0056     /// Isolation from photons (uncorrected)
0057     float photonAbsIsoRaw(const reco::Candidate &cand,
0058                           float dR,
0059                           float innerR = 0,
0060                           float threshold = 0,
0061                           SelfVetoPolicy selfVeto = selfVetoAll) const;
0062 
0063     /// Isolation from all neutrals (with weights)
0064     float neutralAbsIsoWeighted(const reco::Candidate &cand,
0065                                 float dR,
0066                                 float innerR = 0,
0067                                 float threshold = 0,
0068                                 SelfVetoPolicy selfVeto = selfVetoAll) const;
0069 
0070     /// Isolation from neutral hadrons (with weights)
0071     float neutralHadAbsIsoWeighted(const reco::Candidate &cand,
0072                                    float dR,
0073                                    float innerR = 0,
0074                                    float threshold = 0,
0075                                    SelfVetoPolicy selfVeto = selfVetoAll) const;
0076 
0077     /// Isolation from photons (with weights)
0078     float photonAbsIsoWeighted(const reco::Candidate &cand,
0079                                float dR,
0080                                float innerR = 0,
0081                                float threshold = 0,
0082                                SelfVetoPolicy selfVeto = selfVetoAll) const;
0083 
0084   protected:
0085     const std::vector<pat::PackedCandidate> *allcands_;
0086     float weightCone_;
0087     // collections of objects, sorted in eta
0088     std::vector<const pat::PackedCandidate *> charged_, neutral_, pileup_;
0089     mutable std::vector<float> weights_;
0090     std::vector<const reco::Candidate *> vetos_;
0091 
0092     float isoSumRaw(const std::vector<const pat::PackedCandidate *> &cands,
0093                     const reco::Candidate &cand,
0094                     float dR,
0095                     float innerR,
0096                     float threshold,
0097                     SelfVetoPolicy selfVeto,
0098                     int pdgId = -1) const;
0099     float isoSumNeutralsWeighted(const reco::Candidate &cand,
0100                                  float dR,
0101                                  float innerR,
0102                                  float threshold,
0103                                  SelfVetoPolicy selfVeto,
0104                                  int pdgId = -1) const;
0105   };
0106 
0107 }  // namespace heppy
0108 
0109 #endif