CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
BaseEvtVtxGenerator.cc
Go to the documentation of this file.
1 
2 /*
3 */
4 
6 
9 
12 
15 
17 
20 
21 //#include "HepMC/GenEvent.h"
22 // #include "CLHEP/Vector/ThreeVector.h"
23 // #include "HepMC/SimpleVector.h"
24 
25 using namespace edm;
26 using namespace CLHEP;
27 //using namespace HepMC;
28 
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 }
41 
43 
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 }
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
edm
HLT enums.
Definition: AlignableModifier.h:19
RandomNumberGenerator.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
BaseEvtVtxGenerator::~BaseEvtVtxGenerator
~BaseEvtVtxGenerator() override
Definition: BaseEvtVtxGenerator.cc:42
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
EDMException.h
Service.h
Provenance.h
BaseEvtVtxGenerator::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: BaseEvtVtxGenerator.cc:44
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
CLHEP
Definition: CocoaGlobals.h:27
BaseEvtVtxGenerator::BaseEvtVtxGenerator
BaseEvtVtxGenerator(const edm::ParameterSet &)
Definition: BaseEvtVtxGenerator.cc:29
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
BaseEvtVtxGenerator.h
edm::Service
Definition: Service.h:30
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
edm::EventSetup
Definition: EventSetup.h:57
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
edm::Event::streamID
StreamID streamID() const
Definition: Event.h:97
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
Exception.h
edm::HepMCProduct
Definition: HepMCProduct.h:18
ParameterSet.h
HepMCProduct.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27