Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:02

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/EventSetup.h"
0011 #include "FWCore/Framework/interface/Run.h"
0012 #include "FWCore/ServiceRegistry/interface/Service.h"
0013 #include "FWCore/Utilities/interface/Exception.h"
0014 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 
0017 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0018 #include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h"
0019 
0020 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
0021 
0022 #include "IOMC/ParticleGuns/interface/BaseRandomtXiGunProducer.h"
0023 
0024 #include <iostream>
0025 
0026 using namespace edm;
0027 using namespace std;
0028 using namespace CLHEP;
0029 
0030 BaseRandomtXiGunProducer::BaseRandomtXiGunProducer(const edm::ParameterSet& pset)
0031     : fPDGTableToken(esConsumes<Transition::BeginRun>()), fEvt(nullptr) {
0032   Service<RandomNumberGenerator> rng;
0033   if (!rng.isAvailable()) {
0034     throw cms::Exception("Configuration")
0035         << "The RandomNumberProducer module requires the RandomNumberGeneratorService\n"
0036            "which appears to be absent.  Please add that service to your configuration\n"
0037            "or remove the modules that require it.";
0038   }
0039 
0040   ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters");
0041 
0042   // although there's the method ParameterSet::empty(),
0043   // it looks like it's NOT even necessary to check if it is,
0044   // before trying to extract parameters - if it is empty,
0045   // the default values seem to be taken
0046   fPartIDs = pgun_params.getParameter<vector<int> >("PartID");
0047   fMinPhi = pgun_params.getParameter<double>("MinPhi");
0048   fMaxPhi = pgun_params.getParameter<double>("MaxPhi");
0049   fECMS = pgun_params.getParameter<double>("ECMS");
0050   fpEnergy = fECMS / 2.0;
0051 
0052   fVerbosity = pset.getUntrackedParameter<int>("Verbosity", 0);
0053 
0054   fFireBackward = pset.getParameter<bool>("FireBackward");
0055   fFireForward = pset.getParameter<bool>("FireForward");
0056 
0057   produces<GenRunInfoProduct, Transition::EndRun>();
0058 }
0059 
0060 BaseRandomtXiGunProducer::~BaseRandomtXiGunProducer() {}
0061 
0062 void BaseRandomtXiGunProducer::beginRun(const edm::Run& r, const EventSetup& es) {
0063   fPDGTable = es.getHandle(fPDGTableToken);
0064   return;
0065 }
0066 
0067 void BaseRandomtXiGunProducer::endRun(const Run& run, const EventSetup& es) {}
0068 void BaseRandomtXiGunProducer::endRunProduce(Run& run, const EventSetup& es) {
0069   // just create an empty product
0070   // to keep the EventContent definitions happy
0071   // later on we might put the info into the run info that this is a PGun
0072   run.put(std::make_unique<GenRunInfoProduct>());
0073 }