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/SiStripLatency.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 SiStripLatencyFakeESSource : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0029 public:
0030 SiStripLatencyFakeESSource(const edm::ParameterSet&);
0031 ~SiStripLatencyFakeESSource() 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<SiStripLatency> ReturnType;
0038 ReturnType produce(const SiStripLatencyRcd&);
0039
0040 private:
0041 uint32_t m_latency;
0042 uint32_t m_mode;
0043 SiStripDetInfo m_detInfo;
0044 };
0045
0046 SiStripLatencyFakeESSource::SiStripLatencyFakeESSource(const edm::ParameterSet& iConfig) {
0047 setWhatProduced(this);
0048 findingRecord<SiStripLatencyRcd>();
0049
0050 m_latency = iConfig.getParameter<uint32_t>("latency");
0051 m_mode = iConfig.getParameter<uint32_t>("mode");
0052 m_detInfo = SiStripDetInfoFileReader::read(iConfig.getParameter<edm::FileInPath>("SiStripDetInfoFile").fullPath());
0053 }
0054
0055 SiStripLatencyFakeESSource::~SiStripLatencyFakeESSource() {}
0056
0057 void SiStripLatencyFakeESSource::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 SiStripLatencyFakeESSource::ReturnType SiStripLatencyFakeESSource::produce(const SiStripLatencyRcd& iRecord) {
0065 using namespace edm::es;
0066
0067 auto latency = std::make_unique<SiStripLatency>();
0068
0069 const auto& detInfos = m_detInfo.getAllData();
0070
0071 if (!detInfos.empty()) {
0072
0073 edm::LogInfo("SiStripLatencyGenerator") << "detId = " << detInfos.rbegin()->first << " apv = " << 6
0074 << " latency = " << m_latency << " mode = " << m_mode;
0075 latency->put(detInfos.rbegin()->first, 6, m_latency, m_mode);
0076
0077
0078 latency->compress();
0079 } else {
0080 edm::LogError("SiStripLatencyGenerator") << "Error: detInfo map is empty. Cannot get the last detId.";
0081 }
0082
0083 return latency;
0084 }
0085
0086
0087 #include "FWCore/Framework/interface/SourceFactory.h"
0088 DEFINE_FWK_EVENTSETUP_SOURCE(SiStripLatencyFakeESSource);