CMS 3D CMS Logo

BoostIODBWriter.h
Go to the documentation of this file.
1 #ifndef CondTools_Hcal_BoostIODBWriter_h
2 #define CondTools_Hcal_BoostIODBWriter_h
3 
4 // -*- C++ -*-
5 //
6 // Package: CondTools/Hcal
7 // Class: BoostIODBWriter
8 //
16 //
17 // Original Author: Igor Volobouev
18 // Created: Fri Apr 25 17:58:33 CDT 2014
19 //
20 //
21 
22 #include <string>
23 #include <fstream>
24 #include <memory>
25 #include <cassert>
26 
27 #include "CondFormats/Serialization/interface/eos/portable_iarchive.hpp"
28 
32 
34 
37 
39 
40 //
41 // class declaration
42 //
43 template <class DataType>
45 public:
47 
48  explicit BoostIODBWriter(const edm::ParameterSet&);
49  inline ~BoostIODBWriter() override {}
50 
51 private:
52  void analyze(const edm::Event&, const edm::EventSetup&) override;
53 
56 };
57 
58 template <class DataType>
60  : inputFile_(ps.getParameter<std::string>("inputFile")), record_(ps.getParameter<std::string>("record")) {}
61 
62 template <class DataType>
64  std::ifstream is(inputFile_.c_str(), std::ios_base::binary);
65  if (!is.is_open())
66  throw cms::Exception("InvalidArgument") << "Failed to open file \"" << inputFile_ << '"' << std::endl;
67 
68  std::unique_ptr<DataType> datum(new DataType());
69  eos::portable_iarchive ar(is);
70  ar&* datum;
71 
73  if (poolDbService.isAvailable())
74  poolDbService->writeOneIOV(*datum, poolDbService->currentTime(), record_);
75  else
76  throw cms::Exception("ConfigurationError") << "PoolDBOutputService is not available, "
77  << "please configure it properly" << std::endl;
78 }
79 
80 #endif // CondTools_Hcal_BoostIODBWriter_h
void analyze(const edm::Event &, const edm::EventSetup &) override
std::string inputFile_
int iEvent
Definition: GenABIO.cc:224
std::string record_
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
BoostIODBWriter(const edm::ParameterSet &)
~BoostIODBWriter() override
bool isAvailable() const
Definition: Service.h:40