Skip to content

Commit

Permalink
armonize SimBeamSpotObjects units
Browse files Browse the repository at this point in the history
  • Loading branch information
francescobrivio committed Jun 13, 2023
1 parent 68fbaac commit ad63263
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
29 changes: 11 additions & 18 deletions CondTools/BeamSpot/plugins/BeamProfile2DB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,20 @@ class BeamProfile2DB : public edm::global::EDAnalyzer<> {
SimBeamSpotObjects beamSpot_;
};

namespace {
SimBeamSpotObjects read(const edm::ParameterSet& p) {
SimBeamSpotObjects ret;
ret.setX(p.getParameter<double>("X0") * cm);
ret.setY(p.getParameter<double>("Y0") * cm);
ret.setZ(p.getParameter<double>("Z0") * cm);
ret.setSigmaZ(p.getParameter<double>("SigmaZ") * cm);
ret.setAlpha(p.getParameter<double>("Alpha") * radian);
ret.setPhi(p.getParameter<double>("Phi") * radian);
ret.setBetaStar(p.getParameter<double>("BetaStar") * cm);
ret.setEmittance(p.getParameter<double>("Emittance") * cm); // this is not the normalized emittance
ret.setTimeOffset(p.getParameter<double>("TimeOffset") * ns * c_light); // HepMC time units are mm
return ret;
}

} // namespace

//
// constructors and destructor
//
BeamProfile2DB::BeamProfile2DB(const edm::ParameterSet& iConfig) : beamSpot_(read(iConfig)) {}
BeamProfile2DB::BeamProfile2DB(const edm::ParameterSet& iConfig) {
beamSpot_.setX(iConfig.getParameter<double>("X0"));
beamSpot_.setY(iConfig.getParameter<double>("Y0"));
beamSpot_.setZ(iConfig.getParameter<double>("Z0"));
beamSpot_.setSigmaZ(iConfig.getParameter<double>("SigmaZ"));
beamSpot_.setAlpha(iConfig.getParameter<double>("Alpha"));
beamSpot_.setPhi(iConfig.getParameter<double>("Phi"));
beamSpot_.setBetaStar(iConfig.getParameter<double>("BetaStar"));
beamSpot_.setEmittance(iConfig.getParameter<double>("Emittance"));
beamSpot_.setTimeOffset(iConfig.getParameter<double>("TimeOffset"));
}

BeamProfile2DB::~BeamProfile2DB() = default;

Expand Down
19 changes: 10 additions & 9 deletions IOMC/EventVertexGenerators/src/BetafuncEvtVtxGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ BetafuncEvtVtxGenerator::BetafuncEvtVtxGenerator(const edm::ParameterSet& p) : B
}
}
if (readDB_) {
// NOTE: this is currently watching LS transitions, while it should watch Run transitions,
// even though in reality there is no Run Dependent MC (yet) in CMS
beamToken_ = esConsumes<SimBeamSpotObjects, SimBeamSpotObjectsRcd, edm::Transition::BeginLuminosityBlock>();
}
}
Expand All @@ -62,15 +64,14 @@ void BetafuncEvtVtxGenerator::update(const edm::EventSetup& iEventSetup) {
if (readDB_ && parameterWatcher_.check(iEventSetup)) {
edm::ESHandle<SimBeamSpotObjects> beamhandle = iEventSetup.getHandle(beamToken_);

fX0 = beamhandle->x();
fY0 = beamhandle->y();
fZ0 = beamhandle->z();
// falpha=beamhandle->alpha();
fSigmaZ = beamhandle->sigmaZ();
fTimeOffset = beamhandle->timeOffset();
fbetastar = beamhandle->betaStar();
femittance = beamhandle->emittance();
setBoost(beamhandle->alpha(), beamhandle->phi());
fX0 = beamhandle->x() * cm;
fY0 = beamhandle->y() * cm;
fZ0 = beamhandle->z() * cm;
fSigmaZ = beamhandle->sigmaZ() * cm;
fTimeOffset = beamhandle->timeOffset() * ns * c_light; // HepMC time units are mm
fbetastar = beamhandle->betaStar() * cm;
femittance = beamhandle->emittance() * cm;
setBoost(beamhandle->alpha() * radian, beamhandle->phi() * radian);
}
}

Expand Down

0 comments on commit ad63263

Please sign in to comment.