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:
39  ~WriteCTPPSBeamParameters() override = default;
40 
41 private:
42  void analyze(const edm::Event&, const edm::EventSetup&) override;
43 };
44 
45 //---------------------------------------------------------------------------------------
46 
49  iSetup.get<CTPPSBeamParametersRcd>().get(bp);
50 
51  // Pointer for the conditions data object
52  const CTPPSBeamParameters* p = bp.product();
53 
54  // Using "lumiid" as IOV
55  const edm::LuminosityBlock& iLBlock = iEvent.getLuminosityBlock();
56  edm::LuminosityBlockID lu(iLBlock.run(), iLBlock.id().luminosityBlock());
57  cond::Time_t ilumi = (cond::Time_t)(lu.value());
58  // cond::Time_t itime = (cond::Time_t)(iEvent.time().value()) ; // use this for timestamp
59 
60  edm::LogInfo("WriteCTPPSBeamParameters::analyze")
61  << "cond::Time_t ilumi = " << ilumi << " = "
62  << boost::posix_time::to_iso_extended_string(cond::time::to_boost(ilumi)) << "\n";
63 
64  // Write to database or sqlite file
66  if (poolDbService.isAvailable())
67  poolDbService->writeOne(p, ilumi, "CTPPSBeamParametersRcd");
68  // poolDbService->writeOne( p, poolDbService->currentTime(), "CTPPSBeamParametersRcd" );
69  else
70  throw std::runtime_error("PoolDBService required.");
71 }
72 
73 //define this as a plug-in
LuminosityBlockID id() const
void analyze(const edm::Event &, const edm::EventSetup &) override
WriteCTPPSBeamParameters(const edm::ParameterSet &)
~WriteCTPPSBeamParameters() override=default
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
unsigned long long Time_t
Definition: Time.h:14
bool isAvailable() const
Definition: Service.h:40
RunNumber_t run() const
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:98
LuminosityBlockNumber_t luminosityBlock() const
T get() const
Definition: EventSetup.h:73
T const * product() const
Definition: ESHandle.h:86
boost::posix_time::ptime to_boost(Time_t iValue)