Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:17

0001 #include "HcalTimeSlewEP.h"
0002 #include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h"
0003 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "FWCore/ParameterSet/interface/FileInPath.h"
0006 #include "FWCore/Framework/interface/SourceFactory.h"
0007 
0008 #include <string>
0009 #include <vector>
0010 #include <map>
0011 #include <iostream>
0012 
0013 HcalTimeSlewEP::HcalTimeSlewEP(const edm::ParameterSet& pset) : pset_(pset) {
0014   setWhatProduced(this);
0015   findingRecord<HcalTimeSlewRecord>();
0016 }
0017 
0018 HcalTimeSlewEP::~HcalTimeSlewEP() {}
0019 
0020 void HcalTimeSlewEP::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& iKey,
0021                                     const edm::IOVSyncValue& iTime,
0022                                     edm::ValidityInterval& oInterval) {
0023   oInterval = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0024 }
0025 
0026 void HcalTimeSlewEP::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0027   edm::ParameterSetDescription desc;
0028 
0029   edm::ParameterSetDescription desc_M2;
0030   desc_M2.add<double>("tzero");
0031   desc_M2.add<double>("slope");
0032   desc_M2.add<double>("tmax");
0033   std::vector<edm::ParameterSet> default_M2(1);
0034   desc.addVPSet("timeSlewParametersM2", desc_M2, default_M2);
0035 
0036   edm::ParameterSetDescription desc_M3;
0037   desc_M3.add<double>("cap");
0038   desc_M3.add<double>("tspar0");
0039   desc_M3.add<double>("tspar1");
0040   desc_M3.add<double>("tspar2");
0041   desc_M3.add<double>("tspar0_siPM");
0042   desc_M3.add<double>("tspar1_siPM");
0043   desc_M3.add<double>("tspar2_siPM");
0044   std::vector<edm::ParameterSet> default_M3(1);
0045   desc.addVPSet("timeSlewParametersM3", desc_M3, default_M3);
0046 
0047   descriptions.addDefault(desc);
0048 }
0049 
0050 // ------------ method called to produce the data  ------------
0051 HcalTimeSlewEP::ReturnType HcalTimeSlewEP::produce(const HcalTimeSlewRecord& iRecord) {
0052   //Two pset sets for M2/Simulation and M3
0053   std::vector<edm::ParameterSet> p_TimeSlewM2 =
0054       pset_.getParameter<std::vector<edm::ParameterSet>>("timeSlewParametersM2");
0055   std::vector<edm::ParameterSet> p_TimeSlewM3 =
0056       pset_.getParameter<std::vector<edm::ParameterSet>>("timeSlewParametersM3");
0057 
0058   ReturnType hcalTimeSlew = std::make_unique<HcalTimeSlew>();
0059 
0060   //loop over the VPSets
0061   for (const auto& p_timeslew : p_TimeSlewM2) {
0062     float t0 = p_timeslew.getParameter<double>("tzero");
0063     float m = p_timeslew.getParameter<double>("slope");
0064     float tmaximum = p_timeslew.getParameter<double>("tmax");
0065     hcalTimeSlew->addM2ParameterSet(t0, m, tmaximum);
0066   }
0067 
0068   for (const auto& p_timeslew : p_TimeSlewM3) {
0069     double cap_ = p_timeslew.getParameter<double>("cap");
0070     double tspar0_ = p_timeslew.getParameter<double>("tspar0");
0071     double tspar1_ = p_timeslew.getParameter<double>("tspar1");
0072     double tspar2_ = p_timeslew.getParameter<double>("tspar2");
0073     double tspar0_siPM_ = p_timeslew.getParameter<double>("tspar0_siPM");
0074     double tspar1_siPM_ = p_timeslew.getParameter<double>("tspar1_siPM");
0075     double tspar2_siPM_ = p_timeslew.getParameter<double>("tspar2_siPM");
0076     hcalTimeSlew->addM3ParameterSet(cap_, tspar0_, tspar1_, tspar2_, tspar0_siPM_, tspar1_siPM_, tspar2_siPM_);
0077   }
0078 
0079   return hcalTimeSlew;
0080 }
0081 
0082 DEFINE_FWK_EVENTSETUP_SOURCE(HcalTimeSlewEP);