File indexing completed on 2023-03-17 10:41:34
0001
0002
0003
0004
0005
0006
0007 #include <iostream>
0008 #include <fstream>
0009 #include <memory>
0010
0011 #include "FWCore/Framework/interface/ModuleFactory.h"
0012 #include "FWCore/Framework/interface/ESProducer.h"
0013 #include "FWCore/Framework/interface/ESProductHost.h"
0014 #include "FWCore/Utilities/interface/ReusableObjectHolder.h"
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016
0017 #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h"
0018 #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h"
0019
0020 #include "CondFormats/DataRecord/interface/EcalLaserAlphasRcd.h"
0021 #include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRefRcd.h"
0022 #include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRcd.h"
0023 #include "CondFormats/DataRecord/interface/EcalLinearCorrectionsRcd.h"
0024
0025 class EcalLaserCorrectionService : public edm::ESProducer {
0026 public:
0027 EcalLaserCorrectionService(const edm::ParameterSet&);
0028 ~EcalLaserCorrectionService() override;
0029
0030 std::shared_ptr<EcalLaserDbService> produce(const EcalLaserDbRecord&);
0031 static void fillDescriptions(edm::ConfigurationDescriptions&);
0032
0033 private:
0034 using HostType = edm::ESProductHost<EcalLaserDbService,
0035 EcalLaserAlphasRcd,
0036 EcalLaserAPDPNRatiosRefRcd,
0037 EcalLaserAPDPNRatiosRcd,
0038 EcalLinearCorrectionsRcd>;
0039
0040
0041 edm::ReusableObjectHolder<HostType> holder_;
0042
0043 edm::ESGetToken<EcalLaserAlphas, EcalLaserAlphasRcd> alphaToken_;
0044 edm::ESGetToken<EcalLaserAPDPNRatiosRef, EcalLaserAPDPNRatiosRefRcd> apdpnRefToken_;
0045 edm::ESGetToken<EcalLaserAPDPNRatios, EcalLaserAPDPNRatiosRcd> apdpnToken_;
0046 edm::ESGetToken<EcalLinearCorrections, EcalLinearCorrectionsRcd> linearToken_;
0047
0048 int maxExtrapolationTimeInSec_;
0049
0050
0051
0052 };
0053
0054 EcalLaserCorrectionService::EcalLaserCorrectionService(const edm::ParameterSet& fConfig)
0055 : ESProducer()
0056
0057
0058 {
0059
0060
0061
0062
0063 auto cc = setWhatProduced(this);
0064 alphaToken_ = cc.consumes();
0065 apdpnRefToken_ = cc.consumes();
0066 apdpnToken_ = cc.consumes();
0067 linearToken_ = cc.consumes();
0068
0069 maxExtrapolationTimeInSec_ = fConfig.getParameter<unsigned int>("maxExtrapolationTimeInSec");
0070
0071
0072
0073
0074
0075
0076
0077
0078 }
0079
0080 EcalLaserCorrectionService::~EcalLaserCorrectionService() {
0081
0082
0083
0084 }
0085
0086
0087
0088
0089
0090
0091 std::shared_ptr<EcalLaserDbService> EcalLaserCorrectionService::produce(const EcalLaserDbRecord& record) {
0092 auto host = holder_.makeOrGet([]() { return new HostType; });
0093
0094 host.get()->setMaxExtrapolationTimeInSec(maxExtrapolationTimeInSec_);
0095
0096 host->ifRecordChanges<EcalLinearCorrectionsRcd>(
0097 record, [this, h = host.get()](auto const& rec) { h->setLinearCorrectionsData(&rec.get(linearToken_)); });
0098
0099 host->ifRecordChanges<EcalLaserAPDPNRatiosRcd>(
0100 record, [this, h = host.get()](auto const& rec) { h->setAPDPNData(&rec.get(apdpnToken_)); });
0101
0102 host->ifRecordChanges<EcalLaserAPDPNRatiosRefRcd>(
0103 record, [this, h = host.get()](auto const& rec) { h->setAPDPNRefData(&rec.get(apdpnRefToken_)); });
0104
0105 host->ifRecordChanges<EcalLaserAlphasRcd>(
0106 record, [this, h = host.get()](auto const& rec) { h->setAlphaData(&rec.get(alphaToken_)); });
0107
0108 return host;
0109 }
0110
0111 void EcalLaserCorrectionService::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0112 edm::ParameterSetDescription desc;
0113 desc.add<unsigned int>("maxExtrapolationTimeInSec", 0);
0114 descriptions.add("EcalLaserCorrectionService", desc);
0115 }
0116
0117 DEFINE_FWK_EVENTSETUP_MODULE(EcalLaserCorrectionService);