From ad63263ea65605a2c5857161fa0a90930cf7d6f9 Mon Sep 17 00:00:00 2001 From: francescobrivio <francesco.brivio@cern.ch> Date: Sun, 11 Jun 2023 12:55:11 +0200 Subject: [PATCH] armonize SimBeamSpotObjects units --- CondTools/BeamSpot/plugins/BeamProfile2DB.cc | 29 +++++++------------ .../src/BetafuncEvtVtxGenerator.cc | 19 ++++++------ 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/CondTools/BeamSpot/plugins/BeamProfile2DB.cc b/CondTools/BeamSpot/plugins/BeamProfile2DB.cc index ad945628b3ea3..cced0908f064f 100644 --- a/CondTools/BeamSpot/plugins/BeamProfile2DB.cc +++ b/CondTools/BeamSpot/plugins/BeamProfile2DB.cc @@ -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; diff --git a/IOMC/EventVertexGenerators/src/BetafuncEvtVtxGenerator.cc b/IOMC/EventVertexGenerators/src/BetafuncEvtVtxGenerator.cc index 4e9485ee5371d..b09af7a6337ed 100644 --- a/IOMC/EventVertexGenerators/src/BetafuncEvtVtxGenerator.cc +++ b/IOMC/EventVertexGenerators/src/BetafuncEvtVtxGenerator.cc @@ -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>(); } } @@ -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); } }