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->writeOne(datum.release(), 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
EDAnalyzer.h
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
PoolDBOutputService.h
Service.h
BoostIODBWriter::record_
std::string record_
Definition: BoostIODBWriter.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
BoostIODBWriter
Definition: BoostIODBWriter.h:44
edm::Service< cond::service::PoolDBOutputService >
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
BoostIODBWriter::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: BoostIODBWriter.h:63
std
Definition: JetResolutionObject.h:76
BoostIODBWriter::inputFile_
std::string inputFile_
Definition: BoostIODBWriter.h:54
Frameworkfwd.h
Exception
Definition: hltDiff.cc:245
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
Exception.h
BoostIODBWriter::~BoostIODBWriter
~BoostIODBWriter() override
Definition: BoostIODBWriter.h:49
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm::Event
Definition: Event.h:73
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217
HLT_FULL_cff.DataType
DataType
Definition: HLT_FULL_cff.py:32765
BoostIODBWriter::BoostIODBWriter
BoostIODBWriter(const edm::ParameterSet &)
Definition: BoostIODBWriter.h:59
BoostIODBWriter::data_type
DataType data_type
Definition: BoostIODBWriter.h:46