Skip to content

Instantly share code, notes, and snippets.

@jpata
Created November 23, 2020 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpata/a821e8d5640c0938828cd62ca890ad0b to your computer and use it in GitHub Desktop.
Save jpata/a821e8d5640c0938828cd62ca890ad0b to your computer and use it in GitHub Desktop.
32066 remove friend class
diff --git a/CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h b/CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h
index f5d44be83fc..65ab6127780 100644
--- a/CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h
+++ b/CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h
@@ -6,14 +6,8 @@
#include "CondFormats/Serialization/interface/Serializable.h"
-namespace reco {
- class MustacheSCParametersHelper;
-} // namespace reco
-
class EcalMustacheSCParameters {
public:
- EcalMustacheSCParameters(){};
- virtual ~EcalMustacheSCParameters() = default;
struct ParabolaParameters {
double log10EMin;
@@ -28,12 +22,21 @@ public:
COND_SERIALIZABLE;
};
+ EcalMustacheSCParameters() {};
+ void init(const std::vector<ParabolaParameters>& parabolaParametersCollection, float sqrtLogClustETuning) {
+ sqrtLogClustETuning_ = sqrtLogClustETuning;
+ parabolaParametersCollection_ = parabolaParametersCollection;
+ }
+
+ virtual ~EcalMustacheSCParameters() = default;
+
+
float sqrtLogClustETuning() const;
const ParabolaParameters* parabolaParameters(float log10ClustE, float absSeedEta) const;
// helper class to set parameters
- friend class reco::MustacheSCParametersHelper;
+ //friend class reco::MustacheSCParametersHelper;
// print parameters to stream:
void print(std::ostream&) const;
diff --git a/RecoEcal/EgammaCoreTools/interface/MustacheSCParametersHelper.h b/RecoEcal/EgammaCoreTools/interface/MustacheSCParametersHelper.h
index 62d97c7c9df..254a0cf6a93 100644
--- a/RecoEcal/EgammaCoreTools/interface/MustacheSCParametersHelper.h
+++ b/RecoEcal/EgammaCoreTools/interface/MustacheSCParametersHelper.h
@@ -6,20 +6,8 @@
namespace reco {
- class MustacheSCParametersHelper {
- public:
- MustacheSCParametersHelper(EcalMustacheSCParameters &params);
- MustacheSCParametersHelper(EcalMustacheSCParameters &params, const edm::ParameterSet &iConfig);
- ~MustacheSCParametersHelper() = default;
-
- void setSqrtLogClustETuning(const float sqrtLogClustETuning);
-
- void addParabolaParameters(const EcalMustacheSCParameters::ParabolaParameters &params);
- void sortParabolaParametersCollection();
-
- private:
- EcalMustacheSCParameters &parameters_;
- };
+ EcalMustacheSCParameters prepareEcalMustacheSCParameters(const edm::ParameterSet &iConfig);
+ void sortParabolaParametersCollection(std::vector<EcalMustacheSCParameters::ParabolaParameters>& parabolaParametersCollection);
} // namespace reco
diff --git a/RecoEcal/EgammaCoreTools/plugins/EcalMustacheSCParametersESProducer.cc b/RecoEcal/EgammaCoreTools/plugins/EcalMustacheSCParametersESProducer.cc
index 3752dcee4f9..56f6f6d3dd0 100644
--- a/RecoEcal/EgammaCoreTools/plugins/EcalMustacheSCParametersESProducer.cc
+++ b/RecoEcal/EgammaCoreTools/plugins/EcalMustacheSCParametersESProducer.cc
@@ -53,7 +53,7 @@ private:
EcalMustacheSCParametersESProducer::EcalMustacheSCParametersESProducer(const edm::ParameterSet& iConfig) {
setWhatProduced(this);
- reco::MustacheSCParametersHelper mustacheSCParams(params_, iConfig);
+ params_ = reco::prepareEcalMustacheSCParameters(iConfig);
}
EcalMustacheSCParametersESProducer::~EcalMustacheSCParametersESProducer() {}
diff --git a/RecoEcal/EgammaCoreTools/src/MustacheSCParametersHelper.cc b/RecoEcal/EgammaCoreTools/src/MustacheSCParametersHelper.cc
index dfd105b3481..ea540b0f23c 100644
--- a/RecoEcal/EgammaCoreTools/src/MustacheSCParametersHelper.cc
+++ b/RecoEcal/EgammaCoreTools/src/MustacheSCParametersHelper.cc
@@ -7,15 +7,14 @@
using namespace reco;
-MustacheSCParametersHelper::MustacheSCParametersHelper(EcalMustacheSCParameters &params) : parameters_(params) {}
-
-MustacheSCParametersHelper::MustacheSCParametersHelper(EcalMustacheSCParameters &params,
- const edm::ParameterSet &iConfig)
- : parameters_(params) {
- setSqrtLogClustETuning(iConfig.getParameter<double>("sqrtLogClustETuning"));
+EcalMustacheSCParameters reco::prepareEcalMustacheSCParameters(const edm::ParameterSet &iConfig) {
// parabola parameters
const auto parabolaPSets = iConfig.getParameter<std::vector<edm::ParameterSet>>("parabolaParameterSets");
+
+ std::vector<EcalMustacheSCParameters::ParabolaParameters> parabolaParametersCollection;
+ parabolaParametersCollection.reserve(parabolaPSets.size());
+
for (const auto &pSet : parabolaPSets) {
EcalMustacheSCParameters::ParabolaParameters params = {pSet.getParameter<double>("log10EMin"),
pSet.getParameter<double>("etaMin"),
@@ -25,22 +24,18 @@ MustacheSCParametersHelper::MustacheSCParametersHelper(EcalMustacheSCParameters
pSet.getParameter<std::vector<double>>("w1Up"),
pSet.getParameter<std::vector<double>>("w0Low"),
pSet.getParameter<std::vector<double>>("w1Low")};
- addParabolaParameters(params);
- sortParabolaParametersCollection();
+
+ parabolaParametersCollection.emplace_back(params);
+ sortParabolaParametersCollection(parabolaParametersCollection);
}
+ EcalMustacheSCParameters params;
+ params.init(parabolaParametersCollection, iConfig.getParameter<double>("sqrtLogClustETuning"));
+ return params;
}
-void MustacheSCParametersHelper::setSqrtLogClustETuning(const float sqrtLogClustETuning) {
- parameters_.sqrtLogClustETuning_ = sqrtLogClustETuning;
-}
-
-void MustacheSCParametersHelper::addParabolaParameters(const EcalMustacheSCParameters::ParabolaParameters &params) {
- parameters_.parabolaParametersCollection_.emplace_back(params);
-}
-
-void MustacheSCParametersHelper::sortParabolaParametersCollection() {
- std::sort(parameters_.parabolaParametersCollection_.begin(),
- parameters_.parabolaParametersCollection_.end(),
+void reco::sortParabolaParametersCollection(std::vector<EcalMustacheSCParameters::ParabolaParameters>& parabolaParametersCollection) {
+ std::sort(parabolaParametersCollection.begin(),
+ parabolaParametersCollection.end(),
[](const EcalMustacheSCParameters::ParabolaParameters &p1,
const EcalMustacheSCParameters::ParabolaParameters &p2) {
const auto p1Mins = std::make_pair(p1.log10EMin, p1.etaMin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment