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