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/GlobalSystemOfUnits.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_.setSigmaZ(iConfig.getParameter<double>("SigmaZ"));
64  beamSpot_.setAlpha(iConfig.getParameter<double>("Alpha"));
65  beamSpot_.setPhi(iConfig.getParameter<double>("Phi"));
66  beamSpot_.setBetaStar(iConfig.getParameter<double>("BetaStar"));
67  beamSpot_.setEmittance(iConfig.getParameter<double>("Emittance"));
68  beamSpot_.setTimeOffset(iConfig.getParameter<double>("TimeOffset"));
69 }
70 
71 //
72 // member functions
73 //
74 
75 // ------------ method called for each event ------------
77 
78 // ------------ method called once each job just after ending the event loop ------------
81  poolDbService->createOneIOV<SimBeamSpotObjects>(beamSpot_, poolDbService->beginOfTime(), recordName_);
82 }
83 
84 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
86  //The following says we do not know what parameters are allowed so do no validation
87  // Please change this to state exactly what you do use, even if it is no parameters
89  desc.add<std::string>("recordName", "SimBeamSpotObjectsRcd")
90  ->setComment("name of the record to use for the PoolDBOutputService");
91  desc.add<double>("X0")->setComment("in cm");
92  desc.add<double>("Y0")->setComment("in cm");
93  desc.add<double>("Z0")->setComment("in cm");
94  desc.add<double>("SigmaZ")->setComment("in cm");
95  desc.add<double>("BetaStar")->setComment("in cm");
96  desc.add<double>("Emittance")->setComment("in cm");
97  desc.add<double>("Alpha", 0.0)->setComment("in radians");
98  desc.add<double>("Phi", 0.0)->setComment("in radians");
99  desc.add<double>("TimeOffset", 0.0)->setComment("in ns");
100  descriptions.addWithDefaultLabel(desc);
101 }
102 
103 //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:303
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)
set sigmaZ
void setEmittance(double val)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SimBeamSpotObjects beamSpot_
const std::string recordName_
void setTimeOffset(double val)
void analyze(edm::StreamID, const edm::Event &, const edm::EventSetup &) const override
BeamProfile2DBWriter(const edm::ParameterSet &)
void setX(double val)
set X, Y, Z positions