CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::RandomEngineSentry< T > Class Template Reference

#include <RandomEngineSentry.h>

Public Member Functions

CLHEP::HepRandomEngine const * randomEngine () const
 
CLHEP::HepRandomEngine *& randomEngine ()
 
 RandomEngineSentry (T *t, CLHEP::HepRandomEngine *engine)
 
 RandomEngineSentry (T *t, StreamID const &streamID)
 
 RandomEngineSentry (T *t, LuminosityBlockIndex const &lumi)
 
 ~RandomEngineSentry ()
 

Private Attributes

edm::propagate_const< CLHEP::HepRandomEngine * > engine_
 
edm::propagate_const< T * > t_
 

Detailed Description

template<class T>
class edm::RandomEngineSentry< T >

Description:

Definition at line 28 of file RandomEngineSentry.h.

Constructor & Destructor Documentation

template<class T>
edm::RandomEngineSentry< T >::RandomEngineSentry ( T t,
CLHEP::HepRandomEngine *  engine 
)
inlineexplicit

Definition at line 30 of file RandomEngineSentry.h.

30  : t_(t), engine_(engine) {
31  if (t) {
32  t->setRandomEngine(engine);
33  }
34  }
edm::propagate_const< CLHEP::HepRandomEngine * > engine_
edm::propagate_const< T * > t_
template<class T>
edm::RandomEngineSentry< T >::RandomEngineSentry ( T t,
StreamID const &  streamID 
)
inlineexplicit

Definition at line 36 of file RandomEngineSentry.h.

References Exception, and edm::Service< T >::isAvailable().

36  : t_(t), engine_(nullptr) {
37  if (t) {
39  if (!rng.isAvailable()) {
40  throw cms::Exception("Configuration")
41  << "Attempt to get a random engine when the RandomNumberGeneratorService is not configured.\n"
42  "You must configure the service if you want an engine.\n";
43  }
44  engine_ = &rng->getEngine(streamID);
45  t->setRandomEngine(engine_);
46  }
47  }
edm::propagate_const< CLHEP::HepRandomEngine * > engine_
edm::propagate_const< T * > t_
template<class T>
edm::RandomEngineSentry< T >::RandomEngineSentry ( T t,
LuminosityBlockIndex const &  lumi 
)
inlineexplicit

Definition at line 49 of file RandomEngineSentry.h.

References Exception, and edm::Service< T >::isAvailable().

49  : t_(t), engine_(nullptr) {
50  if (t) {
52  if (!rng.isAvailable()) {
53  throw cms::Exception("Configuration")
54  << "Attempt to get a random engine when the RandomNumberGeneratorService is not configured.\n"
55  "You must configure the service if you want an engine.\n";
56  }
57  engine_ = &rng->getEngine(lumi);
58  t->setRandomEngine(engine_);
59  }
60  }
edm::propagate_const< CLHEP::HepRandomEngine * > engine_
edm::propagate_const< T * > t_
template<class T>
edm::RandomEngineSentry< T >::~RandomEngineSentry ( )
inline

Definition at line 62 of file RandomEngineSentry.h.

62  {
63  if (t_)
64  t_->setRandomEngine(nullptr);
65  }
edm::propagate_const< T * > t_

Member Function Documentation

template<class T>
CLHEP::HepRandomEngine const* edm::RandomEngineSentry< T >::randomEngine ( ) const
inline

Definition at line 67 of file RandomEngineSentry.h.

References edm::get_underlying_safe().

67 { return get_underlying_safe(engine_); }
edm::propagate_const< CLHEP::HepRandomEngine * > engine_
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
template<class T>
CLHEP::HepRandomEngine*& edm::RandomEngineSentry< T >::randomEngine ( )
inline

Definition at line 68 of file RandomEngineSentry.h.

References edm::get_underlying_safe().

68 { return get_underlying_safe(engine_); }
edm::propagate_const< CLHEP::HepRandomEngine * > engine_
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)

Member Data Documentation

template<class T>
edm::propagate_const<CLHEP::HepRandomEngine*> edm::RandomEngineSentry< T >::engine_
private

Definition at line 72 of file RandomEngineSentry.h.

template<class T>
edm::propagate_const<T*> edm::RandomEngineSentry< T >::t_
private

Definition at line 71 of file RandomEngineSentry.h.