Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "IOMC/EventVertexGenerators/interface/BaseEvtVtxGenerator.h"
00008
00009 #include "FWCore/Framework/interface/Event.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011
00012 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00013
00014 #include "FWCore/ServiceRegistry/interface/Service.h"
00015 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00016
00017 #include "FWCore/Utilities/interface/Exception.h"
00018
00019 #include "DataFormats/Provenance/interface/Provenance.h"
00020 #include "FWCore/Utilities/interface/EDMException.h"
00021
00022
00023
00024
00025
00026 using namespace edm;
00027 using namespace std;
00028 using namespace CLHEP;
00029
00030
00031 BaseEvtVtxGenerator::BaseEvtVtxGenerator( const ParameterSet& pset )
00032 : fVertex(0), boost_(0), fTimeOffset(0), fEngine(0),
00033 sourceLabel(pset.getParameter<edm::InputTag>("src"))
00034 {
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 Service<RandomNumberGenerator> rng;
00048
00049 if ( ! rng.isAvailable()) {
00050
00051 throw cms::Exception("Configuration")
00052 << "The BaseEvtVtxGenerator requires the RandomNumberGeneratorService\n"
00053 "which is not present in the configuration file. You must add the service\n"
00054 "in the configuration file or remove the modules that require it.";
00055 }
00056
00057 CLHEP::HepRandomEngine& engine = rng->getEngine();
00058 fEngine = &engine;
00059
00060
00061 produces<bool>();
00062 }
00063
00064 BaseEvtVtxGenerator::~BaseEvtVtxGenerator()
00065 {
00066 delete fVertex ;
00067 if (boost_ != 0 ) delete boost_;
00068
00069
00070 }
00071
00072 void BaseEvtVtxGenerator::produce( Event& evt, const EventSetup& )
00073 {
00074
00075
00076 Handle<HepMCProduct> HepMCEvt ;
00077
00078 evt.getByLabel( sourceLabel, HepMCEvt ) ;
00079
00080
00081
00082 HepMCEvt->applyVtxGen( newVertex() ) ;
00083
00084
00085 HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
00086 HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
00087
00088
00089
00090 auto_ptr<bool> NewProduct(new bool(true)) ;
00091 evt.put( NewProduct ) ;
00092
00093 return ;
00094 }
00095
00096 CLHEP::HepRandomEngine& BaseEvtVtxGenerator::getEngine()
00097 {
00098 return *fEngine;
00099 }