BLCMDrandomseed Class Reference

Inheritance diagram for BLCMDrandomseed:

BLCommand

List of all members.

Public Member Functions

 BLCMDrandomseed ()
G4String commandName ()
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
void defineNamedArgs ()


Constructor & Destructor Documentation

BLCMDrandomseed::BLCMDrandomseed (  ) 

References BLCMDTYPE_CONTROL, BLCommand::registerCommand(), BLCommand::setDescription(), and BLCommand::setSynopsis().

00039 {
00040         registerCommand(BLCMDTYPE_CONTROL);
00041         setSynopsis("control pseudo random number generator seeds");
00042         setDescription("This randomseed command controls the pseudo random "
00043                 "number generator seed at the start of each event.\n"
00044                 "The unnamed argument can be any of (case insensitive):\n"
00045                 "   EventNumber\n"
00046                 "   None\n"
00047                 "   Time\n"
00048                 "   Set 12345\n"
00049                 "   Now 12345\n"
00050                 "EventNumber is the default and "
00051                 "permits events to be re-run; None does not re-seed the "
00052                 "PRNG at each event, and Time is like None after seeding "
00053                 "with the time of day in microseconds; Set (Now) seeds the "
00054                 "generator "
00055                 "immediately with the value of the second argument (a long), "
00056                 "and then acts like None.");
00057 }


Member Function Documentation

G4String BLCMDrandomseed::commandName (  )  [inline, virtual]

Implements BLCommand.

00029 { return "randomseed"; }

int BLCMDrandomseed::command ( BLArgumentVector argv,
BLArgumentMap namedArgs 
) [virtual]

Implements BLCommand.

References EVENT_NUMBER, BLManager::getObject(), NO_SEED, BLCommand::printError(), BLManager::setPRNGSeedMethod(), and TIME_US.

00060 {
00061         if(argv.size() < 1) {
00062                 printError("randomseed: invalid command -- need method");
00063                 return -1;
00064         }
00065 
00066         G4String method = argv[0];
00067         for(unsigned i=0; i<method.size(); ++i)
00068                 method[i] = tolower(method[i]);
00069 
00070         if(method == "set" || method == "now") {
00071                 if(argv.size() < 2 || argv[1].size() == 0) {
00072                         printError("randomseed: no value to set");
00073                         return 1;
00074                 }
00075                 char *p;
00076                 long seed = strtol(argv[1].c_str(),&p,0);
00077                 if(*p != '\0') {
00078                         printError("randomseed: invalid value to set");
00079                         return 1;
00080                 }
00081                 CLHEP::HepRandom::setTheSeed(seed);
00082                 CLHEP::RandGauss::setFlag(false);
00083                 BLManager::getObject()->setPRNGSeedMethod(NO_SEED);
00084         } else if(method =="eventnumber")
00085                 BLManager::getObject()->setPRNGSeedMethod(EVENT_NUMBER);
00086         else if(method =="none")
00087                 BLManager::getObject()->setPRNGSeedMethod(NO_SEED);
00088         else if(method =="time")
00089                 BLManager::getObject()->setPRNGSeedMethod(TIME_US);
00090         else
00091                 printError("randomseed: invalid method");
00092 
00093         return 0;
00094 }

void BLCMDrandomseed::defineNamedArgs (  )  [virtual]

Reimplemented from BLCommand.

00097 {
00098 }


The documentation for this class was generated from the following file:
g4beamline