18 #include <TObjString.h>
20 #include <TStopwatch.h>
32 const std::string& treeName,
33 const std::string& branchName,
35 : mPrintInterval(printInterval)
44 throw std::runtime_error(
"No file provided");
46 if (!file->IsWritable()) {
47 throw std::runtime_error(
"File is not writable");
50 mTree =
new TTree(treeName.c_str(),
"PYTHIA 6 events");
53 catch(std::exception& e) {
54 std::cout <<
"Caught exception in erhic::Pythia6::Pythia6() - " <<
55 e.what() << std::endl;
67 TPythia6* pythia = TPythia6::Instance();
71 const int initialNGenerated = pythia->GetMSTI(5);
72 const int initialNTrials = pythia->GetPyint5()->NGEN[2][0];
73 TBranch* branch =
mTree->GetBranch(
"event");
77 mNGenerated += pythia->GetMSTI(5) - initialNGenerated;
78 const int trials = pythia->GetPyint5()->NGEN[2][0] - initialNTrials;
80 if ((
mTree->GetEntries() % mPrintInterval) == 0) {
81 double time = timer.RealTime();
82 std::cout <<
mTree->GetEntries() <<
" events in " <<
83 time <<
" seconds (+" << time - lastTime <<
")" << std::endl;
96 ss << pythia->GetPARI(1) * 1000.;
98 TObjString(s.c_str()).Write(
"crossSection");
104 TObjString(s.c_str()).Write(
"nEvents");
110 TObjString(s.c_str()).Write(
"nTrials");
std::auto_ptr< VirtualEventFactory > mFactory
Event factory.
const int mNEvents
Number of events to produce.
TTree * mTree
Pointer to the generated tree.
Pythia6(TFile *file, VirtualEventFactory *, int nEvents, const std::string &treeName="EICTree", const std::string &branchName="event", int printInterval=1000)
int mNTrials
Number of events thrown by PYTHIA.
TFile * mFile
Pointer to the output file.
int mNGenerated
Number of events passing PYTHIA selection.