2121
2222// user include files
2323#include " FWCore/Framework/interface/Frameworkfwd.h"
24- #include " FWCore/Framework/interface/EDAnalyzer.h"
24+ #include " FWCore/Framework/interface/global/EDAnalyzer.h"
25+ #include " FWCore/ParameterSet/interface/ParameterSet.h"
2526
2627#include " FWCore/Framework/interface/Event.h"
2728#include " FWCore/Framework/interface/MakerMacros.h"
3233#include " CondCore/DBOutputService/interface/PoolDBOutputService.h"
3334#include " CondFormats/BeamSpotObjects/interface/SimBeamSpotObjects.h"
3435
36+ #include " CLHEP/Units/GlobalSystemOfUnits.h"
37+ #include " CLHEP/Units/GlobalPhysicalConstants.h"
38+
3539//
3640// class declaration
3741//
3842
39- class BeamProfile2DB : public edm ::EDAnalyzer {
43+ class BeamProfile2DB : public edm ::global:: EDAnalyzer<> {
4044public:
4145 explicit BeamProfile2DB (const edm::ParameterSet&);
4246 ~BeamProfile2DB () override ;
@@ -45,13 +49,29 @@ class BeamProfile2DB : public edm::EDAnalyzer {
4549
4650private:
4751 void beginJob () override ;
48- void analyze (const edm::Event&, const edm::EventSetup&) override ;
52+ void analyze (edm::StreamID, const edm::Event&, const edm::EventSetup&) const override ;
4953 void endJob () override ;
5054
5155 // ----------member data ---------------------------
52- edm::ParameterSet config_ ;
56+ SimBeamSpotObjects beamSpot_ ;
5357};
5458
59+ namespace {
60+ SimBeamSpotObjects read (const edm::ParameterSet& p) {
61+ SimBeamSpotObjects ret;
62+ ret.fX0 = p.getParameter <double >(" X0" ) * cm;
63+ ret.fY0 = p.getParameter <double >(" Y0" ) * cm;
64+ ret.fZ0 = p.getParameter <double >(" Z0" ) * cm;
65+ ret.fSigmaZ = p.getParameter <double >(" SigmaZ" ) * cm;
66+ ret.fAlpha = p.getParameter <double >(" Alpha" ) * radian;
67+ ret.fPhi = p.getParameter <double >(" Phi" ) * radian;
68+ ret.fbetastar = p.getParameter <double >(" BetaStar" ) * cm;
69+ ret.femittance = p.getParameter <double >(" Emittance" ) * cm; // this is not the normalized emittance
70+ ret.fTimeOffset = p.getParameter <double >(" TimeOffset" ) * ns * c_light; // HepMC time units are mm
71+ return ret;
72+ }
73+
74+ } // namespace
5575//
5676// constants, enums and typedefs
5777//
@@ -63,11 +83,7 @@ class BeamProfile2DB : public edm::EDAnalyzer {
6383//
6484// constructors and destructor
6585//
66- BeamProfile2DB::BeamProfile2DB (const edm::ParameterSet& iConfig)
67-
68- {
69- config_ = iConfig;
70- }
86+ BeamProfile2DB::BeamProfile2DB (const edm::ParameterSet& iConfig) : beamSpot_(read(iConfig)) {}
7187
7288BeamProfile2DB::~BeamProfile2DB () {
7389 // do anything here that needs to be done at desctruction time
@@ -79,28 +95,32 @@ BeamProfile2DB::~BeamProfile2DB() {
7995//
8096
8197// ------------ method called for each event ------------
82- void BeamProfile2DB::analyze (const edm::Event& iEvent, const edm::EventSetup& iSetup) {}
98+ void BeamProfile2DB::analyze (edm::StreamID, const edm::Event& iEvent, const edm::EventSetup& iSetup) const {}
8399
84100// ------------ method called once each job just before starting event loop ------------
85101void BeamProfile2DB::beginJob () {}
86102
87103// ------------ method called once each job just after ending the event loop ------------
88104void BeamProfile2DB::endJob () {
89105 edm::Service<cond::service::PoolDBOutputService> poolDbService;
90- SimBeamSpotObjects* beam = new SimBeamSpotObjects ();
91-
92- beam->read (config_);
93-
94106 poolDbService->createNewIOV <SimBeamSpotObjects>(
95- beam , poolDbService->beginOfTime (), poolDbService->endOfTime (), " SimBeamSpotObjectsRcd" );
107+ &beamSpot_ , poolDbService->beginOfTime (), poolDbService->endOfTime (), " SimBeamSpotObjectsRcd" );
96108}
97109
98110// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
99111void BeamProfile2DB::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
100112 // The following says we do not know what parameters are allowed so do no validation
101113 // Please change this to state exactly what you do use, even if it is no parameters
102114 edm::ParameterSetDescription desc;
103- desc.setUnknown ();
115+ desc.add <double >(" X0" )->setComment (" in cm" );
116+ desc.add <double >(" Y0" )->setComment (" in cm" );
117+ desc.add <double >(" Z0" )->setComment (" in cm" );
118+ desc.add <double >(" SigmaZ" )->setComment (" in cm" );
119+ desc.add <double >(" BetaStar" )->setComment (" in cm" );
120+ desc.add <double >(" Emittance" )->setComment (" in cm" );
121+ desc.add <double >(" Alpha" )->setComment (" in radians" );
122+ desc.add <double >(" Phi" )->setComment (" in radians" );
123+ desc.add <double >(" TimeOffset" )->setComment (" in ns" );
104124 descriptions.addDefault (desc);
105125}
106126
0 commit comments