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 10 of file GaussEvtVtxGenerator.cc.

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

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

References update().

41  {
42  update(iEventSetup);
43 }
void update(const edm::EventSetup &iEventSetup)

◆ fillDescriptions()

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

Definition at line 95 of file GaussEvtVtxGenerator.cc.

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

95  {
97  desc.add<double>("MeanX", 0.0)->setComment("in cm");
98  desc.add<double>("MeanY", 0.0)->setComment("in cm");
99  desc.add<double>("MeanZ", 0.0)->setComment("in cm");
100  desc.add<double>("SigmaX", 0.0)->setComment("in cm");
101  desc.add<double>("SigmaY", 0.0)->setComment("in cm");
102  desc.add<double>("SigmaZ", 0.0)->setComment("in cm");
103  desc.add<double>("TimeOffset", 0.0)->setComment("in ns");
104  desc.add<edm::InputTag>("src");
105  desc.add<bool>("readDB");
106  descriptions.add("GaussEvtVtxGenerator", desc);
107 }
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 58 of file GaussEvtVtxGenerator.cc.

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

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

References Exception, fSigmaX, and alignCSCRings::s.

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

◆ sigmaY()

void GaussEvtVtxGenerator::sigmaY ( double  s = 1.0)

set resolution in Y in cm

Definition at line 77 of file GaussEvtVtxGenerator.cc.

References Exception, fSigmaY, and alignCSCRings::s.

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

◆ sigmaZ()

void GaussEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 86 of file GaussEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

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

◆ update()

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

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

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