|
[Rivet-svn] r1867 - trunk/srcblackhole at projects.hepforge.org blackhole at projects.hepforge.orgMon Oct 5 15:15:02 BST 2009
Author: buckley Date: Mon Oct 5 15:15:02 2009 New Revision: 1867 Log: Fixing use of '-' as a pseudo-filename for stdin (this was previously implemented as an enhancement to HepMC in the Python wrapper) Modified: trunk/src/Run.cc Modified: trunk/src/Run.cc ============================================================================== --- trunk/src/Run.cc Mon Oct 5 14:06:43 2009 (r1866) +++ trunk/src/Run.cc Mon Oct 5 15:15:02 2009 (r1867) @@ -41,16 +41,21 @@ bool Run::processFile(const std::string& evtfile) { - HepMC::IO_GenEvent io(evtfile, std::ios::in); - if (io.rdstate()!=0) { + HepMC::IO_GenEvent* io = 0; + if (evtfile == "-") { + io = new HepMC::IO_GenEvent(std::cin); + } else { + io = new HepMC::IO_GenEvent(evtfile, std::ios::in); + } + if (io->rdstate() != 0) { Log::getLog("Rivet.Run") << Log::ERROR << "Read error on file " << evtfile << endl; return false; } GenEvent* evt = new GenEvent(); - while (io.fill_next_event(evt)) { - if (_numEvents==0) { + while (io->fill_next_event(evt)) { + if (_numEvents == 0) { int num_anas_requested = _ah.analysisNames().size(); _ah.removeIncompatibleAnalyses(beamIds(*evt)); if (num_anas_requested > 0 && _ah.analysisNames().size() == 0) { @@ -102,6 +107,7 @@ evt = new GenEvent(); } delete evt; + delete io; return true; }
More information about the Rivet-svn mailing list |