File indexing completed on 2024-08-23 12:58:59
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 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022
0023 #include "CondFormats/SiStripObjects/interface/SiStripBackPlaneCorrection.h"
0024 #include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
0025 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0026 #include "Geometry/TrackerNumberingBuilder/interface/utils.h"
0027
0028 class SiStripBackPlaneCorrectionFakeESSource : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0029 public:
0030 SiStripBackPlaneCorrectionFakeESSource(const edm::ParameterSet&);
0031 ~SiStripBackPlaneCorrectionFakeESSource() 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<SiStripBackPlaneCorrection> ReturnType;
0038 ReturnType produce(const SiStripBackPlaneCorrectionRcd&);
0039
0040 private:
0041 std::vector<double> m_valuePerModuleGeometry;
0042 edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_tTopoToken;
0043 edm::ESGetToken<GeometricDet, IdealGeometryRecord> m_geomDetToken;
0044 };
0045
0046 SiStripBackPlaneCorrectionFakeESSource::SiStripBackPlaneCorrectionFakeESSource(const edm::ParameterSet& iConfig) {
0047 auto cc = setWhatProduced(this);
0048 m_tTopoToken = cc.consumes();
0049 m_geomDetToken = cc.consumes();
0050 findingRecord<SiStripBackPlaneCorrectionRcd>();
0051
0052 m_valuePerModuleGeometry = iConfig.getParameter<std::vector<double>>("BackPlaneCorrection_PerModuleGeometry");
0053 }
0054
0055 SiStripBackPlaneCorrectionFakeESSource::~SiStripBackPlaneCorrectionFakeESSource() {}
0056
0057 void SiStripBackPlaneCorrectionFakeESSource::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 SiStripBackPlaneCorrectionFakeESSource::ReturnType SiStripBackPlaneCorrectionFakeESSource::produce(
0065 const SiStripBackPlaneCorrectionRcd& iRecord) {
0066 using namespace edm::es;
0067
0068 const auto& geomDetRcd = iRecord.getRecord<TrackerTopologyRcd>();
0069 const auto& geomDet = geomDetRcd.get(m_geomDetToken);
0070 const auto& tTopo = iRecord.get(m_tTopoToken);
0071
0072 auto backPlaneCorrection = std::make_unique<SiStripBackPlaneCorrection>();
0073
0074 for (const auto detId : TrackerGeometryUtils::getSiStripDetIds(geomDet)) {
0075 const auto moduleGeometry = static_cast<unsigned int>(tTopo.moduleGeometry(DetId(detId))) - 1;
0076 if (moduleGeometry > m_valuePerModuleGeometry.size()) {
0077 edm::LogError("SiStripBackPlaneCorrectionGenerator")
0078 << " BackPlaneCorrection_PerModuleGeometry only contains " << m_valuePerModuleGeometry.size()
0079 << "elements and module is out of range";
0080 }
0081 float value = m_valuePerModuleGeometry[moduleGeometry];
0082 if (!backPlaneCorrection->putBackPlaneCorrection(detId, value)) {
0083 edm::LogError("SiStripBackPlaneCorrectionGenerator") << " detid already exists";
0084 }
0085 }
0086
0087 return backPlaneCorrection;
0088 }
0089
0090
0091 #include "FWCore/Framework/interface/SourceFactory.h"
0092 DEFINE_FWK_EVENTSETUP_SOURCE(SiStripBackPlaneCorrectionFakeESSource);