Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8308607
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
View Options
Index: contrib/Sacrifice/src/PythiaMain.cxx
===================================================================
--- contrib/Sacrifice/src/PythiaMain.cxx (revision 858)
+++ contrib/Sacrifice/src/PythiaMain.cxx (revision 859)
@@ -1,170 +1,176 @@
#include "Pythia.h"
#include "Sacrifice/PhotosHandler.hh"
#include "Sacrifice/Exceptions.hh"
#include "Sacrifice/BeamParticle.hh"
#include "Sacrifice/Utils.hh"
#include "Sacrifice/binreloc.h"
#include "tclap/CmdLine.h"
#ifdef HAS_HEPMC
#include "HepMCInterface.h"
#include "HepMC/GenEvent.h"
#include "HepMC/IO_GenEvent.h"
#include "HepMC/Units.h"
#endif // HAS_HEPMC
#include "boost/lexical_cast.hpp"
#include <string>
#include <stdexcept>
int main(int argc, char **argv){
char *envPath=0;
envPath = getenv("PYTHIA8DATA");
string path;
if(envPath){
path = envPath;
}else{
BrInitError brError;
br_init_lib(&brError);
path = br_find_data_dir(DEFAULTDATADIR);
}
//Do this first so we always get the Pythia banner and version information
Pythia8::Pythia pythia(path);
std::string pythiaVersion = boost::lexical_cast<std::string>(pythia.settings.parm("Pythia:versionNumber") + 0.00000000001);
pythiaVersion.erase(5);
std::string message = "Main program for steering Pythia " + pythiaVersion + ". Bug reports to James Monk <jmonk@cern.ch>";
TCLAP::CmdLine cmd(message, ' ', "0.9.0");
Sacrifice::PhotosHandler photosHandler(cmd);
TCLAP::ValueArg<int> seedArg("r", "random-seed", "Random seed", false, -1, "int");
TCLAP::MultiArg<std::string> inputArg("i", "input", "Input command file", false, "string");
TCLAP::ValueArg<std::string> outputArg("o", "output", "Output HepMC file", false, "", "string");
TCLAP::ValueArg<std::string> beam1Arg("f", "beam1", "Forward-going beam type (default PROTON)", false, "PROTON", "string");
TCLAP::ValueArg<std::string> beam2Arg("b", "beam2", "Backward-going beam type (default PROTON)", false, "PROTON", "string");
TCLAP::ValueArg<double> energyArg("e", "collision-energy", "Collision energy in GeV (default 7000 GeV)", false, 7000., "double");
TCLAP::ValueArg<int> nEventsArg("n", "nEvents", "Number of events to generate (default 100)", false, 100, "int");
TCLAP::MultiArg<std::string> paramsArgs("c", "command", "Commands to be read directly in to Pythia. Over-rides command file.", false, "string");
TCLAP::ValueArg<std::string> dataArg("d", "particle-data", "XML file of particle data. Over-rides default in $PYTHIA8DATA.", false, "", "string");
TCLAP::ValueArg<std::string> lhefArg("l", "lhe-file"," Les Houches Event File input", false, "", "string");
+ TCLAP::SwitchArg printArg("w", "write", "Write HepMC events to stdout", false);
cmd.add(seedArg);
cmd.add(inputArg);
cmd.add(outputArg);
cmd.add(beam1Arg);
cmd.add(beam2Arg);
cmd.add(energyArg);
cmd.add(nEventsArg);
cmd.add(paramsArgs);
cmd.add(dataArg);
cmd.add(lhefArg);
+ cmd.add(printArg);
cmd.parse( argc, argv );
#ifdef HAS_HEPMC
std::string hepMCFile = (outputArg.getValue() == "")? "pythia.hepmc": outputArg.getValue();
HepMC::I_Pythia8 pythiaToHepMC;
HepMC::IO_GenEvent ioFile(hepMCFile, std::ios::out);
#else
std::string hepMCFile = outputArg.getValue();
if(hepMCFile != ""){
throw std::runtime_error("HepMC output file requested, but HepMC support not compiled");
}
#endif
if(photosHandler.isEnabled()){
photosHandler.initialise();
}
for(vector<std::string>::const_iterator inputFile = inputArg.getValue().begin();
inputFile != inputArg.getValue().end(); ++inputFile){
std::string path = Sacrifice::findParamFile(*inputFile);
if(!pythia.readFile(path)){
throw std::runtime_error("Could not interpret all of the commands in the input file " + path + "!");
}else{
std::cout<<" Read commands from "<<path<<std::endl<<std::endl;
}
}
for(vector<std::string>::const_iterator command = paramsArgs.getValue().begin();
command != paramsArgs.getValue().end(); ++command){
if(!pythia.readString(*command)){
std::string msg = "Pythia could not understand the command " + *command;
throw std::runtime_error(msg);
}
}
if(seedArg.getValue() > 0){
std::string seedString = "Random:seed=" + boost::lexical_cast<string>(seedArg.getValue());
bool understood = pythia.readString("Random:setSeed=on");
understood = understood && pythia.readString(seedString);
if(! understood) throw std::runtime_error("Your version of Pythia does not understand the random seed commands!");
}
if(photosHandler.isEnabled()){
bool understood = pythia.readString("TimeShower:QEDshowerByL = off");
if(! understood) throw std::runtime_error("Your version of Pythia does not understand the command to turn off QED FSR!");
}
Sacrifice::BeamParticle beam1(beam1Arg.getValue());
Sacrifice::BeamParticle beam2(beam2Arg.getValue());
if(dataArg.getValue() != ""){
if(!pythia.particleData.reInit(dataArg.getValue(), true)) throw std::runtime_error("Could not read particle data file: " + dataArg.getValue());
}
bool isInitialised = false;
if(lhefArg.getValue() != ""){
isInitialised = pythia.init(lhefArg.getValue());
}else{
isInitialised = pythia.init(beam1.asID(), beam2.asID(), energyArg.getValue());
}
if(!isInitialised) throw std::runtime_error("Could not initialise Pythia");
for(int eventNumber = 0; eventNumber < nEventsArg.getValue(); ++eventNumber){
if(!pythia.next()){
if(pythia.info.atEndOfFile()){
std::cout<<"Reached end of LHE file"<<std::endl;
break;
}
}
#ifdef HAS_HEPMC //
#ifdef HEPMC_HAS_UNITS ///
HepMC::GenEvent *hepMCEvent = new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::MM);
#else
HepMC::GenEvent *hepMCEvent = new HepMC::GenEvent();
#endif /// HEPMC_HAS_UNITS
pythiaToHepMC.fill_next_event(pythia, hepMCEvent);
pythiaToHepMC.put_pdf_info(hepMCEvent, pythia, false);
if(photosHandler.isEnabled()){
photosHandler.process(hepMCEvent);
}
+ if(printArg.getValue()){
+ hepMCEvent->print();
+ }
+
ioFile << hepMCEvent;
delete hepMCEvent;
#endif // HAS_HEPMC
}
pythia.statistics();
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Dec 21, 12:35 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4018870
Default Alt Text
(6 KB)
Attached To
rAGILESVN agilesvn
Event Timeline
Log In to Comment