Skip to content

Commit

Permalink
Merge pull request #42502 from makortel/hcalTimeSlewEPPSet
Browse files Browse the repository at this point in the history
Replace reference to ParameterSet with explicit parameter values in HcalTimeSlewEP
  • Loading branch information
cmsbuild authored Aug 8, 2023
2 parents b7c058f + 1db94a2 commit bf549db
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
49 changes: 28 additions & 21 deletions CalibCalorimetry/HcalPlugins/src/HcalTimeSlewEP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,32 @@
#include <map>
#include <iostream>

HcalTimeSlewEP::HcalTimeSlewEP(const edm::ParameterSet& pset) : pset_(pset) {
HcalTimeSlewEP::HcalTimeSlewEP(const edm::ParameterSet& pset) {
setWhatProduced(this);
findingRecord<HcalTimeSlewRecord>();

//Two pset sets for M2/Simulation and M3
std::vector<edm::ParameterSet> p_TimeSlewM2 =
pset.getParameter<std::vector<edm::ParameterSet>>("timeSlewParametersM2");
std::vector<edm::ParameterSet> p_TimeSlewM3 =
pset.getParameter<std::vector<edm::ParameterSet>>("timeSlewParametersM3");

//loop over the VPSets
for (const auto& p_timeslew : p_TimeSlewM2) {
m2parameters_.push_back({static_cast<float>(p_timeslew.getParameter<double>("tzero")),
static_cast<float>(p_timeslew.getParameter<double>("slope")),
static_cast<float>(p_timeslew.getParameter<double>("tmax"))});
}

for (const auto& p_timeslew : p_TimeSlewM3) {
m3parameters_.push_back({p_timeslew.getParameter<double>("cap"),
p_timeslew.getParameter<double>("tspar0"),
p_timeslew.getParameter<double>("tspar1"),
p_timeslew.getParameter<double>("tspar2"),
p_timeslew.getParameter<double>("tspar0_siPM"),
p_timeslew.getParameter<double>("tspar1_siPM"),
p_timeslew.getParameter<double>("tspar2_siPM")});
}
}

HcalTimeSlewEP::~HcalTimeSlewEP() {}
Expand Down Expand Up @@ -49,31 +72,15 @@ void HcalTimeSlewEP::fillDescriptions(edm::ConfigurationDescriptions& descriptio

// ------------ method called to produce the data ------------
HcalTimeSlewEP::ReturnType HcalTimeSlewEP::produce(const HcalTimeSlewRecord& iRecord) {
//Two pset sets for M2/Simulation and M3
std::vector<edm::ParameterSet> p_TimeSlewM2 =
pset_.getParameter<std::vector<edm::ParameterSet>>("timeSlewParametersM2");
std::vector<edm::ParameterSet> p_TimeSlewM3 =
pset_.getParameter<std::vector<edm::ParameterSet>>("timeSlewParametersM3");

ReturnType hcalTimeSlew = std::make_unique<HcalTimeSlew>();

//loop over the VPSets
for (const auto& p_timeslew : p_TimeSlewM2) {
float t0 = p_timeslew.getParameter<double>("tzero");
float m = p_timeslew.getParameter<double>("slope");
float tmaximum = p_timeslew.getParameter<double>("tmax");
hcalTimeSlew->addM2ParameterSet(t0, m, tmaximum);
for (const auto& p : m2parameters_) {
hcalTimeSlew->addM2ParameterSet(p.t0, p.m, p.tmaximum);
}

for (const auto& p_timeslew : p_TimeSlewM3) {
double cap_ = p_timeslew.getParameter<double>("cap");
double tspar0_ = p_timeslew.getParameter<double>("tspar0");
double tspar1_ = p_timeslew.getParameter<double>("tspar1");
double tspar2_ = p_timeslew.getParameter<double>("tspar2");
double tspar0_siPM_ = p_timeslew.getParameter<double>("tspar0_siPM");
double tspar1_siPM_ = p_timeslew.getParameter<double>("tspar1_siPM");
double tspar2_siPM_ = p_timeslew.getParameter<double>("tspar2_siPM");
hcalTimeSlew->addM3ParameterSet(cap_, tspar0_, tspar1_, tspar2_, tspar0_siPM_, tspar1_siPM_, tspar2_siPM_);
for (const auto& p : m3parameters_) {
hcalTimeSlew->addM3ParameterSet(p.cap, p.tspar0, p.tspar1, p.tspar2, p.tspar0_siPM, p.tspar1_siPM, p.tspar2_siPM);
}

return hcalTimeSlew;
Expand Down
9 changes: 8 additions & 1 deletion CalibCalorimetry/HcalPlugins/src/HcalTimeSlewEP.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ class HcalTimeSlewEP : public edm::ESProducer, public edm::EventSetupRecordInter
edm::ValidityInterval&) override;

private:
const edm::ParameterSet& pset_;
struct M2Parameters {
float t0, m, tmaximum;
};
struct M3Parameters {
double cap, tspar0, tspar1, tspar2, tspar0_siPM, tspar1_siPM, tspar2_siPM;
};
std::vector<M2Parameters> m2parameters_;
std::vector<M3Parameters> m3parameters_;
};

#endif

0 comments on commit bf549db

Please sign in to comment.