CalibTracker
SiStripESProducers
plugins
fake
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
18
#include "
FWCore/Framework/interface/ESProducer.h
"
19
#include "
FWCore/Framework/interface/EventSetupRecordIntervalFinder.h
"
20
21
#include "
CondFormats/SiStripObjects/interface/SiStripLatency.h
"
22
#include "
CondFormats/DataRecord/interface/SiStripCondDataRecords.h
"
23
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
24
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
25
26
#include "
CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h
"
27
28
class
SiStripLatencyFakeESSource
:
public
edm::ESProducer
,
public
edm::EventSetupRecordIntervalFinder
{
29
public
:
30
SiStripLatencyFakeESSource
(
const
edm::ParameterSet
&);
31
~SiStripLatencyFakeESSource
()
override
;
32
33
void
setIntervalFor
(
const
edm::eventsetup::EventSetupRecordKey
&,
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
;
43
SiStripDetInfoFileReader
m_detInfoFileReader
;
44
};
45
46
SiStripLatencyFakeESSource::SiStripLatencyFakeESSource
(
const
edm::ParameterSet
& iConfig) {
47
setWhatProduced
(
this
);
48
findingRecord<SiStripLatencyRcd>();
49
50
m_latency
= iConfig.
getParameter
<uint32_t>(
"latency"
);
51
m_mode
= iConfig.
getParameter
<uint32_t>(
"mode"
);
52
m_detInfoFileReader
=
53
SiStripDetInfoFileReader
{iConfig.
getParameter
<
edm::FileInPath
>(
"SiStripDetInfoFile"
).
fullPath
()};
54
}
55
56
SiStripLatencyFakeESSource::~SiStripLatencyFakeESSource
() {}
57
58
void
SiStripLatencyFakeESSource::setIntervalFor
(
const
edm::eventsetup::EventSetupRecordKey
&,
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 ------------
65
SiStripLatencyFakeESSource::ReturnType
SiStripLatencyFakeESSource::produce
(
const
SiStripLatencyRcd
& iRecord) {
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
88
#include "
FWCore/Framework/interface/SourceFactory.h
"
89
DEFINE_FWK_EVENTSETUP_SOURCE
(
SiStripLatencyFakeESSource
);
MessageLogger.h
config_102169_raw_cff.latency
latency
Definition:
config_102169_raw_cff.py:29
contentValuesFiles.fullPath
fullPath
Definition:
contentValuesFiles.py:64
SiStripLatencyFakeESSource::m_mode
uint32_t m_mode
Definition:
SiStripLatencyFakeESSource.cc:42
edm::LogInfo
Definition:
MessageLogger.h:254
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition:
ESProducer.h:138
edm::ValidityInterval
Definition:
ValidityInterval.h:28
ESProducer.h
SiStripDetInfoFileReader
Definition:
SiStripDetInfoFileReader.h:30
edm::EventSetupRecordIntervalFinder
Definition:
EventSetupRecordIntervalFinder.h:33
SiStripLatencyFakeESSource::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
Definition:
SiStripLatencyFakeESSource.cc:58
edm::eventsetup::EventSetupRecordKey
Definition:
EventSetupRecordKey.h:30
edm::FileInPath
Definition:
FileInPath.h:64
SiStripLatencyFakeESSource::produce
ReturnType produce(const SiStripLatencyRcd &)
Definition:
SiStripLatencyFakeESSource.cc:65
SiStripLatencyFakeESSource::ReturnType
std::unique_ptr< SiStripLatency > ReturnType
Definition:
SiStripLatencyFakeESSource.cc:37
SiStripLatencyFakeESSource
Definition:
SiStripLatencyFakeESSource.cc:28
SiStripDetInfoFileReader.h
edm::IOVSyncValue
Definition:
IOVSyncValue.h:31
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition:
SourceFactory.h:91
EventSetupRecordIntervalFinder.h
SourceFactory.h
edm::ParameterSet
Definition:
ParameterSet.h:36
edm::LogError
Definition:
MessageLogger.h:183
SiStripLatencyFakeESSource::m_detInfoFileReader
SiStripDetInfoFileReader m_detInfoFileReader
Definition:
SiStripLatencyFakeESSource.cc:43
SiStripCondDataRecords.h
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition:
IOVSyncValue.cc:82
SiStripLatencyFakeESSource::~SiStripLatencyFakeESSource
~SiStripLatencyFakeESSource() override
Definition:
SiStripLatencyFakeESSource.cc:56
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
SiStripLatencyFakeESSource::SiStripLatencyFakeESSource
SiStripLatencyFakeESSource(const edm::ParameterSet &)
Definition:
SiStripLatencyFakeESSource.cc:46
SiStripDetInfoFileReader::getAllData
const std::map< uint32_t, DetInfo > & getAllData() const
Definition:
SiStripDetInfoFileReader.h:58
edm::es
Definition:
es_Label.h:33
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition:
IOVSyncValue.cc:88
SiStripLatencyFakeESSource::m_latency
uint32_t m_latency
Definition:
SiStripLatencyFakeESSource.cc:41
SiStripLatencyRcd
Definition:
SiStripCondDataRecords.h:36
edm::ESProducer
Definition:
ESProducer.h:101
SiStripLatency.h
ParameterSet.h
Generated for CMSSW Reference Manual by
1.8.16