Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <ostream>
00008 #include <memory>
00009
00010 #include "FWCore/Framework/interface/EDProducer.h"
00011 #include "FWCore/Framework/interface/EventSetup.h"
00012 #include "FWCore/Framework/interface/Run.h"
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 #include "FWCore/Utilities/interface/Exception.h"
00015 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00017
00018 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00019 #include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h"
00020
00021 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
00022
00023 #include "IOMC/ParticleGuns/interface/BaseFlatGunProducer.h"
00024
00025
00026 #include <iostream>
00027
00028 using namespace edm;
00029 using namespace std;
00030 using namespace CLHEP;
00031
00032 namespace {
00033 CLHEP::HepRandomEngine& getEngineReference()
00034 {
00035
00036 Service<RandomNumberGenerator> rng;
00037 if(!rng.isAvailable()) {
00038 throw cms::Exception("Configuration")
00039 << "The RandomNumberProducer module requires the RandomNumberGeneratorService\n"
00040 "which appears to be absent. Please add that service to your configuration\n"
00041 "or remove the modules that require it.";
00042 }
00043
00044
00045 return (rng->getEngine());
00046 }
00047 }
00048
00049 BaseFlatGunProducer::BaseFlatGunProducer( const ParameterSet& pset ) :
00050 fEvt(0),
00051 fRandomEngine(getEngineReference()),
00052 fRandomGenerator(0)
00053
00054 {
00055
00056 ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters") ;
00057
00058
00059
00060
00061
00062 fPartIDs = pgun_params.getParameter< vector<int> >("PartID");
00063 fMinEta = pgun_params.getParameter<double>("MinEta");
00064 fMaxEta = pgun_params.getParameter<double>("MaxEta");
00065 fMinPhi = pgun_params.getParameter<double>("MinPhi");
00066 fMaxPhi = pgun_params.getParameter<double>("MaxPhi");
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 fVerbosity = pset.getUntrackedParameter<int>( "Verbosity",0 ) ;
00089
00090
00091 fRandomGenerator = new CLHEP::RandFlat(fRandomEngine) ;
00092 fAddAntiParticle = pset.getParameter<bool>("AddAntiParticle") ;
00093
00094 produces<GenRunInfoProduct, InRun>();
00095 }
00096
00097 BaseFlatGunProducer::~BaseFlatGunProducer()
00098 {
00099
00100
00101
00102
00103
00104
00105
00106
00107 }
00108
00109
00110 void BaseFlatGunProducer::beginRun( edm::Run & r, const EventSetup& es )
00111 {
00112 es.getData( fPDGTable ) ;
00113 return ;
00114
00115 }
00116
00117
00118 void BaseFlatGunProducer::endRun( Run &run, const EventSetup& es )
00119 {
00120
00121
00122
00123 auto_ptr<GenRunInfoProduct> genRunInfo( new GenRunInfoProduct() );
00124 run.put( genRunInfo );
00125 }