CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
44  typedef DataType data_type;
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 
54 };
55 
56 template <class DataType, class RecordType>
58  : outputFile_(ps.getParameter<std::string>("outputFile")) {}
59 
60 template <class DataType, class RecordType>
62  edm::ESGetToken<DataType, RecordType> tok = esConsumes<DataType, 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
bool getData(T &iHolder) const
Definition: EventSetup.h:122
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
tuple of
Definition: haddnano.py:40
RecordType record_type
~BoostIODBReader() override
std::string outputFile_
BoostIODBReader(const edm::ParameterSet &)