CMS 3D CMS Logo

List of all members | Public Member Functions | Static 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
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

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

Constructor & Destructor Documentation

◆ GaussEvtVtxGenerator() [1/2]

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

Definition at line 13 of file GaussEvtVtxGenerator.cc.

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

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

References update().

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

◆ fillDescriptions()

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

Definition at line 98 of file GaussEvtVtxGenerator.cc.

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

98  {
100  desc.add<double>("MeanX", 0.0)->setComment("in cm");
101  desc.add<double>("MeanY", 0.0)->setComment("in cm");
102  desc.add<double>("MeanZ", 0.0)->setComment("in cm");
103  desc.add<double>("SigmaX", 0.0)->setComment("in cm");
104  desc.add<double>("SigmaY", 0.0)->setComment("in cm");
105  desc.add<double>("SigmaZ", 0.0)->setComment("in cm");
106  desc.add<double>("TimeOffset", 0.0)->setComment("in ns");
107  desc.add<edm::InputTag>("src");
108  desc.add<bool>("readDB");
109  descriptions.add("GaussEvtVtxGenerator", desc);
110 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

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

38 { 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 61 of file GaussEvtVtxGenerator.cc.

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

61  {
62  double X, Y, Z, T;
63  X = CLHEP::RandGaussQ::shoot(engine, fMeanX, fSigmaX);
64  Y = CLHEP::RandGaussQ::shoot(engine, fMeanY, fSigmaY);
65  Z = CLHEP::RandGaussQ::shoot(engine, fMeanZ, fSigmaZ);
66  T = CLHEP::RandGaussQ::shoot(engine, fTimeOffset, fSigmaZ);
67 
68  return HepMC::FourVector(X, Y, Z, T);
69 }
#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 71 of file GaussEvtVtxGenerator.cc.

References Exception, fSigmaX, and alignCSCRings::s.

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

◆ sigmaY()

void GaussEvtVtxGenerator::sigmaY ( double  s = 1.0)

set resolution in Y in cm

Definition at line 80 of file GaussEvtVtxGenerator.cc.

References Exception, fSigmaY, and alignCSCRings::s.

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

◆ sigmaZ()

void GaussEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 89 of file GaussEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

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

◆ update()

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

Definition at line 48 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().

48  {
49  if (readDB_ && parameterWatcher_.check(iEventSetup)) {
50  edm::ESHandle<SimBeamSpotObjects> beamhandle = iEventSetup.getHandle(beamToken_);
51  fMeanX = beamhandle->meanX() * cm;
52  fMeanY = beamhandle->meanY() * cm;
53  fMeanZ = beamhandle->meanZ() * cm;
54  fSigmaX = beamhandle->sigmaX() * cm;
55  fSigmaY = beamhandle->sigmaY() * cm;
56  fSigmaZ = beamhandle->sigmaZ() * cm;
57  fTimeOffset = beamhandle->timeOffset() * ns * c_light; // HepMC distance units are in mm
58  }
59 }
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 63 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), and update().

◆ fMeanX

double GaussEvtVtxGenerator::fMeanX
private

Definition at line 58 of file GaussEvtVtxGenerator.h.

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

◆ fMeanY

double GaussEvtVtxGenerator::fMeanY
private

Definition at line 58 of file GaussEvtVtxGenerator.h.

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

◆ fMeanZ

double GaussEvtVtxGenerator::fMeanZ
private

Definition at line 58 of file GaussEvtVtxGenerator.h.

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

◆ fSigmaX

double GaussEvtVtxGenerator::fSigmaX
private

Definition at line 57 of file GaussEvtVtxGenerator.h.

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

◆ fSigmaY

double GaussEvtVtxGenerator::fSigmaY
private

Definition at line 57 of file GaussEvtVtxGenerator.h.

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

◆ fSigmaZ

double GaussEvtVtxGenerator::fSigmaZ
private

Definition at line 57 of file GaussEvtVtxGenerator.h.

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

◆ fTimeOffset

double GaussEvtVtxGenerator::fTimeOffset
private

Definition at line 59 of file GaussEvtVtxGenerator.h.

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

◆ parameterWatcher_

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

Definition at line 62 of file GaussEvtVtxGenerator.h.

Referenced by update().

◆ readDB_

bool GaussEvtVtxGenerator::readDB_
private

Definition at line 55 of file GaussEvtVtxGenerator.h.

Referenced by GaussEvtVtxGenerator(), and update().