CMS 3D CMS Logo

WriteCTPPSBeamParameters.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Class: WriteCTPPSBeamParameters
4 //
5 // Description: Test analyzer for CTPPS beam parameters condition data
6 //
7 // Simple analyzer that writes one CTTPSBeamParameters record into a sql
8 // database file, as a test of offline conditions implementation.
9 // Another analyzer is then used to retrieve these conditions.
10 //
11 // Original Author: Wagner De Paula Carvalho
12 // Created: Wed, 21 Nov 2018 17:35:07 GMT
13 //
14 //==================================================================================
15 
16 // system include files
17 #include <memory>
18 
19 // user include files
26 
30 
33 
34 #include <cstdint>
35 
37 public:
40 
41  ~WriteCTPPSBeamParameters() override = default;
42 
43 private:
44  void analyze(const edm::Event&, const edm::EventSetup&) override;
45 
47 };
48 
49 //---------------------------------------------------------------------------------------
50 
52  const auto& beamParam = iSetup.getData(tokenBeamParameters_);
53  // Using "lumiid" as IOV
54  const edm::LuminosityBlock& iLBlock = iEvent.getLuminosityBlock();
55  edm::LuminosityBlockID lu(iLBlock.run(), iLBlock.id().luminosityBlock());
56  cond::Time_t ilumi = (cond::Time_t)(lu.value());
57  // cond::Time_t itime = (cond::Time_t)(iEvent.time().value()) ; // use this for timestamp
58 
59  edm::LogInfo("WriteCTPPSBeamParameters::analyze")
60  << "cond::Time_t ilumi = " << ilumi << " = "
61  << boost::posix_time::to_iso_extended_string(cond::time::to_boost(ilumi)) << "\n";
62 
63  // Write to database or sqlite file
65  if (poolDbService.isAvailable())
66  poolDbService->writeOneIOV(beamParam, ilumi, "CTPPSBeamParametersRcd");
67  else
68  throw std::runtime_error("PoolDBService required.");
69 }
70 
71 //define this as a plug-in
void analyze(const edm::Event &, const edm::EventSetup &) override
LuminosityBlockNumber_t luminosityBlock() const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
WriteCTPPSBeamParameters(const edm::ParameterSet &)
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd > tokenBeamParameters_
~WriteCTPPSBeamParameters() override=default
int iEvent
Definition: GenABIO.cc:224
unsigned long long Time_t
Definition: Time.h:14
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Info, false > LogInfo
LuminosityBlockID id() const
bool isAvailable() const
Definition: Service.h:40
boost::posix_time::ptime to_boost(Time_t iValue)