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 private:
29  BufferedBoostIODBWriter() = delete;
32 
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->writeOne(fcp.release(), poolDbService->currentTime(), record);
67  else
68  throw cms::Exception("ConfigurationError") << "PoolDBOutputService is not available, "
69  << "please configure it properly" << std::endl;
70 }
71 
input
static const std::string input
Definition: EdmProvDump.cc:48
BufferedBoostIODBWriter::record
std::string record
Definition: BufferedBoostIODBWriter.cc:36
cms::cuda::assert
assert(be >=bs)
EDAnalyzer.h
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
MakerMacros.h
PoolDBOutputService.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
BufferedBoostIODBWriter::operator=
BufferedBoostIODBWriter & operator=(const BufferedBoostIODBWriter &)=delete
BufferedBoostIODBWriter::BufferedBoostIODBWriter
BufferedBoostIODBWriter()=delete
OOTPileupCorrectionBuffer.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
BufferedBoostIODBWriter
Definition: BufferedBoostIODBWriter.cc:23
edm::Service< cond::service::PoolDBOutputService >
iEvent
int iEvent
Definition: GenABIO.cc:224
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
BufferedBoostIODBWriter::inputFile
std::string inputFile
Definition: BufferedBoostIODBWriter.cc:35
BufferedBoostIODBWriter::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: BufferedBoostIODBWriter.cc:42
edm::EventSetup
Definition: EventSetup.h:58
AlCaHarvesting_cff.record
record
Definition: AlCaHarvesting_cff.py:42
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BufferedBoostIODBWriter::~BufferedBoostIODBWriter
~BufferedBoostIODBWriter() override
Definition: BufferedBoostIODBWriter.cc:26
std
Definition: JetResolutionObject.h:76
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
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
edm::Event
Definition: Event.h:73
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217