Run Class Reference Interface to handle a run of events read from a HepMC stream or file. More...
Collaboration diagram for Run:
Detailed DescriptionInterface to handle a run of events read from a HepMC stream or file. Constructor & Destructor Documentation
The standard constructor. Definition at line 11 of file Run.cc. : _ah(ah), _fileweight(1.0), _xs(NAN) { } Member Function Documentation
Get the current cross-section from the analysis handler in pb. Definition at line 25 of file Run.cc. References Run::_ah, and AnalysisHandler::crossSection(). { return _ah.crossSection(); }
Set up HepMC file readers (using the appropriate file weight for the first file) Definition at line 74 of file Run.cc. References Run::_ah, Run::_evt, Run::_listAnalyses, Run::_xs, AnalysisHandler::analysisNames(), Log::DEBUG, Log::ERROR, Log::getLog(), AnalysisHandler::init(), Run::openFile(), Run::readEvent(), and AnalysisHandler::setCrossSection(). { if (!openFile(evtfile, weight)) return false; // Read first event to define run conditions bool ok = readEvent(); if (!ok) return false; if (_evt->particles_size() == 0) { Log::getLog("Rivet.Run") << Log::ERROR << "Empty first event." << endl; return false; } // Initialise AnalysisHandler with beam information from first event _ah.init(*_evt); // Set cross-section from command line if (_xs >= 0.0) { Log::getLog("Rivet.Run") << Log::DEBUG << "Setting user cross-section = " << _xs << " pb" << endl; _ah.setCrossSection(_xs); } // List the chosen & compatible analyses if requested if (_listAnalyses) { foreach (const std::string& ana, _ah.analysisNames()) { cout << ana << endl; } } return true; }
Open a HepMC GenEvent file (using the appropriate file weight for the first file) Definition at line 54 of file Run.cc. References Run::_fileweight, Run::_io, Run::_istr, Log::ERROR, and Log::getLog(). Referenced by Run::init(). { // Set current weight-scaling member _fileweight = weight; // Set up HepMC input reader objects if (evtfile == "-") { _io.reset(new HepMC::IO_GenEvent(std::cin)); } else { // Ignore the HepMC::IO_GenEvent(filename, ios) constructor, since it's only available from HepMC 2.4 _istr.reset(new std::fstream(evtfile.c_str(), std::ios::in)); _io.reset(new HepMC::IO_GenEvent(*_istr)); } if (_io->rdstate() != 0) { Log::getLog("Rivet.Run") << Log::ERROR << "Read error on file " << evtfile << endl; return false; } return true; }
Handle next event. Definition at line 106 of file Run.cc. References Run::_ah, Run::_evt, Run::_xs, AnalysisHandler::analyze(), Log::DEBUG, Log::ERROR, Log::getLog(), AnalysisHandler::hasCrossSection(), AnalysisHandler::needCrossSection(), and AnalysisHandler::setCrossSection(). { // Set cross-section if found in event and not from command line #ifdef HEPMC_HAS_CROSS_SECTION if (std::isnan(_xs) && _evt->cross_section()) { const double xs = _evt->cross_section()->cross_section(); //< in pb Log::getLog("Rivet.Run") << Log::DEBUG << "Setting cross-section = " << xs << " pb" << endl; _ah.setCrossSection(xs); } #endif // Complain about absence of cross-section if required! if (_ah.needCrossSection() && !_ah.hasCrossSection()) { Log::getLog("Rivet.Run") << Log::ERROR << "Total cross-section needed for at least one of the analyses. " << "Please set it (on the command line with '-x' if using the 'rivet' program)" << endl; return false; } // Analyze event _ah.analyze(*_evt); return true; }
Read the next HepMC event.
Definition at line 37 of file Run.cc. References Run::_evt, Run::_fileweight, Run::_io, Log::DEBUG, Rivet::fuzzyEquals(), and Log::getLog(). Referenced by Run::init(). { /// @todo Clear rather than new the GenEvent object per-event? _evt.reset(new GenEvent()); if (_io->rdstate() != 0 || !_io->fill_next_event(_evt.get()) ) { Log::getLog("Rivet.Run") << Log::DEBUG << "Read failed. End of file?" << endl; return false; } // Rescale event weights by file-level weight, if scaling is non-trivial if (!fuzzyEquals(_fileweight, 1.0)) { for (size_t i = 0; i < (size_t) _evt->weights().size(); ++i) { _evt->weights()[i] *= _fileweight; } } return true; }
Declare whether to list available analyses. Definition at line 30 of file Run.cc. References Run::_listAnalyses. { _listAnalyses = dolist; return *this; } Member Data Documentation
AnalysisHandler object. Definition at line 70 of file Run.hh. Referenced by Run::crossSection(), Run::init(), and Run::processEvent().
Current event. Definition at line 93 of file Run.hh. Referenced by Run::finalize(), Run::init(), Run::processEvent(), and Run::readEvent().
An extra event weight scaling per event file. Useful for e.g. AlpGen n-parton event file combination. Definition at line 77 of file Run.hh. Referenced by Run::openFile(), and Run::readEvent().
HepMC I/O writer. Definition at line 99 of file Run.hh. Referenced by Run::finalize(), Run::openFile(), and Run::readEvent().
Output stream for HepMC writer. Definition at line 96 of file Run.hh. Referenced by Run::finalize(), and Run::openFile().
Flag to show list of analyses. Definition at line 86 of file Run.hh. Referenced by Run::init(), and Run::setListAnalyses().
Cross-section from command line. Definition at line 80 of file Run.hh. Referenced by Run::init(), Run::processEvent(), and Run::setCrossSection(). The documentation for this class was generated from the following files: Generated on Thu Feb 6 2014 17:39:02 for The Rivet MC analysis system by 1.7.6.1 |