File indexing completed on 2024-04-06 11:59:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <memory>
0020
0021 #include "FWCore/Framework/interface/EventSetup.h"
0022 #include "FWCore/Framework/interface/ESProducer.h"
0023 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0024 #include "FWCore/Framework/interface/ModuleFactory.h"
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0029 #include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h"
0030 #include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
0031 #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
0032 #include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
0033
0034 class SiPixelQualityESProducer : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0035 public:
0036 SiPixelQualityESProducer(const edm::ParameterSet& iConfig);
0037 ~SiPixelQualityESProducer() override = default;
0038
0039 std::unique_ptr<SiPixelQuality> produce(const SiPixelQualityRcd& iRecord);
0040
0041 static void fillDescriptions(edm::ConfigurationDescriptions&);
0042
0043 private:
0044 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0045 const edm::IOVSyncValue&,
0046 edm::ValidityInterval&) override;
0047
0048 edm::ESGetToken<SiPixelQuality, SiPixelQualityFromDbRcd> siPixelQualityFromDbToken_;
0049 edm::ESGetToken<SiStripDetVOff, SiPixelDetVOffRcd> voffToken_;
0050 };
0051
0052 SiPixelQualityESProducer::SiPixelQualityESProducer(const edm::ParameterSet& iConfig) {
0053
0054 auto const& appendToDataLabel = iConfig.getParameter<std::string>("appendToDataLabel");
0055 auto esCC = setWhatProduced(this);
0056
0057
0058
0059 auto const& siPixelQualityFromDbLabel = iConfig.getParameter<std::string>("siPixelQualityFromDbLabel");
0060 siPixelQualityFromDbToken_ = esCC.consumes(edm::ESInputTag{"", siPixelQualityFromDbLabel});
0061 voffToken_ = esCC.consumes();
0062
0063 findingRecord<SiPixelQualityRcd>();
0064
0065 edm::LogInfo("SiPixelQualityESProducer")
0066 << "Module = \"" << description().label_ << "\" (appendToDataLabel = \"" << appendToDataLabel
0067 << "\", siPixelQualityFromDbLabel = \"" << siPixelQualityFromDbLabel << "\")";
0068 }
0069
0070 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd& iRecord) {
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 auto dbptr = std::make_unique<SiPixelQuality>(iRecord.get(siPixelQualityFromDbToken_));
0085
0086
0087 dbptr->add(&(iRecord.get(voffToken_)));
0088 return dbptr;
0089 }
0090
0091 void SiPixelQualityESProducer::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0092 const edm::IOVSyncValue& iosv,
0093 edm::ValidityInterval& oValidity) {
0094 edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
0095 oValidity = infinity;
0096 }
0097
0098 void SiPixelQualityESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0099 edm::ParameterSetDescription desc;
0100 desc.add<std::string>("siPixelQualityFromDbLabel", "");
0101 {
0102 edm::ParameterSetDescription desc_ps;
0103 desc_ps.add<std::string>("record", "SiPixelQualityFromDbRcd");
0104 desc_ps.add<std::string>("tag", "");
0105 std::vector<edm::ParameterSet> default_ps;
0106 default_ps.reserve(2);
0107 {
0108 edm::ParameterSet temp;
0109 temp.addParameter<std::string>("record", "SiPixelQualityFromDbRcd");
0110 temp.addParameter<std::string>("tag", "");
0111 default_ps.push_back(temp);
0112 }
0113 {
0114 edm::ParameterSet temp;
0115 temp.addParameter<std::string>("record", "SiPixelDetVOffRcd");
0116 temp.addParameter<std::string>("tag", "");
0117 default_ps.push_back(temp);
0118 }
0119 desc.addVPSet("ListOfRecordToMerge", desc_ps, default_ps);
0120 }
0121 descriptions.addWithDefaultLabel(desc);
0122 }
0123
0124 DEFINE_FWK_EVENTSETUP_MODULE(SiPixelQualityESProducer);