CMS 3D CMS Logo

SiStripLatencyFakeESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibTracker/SiStripESProducers
4 // Class: SiStripLatencyFakeESSource
5 //
14 // system include files
15 #include <memory>
16 
17 // user include files
20 
25 
27 
29 public:
31  ~SiStripLatencyFakeESSource() override;
32 
34  const edm::IOVSyncValue& iov,
35  edm::ValidityInterval& iValidity) override;
36 
37  typedef std::unique_ptr<SiStripLatency> ReturnType;
38  ReturnType produce(const SiStripLatencyRcd&);
39 
40 private:
41  uint32_t m_latency;
42  uint32_t m_mode;
44 };
45 
47  setWhatProduced(this);
48  findingRecord<SiStripLatencyRcd>();
49 
50  m_latency = iConfig.getParameter<uint32_t>("latency");
51  m_mode = iConfig.getParameter<uint32_t>("mode");
53  SiStripDetInfoFileReader{iConfig.getParameter<edm::FileInPath>("SiStripDetInfoFile").fullPath()};
54 }
55 
57 
59  const edm::IOVSyncValue& iov,
60  edm::ValidityInterval& iValidity) {
61  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
62 }
63 
64 // ------------ method called to produce the data ------------
66  using namespace edm::es;
67 
68  auto latency = std::make_unique<SiStripLatency>();
69 
70  const auto& detInfos = m_detInfoFileReader.getAllData();
71  // Take the last detId. Since the map is sorted it will be the biggest value
72  if (!detInfos.empty()) {
73  // Set the apv number as 6, the highest possible
74  edm::LogInfo("SiStripLatencyGenerator") << "detId = " << detInfos.rbegin()->first << " apv = " << 6
75  << " latency = " << m_latency << " mode = " << m_mode;
76  latency->put(detInfos.rbegin()->first, 6, m_latency, m_mode);
77 
78  // Call this method to collapse all consecutive detIdAndApvs with the same latency and mode to a single entry
79  latency->compress();
80  } else {
81  edm::LogError("SiStripLatencyGenerator") << "Error: detInfo map is empty. Cannot get the last detId.";
82  }
83 
84  return latency;
85 }
86 
87 //define this as a plug-in
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
ReturnType produce(const SiStripLatencyRcd &)
SiStripLatencyFakeESSource(const edm::ParameterSet &)
SiStripDetInfoFileReader m_detInfoFileReader
std::unique_ptr< SiStripLatency > ReturnType
const std::map< uint32_t, DetInfo > & getAllData() const
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91