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 
24 
26 public:
28  ~SiStripLatencyFakeESSource() override;
29 
31 
32  typedef std::unique_ptr<SiStripLatency> ReturnType;
33  ReturnType produce(const SiStripLatencyRcd&);
34 
35 private:
36  uint32_t m_latency;
37  uint32_t m_mode;
38 };
39 
42 
44 {
45  setWhatProduced(this);
46  findingRecord<SiStripLatencyRcd>();
47 
48  m_latency = iConfig.getParameter<uint32_t>("latency");
49  m_mode = iConfig.getParameter<uint32_t>("mode");
50 }
51 
53 
55 {
56  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
57 }
58 
59 // ------------ method called to produce the data ------------
62 {
63  using namespace edm::es;
64 
65  auto latency = std::make_unique<SiStripLatency>();
66 
68  const auto& detInfos = reader->getAllData();
69  // Take the last detId. Since the map is sorted it will be the biggest value
70  if ( ! detInfos.empty() ) {
71  // Set the apv number as 6, the highest possible
72  edm::LogInfo("SiStripLatencyGenerator") << "detId = " << detInfos.rbegin()->first << " apv = " << 6
73  << " latency = " << m_latency
74  << " mode = " << m_mode;
75  latency->put(detInfos.rbegin()->first, 6, m_latency, m_mode);
76 
77  // Call this method to collapse all consecutive detIdAndApvs with the same latency and mode to a single entry
78  latency->compress();
79  } else {
80  edm::LogError("SiStripLatencyGenerator") << "Error: detInfo map is empty. Cannot get the last detId.";
81  }
82 
83  return latency;
84 }
85 
86 //define this as a plug-in
T getParameter(std::string const &) const
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
static const IOVSyncValue & beginOfTime()
ReturnType produce(const SiStripLatencyRcd &)
SiStripLatencyFakeESSource(const edm::ParameterSet &)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
std::unique_ptr< SiStripLatency > ReturnType
latency
hardware algo