File indexing completed on 2025-03-13 02:31:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/ModuleFactory.h"
0024 #include "FWCore/Framework/interface/ESProducer.h"
0025 #include "FWCore/Framework/interface/ModuleFactory.h"
0026
0027 #include "FWCore/Framework/interface/ESHandle.h"
0028
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031
0032 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0033 #include "CondFormats/SiStripObjects/interface/SiStripBackPlaneCorrection.h"
0034 #include "CondFormats/SiStripObjects/interface/SiStripLatency.h"
0035 #include "CalibTracker/Records/interface/SiStripDependentRecords.h"
0036
0037 #include "FWCore/Utilities/interface/ESProductTag.h"
0038
0039 class SiStripBackPlaneCorrectionDepESProducer : public edm::ESProducer {
0040 public:
0041 SiStripBackPlaneCorrectionDepESProducer(const edm::ParameterSet&);
0042
0043 std::shared_ptr<SiStripBackPlaneCorrection const> produce(const SiStripBackPlaneCorrectionDepRcd&);
0044
0045 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0046
0047 private:
0048 edm::ESGetToken<SiStripBackPlaneCorrection, SiStripBackPlaneCorrectionRcd> backPlaneCorrectionToken_;
0049 };
0050
0051 SiStripBackPlaneCorrectionDepESProducer::SiStripBackPlaneCorrectionDepESProducer(const edm::ParameterSet& iConfig) {
0052 edm::LogInfo("SiStripBackPlaneCorrectionDepESProducer") << "ctor" << std::endl;
0053
0054 auto getLatency = iConfig.getParameter<edm::ParameterSet>("LatencyRecord");
0055
0056 if (getLatency.getParameter<std::string>("record") != "SiStripLatencyRcd") {
0057 throw edm::Exception(edm::errors::Configuration,
0058 "[SiStripBackPlaneCorrectionDepESProducer::ctor] No Latency Record found ");
0059 }
0060
0061 auto getPeak = iConfig.getParameter<edm::ParameterSet>("BackPlaneCorrectionPeakMode");
0062 if (getPeak.getParameter<std::string>("record") != "SiStripBackPlaneCorrectionRcd") {
0063 throw edm::Exception(edm::errors::Configuration,
0064 "[SiStripBackPlaneCorrectionDepESProducer::ctor] No Lorentz Angle Record found ");
0065 }
0066
0067 auto getDeconv = iConfig.getParameter<edm::ParameterSet>("BackPlaneCorrectionDeconvMode");
0068
0069 if (getDeconv.getParameter<std::string>("record") != "SiStripBackPlaneCorrectionRcd") {
0070 throw edm::Exception(edm::errors::Configuration,
0071 "[SiStripBackPlaneCorrectionDepESProducer::ctor] No Lorentz Angle Record found ");
0072 }
0073
0074 auto peakLabel{getPeak.getUntrackedParameter<std::string>("label")};
0075 auto deconvLabel{getDeconv.getUntrackedParameter<std::string>("label")};
0076
0077 setWhatProduced(this).setMayConsume(
0078 backPlaneCorrectionToken_,
0079 [peakLabel, deconvLabel](auto const& get, edm::ESTransientHandle<SiStripLatency> iLatency) {
0080 if (iLatency->singleReadOutMode() == 1) {
0081 return get("", peakLabel);
0082 }
0083 return get("", deconvLabel);
0084 },
0085 edm::ESProductTag<SiStripLatency, SiStripLatencyRcd>("", getLatency.getUntrackedParameter<std::string>("label")));
0086 }
0087
0088 std::shared_ptr<SiStripBackPlaneCorrection const> SiStripBackPlaneCorrectionDepESProducer::produce(
0089 const SiStripBackPlaneCorrectionDepRcd& iRecord) {
0090 edm::LogInfo("SiStripBackPlaneCorrectionDepESProducer") << "Producer called" << std::endl;
0091
0092
0093 return std::shared_ptr<SiStripBackPlaneCorrection const>(&iRecord.get(backPlaneCorrectionToken_), [](auto) {});
0094 }
0095
0096 void SiStripBackPlaneCorrectionDepESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0097 edm::ParameterSetDescription desc;
0098 {
0099 edm::ParameterSetDescription latency;
0100 latency.add<std::string>("record", "SiStripLatencyRcd");
0101 latency.addUntracked<std::string>("label", "");
0102
0103 desc.add<edm::ParameterSetDescription>("LatencyRecord", latency);
0104 }
0105
0106 {
0107 edm::ParameterSetDescription peak;
0108 peak.add<std::string>("record", "SiStripBackPlaneCorrectionRcd");
0109 peak.addUntracked<std::string>("label", "peak");
0110
0111 desc.add<edm::ParameterSetDescription>("BackPlaneCorrectionPeakMode", peak);
0112 }
0113
0114 {
0115 edm::ParameterSetDescription deconv;
0116 deconv.add<std::string>("record", "SiStripBackPlaneCorrectionRcd");
0117 deconv.addUntracked<std::string>("label", "deconvolution");
0118
0119 desc.add<edm::ParameterSetDescription>("BackPlaneCorrectionDeconvMode", deconv);
0120 }
0121
0122 descriptions.addWithDefaultLabel(desc);
0123 }
0124
0125 DEFINE_FWK_EVENTSETUP_MODULE(SiStripBackPlaneCorrectionDepESProducer);