CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BoostIODBReader.h
Go to the documentation of this file.
1 #ifndef RecoLocalCalo_HcalRecAlgos_BoostIODBReader_h
2 #define RecoLocalCalo_HcalRecAlgos_BoostIODBReader_h
3 
4 // -*- C++ -*-
5 //
6 // Package: RecoLocalCalo/HcalRecAlgos
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:
46  typedef DataType data_type;
47  typedef RecordType record_type;
48 
49  explicit BoostIODBReader(const edm::ParameterSet&);
50  inline virtual ~BoostIODBReader() {}
51 
52 private:
53  virtual 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 // RecoLocalCalo_HcalRecAlgos_BoostIODBReader_h
int iEvent
Definition: GenABIO.cc:230
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
RecordType record_type
const T & get() const
Definition: EventSetup.h:55
std::string outputFile_
BoostIODBReader(const edm::ParameterSet &)
virtual ~BoostIODBReader()