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
 
 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 Attributes

edm::EDGetTokenT< edm::HepMCProductsourceToken
 

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 23 of file BaseEvtVtxGenerator.h.

Constructor & Destructor Documentation

◆ BaseEvtVtxGenerator()

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

Definition at line 29 of file BaseEvtVtxGenerator.cc.

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

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 }
edm::EDGetTokenT< edm::HepMCProduct > sourceToken
bool isAvailable() const
Definition: Service.h:40

◆ ~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, FlatEvtVtxGenerator, PassThroughEvtVtxGenerator, 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.

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

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
edm::EDGetTokenT< edm::HepMCProduct > sourceToken
virtual TMatrixD const * GetInvLorentzBoost() const =0
StreamID streamID() const
Definition: Event.h:98
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
virtual HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const =0
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ sourceToken

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

Definition at line 41 of file BaseEvtVtxGenerator.h.