Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-22 02:39:44

0001 /*
0002  *  $Date: 2010/01/19 16:17:26 $
0003  *  $Revision: 1.7 $
0004  *  \author Julia Yarba
0005  */
0006 
0007 #include <ostream>
0008 #include <memory>
0009 
0010 #include "FWCore/Framework/interface/EDProducer.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/Run.h"
0013 #include "FWCore/ServiceRegistry/interface/Service.h"
0014 #include "FWCore/Utilities/interface/Exception.h"
0015 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 
0018 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0019 #include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h"
0020 
0021 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
0022 
0023 #include "IOMC/ParticleGuns/interface/BaseRandomtXiGunProducer.h"
0024 
0025 #include <iostream>
0026 
0027 using namespace edm;
0028 using namespace std;
0029 using namespace CLHEP;
0030 
0031 BaseRandomtXiGunProducer::BaseRandomtXiGunProducer(const edm::ParameterSet& pset)
0032     : fPDGTableToken(esConsumes<Transition::BeginRun>()), fEvt(nullptr) {
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   // although there's the method ParameterSet::empty(),
0044   // it looks like it's NOT even necessary to check if it is,
0045   // before trying to extract parameters - if it is empty,
0046   // the default values seem to be taken
0047   fPartIDs = pgun_params.getParameter<vector<int> >("PartID");
0048   fMinPhi = pgun_params.getParameter<double>("MinPhi");
0049   fMaxPhi = pgun_params.getParameter<double>("MaxPhi");
0050   fECMS = pgun_params.getParameter<double>("ECMS");
0051   fpEnergy = fECMS / 2.0;
0052 
0053   fVerbosity = pset.getUntrackedParameter<int>("Verbosity", 0);
0054 
0055   fFireBackward = pset.getParameter<bool>("FireBackward");
0056   fFireForward = pset.getParameter<bool>("FireForward");
0057 
0058   produces<GenRunInfoProduct, Transition::EndRun>();
0059 }
0060 
0061 BaseRandomtXiGunProducer::~BaseRandomtXiGunProducer() {}
0062 
0063 void BaseRandomtXiGunProducer::beginRun(const edm::Run& r, const EventSetup& es) {
0064   fPDGTable = es.getHandle(fPDGTableToken);
0065   return;
0066 }
0067 
0068 void BaseRandomtXiGunProducer::endRun(const Run& run, const EventSetup& es) {}
0069 void BaseRandomtXiGunProducer::endRunProduce(Run& run, const EventSetup& es) {
0070   // just create an empty product
0071   // to keep the EventContent definitions happy
0072   // later on we might put the info into the run info that this is a PGun
0073   run.put(std::make_unique<GenRunInfoProduct>());
0074 }