// BLCMDrandomseed.cc /* This source file is part of G4beamline, http://g4beamline.muonsinc.com Copyright (C) 2003,2004,2005,2006 by Tom Roberts, all rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html */ #include #include #include "BLCommand.hh" #include "BLManager.hh" class BLCMDrandomseed : public BLCommand { public: BLCMDrandomseed(); G4String commandName() { return "randomseed"; } int command(BLArgumentVector& argv, BLArgumentMap& namedArgs); void defineNamedArgs(); }; BLCMDrandomseed defaultRandomseedCommand; BLCMDrandomseed::BLCMDrandomseed() { registerCommand(BLCMDTYPE_CONTROL); setSynopsis("control pseudo random number generator seeds"); setDescription("This randomseed command controls the pseudo random " "number generator seed at the start of each event.\n" "The unnamed argument can be any of (case insensitive):\n" " EventNumber\n" " None\n" " Time\n" " Set 12345\n" " Now 12345\n" "EventNumber is the default and " "permits events to be re-run; None does not re-seed the " "PRNG at each event, and Time is like None after seeding " "with the time of day in microseconds; Set (Now) seeds the " "generator " "immediately with the value of the second argument (a long), " "and then acts like None."); } int BLCMDrandomseed::command(BLArgumentVector& argv, BLArgumentMap& namedArgs) { if(argv.size() < 1) { printError("randomseed: invalid command -- need method"); return -1; } G4String method = argv[0]; for(unsigned i=0; isetPRNGSeedMethod(NO_SEED); } else if(method =="eventnumber") BLManager::getObject()->setPRNGSeedMethod(EVENT_NUMBER); else if(method =="none") BLManager::getObject()->setPRNGSeedMethod(NO_SEED); else if(method =="time") BLManager::getObject()->setPRNGSeedMethod(TIME_US); else printError("randomseed: invalid method"); return 0; } void BLCMDrandomseed::defineNamedArgs() { }