File indexing completed on 2024-07-05 03:36:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <memory>
0020
0021
0022 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0023 #include "CondFormats/BeamSpotObjects/interface/SimBeamSpotHLLHCObjects.h"
0024 #include "FWCore/Framework/interface/Event.h"
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "FWCore/ServiceRegistry/interface/Service.h"
0030
0031 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0032 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0033
0034
0035
0036
0037 class BeamProfileHLLHC2DBWriter : public edm::global::EDAnalyzer<> {
0038 public:
0039 explicit BeamProfileHLLHC2DBWriter(const edm::ParameterSet&);
0040 ~BeamProfileHLLHC2DBWriter() override = default;
0041
0042 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0043
0044 private:
0045 void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const override;
0046 void endJob() override;
0047
0048
0049 const std::string recordName_;
0050 SimBeamSpotHLLHCObjects beamSpot_;
0051 };
0052
0053
0054 BeamProfileHLLHC2DBWriter::BeamProfileHLLHC2DBWriter(const edm::ParameterSet& iConfig)
0055 : recordName_(iConfig.getParameter<std::string>("recordName")) {
0056 beamSpot_.setMeanX(iConfig.getParameter<double>("MeanX"));
0057 beamSpot_.setMeanY(iConfig.getParameter<double>("MeanY"));
0058 beamSpot_.setMeanZ(iConfig.getParameter<double>("MeanZ"));
0059 beamSpot_.setEProton(iConfig.getParameter<double>("EProton"));
0060 beamSpot_.setCrabFrequency(iConfig.getParameter<double>("CrabFrequency"));
0061 beamSpot_.setRF800(iConfig.getParameter<double>("RF800"));
0062 beamSpot_.setCrossingAngle(iConfig.getParameter<double>("CrossingAngle"));
0063 beamSpot_.setCrabbingAngleCrossing(iConfig.getParameter<double>("CrabbingAngleCrossing"));
0064 beamSpot_.setCrabbingAngleSeparation(iConfig.getParameter<double>("CrabbingAngleSeparation"));
0065 beamSpot_.setBetaCrossingPlane(iConfig.getParameter<double>("BetaCrossingPlane"));
0066 beamSpot_.setBetaSeparationPlane(iConfig.getParameter<double>("BetaSeparationPlane"));
0067 beamSpot_.setHorizontalEmittance(iConfig.getParameter<double>("HorizontalEmittance"));
0068 beamSpot_.setVerticalEmittance(iConfig.getParameter<double>("VerticalEmittance"));
0069 beamSpot_.setBunchLength(iConfig.getParameter<double>("BunchLength"));
0070 beamSpot_.setTimeOffset(iConfig.getParameter<double>("TimeOffset"));
0071 }
0072
0073
0074 void BeamProfileHLLHC2DBWriter::analyze(edm::StreamID, const edm::Event& iEvent, const edm::EventSetup& iSetup) const {}
0075
0076
0077 void BeamProfileHLLHC2DBWriter::endJob() {
0078 edm::Service<cond::service::PoolDBOutputService> poolDbService;
0079 poolDbService->createOneIOV<SimBeamSpotHLLHCObjects>(beamSpot_, poolDbService->beginOfTime(), recordName_);
0080 }
0081
0082
0083 void BeamProfileHLLHC2DBWriter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0084 edm::ParameterSetDescription desc;
0085 desc.add<std::string>("recordName", "SimBeamSpotHLLHCObjectsRcd")
0086 ->setComment("name of the record to use for the PoolDBOutputService");
0087 desc.add<double>("MeanX", 0.0)->setComment("in cm");
0088 desc.add<double>("MeanY", 0.0)->setComment("in cm");
0089 desc.add<double>("MeanZ", 0.0)->setComment("in cm");
0090 desc.add<double>("EProton", 0.0)->setComment("in GeV");
0091 desc.add<double>("CrabFrequency", 0.0)->setComment("in MHz");
0092 desc.add<double>("RF800", 0.0)->setComment("800 MHz RF?");
0093 desc.add<double>("CrossingAngle", 0.0)->setComment("in urad");
0094 desc.add<double>("CrabbingAngleCrossing", 0.0)->setComment("in urad");
0095 desc.add<double>("CrabbingAngleSeparation", 0.0)->setComment("in urad");
0096 desc.add<double>("BetaCrossingPlane", 0.0)->setComment("in m");
0097 desc.add<double>("BetaSeparationPlane", 0.0)->setComment("in m");
0098 desc.add<double>("HorizontalEmittance", 0.0)->setComment("in mm");
0099 desc.add<double>("VerticalEmittance", 0.0)->setComment("in mm");
0100 desc.add<double>("BunchLength", 0.0)->setComment("in m");
0101 desc.add<double>("TimeOffset", 0.0)->setComment("in ns");
0102 descriptions.addWithDefaultLabel(desc);
0103 }
0104
0105
0106 DEFINE_FWK_MODULE(BeamProfileHLLHC2DBWriter);