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 
53 
54  // Pointer for the conditions data object
55  const CTPPSBeamParameters* p = bp.product();
56 
57  // Using "lumiid" as IOV
58  const edm::LuminosityBlock& iLBlock = iEvent.getLuminosityBlock();
59  edm::LuminosityBlockID lu(iLBlock.run(), iLBlock.id().luminosityBlock());
60  cond::Time_t ilumi = (cond::Time_t)(lu.value());
61  // cond::Time_t itime = (cond::Time_t)(iEvent.time().value()) ; // use this for timestamp
62 
63  edm::LogInfo("WriteCTPPSBeamParameters::analyze")
64  << "cond::Time_t ilumi = " << ilumi << " = "
65  << boost::posix_time::to_iso_extended_string(cond::time::to_boost(ilumi)) << "\n";
66 
67  // Write to database or sqlite file
69  if (poolDbService.isAvailable())
70  poolDbService->writeOne(p, ilumi, "CTPPSBeamParametersRcd");
71  // poolDbService->writeOne( p, poolDbService->currentTime(), "CTPPSBeamParametersRcd" );
72  else
73  throw std::runtime_error("PoolDBService required.");
74 }
75 
76 //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
WriteCTPPSBeamParameters
Definition: WriteCTPPSBeamParameters.cc:36
edm::LuminosityBlockBase::run
RunNumber_t run() const
Definition: LuminosityBlockBase.h:42
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
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
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:51
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::EventSetup
Definition: EventSetup.h:58
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd >
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:63
EventSetup.h
edm::EDConsumerBase::esConsumes
auto esConsumes()
Definition: EDConsumerBase.h:206
ParameterSet.h
edm::Event
Definition: Event.h:73
WriteCTPPSBeamParameters::tokenBeamParameters_
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd > tokenBeamParameters_
Definition: WriteCTPPSBeamParameters.cc:46