File indexing completed on 2024-04-06 12:25:09
0001 #include "PhysicsTools/SelectorUtils/interface/CutApplicatorWithEventContentBase.h"
0002 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0003 #include "CommonTools/Egamma/interface/EffectiveAreas.h"
0004 #include "CommonTools/Utils/interface/StringObjectFunction.h"
0005 #include "CommonTools/Utils/interface/ThreadSafeFunctor.h"
0006 #include "RecoEgamma/EgammaTools/interface/EBEECutValues.h"
0007
0008 class PhoGenericRhoPtScaledCut : public CutApplicatorWithEventContentBase {
0009 public:
0010 PhoGenericRhoPtScaledCut(const edm::ParameterSet& c);
0011
0012 result_type operator()(const reco::PhotonPtr&) const final;
0013
0014 void setConsumes(edm::ConsumesCollector&) final;
0015 void getEventContent(const edm::EventBase&) final;
0016
0017 double value(const reco::CandidatePtr& cand) const final;
0018
0019 CandidateType candidateType() const final { return PHOTON; }
0020
0021 private:
0022 ThreadSafeFunctor<StringObjectFunction<reco::Photon>> varFunc_;
0023 bool lessThan_;
0024
0025
0026
0027 EBEECutValues constTerm_;
0028 EffectiveAreas linearRhoTerm_;
0029 EBEECutValues linearPtTerm_;
0030 EBEECutValues quadraticPtTerm_;
0031
0032 edm::Handle<double> rhoHandle_;
0033 };
0034
0035 DEFINE_EDM_PLUGIN(CutApplicatorFactory, PhoGenericRhoPtScaledCut, "PhoGenericRhoPtScaledCut");
0036
0037 PhoGenericRhoPtScaledCut::PhoGenericRhoPtScaledCut(const edm::ParameterSet& params)
0038 : CutApplicatorWithEventContentBase(params),
0039 varFunc_(params.getParameter<std::string>("cutVariable")),
0040 lessThan_(params.getParameter<bool>("lessThan")),
0041 constTerm_(params, "constTerm"),
0042 linearRhoTerm_(params.getParameter<edm::FileInPath>("effAreasConfigFile").fullPath()),
0043 linearPtTerm_(params, "linearPtTerm"),
0044 quadraticPtTerm_(params, "quadPtTerm") {
0045 edm::InputTag rhoTag = params.getParameter<edm::InputTag>("rho");
0046 contentTags_.emplace("rho", rhoTag);
0047 }
0048
0049 void PhoGenericRhoPtScaledCut::setConsumes(edm::ConsumesCollector& cc) {
0050 auto rho = cc.consumes<double>(contentTags_["rho"]);
0051 contentTokens_.emplace("rho", rho);
0052 }
0053
0054 void PhoGenericRhoPtScaledCut::getEventContent(const edm::EventBase& ev) {
0055 ev.getByLabel(contentTags_["rho"], rhoHandle_);
0056 }
0057
0058 CutApplicatorBase::result_type PhoGenericRhoPtScaledCut::operator()(const reco::PhotonPtr& pho) const {
0059 const double rho = (*rhoHandle_);
0060
0061 const float var = varFunc_(*pho);
0062
0063 const float et = pho->et();
0064 const float absEta = std::abs(pho->superCluster()->eta());
0065 const float cutValue = constTerm_(pho) + linearRhoTerm_.getEffectiveArea(absEta) * rho + linearPtTerm_(pho) * et +
0066 quadraticPtTerm_(pho) * et * et;
0067 if (lessThan_)
0068 return var < cutValue;
0069 else
0070 return var >= cutValue;
0071 }
0072
0073 double PhoGenericRhoPtScaledCut::value(const reco::CandidatePtr& cand) const {
0074 reco::PhotonPtr pho(cand);
0075 return varFunc_(*pho);
0076 }