CMS 3D CMS Logo

BufferedBoostIODBWriter.cc
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <unistd.h>
4 
5 #include <cassert>
6 #include <fstream>
7 #include <memory>
8 
13 
16 
19 
20 //
21 // class declaration
22 //
24 public:
27 
28  BufferedBoostIODBWriter() = delete;
31 
32 private:
33  void analyze(const edm::Event&, const edm::EventSetup&) override;
34 
37 };
38 
40  : inputFile(ps.getParameter<std::string>("inputFile")), record(ps.getParameter<std::string>("record")) {}
41 
43  std::unique_ptr<OOTPileupCorrectionBuffer> fcp;
44 
45  {
46  std::ifstream input(inputFile.c_str(), std::ios_base::binary);
47  if (!input.is_open())
48  throw cms::Exception("InvalidArgument") << "Failed to open file \"" << inputFile << '"' << std::endl;
49 
50  struct stat st;
51  if (stat(inputFile.c_str(), &st))
52  throw cms::Exception("SystemError") << "Failed to stat file \"" << inputFile << '"' << std::endl;
53 
54  const std::size_t len = st.st_size;
55  fcp = std::make_unique<OOTPileupCorrectionBuffer>(len);
56  assert(fcp->length() == len);
57  if (len)
58  input.read(fcp->getBuffer(), len);
59  if (input.fail())
60  throw cms::Exception("SystemError")
61  << "Input stream failure while reading file \"" << inputFile << '"' << std::endl;
62  }
63 
65  if (poolDbService.isAvailable())
66  poolDbService->writeOneIOV(*fcp, poolDbService->currentTime(), record);
67  else
68  throw cms::Exception("ConfigurationError") << "PoolDBOutputService is not available, "
69  << "please configure it properly" << std::endl;
70 }
71 
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
int iEvent
Definition: GenABIO.cc:224
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
BufferedBoostIODBWriter & operator=(const BufferedBoostIODBWriter &)=delete
BufferedBoostIODBWriter()=delete
void analyze(const edm::Event &, const edm::EventSetup &) override
bool isAvailable() const
Definition: Service.h:40