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/SiStripPedestals.h"
0022 #include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.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 SiStripPedestalsFakeESSource : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0029 public:
0030 SiStripPedestalsFakeESSource(const edm::ParameterSet&);
0031 ~SiStripPedestalsFakeESSource() 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<SiStripPedestals> ReturnType;
0038 ReturnType produce(const SiStripPedestalsRcd&);
0039
0040 private:
0041 uint32_t m_pedestalValue;
0042 uint32_t m_printDebug;
0043 SiStripDetInfo m_detInfo;
0044 };
0045
0046 SiStripPedestalsFakeESSource::SiStripPedestalsFakeESSource(const edm::ParameterSet& iConfig) {
0047 setWhatProduced(this);
0048 findingRecord<SiStripPedestalsRcd>();
0049
0050 m_pedestalValue = iConfig.getParameter<uint32_t>("PedestalValue");
0051 m_printDebug = iConfig.getUntrackedParameter<uint32_t>("printDebug", 5);
0052 m_detInfo = SiStripDetInfoFileReader::read(iConfig.getParameter<edm::FileInPath>("SiStripDetInfoFile").fullPath());
0053 }
0054
0055 SiStripPedestalsFakeESSource::~SiStripPedestalsFakeESSource() {}
0056
0057 void SiStripPedestalsFakeESSource::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 SiStripPedestalsFakeESSource::ReturnType SiStripPedestalsFakeESSource::produce(const SiStripPedestalsRcd& iRecord) {
0065 using namespace edm::es;
0066
0067 auto pedestals = std::make_unique<SiStripPedestals>();
0068
0069 uint32_t count{0};
0070 for (const auto& elm : m_detInfo.getAllData()) {
0071
0072 SiStripPedestals::InputVector theSiStripVector;
0073 for (unsigned short j{0}; j < 128 * elm.second.nApvs; ++j) {
0074 if (count < m_printDebug) {
0075 edm::LogInfo("SiStripPedestalsFakeESSource::makePedestals(): ")
0076 << "detid: " << elm.first << " strip: " << j << " ped: " << m_pedestalValue;
0077 }
0078 pedestals->setData(m_pedestalValue, theSiStripVector);
0079 }
0080 ++count;
0081 if (!pedestals->put(elm.first, theSiStripVector)) {
0082 edm::LogError("SiStripPedestalsFakeESSource::produce ") << " detid already exists";
0083 }
0084 }
0085
0086 return pedestals;
0087 }
0088
0089
0090 #include "FWCore/Framework/interface/SourceFactory.h"
0091 DEFINE_FWK_EVENTSETUP_SOURCE(SiStripPedestalsFakeESSource);