Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:06

0001 #ifndef CondTools_Hcal_BufferedBoostIOESProducer_h
0002 #define CondTools_Hcal_BufferedBoostIOESProducer_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    CondTools/Hcal
0007 // Class:      BufferedBoostIOESProducer
0008 //
0009 /**\class BufferedBoostIOESProducer BufferedBoostIOESProducer.h CondTools/Hcal/interface/BufferedBoostIOESProducer.h
0010 
0011  Description: reads objects serialized by boost from simple string buffers
0012 
0013  Implementation:
0014      [Notes on implementation]
0015 */
0016 //
0017 // Original Author:  Igor Volobouev
0018 //         Created:  Sun Aug 31 22:18:44 CDT 2014
0019 // $Id: BufferedBoostIOESProducer.h,v 1.0 2014/08/31 22:18:44 igv Exp $
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  // CondTools_Hcal_BufferedBoostIOESProducer_h