CMS 3D CMS Logo

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

#include <GaussEvtVtxGenerator.h>

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

Public Member Functions

void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
 GaussEvtVtxGenerator (const edm::ParameterSet &p)
 
 GaussEvtVtxGenerator (const GaussEvtVtxGenerator &p)=delete
 
TMatrixD const * GetInvLorentzBoost () const override
 
void meanX (double m=0)
 set mean in X in cm More...
 
void meanY (double m=0)
 set mean in Y in cm More...
 
void meanZ (double m=0)
 set mean in Z in cm More...
 
HepMC::FourVector newVertex (CLHEP::HepRandomEngine *) const override
 return a new event vertex More...
 
GaussEvtVtxGeneratoroperator= (const GaussEvtVtxGenerator &rhs)=delete
 
void sigmaX (double s=1.0)
 set resolution in X in cm More...
 
void sigmaY (double s=1.0)
 set resolution in Y in cm More...
 
void sigmaZ (double s=1.0)
 set resolution in Z in cm More...
 
 ~GaussEvtVtxGenerator () 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
 

Private Member Functions

void update (const edm::EventSetup &iEventSetup)
 

Private Attributes

edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcdbeamToken_
 
double fMeanX
 
double fMeanY
 
double fMeanZ
 
double fSigmaX
 
double fSigmaY
 
double fSigmaZ
 
double fTimeOffset
 
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 20 of file GaussEvtVtxGenerator.h.

Constructor & Destructor Documentation

◆ GaussEvtVtxGenerator() [1/2]

GaussEvtVtxGenerator::GaussEvtVtxGenerator ( const edm::ParameterSet p)

Definition at line 14 of file GaussEvtVtxGenerator.cc.

References beamToken_, Exception, fMeanX, fMeanY, fMeanZ, fSigmaX, fSigmaY, fSigmaZ, fTimeOffset, AlCaHLTBitMon_ParallelJobs::p, and readDB_.

15  readDB_ = p.getParameter<bool>("readDB");
16  if (!readDB_) {
17  fMeanX = p.getParameter<double>("MeanX") * cm;
18  fMeanY = p.getParameter<double>("MeanY") * cm;
19  fMeanZ = p.getParameter<double>("MeanZ") * cm;
20  fSigmaX = p.getParameter<double>("SigmaX") * cm;
21  fSigmaY = p.getParameter<double>("SigmaY") * cm;
22  fSigmaZ = p.getParameter<double>("SigmaZ") * cm;
23  fTimeOffset = p.getParameter<double>("TimeOffset") * ns * c_light; // HepMC distance units are in mm
24 
25  if (fSigmaX < 0) {
26  throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
27  << "Illegal resolution in X (SigmaX is negative)";
28  }
29  if (fSigmaY < 0) {
30  throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
31  << "Illegal resolution in Y (SigmaY is negative)";
32  }
33  if (fSigmaZ < 0) {
34  throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
35  << "Illegal resolution in Z (SigmaZ is negative)";
36  }
37  }
38  if (readDB_) {
39  // NOTE: this is currently watching LS transitions, while it should watch Run transitions,
40  // even though in reality there is no Run Dependent MC (yet) in CMS
41  beamToken_ = esConsumes<SimBeamSpotObjects, SimBeamSpotObjectsRcd, edm::Transition::BeginLuminosityBlock>();
42  }
43 }
edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcd > beamToken_
BaseEvtVtxGenerator(const edm::ParameterSet &)

◆ GaussEvtVtxGenerator() [2/2]

GaussEvtVtxGenerator::GaussEvtVtxGenerator ( const GaussEvtVtxGenerator p)
delete

Copy constructor

◆ ~GaussEvtVtxGenerator()

GaussEvtVtxGenerator::~GaussEvtVtxGenerator ( )
overridedefault

Member Function Documentation

◆ beginLuminosityBlock()

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

Definition at line 45 of file GaussEvtVtxGenerator.cc.

References update().

45  {
46  update(iEventSetup);
47 }
void update(const edm::EventSetup &iEventSetup)

◆ GetInvLorentzBoost()

TMatrixD const* GaussEvtVtxGenerator::GetInvLorentzBoost ( ) const
inlineoverridevirtual

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 35 of file GaussEvtVtxGenerator.h.

35 { return nullptr; }

◆ meanX()

void GaussEvtVtxGenerator::meanX ( double  m = 0)
inline

◆ meanY()

void GaussEvtVtxGenerator::meanY ( double  m = 0)
inline

◆ meanZ()

void GaussEvtVtxGenerator::meanZ ( double  m = 0)
inline

◆ newVertex()

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

return a new event vertex

Implements BaseEvtVtxGenerator.

Definition at line 62 of file GaussEvtVtxGenerator.cc.

References fMeanX, fMeanY, fMeanZ, fSigmaX, fSigmaY, fSigmaZ, fTimeOffset, X, beamSpotPI::Y, and beamSpotPI::Z.

62  {
63  double X, Y, Z, T;
64  X = CLHEP::RandGaussQ::shoot(engine, fMeanX, fSigmaX);
65  Y = CLHEP::RandGaussQ::shoot(engine, fMeanY, fSigmaY);
66  Z = CLHEP::RandGaussQ::shoot(engine, fMeanZ, fSigmaZ);
67  T = CLHEP::RandGaussQ::shoot(engine, fTimeOffset, fSigmaZ);
68 
69  return HepMC::FourVector(X, Y, Z, T);
70 }
#define X(str)
Definition: MuonsGrabber.cc:38
long double T

◆ operator=()

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

Copy assignment operator

◆ sigmaX()

void GaussEvtVtxGenerator::sigmaX ( double  s = 1.0)

set resolution in X in cm

Definition at line 72 of file GaussEvtVtxGenerator.cc.

References Exception, fSigmaX, and alignCSCRings::s.

72  {
73  if (s >= 0) {
74  fSigmaX = s;
75  } else {
76  throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaX: "
77  << "Illegal resolution in X (negative)";
78  }
79 }

◆ sigmaY()

void GaussEvtVtxGenerator::sigmaY ( double  s = 1.0)

set resolution in Y in cm

Definition at line 81 of file GaussEvtVtxGenerator.cc.

References Exception, fSigmaY, and alignCSCRings::s.

81  {
82  if (s >= 0) {
83  fSigmaY = s;
84  } else {
85  throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaY: "
86  << "Illegal resolution in Y (negative)";
87  }
88 }

◆ sigmaZ()

void GaussEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 90 of file GaussEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

90  {
91  if (s >= 0) {
92  fSigmaZ = s;
93  } else {
94  throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaZ: "
95  << "Illegal resolution in Z (negative)";
96  }
97 }

◆ update()

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

Definition at line 49 of file GaussEvtVtxGenerator.cc.

References beamToken_, edm::ESWatcher< T >::check(), fMeanX, fMeanY, fMeanZ, fSigmaX, fSigmaY, fSigmaZ, fTimeOffset, edm::EventSetup::getHandle(), SimBeamSpotObjects::meanX(), SimBeamSpotObjects::meanY(), SimBeamSpotObjects::meanZ(), parameterWatcher_, readDB_, SimBeamSpotObjects::sigmaX(), SimBeamSpotObjects::sigmaY(), SimBeamSpotObjects::sigmaZ(), and SimBeamSpotObjects::timeOffset().

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

49  {
50  if (readDB_ && parameterWatcher_.check(iEventSetup)) {
51  edm::ESHandle<SimBeamSpotObjects> beamhandle = iEventSetup.getHandle(beamToken_);
52  fMeanX = beamhandle->meanX() * cm;
53  fMeanY = beamhandle->meanY() * cm;
54  fMeanZ = beamhandle->meanZ() * cm;
55  fSigmaX = beamhandle->sigmaX() * cm;
56  fSigmaY = beamhandle->sigmaY() * cm;
57  fSigmaZ = beamhandle->sigmaZ() * cm;
58  fTimeOffset = beamhandle->timeOffset() * ns * c_light; // HepMC distance units are in mm
59  }
60 }
double sigmaZ() const
double sigmaX() const
get sigmaX, sigmaY, sigmaZ
edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcd > beamToken_
double meanX() const
get meanX, meanY, meanZ position
edm::ESWatcher< SimBeamSpotObjectsRcd > parameterWatcher_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
double timeOffset() const
double meanY() const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
double meanZ() const

Member Data Documentation

◆ beamToken_

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

Definition at line 60 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), and update().

◆ fMeanX

double GaussEvtVtxGenerator::fMeanX
private

Definition at line 55 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), meanX(), newVertex(), and update().

◆ fMeanY

double GaussEvtVtxGenerator::fMeanY
private

Definition at line 55 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), meanY(), newVertex(), and update().

◆ fMeanZ

double GaussEvtVtxGenerator::fMeanZ
private

Definition at line 55 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), meanZ(), newVertex(), and update().

◆ fSigmaX

double GaussEvtVtxGenerator::fSigmaX
private

Definition at line 54 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), newVertex(), sigmaX(), and update().

◆ fSigmaY

double GaussEvtVtxGenerator::fSigmaY
private

Definition at line 54 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), newVertex(), sigmaY(), and update().

◆ fSigmaZ

double GaussEvtVtxGenerator::fSigmaZ
private

Definition at line 54 of file GaussEvtVtxGenerator.h.

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

◆ fTimeOffset

double GaussEvtVtxGenerator::fTimeOffset
private

Definition at line 56 of file GaussEvtVtxGenerator.h.

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

◆ parameterWatcher_

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

Definition at line 59 of file GaussEvtVtxGenerator.h.

Referenced by update().

◆ readDB_

bool GaussEvtVtxGenerator::readDB_
private

Definition at line 52 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), and update().