CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/GeneratorInterface/Pythia8Interface/src/Py8InterfaceBase.cc

Go to the documentation of this file.
00001 #include "GeneratorInterface/Pythia8Interface/interface/Py8InterfaceBase.h"
00002 #include "GeneratorInterface/Pythia8Interface/interface/RandomP8.h"
00003 #include "GeneratorInterface/Core/interface/RNDMEngineAccess.h"
00004 
00005 #include "FWCore/Utilities/interface/Exception.h"
00006 
00007 using namespace Pythia8;
00008 
00009 namespace gen {
00010 
00011 Py8InterfaceBase::Py8InterfaceBase( edm::ParameterSet const& ps )
00012 {
00013 
00014   randomEngine = &getEngineReference();
00015 
00016   fMasterGen.reset(new Pythia);
00017   fDecayer.reset(new Pythia);
00018 
00019   fMasterGen->readString("Next:numberShowEvent = 0");
00020   fDecayer->readString("Next:numberShowEvent = 0");
00021 
00022   // RandomP8* RP8 = new RandomP8();
00023   fMasterGen->setRndmEnginePtr( new RandomP8() );
00024   fDecayer->setRndmEnginePtr( new RandomP8() );
00025   
00026   fParameters = ps.getParameter<edm::ParameterSet>("PythiaParameters");
00027   
00028   pythiaPylistVerbosity = ps.getUntrackedParameter<int>("pythiaPylistVerbosity", 0);
00029   pythiaHepMCVerbosity  = ps.getUntrackedParameter<bool>("pythiaHepMCVerbosity", false);
00030   maxEventsToPrint      = ps.getUntrackedParameter<int>("maxEventsToPrint", 0);
00031 
00032 }
00033 
00034 bool Py8InterfaceBase::readSettings( int ) 
00035 {
00036 
00037    for ( ParameterCollector::const_iterator line = fParameters.begin();
00038          line != fParameters.end(); ++line ) 
00039    {
00040       if (line->find("Random:") != std::string::npos)
00041          throw cms::Exception("PythiaError") << "Attempted to set random number "
00042          "using Pythia commands. Please use " "the RandomNumberGeneratorService."
00043          << std::endl;
00044 
00045       if (!fMasterGen->readString(*line)) throw cms::Exception("PythiaError")
00046                                       << "Pythia 8 did not accept \""
00047                                       << *line << "\"." << std::endl;
00048    }
00049 
00050    return true;
00051 
00052 }
00053 
00054 bool Py8InterfaceBase::declareStableParticles( const std::vector<int>& pdgIds )
00055 {
00056   
00057   for ( size_t i=0; i<pdgIds.size(); i++ )
00058   {
00059     // FIXME: need to double check if PID's are the same in Py6 & Py8,
00060     //        because the HepPDT translation tool is actually for **Py6** 
00061     // 
00062     // well, actually it looks like Py8 operates in PDT id's rather than Py6's
00063     //
00064     // int PyID = HepPID::translatePDTtoPythia( pdgIds[i] ); 
00065     int PyID = pdgIds[i]; 
00066     std::ostringstream pyCard ;
00067     pyCard << PyID <<":mayDecay=false";
00068     fMasterGen->readString( pyCard.str() );
00069     // alternative:
00070     // set the 2nd input argument warn=false 
00071     // - this way Py8 will NOT print warnings about unknown particle code(s)
00072     // fMasterPtr->readString( pyCard.str(), false )
00073   }
00074         
00075    return true;
00076 
00077 }
00078 
00079 bool Py8InterfaceBase:: declareSpecialSettings( const std::vector<std::string>& settings )
00080 {
00081 
00082    for ( unsigned int iss=0; iss<settings.size(); iss++ )
00083    {
00084       if ( settings[iss].find("QED-brem-off") == std::string::npos ) continue;
00085       fMasterGen->readString( "TimeShower:QEDshowerByL=off" );
00086    }
00087 
00088    return true;
00089 }
00090 
00091 void Py8InterfaceBase::statistics()
00092 {
00093   
00094    fMasterGen->statistics();
00095    return;
00096    
00097 }
00098 
00099 }