CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
BaseEvtVtxGenerator Class Referenceabstract

#include <BaseEvtVtxGenerator.h>

Inheritance diagram for BaseEvtVtxGenerator:
edm::stream::EDProducer<> BeamProfileVtxGenerator BetafuncEvtVtxGenerator FlatEvtVtxGenerator GaussEvtVtxGenerator HLLHCEvtVtxGenerator PassThroughEvtVtxGenerator

Public Member Functions

 BaseEvtVtxGenerator (const edm::ParameterSet &)
 
virtual TMatrixD const * GetInvLorentzBoost () const =0
 
virtual HepMC::FourVector newVertex (CLHEP::HepRandomEngine *) const =0
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~BaseEvtVtxGenerator () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::EDGetTokenT< edm::HepMCProductsourceToken
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 23 of file BaseEvtVtxGenerator.h.

Constructor & Destructor Documentation

◆ BaseEvtVtxGenerator()

BaseEvtVtxGenerator::BaseEvtVtxGenerator ( const edm::ParameterSet pset)
explicit

Definition at line 29 of file BaseEvtVtxGenerator.cc.

29  {
31  if (!rng.isAvailable()) {
32  throw cms::Exception("Configuration") << "The BaseEvtVtxGenerator requires the RandomNumberGeneratorService\n"
33  "which is not present in the configuration file. \n"
34  "You must add the service\n"
35  "in the configuration file or remove the modules that require it.";
36  }
37 
38  sourceToken = consumes<edm::HepMCProduct>(pset.getParameter<edm::InputTag>("src"));
39  produces<edm::HepMCProduct>();
40 }

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

◆ ~BaseEvtVtxGenerator()

BaseEvtVtxGenerator::~BaseEvtVtxGenerator ( )
override

Definition at line 42 of file BaseEvtVtxGenerator.cc.

42 {}

Member Function Documentation

◆ GetInvLorentzBoost()

virtual TMatrixD const* BaseEvtVtxGenerator::GetInvLorentzBoost ( ) const
pure virtual

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.

Implemented in BetafuncEvtVtxGenerator, HLLHCEvtVtxGenerator, PassThroughEvtVtxGenerator, FlatEvtVtxGenerator, BeamProfileVtxGenerator, and GaussEvtVtxGenerator.

◆ newVertex()

virtual HepMC::FourVector BaseEvtVtxGenerator::newVertex ( CLHEP::HepRandomEngine *  ) const
pure virtual

◆ produce()

void BaseEvtVtxGenerator::produce ( edm::Event evt,
const edm::EventSetup  
)
override

Definition at line 44 of file BaseEvtVtxGenerator.cc.

44  {
46  CLHEP::HepRandomEngine* engine = &rng->getEngine(evt.streamID());
47 
48  Handle<HepMCProduct> HepUnsmearedMCEvt;
49 
50  evt.getByToken(sourceToken, HepUnsmearedMCEvt);
51 
52  // Copy the HepMC::GenEvent
53  HepMC::GenEvent* genevt = new HepMC::GenEvent(*HepUnsmearedMCEvt->GetEvent());
54  std::unique_ptr<edm::HepMCProduct> HepMCEvt(new edm::HepMCProduct(genevt));
55  // generate new vertex & apply the shift
56  //
57  HepMCEvt->applyVtxGen(newVertex(engine));
58 
59  //HepMCEvt->LorentzBoost( 0., 142.e-6 );
60  HepMCEvt->boostToLab(GetInvLorentzBoost(), "vertex");
61  HepMCEvt->boostToLab(GetInvLorentzBoost(), "momentum");
62 
63  evt.put(std::move(HepMCEvt));
64 
65  return;
66 }

References edm::Event::getByToken(), edm::RandomNumberGenerator::getEngine(), edm::HepMCProduct::GetEvent(), eostools::move(), edm::Event::put(), and edm::Event::streamID().

Member Data Documentation

◆ sourceToken

edm::EDGetTokenT<edm::HepMCProduct> BaseEvtVtxGenerator::sourceToken
private

Definition at line 41 of file BaseEvtVtxGenerator.h.

edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
edm::Handle
Definition: AssociativeIterator.h:50
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
BaseEvtVtxGenerator::newVertex
virtual HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const =0
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
BaseEvtVtxGenerator::sourceToken
edm::EDGetTokenT< edm::HepMCProduct > sourceToken
Definition: BaseEvtVtxGenerator.h:41
edm::Service
Definition: Service.h:30
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
BaseEvtVtxGenerator::GetInvLorentzBoost
virtual TMatrixD const * GetInvLorentzBoost() const =0
edm::Event::streamID
StreamID streamID() const
Definition: Event.h:98
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
edm::HepMCProduct
Definition: HepMCProduct.h:18
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27