CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Py8InterfaceBase.cc
Go to the documentation of this file.
4 
7 
8 using namespace Pythia8;
9 
10 namespace gen {
11 
12 Py8InterfaceBase::Py8InterfaceBase( edm::ParameterSet const& ps )
13 {
14 
16 
17  fMasterGen.reset(new Pythia);
18  fDecayer.reset(new Pythia);
19 
20  fMasterGen->readString("Next:numberShowEvent = 0");
21  fDecayer->readString("Next:numberShowEvent = 0");
22 
23  // RandomP8* RP8 = new RandomP8();
24  fMasterGen->setRndmEnginePtr( new RandomP8() );
25  fDecayer->setRndmEnginePtr( new RandomP8() );
26 
27  fParameters = ps.getParameter<edm::ParameterSet>("PythiaParameters");
28 
29  pythiaPylistVerbosity = ps.getUntrackedParameter<int>("pythiaPylistVerbosity", 0);
30  pythiaHepMCVerbosity = ps.getUntrackedParameter<bool>("pythiaHepMCVerbosity", false);
31  maxEventsToPrint = ps.getUntrackedParameter<int>("maxEventsToPrint", 0);
32 
33 }
34 
35 bool Py8InterfaceBase::readSettings( int )
36 {
37 
38  for ( ParameterCollector::const_iterator line = fParameters.begin();
39  line != fParameters.end(); ++line )
40  {
41  if (line->find("Random:") != std::string::npos)
42  throw cms::Exception("PythiaError") << "Attempted to set random number "
43  "using Pythia commands. Please use " "the RandomNumberGeneratorService."
44  << std::endl;
45 
46  if (!fMasterGen->readString(*line)) throw cms::Exception("PythiaError")
47  << "Pythia 8 did not accept \""
48  << *line << "\"." << std::endl;
49  }
50 
51  return true;
52 
53 }
54 
55 bool Py8InterfaceBase::declareStableParticles( const std::vector<int>& pdgIds )
56 {
57 
58  for ( size_t i=0; i<pdgIds.size(); i++ )
59  {
60  // FIXME: need to double check if PID's are the same in Py6 & Py8,
61  // because the HepPDT translation tool is actually for **Py6**
62  //
63  // well, actually it looks like Py8 operates in PDT id's rather than Py6's
64  //
65 // int PyID = HepPID::translatePDTtoPythia( pdgIds[i] );
66  int PyID = pdgIds[i];
67  std::ostringstream pyCard ;
68  pyCard << PyID <<":mayDecay=false";
69 
70  if ( fMasterGen->particleData.isParticle( PyID ) ) {
71  fMasterGen->readString( pyCard.str() );
72  } else {
73 
74  edm::LogWarning("DataNotUnderstood") << "Pythia8 does not "
75  << "recognize particle id = "
76  << PyID << std::endl;
77  }
78  // alternative:
79  // set the 2nd input argument warn=false
80  // - this way Py8 will NOT print warnings about unknown particle code(s)
81  // fMasterPtr->readString( pyCard.str(), false )
82  }
83 
84  return true;
85 
86 }
87 
88 bool Py8InterfaceBase:: declareSpecialSettings( const std::vector<std::string>& settings )
89 {
90 
91  for ( unsigned int iss=0; iss<settings.size(); iss++ )
92  {
93  if ( settings[iss].find("QED-brem-off") == std::string::npos ) continue;
94  fMasterGen->readString( "TimeShower:QEDshowerByL=off" );
95  }
96 
97  return true;
98 }
99 
100 
102 {
103 
104  fMasterGen->stat();
105  return;
106 
107 }
108 
109 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
CLHEP::HepRandomEngine * randomEngine
Definition: PYR.cc:4
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
CLHEP::HepRandomEngine & getEngineReference()