Skip to content

Commit 3f59f88

Browse files
authored
Merge pull request cms-sw#33916 from Dr15Jones/removeParameterSetFromSimBeamSpotObjects
Removed ParameterSet usage from SimBeamSpotObjects
2 parents 5dc19ce + 7b1d222 commit 3f59f88

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<use name="CondFormats/Serialization"/>
22
<use name="FWCore/Utilities"/>
3-
<use name="FWCore/ParameterSet"/>
43
<use name="CondFormats/Common"/>
5-
<use name="CLHEP"/>
64
<export>
75
<lib name="1"/>
86
</export>

CondFormats/BeamSpotObjects/interface/SimBeamSpotObjects.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include "CondFormats/Serialization/interface/Serializable.h"
1111

1212
#include <sstream>
13-
#include "CLHEP/Units/GlobalSystemOfUnits.h"
14-
#include "CLHEP/Units/GlobalPhysicalConstants.h"
15-
16-
#include "FWCore/ParameterSet/interface/ParameterSet.h"
1713

1814
class SimBeamSpotObjects {
1915
public:
@@ -28,18 +24,6 @@ class SimBeamSpotObjects {
2824

2925
void print(std::stringstream& ss) const;
3026

31-
void read(edm::ParameterSet& p) {
32-
fX0 = p.getParameter<double>("X0") * cm;
33-
fY0 = p.getParameter<double>("Y0") * cm;
34-
fZ0 = p.getParameter<double>("Z0") * cm;
35-
fSigmaZ = p.getParameter<double>("SigmaZ") * cm;
36-
fAlpha = p.getParameter<double>("Alpha") * radian;
37-
fPhi = p.getParameter<double>("Phi") * radian;
38-
fbetastar = p.getParameter<double>("BetaStar") * cm;
39-
femittance = p.getParameter<double>("Emittance") * cm; // this is not the normalized emittance
40-
fTimeOffset = p.getParameter<double>("TimeOffset") * ns * c_light; // HepMC time units are mm
41-
}
42-
4327
COND_SERIALIZABLE;
4428
};
4529

IOMC/EventVertexGenerators/src/BeamProfile2DB.cc

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
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"
@@ -32,11 +33,14 @@
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<> {
4044
public:
4145
explicit BeamProfile2DB(const edm::ParameterSet&);
4246
~BeamProfile2DB() override;
@@ -45,13 +49,29 @@ class BeamProfile2DB : public edm::EDAnalyzer {
4549

4650
private:
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

7288
BeamProfile2DB::~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 ------------
85101
void BeamProfile2DB::beginJob() {}
86102

87103
// ------------ method called once each job just after ending the event loop ------------
88104
void 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 ------------
99111
void 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

Comments
 (0)