File indexing completed on 2024-04-06 12:19:02
0001
0002
0003
0004
0005 #include <ostream>
0006 #include <memory>
0007
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "FWCore/Framework/interface/Run.h"
0010 #include "FWCore/ServiceRegistry/interface/Service.h"
0011 #include "FWCore/Utilities/interface/Exception.h"
0012 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014
0015 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0016 #include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h"
0017
0018 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
0019
0020 #include "IOMC/ParticleGuns/interface/BaseFlatGunProducer.h"
0021
0022 #include <iostream>
0023
0024 using namespace edm;
0025 using namespace std;
0026 using namespace CLHEP;
0027
0028 BaseFlatGunProducer::BaseFlatGunProducer(const ParameterSet& pset)
0029 : fPDGTableToken(esConsumes<Transition::BeginRun>()),
0030 fEvt(nullptr)
0031
0032 {
0033 Service<RandomNumberGenerator> rng;
0034 if (!rng.isAvailable()) {
0035 throw cms::Exception("Configuration")
0036 << "The RandomNumberProducer module requires the RandomNumberGeneratorService\n"
0037 "which appears to be absent. Please add that service to your configuration\n"
0038 "or remove the modules that require it.";
0039 }
0040
0041 ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters");
0042
0043
0044
0045
0046
0047 fPartIDs = pgun_params.getParameter<vector<int> >("PartID");
0048 fMinEta = pgun_params.getParameter<double>("MinEta");
0049 fMaxEta = pgun_params.getParameter<double>("MaxEta");
0050 fMinPhi = pgun_params.getParameter<double>("MinPhi");
0051 fMaxPhi = pgun_params.getParameter<double>("MaxPhi");
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 fVerbosity = pset.getUntrackedParameter<int>("Verbosity", 0);
0074
0075 fAddAntiParticle = pset.getParameter<bool>("AddAntiParticle");
0076
0077 produces<GenRunInfoProduct, Transition::EndRun>();
0078 }
0079
0080 BaseFlatGunProducer::~BaseFlatGunProducer() {
0081
0082
0083
0084 }
0085
0086 void BaseFlatGunProducer::beginRun(const edm::Run& r, const EventSetup& es) {
0087 fPDGTable = es.getHandle(fPDGTableToken);
0088 return;
0089 }
0090 void BaseFlatGunProducer::endRun(const Run& run, const EventSetup& es) {}
0091
0092 void BaseFlatGunProducer::endRunProduce(Run& run, const EventSetup& es) {
0093
0094
0095
0096 unique_ptr<GenRunInfoProduct> genRunInfo(new GenRunInfoProduct());
0097 run.put(std::move(genRunInfo));
0098 }