CMS 3D CMS Logo

BoostIODBReader.h
Go to the documentation of this file.
1 #ifndef CondTools_Hcal_BoostIODBReader_h
2 #define CondTools_Hcal_BoostIODBReader_h
3 
4 // -*- C++ -*-
5 //
6 // Package: CondTools/Hcal
7 // Class: BoostIODBReader
8 //
16 //
17 // Original Author: Igor Volobouev
18 // Created: Fri Apr 25 18:17:13 CDT 2014
19 //
20 //
21 
22 #include <string>
23 #include <fstream>
24 #include <cassert>
25 
26 #include "CondFormats/Serialization/interface/eos/portable_oarchive.hpp"
27 
32 
34 
37 
38 //
39 // class declaration
40 //
41 template <class DataType, class RecordType>
43 public:
45  typedef RecordType record_type;
46 
47  explicit BoostIODBReader(const edm::ParameterSet&);
48  inline ~BoostIODBReader() override {}
49 
50 private:
51  void analyze(const edm::Event&, const edm::EventSetup&) override;
52 
55 };
56 
57 template <class DataType, class RecordType>
59  : outputFile_(ps.getParameter<std::string>("outputFile")), tok_(esConsumes<DataType, RecordType>()) {}
60 
61 template <class DataType, class RecordType>
63  const DataType* p = &iSetup.getData(tok_);
64 
65  std::ofstream of(outputFile_.c_str(), std::ios_base::binary);
66  if (!of.is_open())
67  throw cms::Exception("InvalidArgument") << "Failed to open file \"" << outputFile_ << '"' << std::endl;
68 
69  eos::portable_oarchive ar(of);
70  ar&* p;
71 }
72 
73 #endif // CondTools_Hcal_BoostIODBReader_h
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< DataType, RecordType > tok_
const std::string outputFile_
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
RecordType record_type
~BoostIODBReader() override
BoostIODBReader(const edm::ParameterSet &)