File indexing completed on 2024-04-06 12:03:06
0001 #ifndef CondTools_Hcal_BufferedBoostIOESProducer_h
0002 #define CondTools_Hcal_BufferedBoostIOESProducer_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include <sstream>
0024 #include <memory>
0025
0026 #include "FWCore/Framework/interface/ModuleFactory.h"
0027 #include "FWCore/Framework/interface/ESProducer.h"
0028
0029 #include "CondFormats/Serialization/interface/eos/portable_iarchive.hpp"
0030 #include "CondFormats/HcalObjects/interface/OOTPileupCorrectionBuffer.h"
0031
0032 template <class DataType, class MyRecord>
0033 class BufferedBoostIOESProducer : public edm::ESProducer {
0034 public:
0035 typedef std::unique_ptr<DataType> ReturnType;
0036
0037 inline BufferedBoostIOESProducer(const edm::ParameterSet&) : token_(setWhatProduced(this).consumes()) {}
0038
0039 inline ~BufferedBoostIOESProducer() override {}
0040
0041 ReturnType produce(const MyRecord&);
0042
0043 private:
0044 const edm::ESGetToken<OOTPileupCorrectionBuffer, MyRecord> token_;
0045 };
0046
0047 template <class DataType, class MyRecord>
0048 typename BufferedBoostIOESProducer<DataType, MyRecord>::ReturnType
0049 BufferedBoostIOESProducer<DataType, MyRecord>::produce(const MyRecord& iRecord) {
0050 const auto& buffer = iRecord.get(token_);
0051 std::istringstream is(buffer.str());
0052 eos::portable_iarchive ar(is);
0053 auto ret = std::make_unique<DataType>();
0054 ar&* ret;
0055 return ret;
0056 }
0057
0058 #endif