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