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

EcalClusterEnergyUncertaintyElectronSpecific to free function #32498

Merged
merged 1 commit into from Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions RecoEgamma/EgammaElectronAlgos/interface/GsfElectronAlgo.h
Expand Up @@ -176,7 +176,6 @@ class GsfElectronAlgo {
const ElectronHcalHelper::Configuration& hcalCfg,
const IsolationConfiguration&,
const EcalRecHitsConfiguration&,
std::unique_ptr<EcalClusterFunctionBaseClass>&& superClusterErrorFunction,
std::unique_ptr<EcalClusterFunctionBaseClass>&& crackCorrectionFunction,
const RegressionHelper::Configuration& regCfg,
const edm::ParameterSet& tkIsol03Cfg,
Expand Down Expand Up @@ -251,7 +250,6 @@ class GsfElectronAlgo {

// additional configuration and helpers
ElectronHcalHelper hcalHelper_;
std::unique_ptr<EcalClusterFunctionBaseClass> superClusterErrorFunction_;
std::unique_ptr<EcalClusterFunctionBaseClass> crackCorrectionFunction_;
RegressionHelper regHelper_;
};
Expand Down
@@ -0,0 +1,25 @@
#ifndef RecoEgamma_EgammaElectronAlgos_ecalClusterEnergyUncertaintyElectronSpecific_h
#define RecoEgamma_EgammaElectronAlgos_ecalClusterEnergyUncertaintyElectronSpecific_h

/** ecalClusterEnergyUncertaintyElectronSpecific
* Function that provides uncertainty on supercluster energy measurement
* Available numbers: total effective uncertainty (in GeV)
* assymetric uncertainties (positive and negative)
*
* $Id: ecalClusterEnergyUncertaintyElectronSpecific.h
* $Date:
* $Revision:
* \author Nicolas Chanon, December 2011
*/

namespace reco {
class SuperCluster;
}

namespace egamma {

float ecalClusterEnergyUncertaintyElectronSpecific(reco::SuperCluster const& superCluster);

}

#endif
9 changes: 2 additions & 7 deletions RecoEgamma/EgammaElectronAlgos/src/GsfElectronAlgo.cc
Expand Up @@ -23,6 +23,7 @@
#include "RecoEgamma/EgammaElectronAlgos/interface/ElectronMomentumCorrector.h"
#include "RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h"
#include "RecoEgamma/EgammaElectronAlgos/interface/GsfElectronAlgo.h"
#include "RecoEgamma/EgammaElectronAlgos/interface/ecalClusterEnergyUncertaintyElectronSpecific.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"

#include <Math/Point3D.h>
Expand Down Expand Up @@ -370,7 +371,6 @@ GsfElectronAlgo::GsfElectronAlgo(const Tokens& input,
const ElectronHcalHelper::Configuration& hcal,
const IsolationConfiguration& iso,
const EcalRecHitsConfiguration& recHits,
std::unique_ptr<EcalClusterFunctionBaseClass>&& superClusterErrorFunction,
std::unique_ptr<EcalClusterFunctionBaseClass>&& crackCorrectionFunction,
const RegressionHelper::Configuration& reg,
const edm::ParameterSet& tkIsol03,
Expand All @@ -389,8 +389,6 @@ GsfElectronAlgo::GsfElectronAlgo(const Tokens& input,
trackerGeometryToken_{cc.esConsumes()},
ecalSeveretyLevelAlgoToken_{cc.esConsumes()},
hcalHelper_{hcal, std::move(cc)},
superClusterErrorFunction_{
std::forward<std::unique_ptr<EcalClusterFunctionBaseClass>>(superClusterErrorFunction)},
crackCorrectionFunction_{std::forward<std::unique_ptr<EcalClusterFunctionBaseClass>>(crackCorrectionFunction)},
regHelper_{reg, cfg_.strategy.useEcalRegression, cfg_.strategy.useCombinationRegression, cc}

Expand All @@ -400,9 +398,6 @@ void GsfElectronAlgo::checkSetup(const edm::EventSetup& es) {
if (cfg_.strategy.useEcalRegression || cfg_.strategy.useCombinationRegression)
regHelper_.checkSetup(es);

if (superClusterErrorFunction_) {
superClusterErrorFunction_->init(es);
}
if (crackCorrectionFunction_) {
crackCorrectionFunction_->init(es);
}
Expand Down Expand Up @@ -923,7 +918,7 @@ void GsfElectronAlgo::createElectron(reco::GsfElectronCollection& electrons,
saturationInfo);
auto& ele = electrons.back();
// Will be overwritten later in the case of the regression
ele.setCorrectedEcalEnergyError(superClusterErrorFunction_->getValue(*(ele.superCluster()), 0));
ele.setCorrectedEcalEnergyError(egamma::ecalClusterEnergyUncertaintyElectronSpecific(*(ele.superCluster())));
ele.setP4(GsfElectron::P4_FROM_SUPER_CLUSTER, momentum, 0, true);

//====================================================
Expand Down
@@ -1,39 +1,7 @@
/** \class EcalClusterEnergyUncertainty
* Function that provides uncertainty on supercluster energy measurement
* Available numbers: total effective uncertainty (in GeV)
* assymetric uncertainties (positive and negative)
*
* $Id: EcalClusterEnergyUncertainty.h
* $Date:
* $Revision:
* \author Nicolas Chanon, December 2011
*/

#include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionBaseClass.h"
#include "CondFormats/EcalObjects/interface/EcalClusterEnergyUncertaintyParameters.h"
#include "FWCore/Framework/interface/EventSetup.h"

class EcalClusterEnergyUncertaintyObjectSpecific : public EcalClusterFunctionBaseClass {
public:
EcalClusterEnergyUncertaintyObjectSpecific(const edm::ParameterSet &){};

// check initialization
void checkInit() const {}

// compute the correction
float getValue(const reco::SuperCluster &, const int mode) const override;
float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const override { return 0.; };

// set parameters
void init(const edm::EventSetup &es) override {}
};

float EcalClusterEnergyUncertaintyObjectSpecific::getValue(const reco::SuperCluster &superCluster,
const int mode) const {
checkInit();

// mode = 0 returns electron energy uncertainty
#include "RecoEgamma/EgammaElectronAlgos/interface/ecalClusterEnergyUncertaintyElectronSpecific.h"
#include "DataFormats/EgammaReco/interface/SuperCluster.h"

float egamma::ecalClusterEnergyUncertaintyElectronSpecific(reco::SuperCluster const& superCluster) {
float en = superCluster.energy();
float eta = fabs(superCluster.eta());
float et = en / cosh(eta);
Expand Down Expand Up @@ -273,8 +241,3 @@ float EcalClusterEnergyUncertaintyObjectSpecific::getValue(const reco::SuperClus

return (uncertainty * en);
}

#include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionFactory.h"
DEFINE_EDM_PLUGIN(EcalClusterFunctionFactory,
EcalClusterEnergyUncertaintyObjectSpecific,
"EcalClusterEnergyUncertaintyObjectSpecific");
Expand Up @@ -212,7 +212,6 @@ void GsfElectronProducer::fillDescriptions(edm::ConfigurationDescriptions& descr
}

// Corrections
desc.add<std::string>("superClusterErrorFunction", "EcalClusterEnergyUncertaintyObjectSpecific");
desc.add<std::string>("crackCorrectionFunction", "EcalClusterCrackCorrection");

desc.add<bool>("ecalWeightsFromDB", true);
Expand Down Expand Up @@ -375,7 +374,6 @@ GsfElectronProducer::GsfElectronProducer(const edm::ParameterSet& cfg, const Gsf
hcalCfg_,
isoCfg,
recHitsCfg,
EcalClusterFunctionFactory::get()->create(cfg.getParameter<std::string>("superClusterErrorFunction"), cfg),
EcalClusterFunctionFactory::get()->create(cfg.getParameter<std::string>("crackCorrectionFunction"), cfg),
regressionCfg,
cfg.getParameter<edm::ParameterSet>("trkIsol03Cfg"),
Expand Down