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 
24 #include <iostream>
25 
26 using namespace edm;
27 using namespace std;
28 using namespace CLHEP;
29 
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( 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 {
83  // no need to cleanup GenEvent memory - done in HepMCProduct
84  // if (fEvt != NULL) delete fEvt ; // double check
85  // delete fPDGTable;
86 
87 }
88 
89 
91 {
92  es.getData( fPDGTable ) ;
93  return ;
94 
95 }
96 void BaseFlatGunProducer::endRun(const Run &run, const EventSetup& es ) {
97 }
98 
99 
101 {
102  // just create an empty product
103  // to keep the EventContent definitions happy
104  // later on we might put the info into the run info that this is a PGun
105  unique_ptr<GenRunInfoProduct> genRunInfo( new GenRunInfoProduct() );
106  run.put(std::move(genRunInfo));
107 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void endRun(edm::Run const &r, const edm::EventSetup &) override
#define nullptr
BaseFlatGunProducer(const ParameterSet &)
void getData(T &iHolder) const
Definition: EventSetup.h:82
void endRunProduce(edm::Run &r, const edm::EventSetup &) override
ESHandle< HepPDT::ParticleDataTable > fPDGTable
bool isAvailable() const
Definition: Service.h:46
void beginRun(const edm::Run &r, const edm::EventSetup &) override
std::vector< int > fPartIDs
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:114
return(e1-e2)*(e1-e2)+dp *dp
HLT enums.
def move(src, dest)
Definition: eostools.py:510
Definition: Run.h:43