--- agile-runmc.r823 2011-07-07 15:23:14.000000000 +0200 +++ agile-runmc 2011-07-07 17:58:04.000000000 +0200 @@ -93,7 +93,7 @@ rungroup = OptionGroup(parser, "Running the generators") rungroup.add_option("-n", "--nevts", help="Specify the number of events to generate", - dest="NEVTS", default="10") + dest="NEVTS", default=None) rungroup.add_option("-b", "--beams", help="Specify the beams. Super-flexible!", dest="BEAMSTR", default=None) rungroup.add_option("-p", "--param", metavar="PNAME=PVAR", action="append", default=[], @@ -111,7 +111,7 @@ "string type, and the output ones must be as well.", dest="PARAMTRFPYFILE") rungroup.add_option("-s", "--seed", help="Specify the generator random number seed", - dest="RNGSEED", type="int", default=31415926) + dest="RNGSEED", type="int", default=None) rungroup.add_option("--randomize-seed", help="Randomize the generator random number seed", action="store_const", const=RANDRANDSEED, dest="RNGSEED") parser.add_option_group(rungroup) @@ -213,25 +213,6 @@ pass -## Parse number-of-events string -if not opts.LISTGENS and not opts.LISTPARAMS: - try: - factor = 1 - base = opts.NEVTS - suffix = opts.NEVTS[-1] - if suffix.upper() == "K": - factor = 1000 - base = opts.NEVTS[:-1] - elif suffix == "M": - factor = 1000000 - base = opts.NEVTS[:-1] - num = int(float(base) * factor) - logging.info("Generating %d events" % num) - opts.NEVTS = num - except: - logging.error("Invalid num events specification, '%s'" % opts.NEVTS) - sys.exit(1) - def readParamStrsFromFile(ppath): paramstrs = [] @@ -390,6 +371,46 @@ if PARAMS.has_key("RG:Mom2"): MOM2 = PARAMS["RG:Mom2"] +## Set random number generator seed +RNGSEED = 31415926 + +if opts.RNGSEED is None: + if PARAMS.has_key("RG:Seed"): + RNGSEED = PARAMS["RG:Seed"] +else: + RNGSEED = opts.RNGSEED + +## Set number of events +NEVTS = "10" + +if opts.NEVTS is None: + if PARAMS.has_key("RG:nEvents"): + NEVTS = PARAMS["RG:nEvents"] +else: + NEVTS = opts.NEVTS + + +## Parse number-of-events string +if not opts.LISTGENS and not opts.LISTPARAMS: + try: + factor = 1 + base = NEVTS + suffix = NEVTS[-1] + if suffix.upper() == "K": + factor = 1000 + base = NEVTS[:-1] + elif suffix == "M": + factor = 1000000 + base = NEVTS[:-1] + num = int(float(base) * factor) + logging.info("Generating %d events" % num) + NEVTS = num + except: + logging.error("Invalid num events specification, '%s'" % NEVTS) + sys.exit(1) + + + ## Build beam string BEAMSTR = "%s:%s,%s:%s" % (BEAM1, MOM1, BEAM2, MOM2) ## Override from params @@ -531,8 +552,8 @@ logging.debug("Generator name = %s" % gen.getName()) logging.info("Setting initial state: %s @ %2.1f GeV -> <- %s @ %2.1f GeV" % (str(PID_A), E_A, str(PID_B), E_B)) gen.setInitialState(PID_A, E_A, PID_B, E_B) -logging.info("Setting random seed = %d" % opts.RNGSEED) -gen.setSeed(opts.RNGSEED) +logging.info("Setting random seed = %d" % RNGSEED) +gen.setSeed(RNGSEED) for pname, pval in PARAMS.iteritems(): if pname.startswith("RG:"): logging.info("Skipping meta-param %s = %s" % (pname, pval)) @@ -551,7 +572,7 @@ run.setFilter(opts.FILTER_EVENTS) ## Make and write events -for i in xrange(opts.NEVTS): +for i in xrange(NEVTS): st = run.makeEvent() logging.debug(run.eventSummary()) if not st: