CMS 3D CMS Logo

BeamProfile2DBWriter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: BeamProfile2DBWriter
4 // Class: BeamProfile2DBWriter
5 //
13 //
14 // Original Author: Jean-Roch Vlimant,40 3-A28,+41227671209,
15 // Created: Fri Jan 6 14:49:42 CET 2012
16 //
17 // Updated; Francesco Brivio, June 11, 2023
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
32 
33 #include <CLHEP/Units/SystemOfUnits.h>
34 #include <CLHEP/Units/GlobalPhysicalConstants.h>
35 
36 //
37 // class declaration
38 //
40 public:
41  explicit BeamProfile2DBWriter(const edm::ParameterSet&);
42  ~BeamProfile2DBWriter() override = default;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46 private:
47  void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const override;
48  void endJob() override;
49 
50  // ----------member data ---------------------------
53 };
54 
55 //
56 // constructors and destructor
57 //
59  : recordName_(iConfig.getParameter<std::string>("recordName")) {
60  beamSpot_.setX(iConfig.getParameter<double>("X0"));
61  beamSpot_.setY(iConfig.getParameter<double>("Y0"));
62  beamSpot_.setZ(iConfig.getParameter<double>("Z0"));
63  beamSpot_.setMeanX(iConfig.getParameter<double>("MeanX"));
64  beamSpot_.setMeanY(iConfig.getParameter<double>("MeanY"));
65  beamSpot_.setMeanZ(iConfig.getParameter<double>("MeanZ"));
66  beamSpot_.setSigmaX(iConfig.getParameter<double>("SigmaX"));
67  beamSpot_.setSigmaY(iConfig.getParameter<double>("SigmaY"));
68  beamSpot_.setSigmaZ(iConfig.getParameter<double>("SigmaZ"));
69  beamSpot_.setAlpha(iConfig.getParameter<double>("Alpha"));
70  beamSpot_.setPhi(iConfig.getParameter<double>("Phi"));
71  beamSpot_.setBetaStar(iConfig.getParameter<double>("BetaStar"));
72  beamSpot_.setEmittance(iConfig.getParameter<double>("Emittance"));
73  beamSpot_.setTimeOffset(iConfig.getParameter<double>("TimeOffset"));
74 }
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called for each event ------------
82 
83 // ------------ method called once each job just after ending the event loop ------------
86  poolDbService->createOneIOV<SimBeamSpotObjects>(beamSpot_, poolDbService->beginOfTime(), recordName_);
87 }
88 
89 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
91  //The following says we do not know what parameters are allowed so do no validation
92  // Please change this to state exactly what you do use, even if it is no parameters
94  desc.add<std::string>("recordName", "SimBeamSpotObjectsRcd")
95  ->setComment("name of the record to use for the PoolDBOutputService");
96  desc.add<double>("X0", 0.0)->setComment("in cm");
97  desc.add<double>("Y0", 0.0)->setComment("in cm");
98  desc.add<double>("Z0", 0.0)->setComment("in cm");
99  desc.add<double>("MeanX", 0.0)->setComment("in cm");
100  desc.add<double>("MeanY", 0.0)->setComment("in cm");
101  desc.add<double>("MeanZ", 0.0)->setComment("in cm");
102  desc.add<double>("SigmaX", -1.0)->setComment("in cm");
103  desc.add<double>("SigmaY", -1.0)->setComment("in cm");
104  desc.add<double>("SigmaZ", 0.0)->setComment("in cm");
105  desc.add<double>("BetaStar", 0.0)->setComment("in cm");
106  desc.add<double>("Emittance", 0.0)->setComment("in cm");
107  desc.add<double>("Alpha", 0.0)->setComment("in radians");
108  desc.add<double>("Phi", 0.0)->setComment("in radians");
109  desc.add<double>("TimeOffset", 0.0)->setComment("in ns");
110  descriptions.addWithDefaultLabel(desc);
111 }
112 
113 //define this as a plug-in
~BeamProfile2DBWriter() override=default
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void setPhi(double val)
set Phi, Alpha and TimeOffset
void setZ(double val)
void setY(double val)
void setAlpha(double val)
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
void setBetaStar(double val)
set BetaStar and Emittance
int iEvent
Definition: GenABIO.cc:224
void setSigmaZ(double val)
void setMeanZ(double val)
void setEmittance(double val)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SimBeamSpotObjects beamSpot_
const std::string recordName_
void setSigmaY(double val)
void setMeanX(double val)
set meanX, meanY, meanZ
void setTimeOffset(double val)
void analyze(edm::StreamID, const edm::Event &, const edm::EventSetup &) const override
BeamProfile2DBWriter(const edm::ParameterSet &)
void setSigmaX(double val)
set sigmaX, sigmaY, sigmaZ
void setX(double val)
set X, Y, Z positions
void setMeanY(double val)