CMS 3D CMS Logo

BaseFlatGunProducer.cc
Go to the documentation of this file.
1 /*
2  * \author Julia Yarba
3  */
4 
5 #include <ostream>
6 #include <memory>
7 
15 
18 
20 
22 
23 #include <iostream>
24 
25 using namespace edm;
26 using namespace std;
27 using namespace CLHEP;
28 
30  : fPDGTableToken(esConsumes<Transition::BeginRun>()),
31  fEvt(nullptr)
32 // fPDGTable( new DefaultConfig::ParticleDataTable("PDG Table") )
33 {
35  if (!rng.isAvailable()) {
36  throw cms::Exception("Configuration")
37  << "The RandomNumberProducer module requires the RandomNumberGeneratorService\n"
38  "which appears to be absent. Please add that service to your configuration\n"
39  "or remove the modules that require it.";
40  }
41 
42  ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters");
43 
44  // although there's the method ParameterSet::empty(),
45  // it looks like it's NOT even necessary to check if it is,
46  // before trying to extract parameters - if it is empty,
47  // the default values seem to be taken
48  fPartIDs = pgun_params.getParameter<vector<int> >("PartID");
49  fMinEta = pgun_params.getParameter<double>("MinEta");
50  fMaxEta = pgun_params.getParameter<double>("MaxEta");
51  fMinPhi = pgun_params.getParameter<double>("MinPhi");
52  fMaxPhi = pgun_params.getParameter<double>("MaxPhi");
53 
54  //
55  //fPDGTablePath = "/afs/cern.ch/sw/lcg/external/clhep/1.9.2.1/slc3_ia32_gcc323/data/HepPDT/" ;
56  /*
57  string HepPDTBase( std::getenv("HEPPDT_PARAM_PATH") ) ;
58  fPDGTablePath = HepPDTBase + "/data/" ;
59  fPDGTableName = "PDG_mass_width_2004.mc"; // should it be 2004 table ?
60 
61  string TableFullName = fPDGTablePath + fPDGTableName ;
62  std::ifstream PDFile( TableFullName.c_str() ) ;
63  if( !PDFile )
64  {
65  throw cms::Exception("FileNotFound", "BaseFlatGunProducer::BaseFlatGunProducer()")
66  << "File " << TableFullName << " cannot be opened.\n";
67  }
68 
69  HepPDT::TableBuilder tb(*fPDGTable) ;
70  if ( !addPDGParticles( PDFile, tb ) ) { cout << " Error reading PDG !" << endl; }
71  // the tb dtor fills fPDGTable
72 */
73 
74  fVerbosity = pset.getUntrackedParameter<int>("Verbosity", 0);
75 
76  fAddAntiParticle = pset.getParameter<bool>("AddAntiParticle");
77 
78  produces<GenRunInfoProduct, Transition::EndRun>();
79 }
80 
82  // no need to cleanup GenEvent memory - done in HepMCProduct
83  // if (fEvt != NULL) delete fEvt ; // double check
84  // delete fPDGTable;
85 }
86 
89  return;
90 }
91 void BaseFlatGunProducer::endRun(const Run& run, const EventSetup& es) {}
92 
94  // just create an empty product
95  // to keep the EventContent definitions happy
96  // later on we might put the info into the run info that this is a PGun
97  unique_ptr<GenRunInfoProduct> genRunInfo(new GenRunInfoProduct());
98  run.put(std::move(genRunInfo));
99 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void endRun(edm::Run const &r, const edm::EventSetup &) override
BaseFlatGunProducer(const ParameterSet &)
void endRunProduce(edm::Run &r, const edm::EventSetup &) override
const ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > fPDGTableToken
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Transition
Definition: Transition.h:12
void beginRun(const edm::Run &r, const edm::EventSetup &) override
std::vector< int > fPartIDs
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
HLT enums.
bool isAvailable() const
Definition: Service.h:40
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45