File indexing completed on 2024-04-06 11:59:52
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/ParameterSet/interface/ParameterSet.h"
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029
0030 #include "FWCore/Utilities/interface/ESProductTag.h"
0031
0032 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0033 #include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h"
0034 #include "CondFormats/SiStripObjects/interface/SiStripLatency.h"
0035 #include "CalibTracker/Records/interface/SiStripDependentRecords.h"
0036
0037 class SiStripLorentzAngleDepESProducer : public edm::ESProducer {
0038 public:
0039 SiStripLorentzAngleDepESProducer(const edm::ParameterSet&);
0040
0041 std::shared_ptr<SiStripLorentzAngle const> produce(const SiStripLorentzAngleDepRcd&);
0042
0043 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044
0045 private:
0046 edm::ESGetToken<SiStripLorentzAngle, SiStripLorentzAngleRcd> lorentzAngleToken_;
0047 };
0048
0049 SiStripLorentzAngleDepESProducer::SiStripLorentzAngleDepESProducer(const edm::ParameterSet& iConfig) {
0050 auto const getLatency = iConfig.getParameter<edm::ParameterSet>("LatencyRecord");
0051
0052 if (getLatency.getParameter<std::string>("record") != "SiStripLatencyRcd") {
0053 throw edm::Exception(edm::errors::Configuration,
0054 "[SiStripLorentzAngleDepESProducer::ctor] No Latency Record found ");
0055 }
0056
0057 auto const getPeak = iConfig.getParameter<edm::ParameterSet>("LorentzAnglePeakMode");
0058 if (getPeak.getParameter<std::string>("record") != "SiStripLorentzAngleRcd") {
0059 throw edm::Exception(edm::errors::Configuration,
0060 "[SiStripLorentzAngleDepESProducer::ctor] No Lorentz Angle Record found ");
0061 }
0062
0063 auto const getDeconv = iConfig.getParameter<edm::ParameterSet>("LorentzAngleDeconvMode");
0064
0065 if (getDeconv.getParameter<std::string>("record") != "SiStripLorentzAngleRcd") {
0066 throw edm::Exception(edm::errors::Configuration,
0067 "[SiStripLorentzAngleDepESProducer::ctor] No Lorentz Angle Record found ");
0068 }
0069
0070 auto const peakLabel{getPeak.getUntrackedParameter<std::string>("label")};
0071 auto const deconvLabel{getDeconv.getUntrackedParameter<std::string>("label")};
0072 setWhatProduced(this).setMayConsume(
0073 lorentzAngleToken_,
0074 [peakLabel, deconvLabel](auto const& get, edm::ESTransientHandle<SiStripLatency> iLatency) {
0075 if (iLatency->singleReadOutMode() == 1) {
0076 return get("", peakLabel);
0077 }
0078 return get("", deconvLabel);
0079 },
0080 edm::ESProductTag<SiStripLatency, SiStripLatencyRcd>("", getLatency.getUntrackedParameter<std::string>("label")));
0081
0082 edm::LogInfo("SiStripLorentzAngleDepESProducer") << "ctor" << std::endl;
0083 }
0084
0085 std::shared_ptr<SiStripLorentzAngle const> SiStripLorentzAngleDepESProducer::produce(
0086 const SiStripLorentzAngleDepRcd& iRecord) {
0087 edm::LogInfo("SiStripLorentzAngleDepESProducer") << "Producer called" << std::endl;
0088
0089
0090 return std::shared_ptr<SiStripLorentzAngle const>(&iRecord.get(lorentzAngleToken_), [](auto) {});
0091 }
0092
0093 void SiStripLorentzAngleDepESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0094 edm::ParameterSetDescription desc;
0095 {
0096 edm::ParameterSetDescription latency;
0097 latency.add<std::string>("record", "SiStripLatencyRcd");
0098 latency.addUntracked<std::string>("label", "");
0099
0100 desc.add<edm::ParameterSetDescription>("LatencyRecord", latency);
0101 }
0102
0103 {
0104 edm::ParameterSetDescription peak;
0105 peak.add<std::string>("record", "SiStripLorentzAngleRcd");
0106 peak.addUntracked<std::string>("label", "peak");
0107
0108 desc.add<edm::ParameterSetDescription>("LorentzAnglePeakMode", peak);
0109 }
0110
0111 {
0112 edm::ParameterSetDescription deconv;
0113 deconv.add<std::string>("record", "SiStripLorentzAngleRcd");
0114 deconv.addUntracked<std::string>("label", "deconvolution");
0115
0116 desc.add<edm::ParameterSetDescription>("LorentzAngleDeconvMode", deconv);
0117 }
0118
0119 descriptions.addDefault(desc);
0120 }
0121
0122 DEFINE_FWK_EVENTSETUP_MODULE(SiStripLorentzAngleDepESProducer);