File indexing completed on 2024-04-06 11:59:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <memory>
0016
0017
0018 #include "FWCore/Framework/interface/ESProducer.h"
0019 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0020
0021 #include "CondFormats/SiStripObjects/interface/SiStripBaseDelay.h"
0022 #include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025
0026 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
0027
0028 class SiStripBaseDelayFakeESSource : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0029 public:
0030 SiStripBaseDelayFakeESSource(const edm::ParameterSet&);
0031 ~SiStripBaseDelayFakeESSource() override;
0032
0033 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0034 const edm::IOVSyncValue& iov,
0035 edm::ValidityInterval& iValidity) override;
0036
0037 typedef std::unique_ptr<SiStripBaseDelay> ReturnType;
0038 ReturnType produce(const SiStripBaseDelayRcd&);
0039
0040 private:
0041 uint16_t m_coarseDelay;
0042 uint16_t m_fineDelay;
0043 SiStripDetInfo m_detInfo;
0044 };
0045
0046 SiStripBaseDelayFakeESSource::SiStripBaseDelayFakeESSource(const edm::ParameterSet& iConfig) {
0047 setWhatProduced(this);
0048 findingRecord<SiStripBaseDelayRcd>();
0049
0050 m_coarseDelay = iConfig.getParameter<uint32_t>("CoarseDelay");
0051 m_fineDelay = iConfig.getParameter<uint32_t>("FineDelay");
0052 m_detInfo = SiStripDetInfoFileReader::read(iConfig.getParameter<edm::FileInPath>("SiStripDetInfoFile").fullPath());
0053 }
0054
0055 SiStripBaseDelayFakeESSource::~SiStripBaseDelayFakeESSource() {}
0056
0057 void SiStripBaseDelayFakeESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0058 const edm::IOVSyncValue& iov,
0059 edm::ValidityInterval& iValidity) {
0060 iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
0061 }
0062
0063
0064 SiStripBaseDelayFakeESSource::ReturnType SiStripBaseDelayFakeESSource::produce(const SiStripBaseDelayRcd& iRecord) {
0065 using namespace edm::es;
0066
0067 auto baseDelay = std::make_unique<SiStripBaseDelay>();
0068
0069 const auto& detInfos = m_detInfo.getAllData();
0070 if (detInfos.empty()) {
0071 edm::LogError("SiStripBaseDelayGenerator") << "Error: detInfo map is empty.";
0072 }
0073 for (const auto& elm : detInfos) {
0074 baseDelay->put(elm.first, m_coarseDelay, m_fineDelay);
0075 }
0076
0077 return baseDelay;
0078 }
0079
0080
0081 #include "FWCore/Framework/interface/SourceFactory.h"
0082 DEFINE_FWK_EVENTSETUP_SOURCE(SiStripBaseDelayFakeESSource);