Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:32

0001 #ifndef PhysicsTools_IsolationAlgos_EventDependentAbsVetos_h
0002 #define PhysicsTools_IsolationAlgos_EventDependentAbsVetos_h
0003 
0004 #include "FWCore/Framework/interface/ConsumesCollector.h"
0005 #include "PhysicsTools/IsolationAlgos/interface/EventDependentAbsVeto.h"
0006 #include "FWCore/Utilities/interface/InputTag.h"
0007 #include "DataFormats/Common/interface/View.h"
0008 #include "DataFormats/Common/interface/AssociationMap.h"
0009 #include "DataFormats/Candidate/interface/Candidate.h"
0010 #include "DataFormats/JetReco/interface/PFJet.h"
0011 
0012 namespace reco {
0013   namespace isodeposit {
0014     class OtherCandidatesDeltaRVeto : public EventDependentAbsVeto {
0015     public:
0016       //! Create a veto specifying the input collection of the candidates, and the deltaR
0017       OtherCandidatesDeltaRVeto(const edm::InputTag& candidates, double deltaR, edm::ConsumesCollector& iC)
0018           : src_(iC.consumes<edm::View<reco::Candidate> >(candidates)), deltaR2_(deltaR * deltaR) {}
0019 
0020       // Virtual destructor (should always be there)
0021       ~OtherCandidatesDeltaRVeto() override {}
0022 
0023       //! Return "true" if a deposit at specific (eta,phi) with that value must be vetoed in the sum
0024       //! This is true if the deposit is within the configured deltaR from any item of the source collection
0025       bool veto(double eta, double phi, float value) const override;
0026 
0027       //! Nothing to do for this
0028       void centerOn(double eta, double phi) override {}
0029 
0030       //! Picks up the directions of the given candidates
0031       void setEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0032 
0033     private:
0034       edm::EDGetTokenT<edm::View<reco::Candidate> > src_;
0035       float deltaR2_;
0036       std::vector<Direction> items_;
0037     };
0038 
0039     class OtherCandVeto : public EventDependentAbsVeto {
0040     public:
0041       //! Create a veto specifying the input collection of the candidates, and the deltaR
0042       OtherCandVeto(const edm::InputTag& candidates, AbsVeto* veto, edm::ConsumesCollector& iC)
0043           : src_(iC.consumes<edm::View<reco::Candidate> >(candidates)), veto_(veto) {}
0044 
0045       // Virtual destructor (should always be there)
0046       ~OtherCandVeto() override {}
0047 
0048       //! Return "true" if a deposit at specific (eta,phi) with that value must be vetoed in the sum
0049       //! This is true if the deposit is within the stored AbsVeto of any item of the source collection
0050       bool veto(double eta, double phi, float value) const override;
0051 
0052       //! Nothing to do for this
0053       void centerOn(double eta, double phi) override {}
0054 
0055       //! Picks up the directions of the given candidates
0056       void setEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0057 
0058     private:
0059       edm::EDGetTokenT<edm::View<reco::Candidate> > src_;
0060       std::vector<Direction> items_;
0061       std::unique_ptr<AbsVeto> veto_;
0062     };
0063 
0064     class OtherJetConstituentsDeltaRVeto : public EventDependentAbsVeto {
0065     public:
0066       //! Create a veto specifying the input collection of the jets, the candidates, and the deltaR
0067       OtherJetConstituentsDeltaRVeto(Direction dir,
0068                                      const edm::InputTag& jets,
0069                                      double dRjet,
0070                                      const edm::InputTag& pfCandAssocMap,
0071                                      double dRconstituent,
0072                                      edm::ConsumesCollector& iC)
0073           : evt_(nullptr),
0074             vetoDir_(dir),
0075             srcJets_(iC.consumes<reco::PFJetCollection>(jets)),
0076             dR2jet_(dRjet * dRjet),
0077             srcPFCandAssocMap_(iC.consumes<JetToPFCandidateAssociation>(pfCandAssocMap)),
0078             dR2constituent_(dRconstituent * dRconstituent) {
0079         //std::cout << "<OtherJetConstituentsDeltaRVeto::OtherJetConstituentsDeltaRVeto>:" << std::endl;
0080         //std::cout << " vetoDir: eta = " << vetoDir_.eta() << ", phi = " << vetoDir_.phi() << std::endl;
0081         //std::cout << " srcJets = " << srcJets_.label() << ":" << srcJets_.instance() << std::endl;
0082         //std::cout << " dRjet = " << sqrt(dR2jet_) << std::endl;
0083         //std::cout << " srcPFCandAssocMap = " << srcPFCandAssocMap_.label() << ":" << srcPFCandAssocMap_.instance() << std::endl;
0084         //std::cout << " dRconstituent = " << sqrt(dR2constituent_) << std::endl;
0085       }
0086 
0087       // Virtual destructor (should always be there)
0088       ~OtherJetConstituentsDeltaRVeto() override {}
0089 
0090       //! Return "true" if a deposit at specific (eta,phi) with that value must be vetoed in the sum
0091       //! This is true if the deposit is within the stored AbsVeto of any item of the source collection
0092       bool veto(double eta, double phi, float value) const override;
0093 
0094       //! Set axis for matching jets
0095       void centerOn(double eta, double phi) override;
0096 
0097       //! Picks up the directions of the given candidates
0098       void setEvent(const edm::Event& evt, const edm::EventSetup& es) override;
0099 
0100     private:
0101       typedef edm::AssociationMap<edm::OneToMany<std::vector<reco::PFJet>, std::vector<reco::PFCandidate>, unsigned int> >
0102           JetToPFCandidateAssociation;
0103 
0104       void initialize();
0105 
0106       const edm::Event* evt_;
0107 
0108       Direction vetoDir_;
0109       edm::EDGetTokenT<reco::PFJetCollection> srcJets_;
0110       double dR2jet_;
0111       edm::EDGetTokenT<JetToPFCandidateAssociation> srcPFCandAssocMap_;
0112       double dR2constituent_;
0113       std::vector<Direction> items_;
0114     };
0115   }  // namespace isodeposit
0116 }  // namespace reco
0117 #endif