![]() |
![]() |
#include <GeneratorInterface/Pythia8Interface/interface/Pythia8Source.h>
Public Member Functions | |
void | endRun (Run &r) |
Pythia8Source (const ParameterSet &, const InputSourceDescription &) | |
Constructor. | |
virtual | ~Pythia8Source () |
Destructor. | |
Private Member Functions | |
bool | call_txgive (const std::string &iParm) |
Interface to the PYGIVE pythia routine, with add'l protections. | |
bool | call_txgive_init () |
void | clear () |
virtual bool | produce (Event &e) |
Private Attributes | |
double | comenergy |
bool | doubleParticle |
double | etamax |
double | etamin |
CLHEP::HepRandomEngine * | fRandomEngine |
CLHEP::RandFlat * | fRandomGenerator |
unsigned int | maxEventsToPrint_ |
Events to print if verbosity. | |
int | particleID |
double | phimax |
double | phimin |
double | ptmax |
double | ptmin |
Pythia8::Pythia * | pythia |
Pythia8::Event * | pythia8event |
bool | pythiaHepMCVerbosity_ |
HepMC verbosity flag. | |
unsigned int | pythiaPylistVerbosity_ |
Pythia PYLIST Verbosity flag. | |
HepMC::I_Pythia8 * | ToHepMC |
Definition at line 34 of file Pythia8Source.h.
Pythia8Source::Pythia8Source | ( | const ParameterSet & | pset, | |
const InputSourceDescription & | desc | |||
) |
Constructor.
Definition at line 39 of file Pythia8Source.cc.
References comenergy, edm::errors::Configuration, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), cmsRelvalreport::exit, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, init, maxEventsToPrint_, pars, pythia, pythia8event, pythiaHepMCVerbosity_, pythiaPylistVerbosity_, and ToHepMC.
00040 : 00041 GeneratedInputSource(pset, desc), 00042 pythiaPylistVerbosity_ (pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0)), 00043 pythiaHepMCVerbosity_ (pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false)), 00044 maxEventsToPrint_ (pset.getUntrackedParameter<int>("maxEventsToPrint",1)), 00045 comenergy(pset.getUntrackedParameter<double>("comEnergy",14000.)) 00046 00047 { 00048 00049 cout << "Pythia8Source: initializing Pythia. " << endl; 00050 00051 00052 // PYLIST Verbosity Level 00053 // Valid PYLIST arguments are: 1, 2, 3, 5, 7, 11, 12, 13 00054 pythiaPylistVerbosity_ = pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0); 00055 cout << "Pythia PYLIST verbosity level = " << pythiaPylistVerbosity_ << endl; 00056 00057 // HepMC event verbosity Level 00058 pythiaHepMCVerbosity_ = pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false); 00059 cout << "Pythia HepMC verbosity = " << pythiaHepMCVerbosity_ << endl; 00060 00061 //Max number of events printed on verbosity level 00062 maxEventsToPrint_ = pset.getUntrackedParameter<int>("maxEventsToPrint",0); 00063 cout << "Number of events to be printed = " << maxEventsToPrint_ << endl; 00064 00065 00066 //In the future, we will get the random number seed on each event and tell 00067 // pythia to use that new seed 00068 cout << "----------------------------------------------" << endl; 00069 cout << "Setting Pythia8 random number seed " << endl; 00070 cout << "----------------------------------------------" << endl; 00071 edm::Service<RandomNumberGenerator> rng; 00072 uint32_t seed = rng->mySeed(); 00073 Pythia8::Rndm::init(seed); 00074 00075 // Generator. Process selection. LHC initialization. Histogram. 00076 pythia = new Pythia8::Pythia; 00077 pythia8event = &(pythia->event); 00078 00079 // Set PYTHIA parameters in a single ParameterSet 00080 ParameterSet pythia_params = 00081 pset.getParameter<ParameterSet>("PythiaParameters") ; 00082 00083 // The parameter sets to be read (default, min bias, user ...) in the 00084 // proper order. 00085 vector<string> setNames = 00086 pythia_params.getParameter<vector<string> >("parameterSets"); 00087 00088 // Loop over the sets 00089 for ( unsigned i=0; i<setNames.size(); ++i ) { 00090 00091 string mySet = setNames[i]; 00092 00093 // Read the PYTHIA parameters for each set of parameters 00094 vector<string> pars = 00095 pythia_params.getParameter<vector<string> >(mySet); 00096 00097 if (mySet != "CSAParameters") { 00098 cout << "----------------------------------------------" << endl; 00099 cout << "Read PYTHIA parameter set " << mySet << endl; 00100 cout << "----------------------------------------------" << endl; 00101 00102 // Loop over all parameters and stop in case of mistake 00103 for( vector<string>::const_iterator 00104 itPar = pars.begin(); itPar != pars.end(); ++itPar ) { 00105 00106 if ( ! pythia->readString(*itPar) ) { 00107 throw edm::Exception(edm::errors::Configuration,"PythiaError") 00108 <<" pythia8 did not accept the following \""<<*itPar<<"\""; 00109 } 00110 00111 } 00112 00113 } else { 00114 cout << " mySet == CSAParameters, not valid for Pythia8 " << endl; 00115 exit(1); 00116 } 00117 00118 } 00119 00120 pythia->init( 2212, 2212, comenergy); 00121 00122 pythia->settings.listChanged(); 00123 00124 ToHepMC = new HepMC::I_Pythia8; 00125 // ToHepMC->set_crash_on_problem(); 00126 00127 cout << endl; // Stetically add for the output 00128 //******** 00129 00130 produces<HepMCProduct>(); 00131 produces<GenInfoProduct, edm::InRun>(); 00132 00133 cout << "Pythia8Source: starting event generation ... " << endl; 00134 00135 }
Pythia8Source::~Pythia8Source | ( | ) | [virtual] |
Destructor.
Definition at line 138 of file Pythia8Source.cc.
References clear(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), pythia, and ToHepMC.
00138 { 00139 cout << "PythiaSource: event generation done. " << endl; 00140 pythia->statistics(); 00141 delete pythia; 00142 delete ToHepMC; 00143 clear(); 00144 }
bool Pythia8Source::call_txgive | ( | const std::string & | iParm | ) | [private] |
Interface to the PYGIVE pythia routine, with add'l protections.
Definition at line 239 of file Pythia8Source.cc.
00239 { 00240 00241 // TXGIVE( iParm.c_str(), iParm.length() ); 00242 // cout << " " << iParm.c_str() << endl; 00243 00244 return 1; 00245 }
bool Pythia8Source::call_txgive_init | ( | ) | [private] |
Definition at line 248 of file Pythia8Source.cc.
00248 { 00249 00250 // TXGIVE_INIT(); 00251 // cout << " Setting CSA defaults. " << endl; 00252 00253 return 1; 00254 }
Reimplemented from edm::ConfigurableInputSource.
Definition at line 151 of file Pythia8Source.cc.
References edm::Run::put(), and pythia.
00151 { 00152 00153 double cs = pythia->info.sigmaGen(); // cross section in mb 00154 auto_ptr<GenInfoProduct> giprod (new GenInfoProduct()); 00155 giprod->set_cross_section(cs); 00156 // giprod->set_external_cross_section(extCrossSect); 00157 // giprod->set_filter_efficiency(extFilterEff); 00158 r.put(giprod); 00159 00160 }
Implements edm::ConfigurableInputSource.
Definition at line 163 of file Pythia8Source.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), edm::ConfigurableInputSource::event(), maxEventsToPrint_, edm::ConfigurableInputSource::numberEventsInRun(), edm::Event::put(), pythia, pythia8event, pythiaHepMCVerbosity_, pythiaPylistVerbosity_, edm::InputSource::remainingEvents(), and ToHepMC.
00163 { 00164 00165 auto_ptr<HepMCProduct> bare_product(new HepMCProduct()); 00166 //cout << " 00167 //******** 00168 // 00169 00170 if (!pythia->next()) return false; // generate one event with Pythia 00171 00172 HepMC::GenEvent* hepmcevt = new HepMC::GenEvent(); 00173 ToHepMC->fill_next_event( *pythia8event, hepmcevt ); 00174 00175 00176 // hepmcevt->set_signal_process_id(pypars.msti[0]); 00177 hepmcevt->set_signal_process_id(pythia->info.code()); 00178 // hepmcevt->set_event_scale(pypars.pari[16]); 00179 hepmcevt->set_event_scale(pythia->info.pTHat()); 00180 hepmcevt->set_event_number(numberEventsInRun() - remainingEvents() - 1); 00181 00182 int id1 = pythia->info.id1(); 00183 int id2 = pythia->info.id2(); 00184 if ( id1 == 21 ) id1 = 0; 00185 if ( id2 == 21 ) id2 = 0; 00186 double x1 = pythia->info.x1(); 00187 double x2 = pythia->info.x2(); 00188 double Q = pythia->info.QRen(); 00189 double pdf1 = pythia->info.pdf1()/pythia->info.x1(); 00190 double pdf2 = pythia->info.pdf2()/pythia->info.x2(); 00191 hepmcevt->set_pdf_info( HepMC::PdfInfo(id1,id2,x1,x2,Q,pdf1,pdf2) ) ; 00192 00193 hepmcevt->weights().push_back( pythia->info.weight() ); 00194 00195 //******** Verbosity ******** 00196 00197 if(event() <= maxEventsToPrint_ && 00198 (pythiaPylistVerbosity_ || pythiaHepMCVerbosity_) ) { 00199 00200 // Prints PYLIST info 00201 if(pythiaPylistVerbosity_) { 00202 // call_pylist(pythiaPylistVerbosity_); 00203 pythia->info.list(); 00204 pythia->event.list(); 00205 } 00206 00207 // Prints HepMC event 00208 if(pythiaHepMCVerbosity_) { 00209 // cout << "Event process = " << pypars.msti[0] << endl 00210 cout << "Event process = " << pythia->info.code() << endl 00211 << "----------------------" << endl; 00212 hepmcevt->print(); 00213 } 00214 } 00215 00216 00217 if(hepmcevt) bare_product->addHepMCData(hepmcevt); 00218 00219 e.put(bare_product); 00220 00221 return true; 00222 }
double edm::Pythia8Source::comenergy [private] |
bool edm::Pythia8Source::doubleParticle [private] |
Definition at line 69 of file Pythia8Source.h.
double edm::Pythia8Source::etamax [private] |
Definition at line 71 of file Pythia8Source.h.
double edm::Pythia8Source::etamin [private] |
Definition at line 71 of file Pythia8Source.h.
CLHEP::HepRandomEngine* edm::Pythia8Source::fRandomEngine [private] |
Definition at line 75 of file Pythia8Source.h.
CLHEP::RandFlat* edm::Pythia8Source::fRandomGenerator [private] |
Definition at line 76 of file Pythia8Source.h.
unsigned int edm::Pythia8Source::maxEventsToPrint_ [private] |
Events to print if verbosity.
Definition at line 61 of file Pythia8Source.h.
Referenced by produce(), and Pythia8Source().
int edm::Pythia8Source::particleID [private] |
Definition at line 68 of file Pythia8Source.h.
double edm::Pythia8Source::phimax [private] |
Definition at line 72 of file Pythia8Source.h.
double edm::Pythia8Source::phimin [private] |
Definition at line 72 of file Pythia8Source.h.
double edm::Pythia8Source::ptmax [private] |
Definition at line 70 of file Pythia8Source.h.
double edm::Pythia8Source::ptmin [private] |
Definition at line 70 of file Pythia8Source.h.
Pythia8::Pythia* edm::Pythia8Source::pythia [private] |
Definition at line 63 of file Pythia8Source.h.
Referenced by endRun(), produce(), Pythia8Source(), and ~Pythia8Source().
Pythia8::Event* edm::Pythia8Source::pythia8event [private] |
HepMC verbosity flag.
Definition at line 59 of file Pythia8Source.h.
Referenced by produce(), and Pythia8Source().
unsigned int edm::Pythia8Source::pythiaPylistVerbosity_ [private] |
Pythia PYLIST Verbosity flag.
Definition at line 57 of file Pythia8Source.h.
Referenced by produce(), and Pythia8Source().
HepMC::I_Pythia8* edm::Pythia8Source::ToHepMC [private] |
Definition at line 65 of file Pythia8Source.h.
Referenced by produce(), Pythia8Source(), and ~Pythia8Source().