Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ElectronIDExternalProducer #46868

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 44 additions & 32 deletions RecoEgamma/ElectronIdentification/plugins/ClassBasedElectronID.cc
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
#include "ClassBasedElectronID.h"
#include "FWCore/Utilities/interface/Exception.h"

// ===========================================================================================================
void ClassBasedElectronID::setup(const edm::ParameterSet& conf)
// ===========================================================================================================
{
// Get all the parameters
//baseSetup(conf);
namespace {
edm::ParameterSet fromQuality(const edm::ParameterSet& conf) {
auto quality = conf.getParameter<std::string>("electronQuality");

quality_ = conf.getParameter<std::string>("electronQuality");

if (quality_ == "Eff95Cuts") {
cuts_ = conf.getParameter<edm::ParameterSet>("Eff95Cuts");
}
if (quality == "Eff95Cuts") {
return conf.getParameter<edm::ParameterSet>("Eff95Cuts");
}

else if (quality_ == "Eff90Cuts") {
cuts_ = conf.getParameter<edm::ParameterSet>("Eff90Cuts");
}
else if (quality == "Eff90Cuts") {
return conf.getParameter<edm::ParameterSet>("Eff90Cuts");
}

else {
edm::LogError("ClassBasedElectronID") << "Invalid electronQuality parameter: must be tight, medium or loose.";
exit(1);
throw cms::Exception("ClassBasedElectronID")
<< "Invalid electronQuality parameter: must be tight, medium or loose.";
}
} // namespace
// ===========================================================================================================
ClassBasedElectronID::ClassBasedElectronID(const edm::ParameterSet& conf)
: cuts_{fromQuality(conf)}
// ===========================================================================================================
{} // end of setup

} // end of setup
ClassBasedElectronID::Cuts::Cuts(const edm::ParameterSet& conf) {
deltaEtaIn_ = conf.getParameter<std::vector<double> >("deltaEtaIn");
sigmaIetaIetaMax_ = conf.getParameter<std::vector<double> >("sigmaIetaIetaMax");
sigmaIetaIetaMin_ = conf.getParameter<std::vector<double> >("sigmaIetaIetaMin");
HoverE_ = conf.getParameter<std::vector<double> >("HoverE");
EoverPOutMax_ = conf.getParameter<std::vector<double> >("EoverPOutMax");
EoverPOutMin_ = conf.getParameter<std::vector<double> >("EoverPOutMin");
deltaPhiInChargeMax_ = conf.getParameter<std::vector<double> >("deltaPhiInChargeMax");
deltaPhiInChargeMin_ = conf.getParameter<std::vector<double> >("deltaPhiInChargeMin");
}

double ClassBasedElectronID::result(const reco::GsfElectron* electron, const edm::Event& e, const edm::EventSetup& es) {
double ClassBasedElectronID::result(const reco::GsfElectron* electron,
const edm::Event& e,
const edm::EventSetup& es) const {
//determine which element of the cut arrays in cfi file to read
//depending on the electron classification
int icut = 0;
Expand Down Expand Up @@ -56,42 +68,42 @@ double ClassBasedElectronID::result(const reco::GsfElectron* electron, const edm
return 1.;
}

bool useDeltaEtaIn = true;
bool useSigmaIetaIeta = true;
bool useHoverE = true;
bool useEoverPOut = true;
bool useDeltaPhiInCharge = true;
constexpr bool useDeltaEtaIn = true;
constexpr bool useSigmaIetaIeta = true;
constexpr bool useHoverE = true;
constexpr bool useEoverPOut = true;
constexpr bool useDeltaPhiInCharge = true;

// DeltaEtaIn
if (useDeltaEtaIn) {
double value = electron->deltaEtaSuperClusterTrackAtVtx();
std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaEtaIn");
std::vector<double> const& maxcut = cuts_.deltaEtaIn_;
if (fabs(value) > maxcut[icut])
return 0.;
}

// SigmaIetaIeta
if (useSigmaIetaIeta) {
double value = electron->sigmaIetaIeta();
std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("sigmaIetaIetaMax");
std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("sigmaIetaIetaMin");
std::vector<double> const& maxcut = cuts_.sigmaIetaIetaMax_;
std::vector<double> const& mincut = cuts_.sigmaIetaIetaMin_;
if (value < mincut[icut] || value > maxcut[icut])
return 0.;
}

// H/E
if (useHoverE) { //_[variables_]) {
double value = electron->hadronicOverEm();
std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("HoverE");
std::vector<double> const& maxcut = cuts_.HoverE_;
if (value > maxcut[icut])
return 0.;
} // if use

// Eseed/Pout
if (useEoverPOut) {
double value = electron->eSeedClusterOverPout();
std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("EoverPOutMax");
std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("EoverPOutMin");
std::vector<double> maxcut = cuts_.EoverPOutMax_;
std::vector<double> mincut = cuts_.EoverPOutMin_;
if (value < mincut[icut] || value > maxcut[icut])
return 0.;
}
Expand All @@ -101,8 +113,8 @@ double ClassBasedElectronID::result(const reco::GsfElectron* electron, const edm
double value1 = electron->deltaPhiSuperClusterTrackAtVtx();
double value2 = electron->charge();
double value = value1 * value2;
std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaPhiInChargeMax");
std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("deltaPhiInChargeMin");
std::vector<double> maxcut = cuts_.deltaPhiInChargeMax_;
std::vector<double> mincut = cuts_.deltaPhiInChargeMin_;
if (value < mincut[icut] || value > maxcut[icut])
return 0.;
}
Expand Down
20 changes: 13 additions & 7 deletions RecoEgamma/ElectronIdentification/plugins/ClassBasedElectronID.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@

class ClassBasedElectronID : public ElectronIDAlgo {
public:
ClassBasedElectronID() {}
explicit ClassBasedElectronID(const edm::ParameterSet&);

~ClassBasedElectronID() override {}

void setup(const edm::ParameterSet& conf) override;
double result(const reco::GsfElectron*, const edm::Event&, const edm::EventSetup&) override;
double result(const reco::GsfElectron*, const edm::Event&, const edm::EventSetup&) const override;

private:
std::string quality_;
edm::ParameterSet cuts_;
struct Cuts {
Cuts(edm::ParameterSet const&);
std::vector<double> deltaEtaIn_;
std::vector<double> sigmaIetaIetaMax_;
std::vector<double> sigmaIetaIetaMin_;
std::vector<double> HoverE_;
std::vector<double> EoverPOutMax_;
std::vector<double> EoverPOutMin_;
std::vector<double> deltaPhiInChargeMax_;
std::vector<double> deltaPhiInChargeMin_;
} cuts_;
};

#endif // ClassBasedElectronID_H
Loading