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 
33 
35 
38 
39 //
40 // class declaration
41 //
42 template<class DataType, class RecordType>
44 {
45 public:
47  typedef RecordType record_type;
48 
49  explicit BoostIODBReader(const edm::ParameterSet&);
50  inline ~BoostIODBReader() override {}
51 
52 private:
53  void analyze(const edm::Event&, const edm::EventSetup&) override;
54 
56 };
57 
58 template<class DataType, class RecordType>
60  : outputFile_(ps.getParameter<std::string>("outputFile"))
61 {
62 }
63 
64 template<class DataType, class RecordType>
66  const edm::EventSetup& iSetup)
67 {
69  iSetup.get<RecordType>().get(p);
70 
71  std::ofstream of(outputFile_.c_str(), std::ios_base::binary);
72  if (!of.is_open())
73  throw cms::Exception("InvalidArgument")
74  << "Failed to open file \"" << outputFile_ << '"' << std::endl;
75 
76  eos::portable_oarchive ar(of);
77  ar & *p;
78 }
79 
80 #endif // CondTools_Hcal_BoostIODBReader_h
int iEvent
Definition: GenABIO.cc:230
void analyze(const edm::Event &, const edm::EventSetup &) override
RecordType record_type
const T & get() const
Definition: EventSetup.h:55
~BoostIODBReader() override
std::string outputFile_
BoostIODBReader(const edm::ParameterSet &)