CMS 3D CMS Logo

BaseFlatGunSource.cc

Go to the documentation of this file.
00001 /*
00002  *  $Date: 2007/05/28 09:53:16 $
00003  *  $Revision: 1.15 $
00004  *  \author Julia Yarba
00005  */
00006 
00007 #include <ostream>
00008 
00009 #include "IOMC/ParticleGuns/interface/BaseFlatGunSource.h"
00010 
00011 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00012 
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00017 
00018 // #include "FWCore/Framework/intercface/ESHandle.h"
00019 // #include "FWCore/Framework/interface/EventSetup.h"
00020 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
00021 
00022 #include "FWCore/Utilities/interface/Exception.h"
00023 
00024 #include <iostream>
00025 
00026 using namespace edm;
00027 using namespace std;
00028 using namespace CLHEP;
00029 
00030 BaseFlatGunSource::BaseFlatGunSource( const ParameterSet& pset,
00031                                       const InputSourceDescription& desc ) : 
00032    GeneratedInputSource (pset, desc),
00033    fEvt(0)
00034    // fPDGTable( new DefaultConfig::ParticleDataTable("PDG Table") )
00035 {
00036 
00037    ParameterSet defpset ;
00038    //ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters") ;
00039    ParameterSet pgun_params = 
00040       pset.getUntrackedParameter<ParameterSet>("PGunParameters", defpset ) ;
00041   
00042    // although there's the method ParameterSet::empty(),  
00043    // it looks like it's NOT even necessary to check if it is,
00044    // before trying to extract parameters - if it is empty,
00045    // the default values seem to be taken
00046    vector<int> defids ;
00047    defids.push_back(13) ;
00048    fPartIDs    = pgun_params.getUntrackedParameter< vector<int> >("PartID",defids);  
00049    fMinEta     = pgun_params.getUntrackedParameter<double>("MinEta",-5.5);
00050    fMaxEta     = pgun_params.getUntrackedParameter<double>("MaxEta",5.5);
00051    fMinPhi     = pgun_params.getUntrackedParameter<double>("MinPhi",-3.14159265358979323846);
00052    fMaxPhi     = pgun_params.getUntrackedParameter<double>("MaxPhi", 3.14159265358979323846);
00053 
00054   //
00055   //fPDGTablePath = "/afs/cern.ch/sw/lcg/external/clhep/1.9.2.1/slc3_ia32_gcc323/data/HepPDT/" ;
00056 /*
00057   string HepPDTBase( getenv("HEPPDT_PARAM_PATH") ) ; 
00058   fPDGTablePath = HepPDTBase + "/data/" ;
00059   fPDGTableName = "PDG_mass_width_2004.mc"; // should it be 2004 table ?
00060 
00061   string TableFullName = fPDGTablePath + fPDGTableName ;
00062   ifstream PDFile( TableFullName.c_str() ) ;
00063   if( !PDFile ) 
00064   {
00065       throw cms::Exception("FileNotFound", "BaseFlatGunSource::BaseFlatGunSource()")
00066         << "File " << TableFullName << " cannot be opened.\n";
00067   }
00068 
00069   HepPDT::TableBuilder tb(*fPDGTable) ;
00070   if ( !addPDGParticles( PDFile, tb ) ) { cout << " Error reading PDG !" << endl; }
00071   // the tb dtor fills fPDGTable
00072 */
00073 
00074   fVerbosity = pset.getUntrackedParameter<int>( "Verbosity",0 ) ;
00075 
00076    Service<RandomNumberGenerator> rng;
00077    long seed = (long)(rng->mySeed()) ;
00078    fRandomEngine = new HepJamesRandom(seed) ;
00079    fRandomGenerator = new RandFlat(fRandomEngine) ;
00080    
00081    fAddAntiParticle = pset.getUntrackedParameter("AddAntiParticle", false) ;
00082    
00083 }
00084 
00085 BaseFlatGunSource::~BaseFlatGunSource()
00086 {
00087   
00088   if ( fRandomGenerator != NULL ) delete fRandomGenerator;
00089   // do I need to delete the Engine, too ?
00090   
00091   // no need to cleanup GenEvent memory - done in HepMCProduct
00092   // if (fEvt != NULL) delete fEvt ; // double check
00093   // delete fPDGTable;
00094   
00095 }
00096 
00097 
00098 void BaseFlatGunSource::beginJob( const EventSetup& es )
00099 {
00100 
00101    es.getData( fPDGTable ) ;
00102 
00103    return ;
00104 
00105 }

Generated on Tue Jun 9 17:39:07 2009 for CMSSW by  doxygen 1.5.4