Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:00

0001 // Implementation of the SC dynamic dPhi parameters interface
0002 
0003 #include "RecoEcal/EgammaCoreTools/interface/SCDynamicDPhiParametersHelper.h"
0004 
0005 #include <algorithm>
0006 #include <utility>
0007 
0008 using namespace reco;
0009 
0010 SCDynamicDPhiParametersHelper::SCDynamicDPhiParametersHelper(EcalSCDynamicDPhiParameters &params,
0011                                                              const edm::ParameterSet &iConfig)
0012     : parameters_(params) {
0013   // dynamic dPhi parameters
0014   // clear the vector in case the EcalMustacheSCParameters had been initialised before
0015   if (!parameters_.dynamicDPhiParametersCollection_.empty()) {
0016     parameters_.dynamicDPhiParametersCollection_.clear();
0017   }
0018   const auto dynamicDPhiPSets = iConfig.getParameter<std::vector<edm::ParameterSet>>("dynamicDPhiParameterSets");
0019   for (const auto &pSet : dynamicDPhiPSets) {
0020     EcalSCDynamicDPhiParameters::DynamicDPhiParameters dynDPhiParams({pSet.getParameter<double>("eMin"),
0021                                                                       pSet.getParameter<double>("etaMin"),
0022                                                                       pSet.getParameter<double>("yoffset"),
0023                                                                       pSet.getParameter<double>("scale"),
0024                                                                       pSet.getParameter<double>("xoffset"),
0025                                                                       pSet.getParameter<double>("width"),
0026                                                                       pSet.getParameter<double>("saturation"),
0027                                                                       pSet.getParameter<double>("cutoff")});
0028     addDynamicDPhiParameters(dynDPhiParams);
0029     sortDynamicDPhiParametersCollection();
0030   }
0031 }
0032 
0033 void SCDynamicDPhiParametersHelper::addDynamicDPhiParameters(
0034     const EcalSCDynamicDPhiParameters::DynamicDPhiParameters &dynDPhiParams) {
0035   parameters_.dynamicDPhiParametersCollection_.emplace_back(dynDPhiParams);
0036 }
0037 
0038 void SCDynamicDPhiParametersHelper::sortDynamicDPhiParametersCollection() {
0039   std::sort(parameters_.dynamicDPhiParametersCollection_.begin(),
0040             parameters_.dynamicDPhiParametersCollection_.end(),
0041             [](const EcalSCDynamicDPhiParameters::DynamicDPhiParameters &p1,
0042                const EcalSCDynamicDPhiParameters::DynamicDPhiParameters &p2) {
0043               const auto p1Mins = std::make_pair(p1.eMin, p1.etaMin);
0044               const auto p2Mins = std::make_pair(p2.eMin, p2.etaMin);
0045               return p1Mins < p2Mins;
0046             });
0047 }