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 
12 
15 
18 
19 //
20 // class declaration
21 //
23 public:
26 
27 private:
28  BufferedBoostIODBWriter() = delete;
31 
32  void analyze(const edm::Event&, const edm::EventSetup&) override;
33 
36 };
37 
39  : inputFile(ps.getParameter<std::string>("inputFile")), record(ps.getParameter<std::string>("record")) {}
40 
42  std::unique_ptr<OOTPileupCorrectionBuffer> fcp;
43 
44  {
45  std::ifstream input(inputFile.c_str(), std::ios_base::binary);
46  if (!input.is_open())
47  throw cms::Exception("InvalidArgument") << "Failed to open file \"" << inputFile << '"' << std::endl;
48 
49  struct stat st;
50  if (stat(inputFile.c_str(), &st))
51  throw cms::Exception("SystemError") << "Failed to stat file \"" << inputFile << '"' << std::endl;
52 
53  const std::size_t len = st.st_size;
54  fcp = std::unique_ptr<OOTPileupCorrectionBuffer>(new OOTPileupCorrectionBuffer(len));
55  assert(fcp->length() == len);
56  if (len)
57  input.read(fcp->getBuffer(), len);
58  if (input.fail())
59  throw cms::Exception("SystemError")
60  << "Input stream failure while reading file \"" << inputFile << '"' << std::endl;
61  }
62 
64  if (poolDbService.isAvailable())
65  poolDbService->writeOne(fcp.release(), poolDbService->currentTime(), record);
66  else
67  throw cms::Exception("ConfigurationError") << "PoolDBOutputService is not available, "
68  << "please configure it properly" << std::endl;
69 }
70 
input
static const std::string input
Definition: EdmProvDump.cc:48
BufferedBoostIODBWriter::record
std::string record
Definition: BufferedBoostIODBWriter.cc:35
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
cms::cuda::assert
assert(be >=bs)
EDAnalyzer.h
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
MakerMacros.h
PoolDBOutputService.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1111
Service.h
BufferedBoostIODBWriter::operator=
BufferedBoostIODBWriter & operator=(const BufferedBoostIODBWriter &)=delete
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BufferedBoostIODBWriter::BufferedBoostIODBWriter
BufferedBoostIODBWriter()=delete
OOTPileupCorrectionBuffer.h
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
BufferedBoostIODBWriter
Definition: BufferedBoostIODBWriter.cc:22
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:34
BufferedBoostIODBWriter::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: BufferedBoostIODBWriter.cc:41
edm::EventSetup
Definition: EventSetup.h:57
BufferedBoostIODBWriter::~BufferedBoostIODBWriter
~BufferedBoostIODBWriter() override
Definition: BufferedBoostIODBWriter.cc:25
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
Exception
Definition: hltDiff.cc:246
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:56
OOTPileupCorrectionBuffer
Definition: OOTPileupCorrectionBuffer.h:14
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:179