Skip to content

Commit

Permalink
set SigmaX and SigmaY from LPC-like calculation in BetaFunc case
Browse files Browse the repository at this point in the history
  • Loading branch information
francescobrivio committed Nov 1, 2023
1 parent b9a4b4c commit a773608
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
8 changes: 4 additions & 4 deletions CondFormats/BeamSpotObjects/interface/SimBeamSpotObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class SimBeamSpotObjects {
fMeanX = 0.0;
fMeanY = 0.0;
fMeanZ = 0.0;
fSigmaX = 0.0;
fSigmaY = 0.0;
fSigmaX = -1.0;
fSigmaY = -1.0;
fSigmaZ = 0.0;
fbetastar = 0.0;
femittance = 0.0;
Expand All @@ -56,8 +56,8 @@ class SimBeamSpotObjects {
void setMeanY(double val) { fMeanY = val; }
void setMeanZ(double val) { fMeanZ = val; }
/// set sigmaX, sigmaY, sigmaZ
void setSigmaX(double val) { fSigmaX = val; }
void setSigmaY(double val) { fSigmaY = val; }
void setSigmaX(double val);
void setSigmaY(double val);
void setSigmaZ(double val) { fSigmaZ = val; }
/// set BetaStar and Emittance
void setBetaStar(double val) { fbetastar = val; }
Expand Down
21 changes: 21 additions & 0 deletions CondFormats/BeamSpotObjects/src/SimBeamSpotObjects.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
#include "CondFormats/BeamSpotObjects/interface/SimBeamSpotObjects.h"

#include <cmath>
#include <iostream>

// Set SigmaX and SigmaY:
// - from value in case of Gaussian Smearing
// - from LPC-like calculation in case of BetaFunc Smearing
void SimBeamSpotObjects::setSigmaX(double val) {
if (val >= 0.) { // Gaussian smearing
fSigmaX = val;
} else { // BetaFunc smearing
fSigmaX = (1 / std::sqrt(2)) * std::sqrt(femittance * fbetastar);
}
}

void SimBeamSpotObjects::setSigmaY(double val) {
if (val >= 0.) { // Gaussian smearing
fSigmaY = val;
} else { // BetaFunc smearing
fSigmaY = (1 / std::sqrt(2)) * std::sqrt(femittance * fbetastar);
}
}

// Printout SimBeamSpotObjects
void SimBeamSpotObjects::print(std::stringstream& ss) const {
ss << "-----------------------------------------------------\n"
<< " Sim Beam Spot Data\n\n"
Expand Down
8 changes: 4 additions & 4 deletions CondTools/BeamSpot/plugins/BeamProfile2DBWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ BeamProfile2DBWriter::BeamProfile2DBWriter(const edm::ParameterSet& iConfig)
beamSpot_.setMeanX(iConfig.getParameter<double>("MeanX"));
beamSpot_.setMeanY(iConfig.getParameter<double>("MeanY"));
beamSpot_.setMeanZ(iConfig.getParameter<double>("MeanZ"));
beamSpot_.setSigmaX(iConfig.getParameter<double>("SigmaX"));
beamSpot_.setSigmaY(iConfig.getParameter<double>("SigmaY"));
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"));
beamSpot_.setSigmaX(iConfig.getParameter<double>("SigmaX"));
beamSpot_.setSigmaY(iConfig.getParameter<double>("SigmaY"));
}

//
Expand Down Expand Up @@ -99,8 +99,8 @@ void BeamProfile2DBWriter::fillDescriptions(edm::ConfigurationDescriptions& desc
desc.add<double>("MeanX", 0.0)->setComment("in cm");
desc.add<double>("MeanY", 0.0)->setComment("in cm");
desc.add<double>("MeanZ", 0.0)->setComment("in cm");
desc.add<double>("SigmaX", 0.0)->setComment("in cm");
desc.add<double>("SigmaY", 0.0)->setComment("in cm");
desc.add<double>("SigmaX", -1.0)->setComment("in cm");
desc.add<double>("SigmaY", -1.0)->setComment("in cm");
desc.add<double>("SigmaZ", 0.0)->setComment("in cm");
desc.add<double>("BetaStar", 0.0)->setComment("in cm");
desc.add<double>("Emittance", 0.0)->setComment("in cm");
Expand Down
11 changes: 11 additions & 0 deletions CondTools/BeamSpot/test/BeamProfile2DBWriter_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,22 @@
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))

from CondTools.BeamSpot.beamProfile2DBWriter_cfi import beamProfile2DBWriter
# For the BetaFunc smearing (realistic Beamspot) set the following parameters:
# - X0, Y0, Z0, SigmaZ, BetaStar, Emittance
process.BeamProfile2DBWriter = beamProfile2DBWriter.clone(X0 = 0.0458532,
Y0 = -0.016966,
Z0 = -0.074992,
SigmaZ = 3.6,
BetaStar = 30.0,
Emittance = 3.931e-8,)

# For the Gaussian smearing (ideal Beamspot) set the following parameters:
# - MeanX, MeanY, MeanZ, SigmaX, SigmaY, SigmaZ
#process.BeamProfile2DBWriter = beamProfile2DBWriter.clone(MeanX = 0.0,
# MeanY = 0.0,
# MeanZ = 0.0,
# SigmaX = 0.0015,
# SigmaY = 0.0015,
# SigmaZ = 3.6,)

process.p = cms.Path(process.BeamProfile2DBWriter)

0 comments on commit a773608

Please sign in to comment.