|
[Rivet-svn] r1924 - in trunk: . binblackhole at projects.hepforge.org blackhole at projects.hepforge.orgSat Oct 17 13:24:00 BST 2009
Author: buckley Date: Sat Oct 17 13:24:00 2009 New Revision: 1924 Log: Adding units parsing to the -x cross-section flag, so that cross-sections can be supplied as reported by the generator, e.g. '-x 101mb'. Also fixing cross-sec handling, so that generator cross-sections are overridden before finalize with the value supplied on the command line: if using Rivet as a library from C++, this needs to be done by explicitly calling AH::setCrossSection before finalize. Modified: trunk/ChangeLog trunk/bin/rivet Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Sat Oct 17 11:40:15 2009 (r1923) +++ trunk/ChangeLog Sat Oct 17 13:24:00 2009 (r1924) @@ -1,3 +1,8 @@ +2009-10-17 Andy Buckley <andy at insectnation.org> + + * Adding parsing of units in cross-sections passed to the "-x" + flag, i.e. "-x 101 mb" is parsed internally into 1.01e11 pb. + 2009-10-16 Hendrik Hoeth <hendrik.hoeth at cern.ch> * Disabling DELPHI_2003_WUD_03_11 in the Makefiles, since I don't Modified: trunk/bin/rivet ============================================================================== --- trunk/bin/rivet Sat Oct 17 11:40:15 2009 (r1923) +++ trunk/bin/rivet Sat Oct 17 13:24:00 2009 (r1924) @@ -96,7 +96,7 @@ help="give an optional run name, to be prepended as a 'top level directory' in histo paths") parser.add_option("-H", "--histo-file", dest="HISTOFILE", default="Rivet", help="specify the output histo file path") -parser.add_option("-x", "--cross-section", dest="CROSS_SECTION", type="float", +parser.add_option("-x", "--cross-section", dest="CROSS_SECTION", default=None, metavar="XS", help="specify the signal process cross-section in pb") @@ -157,6 +157,39 @@ logging.warning("Couldn't process logging string '%s'" % l) +## Parse supplied cross-section +if opts.CROSS_SECTION is not None: + xsstr = opts.CROSS_SECTION + try: + opts.CROSS_SECTION = float(xsstr) + except: + import re + suffmatch = re.search(r"[^\d.]", xsstr) + if not suffmatch: + raise ValueError("Bad cross-section string: %s" % xsstr) + factor = base = None + suffstart = suffmatch.start() + if suffstart != -1: + base = xsstr[:suffstart] + suffix = xsstr[suffstart:].lower() + if suffix == "mb": + factor = 1e+9 + elif suffix == "mub": + factor = 1e+6 + elif suffix == "nb": + factor = 1e+3 + elif suffix == "pb": + factor = 1 + elif suffix == "fb": + factor = 1e-3 + elif suffix == "ab": + factor = 1e-6 + if factor is None or base is None: + raise ValueError("Bad cross-section string: %s" % xsstr) + xs = float(base) * factor + opts.CROSS_SECTION = xs + + ## Print the available CLI options! #if opts.LIST_OPTIONS: # for o in parser.option_list: @@ -312,6 +345,8 @@ for evtfile in HEPMCFILES: import platform logging.info("Rivet running on machine %s (%s)" % (platform.node(), platform.machine())) + if opts.CROSS_SECTION is not None: + logging.info("User-supplied cross-section = %e pb" % opts.CROSS_SECTION) logging.info("Reading events from '%s'" % evtfile) if not run.processFile(evtfile): break @@ -320,8 +355,10 @@ break logging.info("Finished event loop") +## Override any generator cross-section to that supplied on the command line, if there was one +if opts.CROSS_SECTION is not None: + run.setCrossSection(opts.CROSS_SECTION) ## Finalize and write out data file ah.finalize() ah.commitData(); -
More information about the Rivet-svn mailing list |