|
[Rivet-svn] r3297 - in trunk: bin include/Rivet src/Core src/Projectionsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Aug 19 22:25:31 BST 2011
Author: fsiegert Date: Fri Aug 19 22:25:31 2011 New Revision: 3297 Log: More NLO parton level generator friendliness: Don't crash or fail when there are no beam particles. Modified: trunk/bin/rivet trunk/include/Rivet/AnalysisHandler.hh trunk/include/Rivet/Run.hh trunk/src/Core/AnalysisHandler.cc trunk/src/Core/Run.cc trunk/src/Projections/Beam.cc Modified: trunk/bin/rivet ============================================================================== --- trunk/bin/rivet Fri Aug 19 17:55:12 2011 (r3296) +++ trunk/bin/rivet Fri Aug 19 22:25:31 2011 (r3297) @@ -106,6 +106,8 @@ parser.add_option("-x", "--cross-section", dest="CROSS_SECTION", default=None, metavar="XS", help="specify the signal process cross-section in pb") +parser.add_option("--ignore-beams", dest="IGNORE_BEAMS", action="store_true", default=False, + help="Ignore input event beams when checking analysis compatibility.") verbgroup = OptionGroup(parser, "Verbosity control") parser.add_option("-l", dest="NATIVE_LOG_STRS", action="append", @@ -432,7 +434,7 @@ try: if opts.EVENT_TIMEOUT or opts.RUN_TIMEOUT: signal.alarm(min_nonnull(opts.EVENT_TIMEOUT, opts.RUN_TIMEOUT)) - init_ok = run.init(hepmcfile, hepmcfileweight) + init_ok = run.init(hepmcfile, hepmcfileweight, opts.IGNORE_BEAMS) signal.alarm(0) if not init_ok: logging.error("Failed to initialise using event file '%s'... exiting" % hepmcfile) Modified: trunk/include/Rivet/AnalysisHandler.hh ============================================================================== --- trunk/include/Rivet/AnalysisHandler.hh Fri Aug 19 17:55:12 2011 (r3296) +++ trunk/include/Rivet/AnalysisHandler.hh Fri Aug 19 22:25:31 2011 (r3297) @@ -182,7 +182,7 @@ /// Initialize a run, with the run beams taken from the example event. - void init(const GenEvent& event); + void init(const GenEvent& event, bool ignorebeams=false); /// Analyze the given \a event. This function will call the Modified: trunk/include/Rivet/Run.hh ============================================================================== --- trunk/include/Rivet/Run.hh Fri Aug 19 17:55:12 2011 (r3296) +++ trunk/include/Rivet/Run.hh Fri Aug 19 22:25:31 2011 (r3297) @@ -48,7 +48,7 @@ //@{ /// Set up HepMC file readers (using the appropriate file weight for the first file) - bool init(const std::string& evtfile, double weight=1.0); + bool init(const std::string& evtfile, double weight=1.0, bool ignorebeams=false); /// Open a HepMC GenEvent file (using the appropriate file weight for the first file) bool openFile(const std::string& evtfile, double weight=1.0); Modified: trunk/src/Core/AnalysisHandler.cc ============================================================================== --- trunk/src/Core/AnalysisHandler.cc Fri Aug 19 17:55:12 2011 (r3296) +++ trunk/src/Core/AnalysisHandler.cc Fri Aug 19 22:25:31 2011 (r3297) @@ -46,7 +46,7 @@ } - void AnalysisHandler::init(const GenEvent& ge) { + void AnalysisHandler::init(const GenEvent& ge, bool ignorebeams) { assert(!_initialised); setRunBeams(Rivet::beams(ge)); MSG_DEBUG("Initialising the analysis handler"); @@ -57,7 +57,7 @@ const size_t num_anas_requested = analysisNames().size(); vector<string> anamestodelete; foreach (const AnaHandle a, _analyses) { - if (!a->isCompatible(beams())) { + if ((!a->isCompatible(beams())) && (!ignorebeams)) { //MSG_DEBUG(a->name() << " requires beams " << a->requiredBeams() << " @ " << a->requiredEnergies() << " GeV"); anamestodelete.push_back(a->name()); } Modified: trunk/src/Core/Run.cc ============================================================================== --- trunk/src/Core/Run.cc Fri Aug 19 17:55:12 2011 (r3296) +++ trunk/src/Core/Run.cc Fri Aug 19 22:25:31 2011 (r3297) @@ -2,7 +2,6 @@ #include "Rivet/Run.hh" #include "Rivet/AnalysisHandler.hh" #include "HepMC/IO_GenEvent.h" -#include "Rivet/Projections/Beam.hh" #include "Rivet/Math/MathUtils.hh" #include <limits> @@ -72,7 +71,7 @@ } - bool Run::init(const std::string& evtfile, double weight) { + bool Run::init(const std::string& evtfile, double weight, bool ignorebeams) { if (!openFile(evtfile, weight)) return false; // Read first event to define run conditions @@ -84,7 +83,7 @@ } // Initialise AnalysisHandler with beam information from first event - _ah.init(*_evt); + _ah.init(*_evt, ignorebeams); // Set cross-section from command line if (_xs >= 0.0) { Modified: trunk/src/Projections/Beam.cc ============================================================================== --- trunk/src/Projections/Beam.cc Fri Aug 19 17:55:12 2011 (r3296) +++ trunk/src/Projections/Beam.cc Fri Aug 19 22:25:31 2011 (r3297) @@ -54,10 +54,14 @@ assert(beams.first && beams.second); _theBeams.first = *(beams.first); _theBeams.second = *(beams.second); - } else { + } else if(e.genEvent().barcode_to_particle(1) && e.genEvent().barcode_to_particle(2)) { _theBeams.first = *(e.genEvent().barcode_to_particle(1)); _theBeams.second = *(e.genEvent().barcode_to_particle(2)); } + else { + _theBeams.first = Particle(ANY, FourMomentum()); + _theBeams.second = Particle(ANY, FourMomentum()); + } //getLog() << Log::DEBUG << "Beam particle IDs = " << beamIds() << endl; }
More information about the Rivet-svn mailing list |