CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
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 }
54 
56 
58  const edm::IOVSyncValue& iov,
59  edm::ValidityInterval& iValidity) {
60  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
61 }
62 
63 // ------------ method called to produce the data ------------
65  using namespace edm::es;
66 
67  auto latency = std::make_unique<SiStripLatency>();
68 
69  const auto& detInfos = m_detInfo.getAllData();
70  // Take the last detId. Since the map is sorted it will be the biggest value
71  if (!detInfos.empty()) {
72  // Set the apv number as 6, the highest possible
73  edm::LogInfo("SiStripLatencyGenerator") << "detId = " << detInfos.rbegin()->first << " apv = " << 6
74  << " latency = " << m_latency << " 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
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
Log< level::Error, false > LogError
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 &)
SiStripDetInfo read(std::string filePath)
SiStripLatencyFakeESSource(const edm::ParameterSet &)
Log< level::Info, false > LogInfo
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
std::unique_ptr< SiStripLatency > ReturnType
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::map< uint32_t, DetInfo > & getAllData() const noexcept
std::string fullPath() const
Definition: FileInPath.cc:161