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
CTPPSBeamParameters
Definition: CTPPSBeamParameters.h:22
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
CTPPSBeamParameters.h
EDAnalyzer.h
CTPPSBeamParametersRcd.h
cond::time::to_boost
boost::posix_time::ptime to_boost(Time_t iValue)
Definition: TimeConversions.h:39
ESHandle.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::LogInfo
Definition: MessageLogger.h:254
WriteCTPPSBeamParameters
Definition: WriteCTPPSBeamParameters.cc:36
edm::LuminosityBlockBase::run
RunNumber_t run() const
Definition: LuminosityBlockBase.h:42
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
MakerMacros.h
PoolDBOutputService.h
WriteCTPPSBeamParameters::~WriteCTPPSBeamParameters
~WriteCTPPSBeamParameters() override=default
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
edm::ESHandle< CTPPSBeamParameters >
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
WriteCTPPSBeamParameters::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: WriteCTPPSBeamParameters.cc:47
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
edm::Service< cond::service::PoolDBOutputService >
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
CTPPSBeamParametersRcd
Definition: CTPPSBeamParametersRcd.h:14
Frameworkfwd.h
WriteCTPPSBeamParameters::WriteCTPPSBeamParameters
WriteCTPPSBeamParameters(const edm::ParameterSet &)
Definition: WriteCTPPSBeamParameters.cc:38
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:57
EventSetup.h
ParameterSet.h
edm::Event
Definition: Event.h:73