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