CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
BetafuncEvtVtxGenerator Class Reference

#include <BetafuncEvtVtxGenerator.h>

Inheritance diagram for BetafuncEvtVtxGenerator:
BaseEvtVtxGenerator edm::stream::EDProducer<>

Public Member Functions

void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
 BetafuncEvtVtxGenerator (const edm::ParameterSet &p)
 
 BetafuncEvtVtxGenerator (const BetafuncEvtVtxGenerator &p)=delete
 
double BetaFunction (double z, double z0) const
 beta function More...
 
void betastar (double m=0)
 set beta_star More...
 
void emittance (double m=0)
 emittance (no the normalized) More...
 
TMatrixD const * GetInvLorentzBoost () const override
 
HepMC::FourVector newVertex (CLHEP::HepRandomEngine *) const override
 return a new event vertex More...
 
BetafuncEvtVtxGeneratoroperator= (const BetafuncEvtVtxGenerator &rhs)=delete
 
void sigmaZ (double s=1.0)
 set resolution in Z in cm More...
 
void X0 (double m=0)
 set mean in X in cm More...
 
void Y0 (double m=0)
 set mean in Y in cm More...
 
void Z0 (double m=0)
 set mean in Z in cm More...
 
 ~BetafuncEvtVtxGenerator () override=default
 
- Public Member Functions inherited from BaseEvtVtxGenerator
 BaseEvtVtxGenerator (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~BaseEvtVtxGenerator () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void setBoost (double alpha, double phi)
 
void update (const edm::EventSetup &iEventSetup)
 

Private Attributes

edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcdbeamToken_
 
TMatrixD boost_
 
double fbetastar
 
double femittance
 
double fSigmaZ
 
double fTimeOffset
 
double fX0
 
double fY0
 
double fZ0
 
edm::ESWatcher< SimBeamSpotObjectsRcdparameterWatcher_
 
bool readDB_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 32 of file BetafuncEvtVtxGenerator.h.

Constructor & Destructor Documentation

◆ BetafuncEvtVtxGenerator() [1/2]

BetafuncEvtVtxGenerator::BetafuncEvtVtxGenerator ( const edm::ParameterSet p)

Definition at line 29 of file BetafuncEvtVtxGenerator.cc.

References beamToken_, Exception, fbetastar, femittance, fSigmaZ, fTimeOffset, fX0, fY0, fZ0, AlCaHLTBitMon_ParallelJobs::p, readDB_, and setBoost().

29  : BaseEvtVtxGenerator(p), boost_(4, 4) {
30  readDB_ = p.getParameter<bool>("readDB");
31  if (!readDB_) {
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  fbetastar = p.getParameter<double>("BetaStar") * cm;
37  femittance = p.getParameter<double>("Emittance") * cm; // this is not the normalized emittance
38  fTimeOffset = p.getParameter<double>("TimeOffset") * ns * c_light; // HepMC distance units are in mm
39 
40  setBoost(p.getParameter<double>("Alpha") * radian, p.getParameter<double>("Phi") * radian);
41  if (fSigmaZ <= 0) {
42  throw cms::Exception("Configuration") << "Error in BetafuncEvtVtxGenerator: "
43  << "Illegal resolution in Z (SigmaZ is negative)";
44  }
45  }
46  if (readDB_) {
47  // NOTE: this is currently watching LS transitions, while it should watch Run transitions,
48  // even though in reality there is no Run Dependent MC (yet) in CMS
49  beamToken_ = esConsumes<SimBeamSpotObjects, SimBeamSpotObjectsRcd, edm::Transition::BeginLuminosityBlock>();
50  }
51 }
void setBoost(double alpha, double phi)
BaseEvtVtxGenerator(const edm::ParameterSet &)
edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcd > beamToken_

◆ BetafuncEvtVtxGenerator() [2/2]

BetafuncEvtVtxGenerator::BetafuncEvtVtxGenerator ( const BetafuncEvtVtxGenerator p)
delete

Copy constructor

◆ ~BetafuncEvtVtxGenerator()

BetafuncEvtVtxGenerator::~BetafuncEvtVtxGenerator ( )
overridedefault

Member Function Documentation

◆ beginLuminosityBlock()

void BetafuncEvtVtxGenerator::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  iEventSetup 
)
override

Definition at line 53 of file BetafuncEvtVtxGenerator.cc.

References update().

53  {
54  update(iEventSetup);
55 }
void update(const edm::EventSetup &iEventSetup)

◆ BetaFunction()

double BetafuncEvtVtxGenerator::BetaFunction ( double  z,
double  z0 
) const

beta function

Definition at line 93 of file BetafuncEvtVtxGenerator.cc.

References fbetastar, femittance, mathSSE::sqrt(), z, and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by newVertex().

◆ betastar()

void BetafuncEvtVtxGenerator::betastar ( double  m = 0)
inline

◆ emittance()

void BetafuncEvtVtxGenerator::emittance ( double  m = 0)
inline

◆ fillDescriptions()

void BetafuncEvtVtxGenerator::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 141 of file BetafuncEvtVtxGenerator.cc.

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

141  {
143  desc.add<double>("X0", 0.0)->setComment("in cm");
144  desc.add<double>("Y0", 0.0)->setComment("in cm");
145  desc.add<double>("Z0", 0.0)->setComment("in cm");
146  desc.add<double>("SigmaZ", 0.0)->setComment("in cm");
147  desc.add<double>("BetaStar", 0.0)->setComment("in cm");
148  desc.add<double>("Emittance", 0.0)->setComment("in cm");
149  desc.add<double>("Alpha", 0.0)->setComment("in radians");
150  desc.add<double>("Phi", 0.0)->setComment("in radians");
151  desc.add<double>("TimeOffset", 0.0)->setComment("in ns");
152  desc.add<edm::InputTag>("src");
153  desc.add<bool>("readDB");
154  descriptions.add("BetafuncEvtVtxGenerator", desc);
155 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ GetInvLorentzBoost()

TMatrixD const * BetafuncEvtVtxGenerator::GetInvLorentzBoost ( ) const
overridevirtual

This method - and the comment - is a left-over from COBRA-OSCAR time : return the last generated event vertex. If no vertex has been generated yet, a NULL pointer is returned.

Implements BaseEvtVtxGenerator.

Definition at line 139 of file BetafuncEvtVtxGenerator.cc.

References boost_.

139 { return &boost_; }

◆ newVertex()

HepMC::FourVector BetafuncEvtVtxGenerator::newVertex ( CLHEP::HepRandomEngine *  engine) const
overridevirtual

return a new event vertex

Implements BaseEvtVtxGenerator.

Definition at line 71 of file BetafuncEvtVtxGenerator.cc.

References BetaFunction(), fSigmaZ, fTimeOffset, fX0, fY0, fZ0, mathSSE::sqrt(), X, beamSpotPI::Y, and beamSpotPI::Z.

71  {
72  double X, Y, Z;
73 
74  double tmp_sigz = CLHEP::RandGaussQ::shoot(engine, 0., fSigmaZ);
75  Z = tmp_sigz + fZ0;
76 
77  double tmp_sigx = BetaFunction(Z, fZ0);
78  // need sqrt(2) for beamspot width relative to single beam width
79  tmp_sigx /= sqrt(2.0);
80  X = CLHEP::RandGaussQ::shoot(engine, 0., tmp_sigx) + fX0; // + Z*fdxdz ;
81 
82  double tmp_sigy = BetaFunction(Z, fZ0);
83  // need sqrt(2) for beamspot width relative to single beam width
84  tmp_sigy /= sqrt(2.0);
85  Y = CLHEP::RandGaussQ::shoot(engine, 0., tmp_sigy) + fY0; // + Z*fdydz;
86 
87  double tmp_sigt = CLHEP::RandGaussQ::shoot(engine, 0., fSigmaZ);
88  double T = tmp_sigt + fTimeOffset;
89 
90  return HepMC::FourVector(X, Y, Z, T);
91 }
double BetaFunction(double z, double z0) const
beta function
#define X(str)
Definition: MuonsGrabber.cc:38
T sqrt(T t)
Definition: SSEVec.h:19
long double T

◆ operator=()

BetafuncEvtVtxGenerator& BetafuncEvtVtxGenerator::operator= ( const BetafuncEvtVtxGenerator rhs)
delete

Copy assignment operator

◆ setBoost()

void BetafuncEvtVtxGenerator::setBoost ( double  alpha,
double  phi 
)
private

Definition at line 97 of file BetafuncEvtVtxGenerator.cc.

References simBeamSpotPI::alpha, boost_, funct::cos(), phi, funct::sin(), and funct::tan().

Referenced by BetafuncEvtVtxGenerator(), and update().

97  {
98  //boost_.ResizeTo(4,4);
99  //boost_ = new TMatrixD(4,4);
100  TMatrixD tmpboost(4, 4);
101 
102  //if ( (alpha_ == 0) && (phi_==0) ) { boost_->Zero(); return boost_; }
103 
104  // Lorentz boost to frame where the collision is head-on
105  // phi is the half crossing angle in the plane ZS
106  // alpha is the angle to the S axis from the X axis in the XY plane
107 
108  tmpboost(0, 0) = 1. / cos(phi);
109  tmpboost(0, 1) = -cos(alpha) * sin(phi);
110  tmpboost(0, 2) = -tan(phi) * sin(phi);
111  tmpboost(0, 3) = -sin(alpha) * sin(phi);
112  tmpboost(1, 0) = -cos(alpha) * tan(phi);
113  tmpboost(1, 1) = 1.;
114  tmpboost(1, 2) = cos(alpha) * tan(phi);
115  tmpboost(1, 3) = 0.;
116  tmpboost(2, 0) = 0.;
117  tmpboost(2, 1) = -cos(alpha) * sin(phi);
118  tmpboost(2, 2) = cos(phi);
119  tmpboost(2, 3) = -sin(alpha) * sin(phi);
120  tmpboost(3, 0) = -sin(alpha) * tan(phi);
121  tmpboost(3, 1) = 0.;
122  tmpboost(3, 2) = sin(alpha) * tan(phi);
123  tmpboost(3, 3) = 1.;
124 
125  tmpboost.Invert();
126  boost_ = tmpboost;
127  //boost_->Print();
128 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22

◆ sigmaZ()

void BetafuncEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 130 of file BetafuncEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

130  {
131  if (s >= 0) {
132  fSigmaZ = s;
133  } else {
134  throw cms::Exception("LogicError") << "Error in BetafuncEvtVtxGenerator::sigmaZ: "
135  << "Illegal resolution in Z (negative)";
136  }
137 }

◆ update()

void BetafuncEvtVtxGenerator::update ( const edm::EventSetup iEventSetup)
private

Definition at line 57 of file BetafuncEvtVtxGenerator.cc.

References SimBeamSpotObjects::alpha(), beamToken_, SimBeamSpotObjects::betaStar(), edm::ESWatcher< T >::check(), SimBeamSpotObjects::emittance(), fbetastar, femittance, fSigmaZ, fTimeOffset, fX0, fY0, fZ0, edm::EventSetup::getHandle(), parameterWatcher_, SimBeamSpotObjects::phi(), readDB_, setBoost(), SimBeamSpotObjects::sigmaZ(), SimBeamSpotObjects::timeOffset(), SimBeamSpotObjects::x(), SimBeamSpotObjects::y(), and SimBeamSpotObjects::z().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), beginLuminosityBlock(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

57  {
58  if (readDB_ && parameterWatcher_.check(iEventSetup)) {
59  edm::ESHandle<SimBeamSpotObjects> beamhandle = iEventSetup.getHandle(beamToken_);
60  fX0 = beamhandle->x() * cm;
61  fY0 = beamhandle->y() * cm;
62  fZ0 = beamhandle->z() * cm;
63  fSigmaZ = beamhandle->sigmaZ() * cm;
64  fTimeOffset = beamhandle->timeOffset() * ns * c_light; // HepMC distance units are in mm
65  fbetastar = beamhandle->betaStar() * cm;
66  femittance = beamhandle->emittance() * cm;
67  setBoost(beamhandle->alpha() * radian, beamhandle->phi() * radian);
68  }
69 }
double sigmaZ() const
void setBoost(double alpha, double phi)
double alpha() const
edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcd > beamToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
double timeOffset() const
edm::ESWatcher< SimBeamSpotObjectsRcd > parameterWatcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
double emittance() const
double phi() const
get Phi, Alpha and TimeOffset
double betaStar() const
get BetaStar and Emittance
double x() const
get X, Y, Z position

◆ X0()

void BetafuncEvtVtxGenerator::X0 ( double  m = 0)
inline

◆ Y0()

void BetafuncEvtVtxGenerator::Y0 ( double  m = 0)
inline

◆ Z0()

void BetafuncEvtVtxGenerator::Z0 ( double  m = 0)
inline

Member Data Documentation

◆ beamToken_

edm::ESGetToken<SimBeamSpotObjects, SimBeamSpotObjectsRcd> BetafuncEvtVtxGenerator::beamToken_
private

Definition at line 86 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), and update().

◆ boost_

TMatrixD BetafuncEvtVtxGenerator::boost_
private

Definition at line 82 of file BetafuncEvtVtxGenerator.h.

Referenced by GetInvLorentzBoost(), and setBoost().

◆ fbetastar

double BetafuncEvtVtxGenerator::fbetastar
private

Definition at line 78 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), BetaFunction(), betastar(), and update().

◆ femittance

double BetafuncEvtVtxGenerator::femittance
private

Definition at line 78 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), BetaFunction(), emittance(), and update().

◆ fSigmaZ

double BetafuncEvtVtxGenerator::fSigmaZ
private

Definition at line 76 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), newVertex(), sigmaZ(), and update().

◆ fTimeOffset

double BetafuncEvtVtxGenerator::fTimeOffset
private

Definition at line 80 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), newVertex(), and update().

◆ fX0

double BetafuncEvtVtxGenerator::fX0
private

Definition at line 75 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), newVertex(), update(), and X0().

◆ fY0

double BetafuncEvtVtxGenerator::fY0
private

Definition at line 75 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), newVertex(), update(), and Y0().

◆ fZ0

double BetafuncEvtVtxGenerator::fZ0
private

Definition at line 75 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), newVertex(), update(), and Z0().

◆ parameterWatcher_

edm::ESWatcher<SimBeamSpotObjectsRcd> BetafuncEvtVtxGenerator::parameterWatcher_
private

Definition at line 85 of file BetafuncEvtVtxGenerator.h.

Referenced by update().

◆ readDB_

bool BetafuncEvtVtxGenerator::readDB_
private

Definition at line 73 of file BetafuncEvtVtxGenerator.h.

Referenced by BetafuncEvtVtxGenerator(), and update().